Function: sandboxedExecutor()
function sandboxedExecutor(options: SandboxedExecutorOptions): BinaryExecutor;Defined in: src/batteries/sandbox/executor.ts:60
Adapt a BinaryExecutor to a command sandbox. This WRAPS inner.exec() and DOES NOT STREAM: the shipped BinaryExecutor contract returns settled strings. Consequently an execa inner executor retains its output and inherits execa's bounded maxBuffer behaviour; this adapter does not raise that bound (and never sets maxBuffer: Infinity). The streaming path is createRunShellCommandTool, which uses the policy-enforcer stream contract instead.
The adapter hands the invocation to BinarySandbox.wrap verbatim and runs what comes back: inner.exec(await sandbox.wrap(invocation)). The returned cmd/args are the complete wrapped argv, so the original args are not re-appended — a wrapper that wants them in the wrapped command puts them there itself. Quoting is therefore the wrapper's job, not this adapter's.
Bypass is an audit-only opt-out. Its predicate receives cmd only, never argv: callers must allow only binaries safe with hostile arguments and must never allow an interpreter. Non-zero exits remain data and are never thrown. Removing this wrapper call restores the inner executor.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SandboxedExecutorOptions | The wrapper, the inner executor, and the optional audit hooks. |
Returns
A BinaryExecutor whose non-bypassed invocations go through options.sandbox.wrap.