MCPcopy Index your code
hub / github.com/amlalabs/amla-sandbox

github.com/amlalabs/amla-sandbox @v0.2.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.8 ↗ · + Follow
1,059 symbols 4,053 edges 71 files 837 documented · 79%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

amla-sandbox

This repository is the release source for the amla-sandbox Python package. Development happens in the amlalabs monorepo; this repo is updated on release. The Rust runtime that compiles to amla_sandbox.wasm lives in amla-sandbox-core; the exact release tag this Python package was built against is recorded in .mirror-deps.json.

amla-sandbox is a WASM sandbox with capability enforcement for AI agent code. Agents can only call tools you explicitly provide, with constraints you define. Sandboxed virtual filesystem. No network. No shell escape.

Install

pip install amla-sandbox

No Docker. No VM. One binary, works everywhere.

Quick start

from amla_sandbox import create_sandbox_tool

sandbox = create_sandbox_tool()

# JavaScript
sandbox.run("console.log('hello'.toUpperCase())", language="javascript")
# Shell
sandbox.run("echo 'hello' | tr 'a-z' 'A-Z'", language="shell")

# With tools
def get_weather(city: str) -> dict:
    return {"city": city, "temp": 72}

sandbox = create_sandbox_tool(tools=[get_weather])
sandbox.run(
    "const w = await get_weather({city: 'SF'}); console.log(w);",
    language="javascript",
)

With capability constraints:

from amla_sandbox import Sandbox, ToolCallCap, ConstraintSet, Param

sandbox = Sandbox(
    capabilities=[
        ToolCallCap(
            method_pattern="stripe/charges/*",
            constraints=ConstraintSet([
                Param("amount") <= 10000,
                Param("currency").is_in(["USD", "EUR"]),
            ]),
            max_calls=100,
        ),
    ],
    tool_handler=my_handler,
)

See the PyPI page and the examples/ directory for the full API surface, framework integrations, and the constraint DSL.

Security model

The sandbox runs inside WebAssembly with WASI for a minimal syscall surface. On top of WASM isolation, every tool call goes through capability validation; access is explicitly granted, not implicitly available. See the Quick start above and the upstream PyPI README for the full explanation and tradeoffs.

Building from source

For most users, installing from PyPI is recommended; the wheel includes the prebuilt WASM binary. If you want to build the wheel yourself:

uv build

To regenerate the WASM artifact bundled inside the wheel, build it from amla-sandbox-core at the tag pinned in .mirror-deps.json, then drop the result at src/amla_sandbox/_wasm/amla_sandbox.wasm before running uv build.

Contributing

See CONTRIBUTING.md. Pull requests against this mirror will be clobbered on next release; please target the monorepo or open an issue here.

License

Python package code is MIT licensed. The bundled Rust WASM runtime is AGPL-3.0-or-later OR BUSL-1.1.

Core symbols most depended-on inside this repo

run
called by 170
src/amla_sandbox/langgraph.py
create_sandbox_tool
called by 96
src/amla_sandbox/bash_tool.py
execute
called by 95
src/amla_sandbox/sandbox.py
evaluate
called by 62
src/amla_sandbox/capabilities/constraints.py
validate_call
called by 59
src/amla_sandbox/capabilities/tool_call.py
can_call
called by 38
src/amla_sandbox/sandbox.py
method_matches_pattern
called by 30
src/amla_sandbox/capabilities/patterns.py
get_remaining_calls
called by 29
src/amla_sandbox/sandbox.py

Shape

Method 584
Function 362
Class 113

Languages

Python100%

Modules by API surface

tests/test_e2e.py95 symbols
src/amla_sandbox/runtime/wasm.py61 symbols
src/amla_sandbox/capabilities/constraints.py58 symbols
tests/test_bash_tool.py42 symbols
tests/test_langgraph.py39 symbols
tests/test_integration.py39 symbols
tests/test_constraints.py39 symbols
examples/testing.py36 symbols
tests/test_ingest.py30 symbols
tests/test_audit.py28 symbols
examples/streaming.py27 symbols
examples/benchmarks/base.py26 symbols

For agents

$ claude mcp add amla-sandbox \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page