Bash
Execute bounded shell commands through the daemon.
client.bash
client.bash.run executes one bounded bash -c command through the daemon.
const result = await client.bash.run({
command: 'printf "%s\\n" "$MESSAGE"',
cwd: '/absolute/path/to/project',
env: { MESSAGE: 'hello' },
timeout_s: 30,
profile: 'my-app',
});
if (result.exit_code !== 0) console.error(result.stderr);
run(params, options?) returns Promise<BashRunDTO>. Its final options object is the normal request-options object: headers, signal, timeout, and maxRetries.
| Result field | Type | Meaning |
|---|---|---|
| exit_code | number \| null | Process exit code, or null after a timeout. A non-zero code is returned, not thrown. |
| signal | string \| null | Signal that ended the process, when one did. |
| stdout / stderr | string | Captured output prefix. |
| stdout_truncated / stderr_truncated | boolean | Whether that output stream exceeded its 256 KiB capture limit. |
| timed_out | boolean | true after the daemon terminates the process group for a timeout. |
| duration_ms | number | Command duration in milliseconds. |
cwd is required, absolute, and must name an existing directory. The daemon never uses its own working directory as a fallback. timeout_s defaults to 60, must be greater than 0, and cannot exceed 600. The SDK keeps the HTTP request open for the command timeout plus 15 seconds, unless its configured request timeout is already longer.
Pass dynamic values through env and reference them from the command as "$NAME", rather than interpolating them into shell source. The command receives the daemon's default-deny operational environment, selected profile environment, then your env values.
Authority
The token is the owner credential. Anyone holding it can already create an agent with a bash tool, so this command runs with the daemon user's authority and does not provide a restricted command area.