export interface UnicodeEscapePositionEvidence { /** UTF-16 offset of the escape's leading backslash in the raw JSON. */ readonly offset: number; /** Process-keyed tag of the encoded scalar; never the recoverable character. */ readonly scalarTag: string; /** Process-keyed tag of the unambiguous array-index-free path; never raw field names. */ readonly pathTag: string; /** Escapes in object keys are structural and can never be display-safe. */ readonly location: "key" | "value"; /** Ordinal of this string among values sharing the array-index-free path. */ readonly valueOrdinal: number; /** UTF-16 offset of the decoded scalar inside that string value. */ readonly valueOffset: number; } export interface UnicodeEscapeEvidence { readonly positions: readonly UnicodeEscapePositionEvidence[]; /** Total qualifying escapes observed, including positions omitted by the cap. */ readonly totalPositions: number; /** More qualifying escapes existed than the bounded evidence can carry. */ readonly truncated: boolean; /** The raw JSON could not be mapped exactly and unambiguously; validation must fail closed. */ readonly malformed: boolean; /** Process-local HMAC binding the complete collector-produced envelope. */ readonly integrity: string; } interface UnicodeEscapeEvidenceTarget { escapedNonAsciiArguments?: boolean; escapedUnicodeArgumentEvidence?: UnicodeEscapeEvidence; } /** Stable, payload-free identity for an unambiguous array-index-free argument path. */ export declare function unicodeEscapePathTag(path: readonly string[]): string; /** Process-keyed scalar identity used without retaining recoverable argument text. */ export declare function unicodeEscapeScalarTag(codePoint: number): string; /** Verify that an evidence envelope is complete and was produced in this process. */ export declare function verifyUnicodeEscapeEvidence(evidence: UnicodeEscapeEvidence): boolean; export declare function repairJson(json: string): string; /** * First unnecessary `\uXXXX` escape in a JSON document, or `undefined` when the * document contains none. * * "Unnecessary" means the escape encodes a printable character JSON can carry * literally, including ASCII. ASCII must remain observable because one mistyped * nibble can move a non-ASCII escape into ASCII (`\u00b7` → `\u0077`). Control * characters (< U+0020), DEL, and unpaired surrogates are excluded. A `\\uXXXX` * sequence is a literal backslash followed by `u` — the * intended source syntax when the model is writing code or a nested JSON * document — and is skipped, which is why this scans the raw text with the same * string/escape state machine as {@link repairJson} instead of using a regex. * * Models that spell text as hand-written hex instead of literal characters * mistype the digits, and every mistyped nibble silently decodes to a different * but perfectly valid character (`\uc7a5` vs `\uc7a4`). The resulting arguments * parse cleanly and cannot be repaired after the fact, so the escape itself is * the only observable evidence that the payload is untrustworthy. */ export declare function findUnnecessaryUnicodeEscape(json: string): string | undefined; /** * Bounded raw-position/scalar evidence for every suspicious `\uXXXX` escape. * * Scalars and paths are carried only as process-keyed HMAC tags, so terminal * validation can match them against decoded arguments without retaining * recoverable characters, keys, or values in messages, diagnostics, or durable * session artifacts. Array indices are * intentionally omitted to preserve `questions.question`-style field matching. */ export declare function collectUnicodeEscapeEvidence(json: string): UnicodeEscapeEvidence | undefined; /** Attach bounded raw evidence while preserving the existing call-level guard flag. */ export declare function captureUnicodeEscapeEvidence(target: UnicodeEscapeEvidenceTarget, json: string): boolean; /** Attach evidence as transient, non-enumerable metadata excluded from serialization. */ export declare function attachUnicodeEscapeEvidence(target: UnicodeEscapeEvidenceTarget, evidence: UnicodeEscapeEvidence): void; export declare function parseJsonWithRepair(json: string): T; /** * Attempts to parse potentially incomplete JSON during streaming. * Always returns a valid object, even if the JSON is incomplete. * * @param partialJson The partial JSON string from streaming * @returns Parsed object or empty object if parsing fails */ export declare function parseStreamingJson>(partialJson: string | undefined): T; /** * Whether a string is a complete, well-formed JSON document (strict parse, no * repair). Used to distinguish a tool-call argument blob that finished cleanly * from one that was cut off mid-stream (truncation). An empty / whitespace-only * string is treated as complete: a tool invoked with no arguments legitimately * streams an empty buffer and must not be flagged as truncated. */ export declare function isCompleteJson(text: string | undefined): boolean; export {};