/** * Repairs JSON that a provider cut off mid-value. * * Why this exists: when a structured call hits its output cap the provider * returns `finish_reason: "length"` and a payload that simply STOPS — commonly * inside a string, e.g. * * {"chunks":[{"text":"…complete…"},{"text":"…trunca * * Every rung of the salvage ladder above this one hands that text to * `JSON.parse`, which rejects it outright, so a call that produced dozens of * perfectly good elements returned NOTHING. This trims back to the last element * that actually completed, drops the partial tail, and closes whatever * containers were left open — turning a total loss into an N-1 result the * caller's schema can validate. * * Deliberately conservative: a value is "complete" only when the input proves it * (a separating comma, or a closing bracket). A bare trailing token such as the * `3` in `[1,2,3` could itself be a truncated `35`, so it is dropped too. * * Pure and total — never throws. * * @param raw - The model's raw text. Leading prose / markdown fences are skipped * up to the first `{` or `[`. * @returns Parseable JSON text, the input verbatim when it already parses, or * `null` when nothing recoverable is present. */ export declare function repairTruncatedJson(raw: string): string | null; //# sourceMappingURL=repair-truncated-json.d.ts.map