Sandbox
sandbox.exec()
Example
Example
execStream() instead.
Parameters
cmdstring“python3”, “/usr/bin/node”).args?Iterable<string>[“-c”, “print(‘hello’)”]).Returns
sandbox.execWith()
Example
Example
Parameters
cmdstringReturns
sandbox.shell()
Example
Example
/bin/sh). Shell syntax like pipes, redirects, and && chains works.
Parameters
scriptstring“ls -la /app && echo done”).Returns
sandbox.attachShell()
Example
Example
Returns
Stream and attach
sandbox.execStream()
Example
Example
Parameters
cmdstringargs?Iterable<string>Returns
sandbox.execStreamWith()
Example
Example
execWith(): same configuration via ExecOptionsBuilder, but returns an ExecHandle instead of buffering output. For sessions configured with .tty(true), call resize(rows, cols) when the terminal dimensions change.
Parameters
cmdstringReturns
sandbox.shellStream()
Example
Example
Parameters
scriptstringReturns
sandbox.attach()
Example
Example
Ctrl+] (or configured detach keys) to disconnect without stopping the process.
Parameters
cmdstringargs?Iterable<string>Returns
sandbox.attachWith()
Example
Example
Parameters
cmdstringReturns
ExecOutput
Returned by exec() · execWith() · shell() · ExecHandle.collect()
Collected output and exit status.output.code
number (getter)
Process exit code
output.success
boolean (getter)
true when code === 0
output.status
ExitStatus (getter)
Exit status object
output.stdout()
Returns
string
output.stderr()
Returns
string
output.stdoutBytes()
Returns
Uint8Array
output.stderrBytes()
Returns
Uint8Array
ExecHandle
Returned by execStream() · execStreamWith() · shellStream()
A handle to a running streaming execution and its events.handle.recv()
null once the stream ends
Returns
Promise<ExecEvent \| null>
handle.takeStdin()
null after the first call
Returns
Promise<ExecSink \| null>
handle.wait()
Returns
Promise<ExitStatus>
handle.collect()
Returns
Promise<ExecOutput>
handle.signal()
Returns
Promise<void>
handle.kill()
Returns
Promise<void>
handle.resize()
Returns
Promise<void>
handle.Symbol.asyncIterator
for await...of
Returns
AsyncIterator<ExecEvent>
handle.Symbol.asyncDispose
await using scope exit
Returns
Promise<void>
ExecSink
Returned by ExecHandle.takeStdin()
Writer for sending data to a running process’s stdin. ImplementsAsyncDisposable. Obtained from ExecHandle.takeStdin() when the execution was configured with .stdinPipe().
sink.write()
Returns
(data: Uint8Array \| string) => Promise<void>
sink.close()
Returns
() => Promise<void>
sink.Symbol.asyncDispose
close() on await using scope exit
Returns
Promise<void>
ExecOptionsBuilder
Used by execWith() · execStreamWith()
Fluent builder passed to the callback inexecWith(cmd, b => ...) and execStreamWith(cmd, b => ...). Every setter mutates the builder and returns it, so calls chain.
execOptions.arg()
Returns
(arg: string) => this
execOptions.args()
Returns
(args: string[]) => this
execOptions.cwd()
Returns
(cwd: string) => this
execOptions.user()
Returns
(user: string) => this
execOptions.env()
Returns
(key: string, value: string) => this
execOptions.envs()
Returns
(vars: Record<string, string>) => this
execOptions.timeout()
Returns
(ms: number) => this
execOptions.stdinNull()
/dev/null (default)
Returns
() => this
execOptions.stdinPipe()
ExecHandle.takeStdin()
Returns
() => this
execOptions.stdinBytes()
Returns
(data: Buffer) => this
execOptions.tty()
Returns
(enabled: boolean) => this
execOptions.rlimit()
Returns
(resource: RlimitResource, limit: number) => this
execOptions.rlimitRange()
Returns
(resource: RlimitResource, soft: number, hard: number) => this
AttachOptionsBuilder
Used by attachWith()
Fluent builder passed to the callback inattachWith(cmd, b => ...). Every setter mutates the builder and returns it, so calls chain.
attachOptions.arg()
Returns
(arg: string) => this
attachOptions.args()
Returns
(args: string[]) => this
attachOptions.cwd()
Returns
(cwd: string) => this
attachOptions.user()
Returns
(user: string) => this
attachOptions.env()
Returns
(key: string, value: string) => this
attachOptions.envs()
Returns
(vars: Record<string, string>) => this
attachOptions.detachKeys()
"ctrl-]" or "ctrl-p,ctrl-q")
Returns
(spec: string) => this
attachOptions.rlimit()
Returns
(resource: RlimitResource, limit: number) => this
attachOptions.rlimitRange()
Returns
(resource: RlimitResource, soft: number, hard: number) => this
Stdin
Produces StdinMode
Helper factory for constructing aStdinMode. Equivalent to the stdinNull / stdinPipe / stdinBytes setters on ExecOptionsBuilder.
Stdin.null()
/dev/null
Returns
() => StdinMode
Stdin.pipe()
ExecHandle.takeStdin()
Returns
() => StdinMode
Stdin.bytes()
Returns
(data: Uint8Array \| string) => StdinMode
Types
ExecEvent
Emitted by ExecHandle
Discriminated union emitted while iterating anExecHandle. The discriminator is kind.
ExitStatus
Returned by ExecHandle.wait() · ExecOutput.status
The exit result of a process.StdinMode
Produced by Stdin
Discriminated union describing stdin behavior for an execution.Rlimit
Set via ExecOptionsBuilder.rlimit() · AttachOptionsBuilder.rlimit()
A POSIX resource limit applied to the process.RlimitResource
Used by Rlimit.resource · rlimit() · rlimit()
String union naming a limitable POSIX resource.