/** * SandboxGuard — Fail-Fast Syntax Checker for LLM-Provided Code * * Provides quick feedback BEFORE sending code to the isolated-vm engine. * This is NOT a security boundary — security comes from the empty V8 * Context (no `process`, `require`, `fs`, or `globalThis` injected). * * Purpose: * - Validate that the code is syntactically valid JavaScript * - Check that it looks like a function expression / arrow function * - Provide fast, descriptive error messages to the LLM * * Properties: * - Zero runtime dependencies (pure string analysis) * - Fail-fast: rejects obviously broken code before V8 boot * - NOT a security gate (LLMs can obfuscate; the Isolate is the real wall) * * @module * @internal */ export interface GuardResult { /** Whether the code passed the fail-fast check */ readonly ok: boolean; /** Human-readable reason for rejection (present when `ok` is false) */ readonly violation?: string; } /** * Validate LLM-provided code before sending it to the sandbox. * * Performs two checks: * 1. **Shape check**: The code must look like a function expression * 2. **Suspicious pattern check**: Fail-fast for obviously unsandboxable patterns * * @param code - The JavaScript code string from the LLM * @returns A `GuardResult` indicating whether the code passed * * @example * ```typescript * const result = validateSandboxCode('(data) => data.filter(d => d.x > 5)'); * // { ok: true } * * const bad = validateSandboxCode('require("fs").readFileSync("/etc/passwd")'); * // { ok: false, violation: 'Code must be a function expression...' } * ``` */ export declare function validateSandboxCode(code: string): GuardResult; //# sourceMappingURL=SandboxGuard.d.ts.map