wasm_runner
wasm_runner
¶
WASM sandbox — lightweight isolation via Wasmtime.
Classes¶
WasmResult
dataclass
¶
WasmResult(success: bool = True, output: str = '', duration_seconds: float = 0.0, fuel_consumed: int = 0, memory_used_bytes: int = 0)
Result from a WASM execution.
WasmRunner
¶
Execute WASM modules with resource limits.
Uses wasmtime-py for sub-100ms isolation. Supplements Docker-based ContainerRunner for lightweight, fast sandboxing.
Requires: uv sync --extra sandbox-wasm
Source code in src/openjarvis/sandbox/wasm_runner.py
Functions¶
available
staticmethod
¶
run
¶
run(wasm_bytes: bytes, input_data: Optional[Dict[str, Any]] = None) -> WasmResult
Execute a WASM module with input data.
The module is expected to export a run function that takes
a pointer and length and returns a pointer and length.
For simpler modules, we attempt to call _start (WASI).
Source code in src/openjarvis/sandbox/wasm_runner.py
validate
¶
Validate that bytes represent a valid WASM module.
Source code in src/openjarvis/sandbox/wasm_runner.py
Functions¶
create_sandbox_runner
¶
Factory: select Docker or WASM runner based on config/availability.