Sandbox
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/sandboxDocker 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:
| Workflow | Why sandbox it |
|---|---|
| Execute generated code | Keep untrusted code away from the host filesystem |
| Write temporary files | Clean up the workspace after the run |
| Inspect command output | Capture stdout, stderr, exit code, and timeout state |
| Run multi-step tool flows | Share 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.
