agent-sandbox
A secure, embeddable, WASM-based sandbox for AI agents. 40+ built-in CLI tools, a JavaScript runtime, <13ms startup, no Docker/VMs required.
Installation
Rust
Node.js
Prebuilt binaries are available for macOS (arm64, x64), Linux (x64, arm64), and Windows (x64).
Quick Start
Rust
use ;
let config = SandboxConfig ;
let sandbox = new?;
let result = sandbox.exec.await?;
println!;
// Execute JavaScript inside the sandbox
let js_result = sandbox.exec_js.await?;
Node.js
import from "@parassharmaa/agent-sandbox";
const sandbox = ;
const result = await sandbox.;
console.log;
// Execute JavaScript inside the sandbox
const jsResult = await sandbox.;
const changes = await sandbox.;
await sandbox.;
Features
- 40+ tools: cat, grep, find, sed, awk, jq, git, tar, zip, and more
- Built-in JavaScript runtime (Boa engine) via
nodecommand orexecJs()API - Filesystem sandboxing with path traversal prevention
- Resource limits: fuel, timeout, memory
- Change tracking via filesystem snapshots
- AOT precompiled WASM — <13ms cold start, ~55us cached
- Node.js bindings (NAPI)
JavaScript Runtime
The sandbox includes a built-in JavaScript engine (Boa) that runs entirely inside the WASM sandbox. Use it via the node command or the execJs() convenience method.
// Inline evaluation
await sandbox.;
// Evaluate and print result
await sandbox.; // stdout: "14"
// Run a script file (from /work)
await sandbox.;
await sandbox.;
// Convenience method
await sandbox.;
Supported JS features: ES2023+ (variables, arrow functions, destructuring, template literals, Promises, Map/Set, JSON, Math, RegExp, Array methods, and more). No network access or Node.js built-in modules — runs in pure WASM isolation.
Limitations
- No network access (WASI p1)
- No process spawning or shell pipes
- JS runtime has no Node.js built-in modules (fs, http, etc.)
- Single-threaded execution
- Same-architecture precompiled binary
Best for: file-manipulation agents (code analysis, refactoring, git ops), sandboxed JS evaluation. Not for: arbitrary network requests, API calls, databases, GPU.
License
MIT