Skip to content

wasm_runner

diapason.sandbox.wasm_runner

WASM sandbox — lightweight isolation via Wasmtime.

WasmResult dataclass

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

available() staticmethod

Check if wasmtime is available.

run(wasm_bytes, input_data=None)

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).

validate(wasm_bytes)

Validate that bytes represent a valid WASM module.

create_sandbox_runner(config=None)

Factory: select Docker or WASM runner based on config/availability.