Skip to main content
System

Processes

Run commands and manage long-lived processes inside the sandbox.

The process API supports:

  • One-shot execution — run a command to completion and capture stdout, stderr, and exit code
  • Managed processes — spawn, list, stop, kill, and delete long-lived processes
  • Log streaming — fetch buffered logs or follow live output
  • Terminals — full PTY support with bidirectional WebSocket I/O
  • Configurable limits — control concurrency, timeouts, and buffer sizes per runtime

Run a command

Execute a command to completion and get its output.

You can set a timeout and cap output size:

Managed processes

Create a long-lived process that you can interact with, monitor, and stop later.

Create

List and get

Stop, kill, and delete

Logs

Fetch buffered logs

Follow logs

Stream log entries in real time. The subscription replays buffered entries first, then streams new output as it arrives.

const sub = await sdk.followProcessLogs("proc_1", (entry) => {
  console.log(entry.stream, atob(entry.data));
});

// Later, stop following
sub.close();
await sub.closed;

Terminals

Create a process with tty: true to allocate a pseudo-terminal, then connect via WebSocket for full bidirectional I/O.

const proc = await sdk.createProcess({
  command: "bash",
  tty: true,
});

Write input

Connect to a terminal

Use ProcessTerminalSession unless you need direct frame access.

const terminal = sdk.connectProcessTerminal("proc_1");

terminal.onReady(() => {
  terminal.resize({ cols: 120, rows: 40 });
  terminal.sendInput("ls\n");
});

terminal.onData((bytes) => {
  process.stdout.write(new TextDecoder().decode(bytes));
});

terminal.onExit((status) => {
  console.log("exit:", status.exitCode);
});

terminal.onError((error) => {
  console.error(error instanceof Error ? error.message : error.message);
});

terminal.onClose(() => {
  console.log("terminal closed");
});

Since the browser WebSocket API cannot send custom headers, the endpoint accepts an access_token query parameter for authentication. The SDK handles this automatically.

Browser terminal emulators

The terminal session works with any browser terminal emulator like ghostty-web or xterm.js. For a drop-in React terminal, see React Components.

Configuration

Adjust runtime limits like max concurrent processes, timeouts, and buffer sizes.