attach()
Ctrl+] (or configured detach keys) to disconnect without stopping the process.
Parameters
| Name | Type | Description |
|---|---|---|
| cmd | string | Command to run |
| args? | Array<string> | Command arguments |
| Type | Description |
|---|---|
number | Exit code of the process |
attachShell()
| Type | Description |
|---|---|
number | Exit code |
attachWithConfig()
| Name | Type | Description |
|---|---|---|
| config | AttachConfig | Attach configuration |
| Type | Description |
|---|---|
number | Exit code |
exec()
execStream() instead.
Parameters
| Name | Type | Description |
|---|---|---|
| cmd | string | Command to execute (e.g. "python", "/usr/bin/node") |
| args? | Array<string> | Command arguments (e.g. ["-c", "print('hello')"]) |
| Type | Description |
|---|---|
ExecOutput | Collected stdout, stderr, and exit status |
execStream()
| Name | Type | Description |
|---|---|---|
| cmd | string | Command to execute |
| args? | Array<string> | Command arguments |
| Type | Description |
|---|---|
ExecHandle | Streaming handle for receiving events and controlling the process |
execWithConfig()
| Name | Type | Description |
|---|---|---|
| config | ExecConfig | Execution configuration |
| Type | Description |
|---|---|
ExecOutput | Collected stdout, stderr, and exit status |
shell()
/bin/sh). Shell syntax like pipes, redirects, and && chains works.
Parameters
| Name | Type | Description |
|---|---|---|
| script | string | Shell command string (e.g. "ls -la /app && echo done") |
| Type | Description |
|---|---|
ExecOutput | Collected stdout, stderr, and exit status |
shellStream()
| Name | Type | Description |
|---|---|---|
| script | string | Shell command string |
| Type | Description |
|---|---|
ExecHandle | Streaming handle |
Types
AttachConfig
| Field | Type | Default | Description |
|---|---|---|---|
| args? | Array<string> | [] | Command arguments |
| cmd | string | - | Command to run (required) |
| cwd? | string | - | Working directory |
| detachKeys? | string | Ctrl+] | Key sequence to detach without stopping |
| env? | Record<string, string> | {} | Environment variables |
| user? | string | - | Guest user |
ExecConfig
Per-execution overrides.| Field | Type | Default | Description |
|---|---|---|---|
| args? | Array<string> | [] | Command arguments |
| cmd | string | - | Command to execute (required) |
| cwd? | string | - | Working directory |
| env? | Record<string, string> | {} | Environment variables (merged on top of sandbox env) |
| stdin? | string | - | Fixed stdin content |
| timeoutMs? | number | - | Kill the process after this many milliseconds |
| tty? | boolean | false | Allocate a pseudo-terminal |
| user? | string | - | Guest user |
ExecEvent
| Field | Type | Description |
|---|---|---|
| code? | number | Exit code (on 'exited') |
| data? | Buffer | Output data (on 'stdout' / 'stderr') |
| eventType | ExecEventType | Event type |
| pid? | number | Guest PID (on 'started') |
ExecEventType
| Value | Description |
|---|---|
'exited' | The process has exited |
'started' | The process has started |
'stderr' | A chunk of stderr data |
'stdout' | A chunk of stdout data |
ExecHandle
A handle to a running streaming execution.| Property / Method | Type | Description |
|---|---|---|
| collect() | Promise<ExecOutput> | Wait and collect all remaining output |
| id | Promise<string> | Session ID for this execution |
| kill() | Promise<void> | Send SIGKILL |
| recv() | Promise<ExecEvent | null> | Receive the next event. Returns null when done. |
| signal(signal) | Promise<void> | Send a POSIX signal to the process |
| takeStdin() | Promise<ExecSink | null> | Take the stdin writer. Returns null after first call. |
| wait() | Promise<ExitStatus> | Wait for the process to exit |
ExecOutput
The result of a completed command execution.| Property / Method | Type | Description |
|---|---|---|
| code | number | Exit code |
| status() | ExitStatus | Exit status object |
| stderr() | string | Collected stderr decoded as a string |
| stderrBytes() | Buffer | Raw stderr bytes |
| stdout() | string | Collected stdout decoded as a string |
| stdoutBytes() | Buffer | Raw stdout bytes |
| success | boolean | true if code is 0 |
ExecSink
Writer for sending data to a running process’s stdin.| Method | Parameters | Description |
|---|---|---|
| close() | - | Close stdin. The process sees EOF. |
| write() | data: Buffer | Write bytes to the process’s stdin |
ExitStatus
| Field | Type | Description |
|---|---|---|
| code | number | Exit code. 0 typically means success. |
| success | boolean | true if code is 0 |