/** * Best-effort salvage of complete `script` (+ optional complete `files`) from * truncated code tool_use JSON. Returns null when script string is incomplete. */ export declare function salvageTruncatedCodeInput(raw: string): { script: string; files?: Record; } | null; /** Lone expression with no top-level return → wrap as return (). */ export declare function salvageExpressionReturn(script: string): string | null; /** `async function main(){...}\nmain()` → return await main(). */ export declare function salvageTrailingInvocation(script: string): string | null; export declare function rewriteJsonParseOnText(script: string): string | null; /** * If the script is shell/python (not JS) and a bash client tool exists, rewrite * to call that tool. Fail-open: null means run as written. */ export declare function planScriptReroute(script: string, toolNames: readonly string[]): { kind: "bash" | "python"; script: string; } | null; /** * Apply all body-level salvages in order. Returns the (possibly rewritten) * script plus a list of applied salvage kinds for logging/tests. */ export declare function salvageCodeScript(script: string, toolNames?: readonly string[]): { script: string; applied: string[]; }; /** * Normalize/heal files payload into a path→content string map. * Accepts: object map, nested {content|body|text}, array of {path|name, content|body}, * [[path, content]] tuples, and JSON-stringified maps (incl. fenced/BOM). * Returns { files, healed } where healed is a label when a non-canonical shape was folded. */ export declare function normalizeFilesShape(raw: unknown): { files: Record; healed: string | null; }; /** Back-compat thin wrapper — returns only the map. */ export declare function normalizeFilesPayload(raw: unknown): Record; /** Coaching text when code() arrives with no usable script. */ export declare function emptyScriptCoachMessage(rawArgs: string): string; /** * Wrap direct Promise-style chains on synchronous catalog calls. The mask keeps * non-code text invisible while the balanced scan preserves call bytes. Fires * only on scripts that already compile - the opposite eligibility gate from the * syntax-level salvages above. Returns null to run as written. */ export declare function healDirectChainCatch(authored: string): { script: string; kind: "direct-chain-catch"; names: string[]; } | null; export type IncompleteSyntax = { kind: "template" | "dq" | "sq" | "regex" | "expression"; startLine: number; bytesToEof: number; } | { kind: "delimiters"; startLine: number; bytesToEof: number; delimiters: string; }; /** * Incomplete lexical token or proof-completable delimiter stack at EOF, with * the line of its first unmatched opening byte and its span to EOF. Returns * null for any script that compiles, and for breakage that is not a clean cut. */ export declare function incompleteSyntaxAtEof(script: unknown): IncompleteSyntax | null; /** * Honest hold text for a provably incomplete script. Nothing is closed, nothing * is executed, and no tool calls are dispatched - the model re-issues the * complete script. Returns null when the script is not a clean cut, so ordinary * syntax errors keep their existing compile diagnostics. */ export declare function incompleteScriptCoachMessage(script: string): string | null;