import { sha256Hex } from "./canonicalize.js"; import type { TruncatedJsonOutcome } from "./types.js"; /** * Bounded, deterministic recovery of truncated JSON tool-call arguments caused * by streaming interruption or provider truncation. * * Invariants: * - Distinguishes incomplete JSON from invalid complete JSON. * - Only closes structural containers / finishes a trailing string token. * - NEVER fabricates missing field values or guessed keys. * - Enforces a maximum repair size, maximum depth, and max continuations. */ export declare const TOOL_CALL_TRUNCATED_UNRECOVERABLE = "TOOL_CALL_TRUNCATED_UNRECOVERABLE"; export interface TruncatedJsonRecoveryResult { outcome: TruncatedJsonOutcome; /** Recovered JSON value, when recovered. */ value?: unknown; } /** * Scan a JSON text and, when it is an INCOMPLETE but coherent prefix (near the * end of a stream), produce the shortest deterministic completion by closing * open containers / a trailing value string. Returns null when the text is not * a recoverable incomplete JSON document. * * The scanner advances through whitespace-aware tokens and, at end-of-input, * verifies we ended in a position that admits a structural close. */ export declare function tryCloseTruncatedJson(raw: string, maxBytes: number): string | null; /** * Deterministic recovery driver. Bounded by content size and continuation * attempts. */ export declare function recoverTruncatedJson(raw: string, opts?: { maxBytes?: number; maxContinuations?: number; continuation?: (fragment: string) => Promise; }): TruncatedJsonRecoveryResult; /** Escape helper reused by diagnostics so raw fragments are hashed, not logged. */ export { sha256Hex as fragmentHash }; //# sourceMappingURL=truncated-json.d.ts.map