SandboxNew

Sandbox

Run code and file operations inside an isolated Docker workspace.

@anvia/sandbox lets an agent work inside an isolated Docker workspace instead of the host filesystem.

Use it when a tool workflow needs to execute generated code, write files, inspect outputs, or run a short command with a cleanup boundary.

Install

pnpm add @anvia/sandbox

Docker must be installed and running on the machine that hosts the agent.

When to Use It

Use a sandbox when an agent needs a scratch workspace for operations such as:

WorkflowWhy sandbox it
Execute generated codeKeep untrusted code away from the host filesystem
Write temporary filesClean up the workspace after the run
Inspect command outputCapture stdout, stderr, exit code, and timeout state
Run multi-step tool flowsShare files between sandbox tools without exposing project files

Sessions are ephemeral by default. destroy() removes the container and workspace volume unless you explicitly choose a persistent workspace.

Next, create your first Docker session.