import type { EdictHostAdapter } from "./host-adapter.js"; import type { ReplayToken } from "./replay-types.js"; /** Configuration for execution sandbox limits */ export interface RunLimits { /** Max execution time in ms (default: 15_000, min: 100) */ timeoutMs?: number; /** Max WASM memory in MB (compile-time, default: 1) */ maxMemoryMb?: number; /** Sandbox directory for file IO builtins. If unset, readFile/writeFile return Err. */ sandboxDir?: string; /** Optional list of allowed hostnames for HTTP requests. If unset, all hosts are allowed. */ allowedHosts?: string[]; /** Optional host adapter for platform-specific operations. Defaults to NodeHostAdapter. */ adapter?: EdictHostAdapter; /** External WASM modules keyed by import namespace (base64-encoded). */ externalModules?: Record; /** When true, record all non-deterministic host responses and return a ReplayToken. */ record?: boolean; /** When provided, replay from this token instead of calling real host functions. */ replayToken?: ReplayToken; } export interface RunResult { /** Captured stdout output */ output: string; /** Exit code (0 = success) */ exitCode: number; /** Return value from main (if any) */ returnValue?: number; /** Runtime limit error, if execution was killed */ error?: "execution_timeout" | "execution_oom"; /** Limit values that were enforced */ limitInfo?: { timeoutMs?: number; maxMemoryMb?: number; }; /** Heap bytes consumed by the program's allocations (only set on success) */ heapUsed?: number; /** Replay token containing all recorded non-deterministic responses (only when record: true) */ replayToken?: ReplayToken; } /** * Run a compiled Edict WASM binary with sandbox limits. * * Spawns a worker thread and enforces a timeout. If execution exceeds * the timeout, the worker is terminated and a structured error is returned. * * @param wasm - The WASM binary (Uint8Array from codegen) * @param entryFn - Name of the function to call (default: "main") * @param limits - Optional execution limits (timeout, memory) */ export declare function run(wasm: Uint8Array, entryFn?: string, limits?: RunLimits): Promise; /** * Direct (in-process) WASM execution — no worker thread, no timeout. * * Used by the worker thread internally and available for tests * that don't need sandbox limits. * * @param wasm - The WASM binary (Uint8Array from codegen) * @param entryFn - Name of the function to call (default: "main") * @param limits - Optional execution limits (sandboxDir for file IO) */ export declare function runDirect(wasm: Uint8Array, entryFn?: string, limits?: RunLimits): Promise; import type { DebugMetadata } from "./types.js"; /** Result from debug execution — includes crash diagnostics and trace info */ export interface DebugResult { /** Captured stdout output */ output: string; /** Exit code (0 = success) */ exitCode: number; /** Return value from main (if any) */ returnValue?: number; /** Call stack at crash time (function names, outermost first) */ callStack?: string[]; /** Crash location — mapped from debug metadata */ crashLocation?: { fn: string; nodeId: string; }; /** Number of function entries recorded */ stepsExecuted: number; /** Error type, if execution was killed */ error?: "execution_timeout" | "execution_oom" | "step_limit_exceeded"; } /** Options for debug execution */ export interface DebugOptions { /** Maximum number of function entries before stopping (default: 10_000) */ maxSteps?: number; /** Sandbox directory for file IO builtins */ sandboxDir?: string; /** Optional list of allowed hostnames for HTTP requests. */ allowedHosts?: string[]; /** Optional host adapter */ adapter?: EdictHostAdapter; } /** * Execute a debug-instrumented WASM binary with call stack tracking. * * Must be compiled with `debugMode: true` so the WASM contains * `__trace_enter` / `__trace_exit` calls. * * @param wasm - The WASM binary (compiled with debugMode: true) * @param debugMetadata - fnName→nodeId mapping from compile result * @param options - Debug execution options (maxSteps, sandboxDir) */ export declare function runDebug(wasm: Uint8Array, debugMetadata: DebugMetadata, options?: DebugOptions): Promise; //# sourceMappingURL=runner.d.ts.map