Commands
Module for starting and interacting with commands in the sandbox.Constructors
Parameters
| Parameter | Type |
|---|---|
transport | Transport |
connectionConfig | ConnectionConfig |
metadata | object |
metadata.version | string |
Returns
Commands
Methods
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()
run(cmd, opts)
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.
run(cmd, opts)
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.
run(cmd, opts)
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<CommandResult | CommandHandle>
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 | 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 | object |
metadata.version | string |
Returns
Pty
Methods
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, "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 | object | new size of the PTY. |
size.cols | number | - |
size.rows? | number | - |
opts? | Pick<ConnectionOpts, "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, "requestTimeoutMs"> | connection options. |
Returns
Promise<void>
Interfaces
CommandRequestOpts
Options for sending a command request.Extended by
CommandStartOpts
Properties
requestTimeoutMs?
Default
CommandStartOpts
Options for starting a new command.Properties
background?
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
stdin?
Default
timeoutMs?
Default
user?
Default
default Sandbox user (as specified in the template)