( isHeadless: boolean, )
| 77 | |
| 78 | // Get all builtin tools including dynamic ones, with capability-based filtering |
| 79 | export async function getAllAvailableTools( |
| 80 | isHeadless: boolean, |
| 81 | ): Promise<Tool[]> { |
| 82 | const tools = [...BASE_BUILTIN_TOOLS]; |
| 83 | |
| 84 | const isRipgrepInstalled = await checkIfRipgrepIsInstalled(); |
| 85 | if (isRipgrepInstalled) { |
| 86 | tools.push(...BUILTIN_SEARCH_TOOLS); |
| 87 | } |
| 88 | |
| 89 | // Add agent-specific tools if agent ID is present |
| 90 | // (these require --id to function and will confuse the agent if unavailable) |
| 91 | const agentId = getAgentIdFromArgs(); |
| 92 | if (agentId) { |
| 93 | tools.push(reportFailureTool); |
| 94 | |
| 95 | // UploadArtifact tool is gated behind beta flag |
| 96 | if (isBetaUploadArtifactToolEnabled()) { |
| 97 | tools.push(uploadArtifactTool); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // If model is capable, exclude editTool in favor of multiEditTool |
| 102 | const modelState = await serviceContainer.get<ModelServiceState>( |
| 103 | SERVICE_NAMES.MODEL, |
| 104 | ); |
| 105 | if (!modelState.model) { |
| 106 | throw new Error("Model service is not initialized"); |
| 107 | } |
| 108 | |
| 109 | const { provider, name, model } = modelState.model; |
| 110 | |
| 111 | const isCapable = isModelCapable(provider, name, model); |
| 112 | if (isCapable) { |
| 113 | tools.push(multiEditTool); |
| 114 | } else { |
| 115 | tools.push(editTool); |
| 116 | logger.debug( |
| 117 | "Excluded Edit tool for capable model - MultiEdit will be used instead", |
| 118 | ); |
| 119 | } |
| 120 | |
| 121 | logger.debug("Capability-based tool filtering", { |
| 122 | provider, |
| 123 | name, |
| 124 | isCapable, |
| 125 | }); |
| 126 | |
| 127 | if (isHeadless) { |
| 128 | tools.push(exitTool); |
| 129 | } |
| 130 | |
| 131 | if (isBetaSubagentToolEnabled()) { |
| 132 | tools.push(await subagentTool()); |
| 133 | } |
| 134 | |
| 135 | tools.push(await skillsTool()); |
| 136 |
no test coverage detected