/** * WASM-sandboxed JavaScript executor for code mode. * * Runs LLM-generated processing scripts against raw tool output in a QuickJS * WASM sandbox. The sandbox has NO filesystem or network access — only DATA * (the tool's response as a string) and console.log() for output. * * Usage: * import { executeInSandbox } from "./sandbox.js"; * const result = await executeInSandbox(rawJsonString, userScript); * // result.stdout contains only what the script console.log()'d * * The QuickJS WASM module is loaded once and reused across calls. * Each execution gets a fresh context (no state leakage between calls). */ export interface SandboxResult { /** Script's console.log() output. */ stdout: string; /** Size of the input data in bytes. */ beforeBytes: number; /** Size of the script output in bytes. */ afterBytes: number; /** Context reduction percentage (0-100). */ reductionPct: number; /** Script error message, if execution failed. */ error?: string; } /** * Execute a JavaScript script in a WASM sandbox with DATA injected. * * The script can: * - Read `DATA` (string — the raw tool response) * - Use `JSON.parse(DATA)` to parse it * - Use `console.log(...)` to produce output * - Use standard JS: loops, map/filter/reduce, string ops, Math, etc. * * The script CANNOT: * - Access the filesystem * - Make network requests * - Import modules * - Access Node.js APIs * - Leak state between calls * * @param data - Raw tool response string (injected as `DATA` global) * @param script - JavaScript code to execute * @returns SandboxResult with stdout and size metrics */ export declare function executeInSandbox(data: string, script: string): Promise; //# sourceMappingURL=sandbox.d.ts.map