Eryx
eryx (noun): A genus of sand boas (Erycinae) - non-venomous snakes that live in sand. Perfect for "Python running inside a sandbox."
A Python sandbox with async callbacks powered by WebAssembly.
Features
- Async callback mechanism - Callbacks are exposed as direct async functions (e.g.,
await get_time()) - Parallel execution - Multiple callbacks can run concurrently via
asyncio.gather() - Execution tracing - Line-level progress reporting via
sys.settrace - Introspection - Python can discover available callbacks at runtime
- Composable runtime libraries - Pre-built APIs with Python wrappers and type stubs
- LLM-friendly - Type stubs (
.pyi) for including in context windows
Quick Start
use Sandbox;
async
Returning a structured result
Assign a variable named result in the script and it is JSON-serialized and
returned as ExecuteResult::result — a structured channel separate from stdout:
use Sandbox;
async
If the value is not JSON-serializable, result.result is None and
result.result_error explains why (execution still succeeds). Use
SandboxBuilder::with_result_variable to capture a different variable name.
With Callbacks
Use the #[callback] macro for strongly-typed callbacks with automatic JSON Schema generation:
use ;
use ;
/// Returns the current Unix timestamp
async
/// Echoes back the message
async
async
Dynamic Callbacks
For runtime-defined callbacks (e.g., from configuration or plugins):
use ;
use json;
let greet = builder
.param
.build;
let sandbox = builder
.with_callback
.build?;
With Runtime Libraries
Runtime libraries bundle callbacks with Python wrappers and type stubs:
use ;
let library = new
.with_callback
.with_preamble
.with_stubs;
let sandbox = builder
.with_library
.build?;
License
MIT OR Apache-2.0