Sandbox class is the main entry point to OpenSandbox. Use it to create new sandboxes, connect to existing ones, and access all sub-modules (commands, filesystem, PTY, templates).
Creating a Sandbox
Sandbox.create(opts?)
Creates a new sandbox and returns a connected Sandbox instance.
Promise<Sandbox>
Connecting to an Existing Sandbox
Sandbox.connect(sandboxId, opts?)
Connects to a running sandbox by ID.
The ID of the sandbox to connect to.
Promise<Sandbox>
Properties
| Property | Type | Description |
|---|---|---|
sandboxId | string | Unique identifier for the sandbox |
status | string | Current status: "running", "stopped", or "error" |
files | Filesystem | Filesystem operations |
commands | Commands | Command execution |
pty | Pty | PTY terminal access |
Instance Methods
sandbox.kill()
Stops and destroys the sandbox. All data is lost.
Promise<void>
sandbox.isRunning()
Checks if the sandbox is still alive.
Promise<boolean>
sandbox.setTimeout(timeout)
Updates the sandbox timeout. Resets the TTL countdown.
New timeout in seconds.
Promise<void>