( executeCommand: (command: string) => Promise<string>, )
| 6 | * Replicates the functionality of anthropic.tools.bash_20250124 |
| 7 | */ |
| 8 | export function createGenericBashTool( |
| 9 | executeCommand: (command: string) => Promise<string>, |
| 10 | ) { |
| 11 | return tool({ |
| 12 | description: `Execute bash commands to interact with the system. Use this to run shell commands, manage files, and interact with git. |
| 13 | |
| 14 | Available commands: |
| 15 | - ls, cat, find: File operations |
| 16 | - git: Version control |
| 17 | - mkdir, cd: Directory operations |
| 18 | - npm, pnpm: Package management |
| 19 | - gh: GitHub CLI |
| 20 | |
| 21 | IMPORTANT: Only specific commands are allowed for security. Commands that modify git config (user.name, user.email) are forbidden.`, |
| 22 | inputSchema: z.object({ |
| 23 | command: z.string().describe("The bash command to execute"), |
| 24 | restart: z |
| 25 | .boolean() |
| 26 | .optional() |
| 27 | .describe( |
| 28 | "Whether to restart the bash session (currently not supported)", |
| 29 | ), |
| 30 | }), |
| 31 | execute: async ({ command }) => { |
| 32 | return await executeCommand(command); |
| 33 | }, |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Generic text editor tool that works with any AI provider |
no test coverage detected