({ workspaceDir, name, input, confirmShellCommand })
| 166 | } |
| 167 | |
| 168 | async function dispatchTool({ workspaceDir, name, input, confirmShellCommand }) { |
| 169 | switch (name) { |
| 170 | case 'list_dir': |
| 171 | return listDir(workspaceDir, input) |
| 172 | case 'read_file': |
| 173 | return readFile(workspaceDir, input) |
| 174 | case 'write_file': |
| 175 | return writeFile(workspaceDir, input) |
| 176 | case 'search_text': |
| 177 | return searchText(workspaceDir, input) |
| 178 | case 'shell_command': |
| 179 | return runShellCommand(workspaceDir, input, confirmShellCommand) |
| 180 | default: |
| 181 | throw new Error(`Unsupported tool: ${name}`) |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | async function listDir(workspaceDir, input) { |
| 186 | const requestedPath = typeof input.path === 'string' && input.path ? input.path : '.' |
no test coverage detected