/** * JSON repair — ported from Pi's `utils/json-parse.ts` (v0.80.3). * * LLMs sometimes produce JSON with raw control characters inside string * literals (e.g. a literal newline in a tool-call argument) or invalid escape * sequences (e.g. `\x` or `\d`). Standard `JSON.parse` rejects these, causing * tool-call parsing to fail. `repairJson` normalizes the string before parse: * * - Escapes raw control characters (U+0000–U+001F) inside string literals. * - Doubles backslashes before invalid escape characters (so `\d` → `\\d`). * * Zero dependencies. The `parseStreamingJson` function from Pi (which uses the * `partial-json` library for incomplete-JSON parsing) is NOT ported — moss has * its own `tryParsePartialArgsString` for that use case. */ /** * Repairs malformed JSON string literals by: * - escaping raw control characters inside strings * - doubling backslashes before invalid escape characters * * Only modifies content inside string literals (between unescaped double * quotes). Structural JSON (keys, braces, brackets, numbers) is untouched. */ export declare function repairJson(json: string): string; /** * Parse JSON, attempting repair if the initial parse fails. * Returns `null` if the JSON cannot be parsed even after repair. */ export declare function parseJsonLoose(text: string): unknown | null; //# sourceMappingURL=json-repair.d.ts.map