Commands
Module for starting and interacting with commands in the sandbox.Constructors
Parameters
| Parameter | Type |
|---|---|
transport | Transport |
connectionConfig | ConnectionConfig |
metadata | { version: string; } |
metadata.version | string |
Returns
Commands
Methods
closeStdin()
stdin: true.
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the command. You can get the list of running commands using Commands.list. |
opts? | CommandRequestOpts | connection options. |
Returns
Promise<void>
connect()
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the command to connect to. You can get the list of running commands using Commands.list. |
opts? | CommandConnectOpts | connection options. |
Returns
Promise<CommandHandle>
CommandHandle handle to interact with the running command.
kill()
SIGKILL signal to kill the command.
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the command. You can get the list of running commands using Commands.list. |
opts? | CommandRequestOpts | connection options. |
Returns
Promise<boolean>
true if the command was killed, false if the command was not found.
list()
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | CommandRequestOpts | connection options. |
Returns
Promise<ProcessInfo[]>
list of running commands and PTY sessions.
run()
Call Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
cmd | string | command to execute. |
opts? | CommandStartOpts & object | options for starting the command. |
Returns
Promise<CommandResult>
CommandResult result of the command execution.
Call Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
cmd | string | command to execute. |
opts | CommandStartOpts & object | options for starting the command |
Returns
Promise<CommandHandle>
CommandHandle handle to interact with the running command.
Call Signature
Parameters
| Parameter | Type | Description | |
|---|---|---|---|
cmd | string | command to execute. | |
opts? | CommandStartOpts & object | options for starting the command. - opts.background: true - runs in background, returns CommandHandle - `opts.background: false | undefined- waits for completion, returnsCommandResult` |
Returns
Promise<CommandHandle | CommandResult>
Either a CommandHandle or a CommandResult (depending on opts.background).
sendStdin()
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the command. You can get the list of running commands using Commands.list. |
data | string | Uint8Array<ArrayBufferLike> | data to send to the command. |
opts? | CommandRequestOpts | connection options. |
Returns
Promise<void>
Pty
Module for interacting with PTYs (pseudo-terminals) in the sandbox.Constructors
Parameters
| Parameter | Type |
|---|---|
transport | Transport |
connectionConfig | ConnectionConfig |
metadata | { version: string; } |
metadata.version | string |
Returns
Pty
Methods
connect()
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the PTY to connect to. You can get the list of running PTYs using Commands.list. |
opts? | PtyConnectOpts | connection options. |
Returns
Promise<CommandHandle>
handle to interact with the PTY.
create()
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | PtyCreateOpts | options for creating the PTY. |
Returns
Promise<CommandHandle>
handle to interact with the PTY.
kill()
SIGKILL signal to kill the PTY.
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the PTY. |
opts? | Pick<ConnectionOpts, "signal" | "requestTimeoutMs"> | connection options. |
Returns
Promise<boolean>
true if the PTY was killed, false if the PTY was not found.
resize()
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the PTY. |
size | { cols: number; rows: number; } | new size of the PTY. |
size.cols | number | - |
size.rows? | number | - |
opts? | Pick<ConnectionOpts, "signal" | "requestTimeoutMs"> | connection options. |
Returns
Promise<void>
sendInput()
Parameters
| Parameter | Type | Description |
|---|---|---|
pid | number | process ID of the PTY. |
data | Uint8Array | input data to send to the PTY. |
opts? | Pick<ConnectionOpts, "signal" | "requestTimeoutMs"> | connection options. |
Returns
Promise<void>
Interfaces
CommandRequestOpts
Options for sending a command request.Extended by
CommandStartOpts
Properties
requestTimeoutMs?
Default
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
cwd?
Default
envs?
Sandbox constructor.
Default
{}
onStderr()?
Parameters
| Parameter | Type |
|---|---|
data | string |
Returns
void | Promise<void>
onStdout()?
Parameters
| Parameter | Type |
|---|---|
data | string |
Returns
void | Promise<void>
requestTimeoutMs?
Default
signal?
AbortSignal that can be used to cancel the in-flight request.
When the signal is aborted, the underlying fetch is aborted and the
returned promise rejects with an AbortError.
stdin?
Default
timeoutMs?
Default
user?
Default
default Sandbox user (as specified in the template)