MCPcopy Create free account
hub / github.com/apache/maka / buildForegroundBashTool

Function buildForegroundBashTool

packages/runtime/src/shell-tools.ts:90–121  ·  view source on GitHub ↗
(options: BuildForegroundBashToolOptions)

Source from the content-addressed store, hash-verified

88}
89
90export function buildForegroundBashTool(options: BuildForegroundBashToolOptions): MakaTool {
91 const maxTimeoutMs = options.maxTimeoutMs ?? 600_000;
92 return {
93 name: 'Bash',
94 activityKind: 'command',
95 description: options.description,
96 parameters: z.object({
97 command: z.string().describe('The shell command to execute'),
98 timeout_ms: z.number().int().positive().max(maxTimeoutMs).optional(),
99 }),
100 toModelOutput: ({ output }) => bashToolResultToModelOutput(output),
101 ...(options.executionFacts ? { executionFacts: options.executionFacts } : {}),
102 impl: async ({ command, timeout_ms }, ctx) => {
103 const timeoutMs = timeout_ms ?? options.defaultTimeoutMs?.(command);
104 const result = await options.execute({ command, cwd: ctx.cwd, timeoutMs, ctx });
105 if (options.emitReturnedOutput) {
106 if (result.stdout) ctx.emitOutput('stdout', result.stdout);
107 if (result.stderr) ctx.emitOutput('stderr', result.stderr);
108 }
109 await options.afterResult?.(
110 { command, cwd: ctx.cwd, ...(timeoutMs !== undefined ? { timeoutMs } : {}) },
111 result,
112 ctx,
113 );
114 return shapeTerminalResult({
115 cwd: ctx.cwd,
116 command,
117 result,
118 });
119 },
120 };
121}
122
123export function buildLocalForegroundBashTool(
124 options: { executionFacts?: ToolExecutionFacts; shell?: ShellPlan } = {},

Calls 3

shapeTerminalResultFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected