(
kind: ToolKind,
toolName: string,
args: Record<string, unknown>,
)
| 183 | } |
| 184 | |
| 185 | private async tryDirectToolCall( |
| 186 | kind: ToolKind, |
| 187 | toolName: string, |
| 188 | args: Record<string, unknown>, |
| 189 | ): Promise<ToolCallResult | undefined> { |
| 190 | try { |
| 191 | return await this.callMappedToolDirectly(toolName, args); |
| 192 | } catch (error) { |
| 193 | const action = classifyToolError(error); |
| 194 | |
| 195 | if (action === 'reset-session') { |
| 196 | await this.resetConnection(true); |
| 197 | return undefined; |
| 198 | } |
| 199 | |
| 200 | if (action === 'refresh-tools') { |
| 201 | await this.clearToolCache(); |
| 202 | return undefined; |
| 203 | } |
| 204 | |
| 205 | throw new OperationError(`Failed to invoke the ${kind} Learn MCP tool directly.`, { cause: error }); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | private async callMappedToolWithSdk(kind: ToolKind, args: Record<string, unknown>): Promise<ToolCallResult> { |
| 210 | await this.ensureConnected(); |
no test coverage detected