(permissionContext: ToolPermissionContext)
| 269 | } |
| 270 | |
| 271 | export const getTools = (permissionContext: ToolPermissionContext): Tools => { |
| 272 | // Simple mode: only Bash, Read, and Edit tools |
| 273 | if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) { |
| 274 | // --bare + REPL mode: REPL wraps Bash/Read/Edit/etc inside the VM, so |
| 275 | // return REPL instead of the raw primitives. Matches the non-bare path |
| 276 | // below which also hides REPL_ONLY_TOOLS when REPL is enabled. |
| 277 | if (isReplModeEnabled() && REPLTool) { |
| 278 | const replSimple: Tool[] = [REPLTool] |
| 279 | if ( |
| 280 | feature('COORDINATOR_MODE') && |
| 281 | coordinatorModeModule?.isCoordinatorMode() |
| 282 | ) { |
| 283 | replSimple.push(TaskStopTool, getSendMessageTool()) |
| 284 | } |
| 285 | return filterToolsByDenyRules(replSimple, permissionContext) |
| 286 | } |
| 287 | const simpleTools: Tool[] = [BashTool, FileReadTool, FileEditTool] |
| 288 | // When coordinator mode is also active, include AgentTool and TaskStopTool |
| 289 | // so the coordinator gets Task+TaskStop (via useMergedTools filtering) and |
| 290 | // workers get Bash/Read/Edit (via filterToolsForAgent filtering). |
| 291 | if ( |
| 292 | feature('COORDINATOR_MODE') && |
| 293 | coordinatorModeModule?.isCoordinatorMode() |
| 294 | ) { |
| 295 | simpleTools.push(AgentTool, TaskStopTool, getSendMessageTool()) |
| 296 | } |
| 297 | return filterToolsByDenyRules(simpleTools, permissionContext) |
| 298 | } |
| 299 | |
| 300 | // Get all base tools and filter out special tools that get added conditionally |
| 301 | const specialTools = new Set([ |
| 302 | ListMcpResourcesTool.name, |
| 303 | ReadMcpResourceTool.name, |
| 304 | SYNTHETIC_OUTPUT_TOOL_NAME, |
| 305 | ]) |
| 306 | |
| 307 | const tools = getAllBaseTools().filter(tool => !specialTools.has(tool.name)) |
| 308 | |
| 309 | // Filter out tools that are denied by the deny rules |
| 310 | let allowedTools = filterToolsByDenyRules(tools, permissionContext) |
| 311 | |
| 312 | // When REPL mode is enabled, hide primitive tools from direct use. |
| 313 | // They're still accessible inside REPL via the VM context. |
| 314 | if (isReplModeEnabled()) { |
| 315 | const replEnabled = allowedTools.some(tool => |
| 316 | toolMatchesName(tool, REPL_TOOL_NAME), |
| 317 | ) |
| 318 | if (replEnabled) { |
| 319 | allowedTools = allowedTools.filter( |
| 320 | tool => !REPL_ONLY_TOOLS.has(tool.name), |
| 321 | ) |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | const isEnabled = allowedTools.map(_ => _.isEnabled()) |
| 326 | return allowedTools.filter((_, i) => isEnabled[i]) |
| 327 | } |
| 328 |
no test coverage detected