Skip to main content
Sandboxes have PTY session support for interactive terminal sessions. SDK is available for Node.js and Python to build your own terminal client. This page documents how to build a terminal client, to start a terminal session, see CLI Terminal.

Create and Attach to a Terminal

Create a terminal and attach to its websocket stream:

Write Input and Resize the PTY

Send input through the attached connection and resize the terminal:

Get, Refresh, and Wait

Fetch an existing terminal or wait for it to complete:

Signal and Kill

You can signal or kill a terminal-backed process:
status.running tells you whether the terminal session is still alive after the signal. After signal("TERM") and a successful wait(...), you would usually expect status.running to be false.

Common Terminal Parameters

string
required
Command to launch inside the terminal session.
string[]
Optional command arguments.
string
Working directory for the terminal process.
object
Environment variables to set for the terminal process.
number
Initial terminal row count.
number
Initial terminal column count.
number
Optional PTY runtime limit in milliseconds.
sandbox.pty is an alias for sandbox.terminal.

Create Interactive Terminal

Run an interactive sandbox shell from your backend process and bridge local terminal input/output to the sandbox PTY stream.
The Python raw-mode bridge uses termios and tty, so it is intended for POSIX terminals (Linux/macOS).