(
shellRuns: ShellRunLauncher,
options: {
executionFacts?: ToolExecutionFacts;
shell?: ShellPlan;
/** Opening sentence of the description, before the shared foreground/background/PTY contract. */
lead?: string;
/**
* Whether this host has a sandbox boundary the model can be asked to declare.
* False drops `required_boundary` from the schema entirely rather than
* accepting and ignoring it: a parameter no host enforces is pure noise in
* the model's tool selection.
*/
declareSandboxBoundary?: boolean;
/**
* Foreground timeout when the model does not ask for one, per command —
* the same hook shape buildForegroundBashTool exposes, so a host that
* carves out a slow command keeps that carve-out on both paths instead of
* re-implementing it on one.
*
* A host default is CLAMPED to MAX_FOREGROUND_BASH_TIMEOUT_MS rather than
* passed through: the launcher REJECTS anything larger, so an operator who
* raised their own floor past ten minutes would otherwise break every
* foreground command instead of merely capping it. A timeout the model asks
* for explicitly is still rejected above the maximum — that is a stated
* schema bound, not a host misconfiguration.
*/
defaultTimeoutMs?: (command: string) => number | undefined;
/** Observes each committed result; used by hosts that record tool evidence. */
afterResult?: (
input: { command: string; cwd: string; timeoutMs?: number },
result: TerminalToolResult | ShellRunToolResult,
ctx: MakaToolContext,
) => Promise<void> | void;
transformCommand?: (input: {
command: string;
pty: boolean;
requiredBoundary?: SandboxBoundaryExpansion;
ctx: MakaToolContext;
}) =>
| {
argv?: readonly string[];
cwd: string;
env?: NodeJS.ProcessEnv;
fdInputs?: readonly ChildFdInput[];
sandboxType?: SandboxType;
onCompletion?: (outcome: { successful: boolean }) => void;
}
| undefined;
} = {},
)
| 142 | } |
| 143 | |
| 144 | export function buildManagedBashTool( |
| 145 | shellRuns: ShellRunLauncher, |
| 146 | options: { |
| 147 | executionFacts?: ToolExecutionFacts; |
| 148 | shell?: ShellPlan; |
| 149 | /** Opening sentence of the description, before the shared foreground/background/PTY contract. */ |
| 150 | lead?: string; |
| 151 | /** |
| 152 | * Whether this host has a sandbox boundary the model can be asked to declare. |
| 153 | * False drops `required_boundary` from the schema entirely rather than |
| 154 | * accepting and ignoring it: a parameter no host enforces is pure noise in |
| 155 | * the model's tool selection. |
| 156 | */ |
| 157 | declareSandboxBoundary?: boolean; |
| 158 | /** |
| 159 | * Foreground timeout when the model does not ask for one, per command — |
| 160 | * the same hook shape buildForegroundBashTool exposes, so a host that |
| 161 | * carves out a slow command keeps that carve-out on both paths instead of |
| 162 | * re-implementing it on one. |
| 163 | * |
| 164 | * A host default is CLAMPED to MAX_FOREGROUND_BASH_TIMEOUT_MS rather than |
| 165 | * passed through: the launcher REJECTS anything larger, so an operator who |
| 166 | * raised their own floor past ten minutes would otherwise break every |
| 167 | * foreground command instead of merely capping it. A timeout the model asks |
| 168 | * for explicitly is still rejected above the maximum — that is a stated |
| 169 | * schema bound, not a host misconfiguration. |
| 170 | */ |
| 171 | defaultTimeoutMs?: (command: string) => number | undefined; |
| 172 | /** Observes each committed result; used by hosts that record tool evidence. */ |
| 173 | afterResult?: ( |
| 174 | input: { command: string; cwd: string; timeoutMs?: number }, |
| 175 | result: TerminalToolResult | ShellRunToolResult, |
| 176 | ctx: MakaToolContext, |
| 177 | ) => Promise<void> | void; |
| 178 | transformCommand?: (input: { |
| 179 | command: string; |
| 180 | pty: boolean; |
| 181 | requiredBoundary?: SandboxBoundaryExpansion; |
| 182 | ctx: MakaToolContext; |
| 183 | }) => |
| 184 | | { |
| 185 | argv?: readonly string[]; |
| 186 | cwd: string; |
| 187 | env?: NodeJS.ProcessEnv; |
| 188 | fdInputs?: readonly ChildFdInput[]; |
| 189 | sandboxType?: SandboxType; |
| 190 | onCompletion?: (outcome: { successful: boolean }) => void; |
| 191 | } |
| 192 | | undefined; |
| 193 | } = {}, |
| 194 | ): MakaTool { |
| 195 | const shell = options.shell ?? defaultShellPlan(); |
| 196 | const declareSandboxBoundary = options.declareSandboxBoundary !== false; |
| 197 | const managedBashFields = { |
| 198 | command: z.string().describe('The shell command to execute'), |
| 199 | timeout_ms: z.number().int().positive().max(MAX_SHELL_RUN_TIMEOUT_MS).optional(), |
| 200 | run_in_background: z.boolean().optional(), |
| 201 | pty: z.boolean().optional(), |
no test coverage detected