1234567891011import { Sandbox } from "@opencomputer/sdk"; const sandbox = await Sandbox.create(); const pty = await sandbox.pty.create({ onOutput: (data) => process.stdout.write(data), }); pty.send("ls -la /app\n"); // ... wait for output ... pty.close(); await sandbox.kill();
12345const pty = await sandbox.pty.create({ cols: 120, rows: 40, onOutput: (data) => process.stdout.write(data), });
| Parameter | Type | Default | Description |
cols | number | 80 | Terminal columns |
rows | number | 24 | Terminal rows |
onOutput | callback | — | Called with output data (TS: Uint8Array, Python: bytes) |
| Member | TypeScript | Python | Description |
| Session ID | pty.sessionId | pty.session_id | Unique session ID |
| Send input | pty.send(data) | pty.send(data) | Send keystrokes or commands |
| Receive output | via onOutput callback | await pty.recv() | Get terminal output |
| Close | pty.close() | await pty.close() | Close the PTY session |
recv() is Python-only — a pull-based alternative to the on_output callback. Returns raw bytes.POST /api/sandboxes/:id/pty/:sessionID/resize). The SDKs do not expose a resize method — the CLI handles resize automatically for interactive sessions.12oc shell sb-abc123 oc shell sb-abc123 --shell /bin/zsh
oc shell for details.