switch to shell tool, deprecating terminal (#203)

* switch to shell tool, deprecating terminal

* Merge remote-tracking branch 'origin/main' into deprecate_terminal
This commit is contained in:
Olcan
2025-04-28 15:05:36 -07:00
committed by GitHub
parent 30b04295d2
commit 57ceadb7d8
6 changed files with 53 additions and 36 deletions

View File

@@ -24,7 +24,6 @@ export interface ShellToolParams {
import { spawn } from 'child_process';
export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
// name should match TerminalTool.Name used in prompts.ts for now
static Name: string = 'execute_bash_command';
private readonly config: Config;
private whitelist: Set<string> = new Set();
@@ -193,18 +192,19 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
// wait for the shell to exit
await new Promise((resolve) => shell.on('close', resolve));
return {
llmContent: [
`Command: ${params.command}`,
`Directory: ${params.directory || '(root)'}`,
`Stdout: ${stdout || '(empty)'}`,
`Stderr: ${stderr || '(empty)'}`,
`Error: ${error ?? '(none)'}`,
`Exit Code: ${code ?? '(none)'}`,
`Signal: ${signal ?? '(none)'}`,
`Background PIDs: ${backgroundPIDs.length ? backgroundPIDs.join(', ') : '(none)'}`,
].join('\n'),
returnDisplay: output,
};
const llmContent = [
`Command: ${params.command}`,
`Directory: ${params.directory || '(root)'}`,
`Stdout: ${stdout || '(empty)'}`,
`Stderr: ${stderr || '(empty)'}`,
`Error: ${error ?? '(none)'}`,
`Exit Code: ${code ?? '(none)'}`,
`Signal: ${signal ?? '(none)'}`,
`Background PIDs: ${backgroundPIDs.length ? backgroundPIDs.join(', ') : '(none)'}`,
].join('\n');
const returnDisplay = this.config.getDebugMode() ? llmContent : output;
return { llmContent, returnDisplay };
}
}