WBX Sandbox
Executes workspace commands in WBX Sandbox, isolated Firecracker microVMs hosted in Europe. A named sandbox sleeps between sessions with its files kept, so an agent can continue where it left off. For interface details, see WorkspaceSandbox interface.
The WBX Sandbox team maintains the @wbx-sandbox/mastra package. Report issues in the package repository.
Before you beginDirect link to Before you begin
- A WBX Sandbox account and API key
- Node.js
v22.13.0or later @mastra/corev1.80.0or later
InstallationDirect link to Installation
- npm
- pnpm
- Yarn
- Bun
npm install @wbx-sandbox/mastra
pnpm add @wbx-sandbox/mastra
yarn add @wbx-sandbox/mastra
bun add @wbx-sandbox/mastra
Set your API key:
WBXSANDBOX_API_KEY=your-api-key
UsageDirect link to Usage
Add a WBXSandbox to a workspace and assign it to an agent:
import { Agent } from '@mastra/core/agent'
import { Workspace } from '@mastra/core/workspace'
import { WBXSandbox } from '@wbx-sandbox/mastra'
const workspace = new Workspace({
sandbox: new WBXSandbox({ id: 'my-project' }),
})
export const agent = new Agent({
id: 'code-agent',
name: 'Code Agent',
instructions: 'You write and run code in your sandbox.',
model: 'anthropic/claude-sonnet-5.5',
workspace,
})
Ask the agent to run a command in the sandbox:
const response = await agent.generate('Run `uname -a`.')
console.log(response.text)
The response includes the sandbox's Linux kernel version.
The id is the sandbox name. Starting a sandbox with the same id reconnects to the existing sandbox and its files instead of creating a new one. Every request that uses this agent shares the same sandbox. To give each user or thread its own sandbox, see Sandboxes per user or thread.
LifecycleDirect link to Lifecycle
start()gets the sandbox namedidor creates it.stop()stops background processes and, by default, puts the sandbox to sleep. Its files are kept.destroy()deletes the sandbox and its files.
For templates, network rules, checkpoints, desktop access, and all constructor options, see the WBX Sandbox Mastra guide.