Sandbox Class
TheSandbox class is the main entry point for interacting with Hopx sandboxes in JavaScript/TypeScript. It provides methods for creating, connecting to, and managing sandboxes, as well as access to all resources.
Class Definition
Static Methods
Sandbox.create()
Create a new sandbox from a template.
Promise<Sandbox>
Example:
Sandbox.connect()
Connect to an existing sandbox.
sandboxId(string): Sandbox IDoptions(object, optional): Connection options
Promise<Sandbox>
Note: If the sandbox is paused, it will be automatically resumed.
Sandbox.list()
List all sandboxes.
Instance Methods
Lifecycle Methods
init()
Initialize agent client (required before using resources).
getInfo()
Get sandbox information.
Promise<SandboxInfo>
kill()
Delete the sandbox.
start()
Start a stopped sandbox.
stop()
Stop a running sandbox.
pause()
Pause a running sandbox.
resume()
Resume a paused sandbox.
Code Execution
runCode()
Execute code synchronously.
Resources
files
File operations resource (lazy-loaded).
commands
Command execution resource (lazy-loaded).
env
Environment variables resource (lazy-loaded).
desktop
Desktop automation resource (lazy-loaded).
cache
Cache management resource (lazy-loaded).
terminal
Interactive terminal resource (lazy-loaded).
Complete Example
Related
- Code Execution - Execute code
- File Operations - File management
- Commands - Shell commands
- JavaScript SDK Overview - Overview

