/** * Lightweight string-level repair of the escape/control-char hazards that make * otherwise-valid JSON fail `JSON.parse`: raw control characters inside strings * are escaped, and invalid `\x` escapes have their backslash escaped. Returns the * input unchanged when no repair is needed. Pure string→string; does not parse. */ export declare function repairJson(json: string): string; /** * Final-parse a JSON value, repairing the common LLM malformations * ({@link RelaxedJson}). Tries strict `JSON.parse` first (fast path, exact JSON * semantics), then the relaxed parser. Throws when the input is unrepairable, * truncated, or carries trailing garbage — so callers can skip a bad tool call * rather than execute a half-formed one. */ export declare function parseJsonWithRepair(json: string): T; /** * Parse possibly-incomplete JSON during streaming. Always returns a value, never * throws: `{}` for empty/whitespace/unrecoverable buffers, and an auto-closed * best-effort object for truncated ones. */ export declare function parseStreamingJson>(partialJson: string | undefined): T; /** * Default minimum byte growth before `parseStreamingJsonThrottled` will * re-parse a streaming tool-call argument buffer. Bounds the mid-stream * partial-parse cost from quadratic to linear in N. */ export declare const STREAMING_JSON_PARSE_MIN_GROWTH = 256; /** * Throttled variant of {@link parseStreamingJson} for the per-delta hot path. * * Tool calls arrive as a long sequence of small deltas — calling * `parseStreamingJson(buffer)` on every delta re-parses the entire buffer * each time, giving O(N²) work in the total buffer length. Throttling skips * the re-parse until at least `minGrowthBytes` of new content has arrived * since the last successful parse, bounding mid-stream cost to O(N). * * Each provider tracks the last parsed length on its tool-call block, so the * final `toolcall_end` parse (which providers already perform unconditionally) * is the authoritative full parse — the throttle only delays mid-stream UI * updates by at most `minGrowthBytes` of accumulated partial content. * * @returns the parsed object plus the new `parsedLen` to persist; or `null` * when the buffer has not grown enough to warrant a re-parse. */ export declare function parseStreamingJsonThrottled>(partialJson: string | undefined, lastParsedLen: number, minGrowthBytes?: number): { value: T; parsedLen: number; } | null;