summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/shell.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-08-15 12:08:29 -0700
committerGitHub <[email protected]>2025-08-15 19:08:29 +0000
commit01b8a7565cb419f906817507f6e788e14d6f8aae (patch)
tree15c371ad0f73e3e2d598befbcfc41dcff1e9273d /packages/core/src/tools/shell.ts
parent088f07483928aeeba26e259f4582d72ee1013f7a (diff)
Fix shell tool description to be os-specific (#6335)
Diffstat (limited to 'packages/core/src/tools/shell.ts')
-rw-r--r--packages/core/src/tools/shell.ts46
1 files changed, 32 insertions, 14 deletions
diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts
index 5b01a82f..8db66339 100644
--- a/packages/core/src/tools/shell.ts
+++ b/packages/core/src/tools/shell.ts
@@ -293,18 +293,8 @@ class ShellToolInvocation extends BaseToolInvocation<
}
}
-export class ShellTool extends BaseDeclarativeTool<
- ShellToolParams,
- ToolResult
-> {
- static Name: string = 'run_shell_command';
- private allowlist: Set<string> = new Set();
-
- constructor(private readonly config: Config) {
- super(
- ShellTool.Name,
- 'Shell',
- `This tool executes a given shell command as \`bash -c <command>\`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`.
+function getShellToolDescription(): string {
+ const returnedInfo = `
The following information is returned:
@@ -316,14 +306,42 @@ export class ShellTool extends BaseDeclarativeTool<
Exit Code: Exit code or \`(none)\` if terminated by signal.
Signal: Signal number or \`(none)\` if no signal was received.
Background PIDs: List of background processes started or \`(none)\`.
- Process Group PGID: Process group started or \`(none)\``,
+ Process Group PGID: Process group started or \`(none)\``;
+
+ if (os.platform() === 'win32') {
+ return `This tool executes a given shell command as \`cmd.exe /c <command>\`. Command can start background processes using \`start /b\`.${returnedInfo}`;
+ } else {
+ return `This tool executes a given shell command as \`bash -c <command>\`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`.${returnedInfo}`;
+ }
+}
+
+function getCommandDescription(): string {
+ if (os.platform() === 'win32') {
+ return 'Exact command to execute as `cmd.exe /c <command>`';
+ } else {
+ return 'Exact bash command to execute as `bash -c <command>`';
+ }
+}
+
+export class ShellTool extends BaseDeclarativeTool<
+ ShellToolParams,
+ ToolResult
+> {
+ static Name: string = 'run_shell_command';
+ private allowlist: Set<string> = new Set();
+
+ constructor(private readonly config: Config) {
+ super(
+ ShellTool.Name,
+ 'Shell',
+ getShellToolDescription(),
Kind.Execute,
{
type: 'object',
properties: {
command: {
type: 'string',
- description: 'Exact bash command to execute as `bash -c <command>`',
+ description: getCommandDescription(),
},
description: {
type: 'string',