/** * Parse a tool-call arguments JSON blob into a canonical * `Record`. * * Why this exists: providers stream tool-call arguments as raw JSON strings * accumulated over multiple `delta` events. Once complete, callers want a * dictionary. Naive `JSON.parse` plus `as Record` is unsafe * — a buggy provider, a proxy that rewrites payloads, or a future API change * can yield `null`, an array, or a number, all of which would * type-check fine but crash downstream tool executors that index into the * input by key. * * Repair ladder (each step only runs when the previous ones failed, so a * well-formed payload costs a single JSON.parse): * 1. direct parse * 2. code-fence stripping (```json … ``` wrappers, fenced block in prose) * 3. JSON5-style sanitize (comments, trailing commas, literal control chars) * 4. truncation completion (auto-close braces/strings) * 5. both composed (truncated payloads with raw newlines inside strings) * 6. double-wrapped-string salvage (arguments serialized twice) * * Result contract: * - Valid JSON object → returned as-is, typed as `Record`. * - Valid JSON array / scalar → wrapped under `{ __raw: value }` so the * tool still receives an object (the executor can detect the anomaly). * - Unrecoverable input → `{ __raw: rawString }` so no information is lost; * the tool layer can decide whether to fail or salvage. * - Empty/null input → returns `{}` (the "no arguments" case). */ export declare function parseToolInput(raw: string | undefined): Record; //# sourceMappingURL=_tool-input.d.ts.map