JsBox handle.
Box Handle
JsBox
Handle to a running or stopped box.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique box identifier (ULID) |
name | string | null | User-defined name |
Methods
| Method | Signature | Description |
|---|---|---|
info() | () => JsBoxInfo | Get box metadata (sync) |
exec() | (cmd, args?, env?, tty?) => Promise<JsExecution> | Execute command |
stop() | () => Promise<void> | Stop the box |
metrics() | () => Promise<JsBoxMetrics> | Get resource metrics |
JsBoxInfo
Metadata about a box.
| Field | Type | Description |
|---|---|---|
id | string | Unique box identifier (ULID) |
name | string | undefined | User-defined name |
status | string | Current status: "Starting", "Running", "Stopped", etc. |
createdAt | string | Creation timestamp (ISO 8601) |
lastUpdated | string | Last state change (ISO 8601) |
pid | number | undefined | Process ID (if running) |
BoxStatus
A box can be in one of the following states:
| Status | Description |
|---|---|
"Starting" | Box is being initialized |
"Running" | Box is active and accepting commands |
"Stopped" | Box has been stopped |
SimpleBox
Context manager for basic command execution with automatic cleanup.Constructor Options
Properties
| Property | Type | Description |
|---|---|---|
id | string | Box ID (throws if not started) |
name | string | undefined | Box name |
Methods
| Method | Signature | Description |
|---|---|---|
getId() | () => Promise<string> | Get box ID (async) |
getInfo() | () => Promise<JsBoxInfo> | Get box info (async) |
exec() | (cmd, ...args) => Promise<ExecResult> | Execute and wait |
stop() | () => Promise<void> | Stop the box |
[Symbol.asyncDispose]() | () => Promise<void> | Async disposal |
Example
CodeBox
Python code execution sandbox.Constructor Options
Methods
| Method | Signature | Description |
|---|---|---|
run() | (code: string) => Promise<string> | Execute Python code |
runScript() | (scriptPath: string) => Promise<string> | Run script file |
installPackage() | (pkg: string) => Promise<string> | pip install |
installPackages() | (...pkgs: string[]) => Promise<string> | Install multiple |
Example
BrowserBox
Browser automation with Chrome DevTools Protocol.Constructor Options
BrowserType
Supported browser types.
Browser CDP Ports
| Browser | Port | Image |
|---|---|---|
chromium | 9222 | mcr.microsoft.com/playwright:v1.47.2-jammy |
firefox | 9223 | browserless/firefox:latest |
webkit | 9224 | browserless/webkit:latest |
Methods
| Method | Signature | Description |
|---|---|---|
start() | (timeout?: number) => Promise<void> | Start browser |
endpoint() | () => string | Get CDP endpoint URL |
Example
ComputerBox
Desktop automation with full GUI environment.Constructor Options
Mouse Methods
| Method | Signature | Description |
|---|---|---|
mouseMove() | (x: number, y: number) => Promise<void> | Move cursor |
leftClick() | () => Promise<void> | Left click |
rightClick() | () => Promise<void> | Right click |
middleClick() | () => Promise<void> | Middle click |
doubleClick() | () => Promise<void> | Double click |
tripleClick() | () => Promise<void> | Triple click |
leftClickDrag() | (startX, startY, endX, endY) => Promise<void> | Drag |
cursorPosition() | () => Promise<[number, number]> | Get cursor pos |
Keyboard Methods
| Method | Signature | Description |
|---|---|---|
type() | (text: string) => Promise<void> | Type text |
key() | (keySequence: string) => Promise<void> | Press key(s) |
Key Syntax Reference (xdotool format)
| Key | Syntax |
|---|---|
| Enter | Return |
| Tab | Tab |
| Escape | Escape |
| Backspace | BackSpace |
| Delete | Delete |
| Space | space |
| Arrow keys | Up, Down, Left, Right |
| Function keys | F1, F2, … F12 |
| Page keys | Page_Up, Page_Down, Home, End |
| Modifiers | ctrl, alt, shift, super |
| Combinations | ctrl+c, ctrl+shift+s, alt+Tab |
Display Methods
| Method | Signature | Description |
|---|---|---|
waitUntilReady() | (timeout?: number) => Promise<void> | Wait for desktop |
screenshot() | () => Promise<Screenshot> | Capture screen |
scroll() | (x, y, direction, amount?) => Promise<void> | Scroll |
getScreenSize() | () => Promise<[number, number]> | Get dimensions |
Screenshot Return Type
Scroll Directions
| Direction | Description |
|---|---|
"up" | Scroll up |
"down" | Scroll down |
"left" | Scroll left |
"right" | Scroll right |
Example
InteractiveBox
Interactive terminal sessions with PTY support.Constructor Options
TTY Mode
| Value | Behavior |
|---|---|
undefined | Auto-detect from stdin |
true | Force TTY with I/O forwarding |
false | No I/O forwarding |
Methods
| Method | Signature | Description |
|---|---|---|
start() | () => Promise<void> | Start PTY session |
wait() | () => Promise<void> | Wait for shell exit |