Skip to content

Commands / Commands

Interface: Commands ​

Module for starting and interacting with commands in the sandbox.

Methods ​

closeStdin() ​

closeStdin(pid, opts?): Promise<void>

Close command stdin.

This signals EOF to the command. The command must have been started with stdin: true.

Parameters ​

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() ​

connect(pid, opts?): Promise<CommandHandle>

Connect to a running command. You can use CommandHandle.wait to wait for the command to finish and get execution results.

Parameters ​

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() ​

kill(pid, opts?): Promise<boolean>

Kill a running command specified by its process ID. It uses SIGKILL signal to kill the command.

Parameters ​

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() ​

list(opts?): Promise<ProcessInfo[]>

List all running commands and PTY sessions.

Parameters ​

opts? ​

CommandRequestOpts

connection options.

Returns ​

Promise<ProcessInfo[]>

list of running commands and PTY sessions.


run() ​

Call Signature ​

run(cmd, opts?): Promise<CommandResult>

Start a new command and wait until it finishes executing.

Parameters ​
cmd ​

string

command to execute.

opts? ​

CommandStartOpts & object

options for starting the command.

Returns ​

Promise<CommandResult>

CommandResult result of the command execution.

Call Signature ​

run(cmd, opts): Promise<CommandHandle>

Start a new command in the background. You can use CommandHandle.wait to wait for the command to finish and get its result.

Parameters ​
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 ​

run(cmd, opts?): Promise<CommandResult | CommandHandle>

Start a new command.

Parameters ​
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, returns CommandResult
Returns ​

Promise<CommandResult | CommandHandle>

Either a CommandHandle or a CommandResult (depending on opts.background).


sendStdin() ​

sendStdin(pid, data, opts?): Promise<void>

Send data to command stdin.

Parameters ​

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>