* Run a single read tool to completion and return its raw ToolResult, * classifying expected failures the same way execute's catch does so * the SHAPE is identical whether dispatch runs in-process or on a worker: * NotIndexed → success-shaped guidance, PathRefusal → clean er
(toolName: string, args: Record<string, unknown>)
| 3476 | * path validation already ran in {@link execute} before routing here. |
| 3477 | */ |
| 3478 | async executeReadTool(toolName: string, args: Record<string, unknown>): Promise<ToolResult> { |
| 3479 | try { |
| 3480 | return await this.dispatchTool(toolName, args); |
| 3481 | } catch (err) { |
| 3482 | if (err instanceof NotIndexedError) { |
| 3483 | return this.textResult(err.message); |
| 3484 | } |
| 3485 | if (err instanceof WslSharedIndexError) { |
| 3486 | return this.textResult(wslSharedIndexGuidance(err)); |
| 3487 | } |
| 3488 | if (err instanceof PathRefusalError) { |
| 3489 | return this.errorResult(err.message); |
| 3490 | } |
| 3491 | if (isDatabaseOpenFailure(err)) { |
| 3492 | return this.errorResult(databaseOpenFailureText(err)); |
| 3493 | } |
| 3494 | return this.errorResult( |
| 3495 | `Tool execution failed: ${err instanceof Error ? err.message : String(err)}. ` + |
| 3496 | 'This is an internal codegraph error — retry the call once; if it persists, ' + |
| 3497 | 'continue without codegraph for this task.' |
| 3498 | ); |
| 3499 | } |
| 3500 | } |
| 3501 | |
| 3502 | /** |
| 3503 | * Pure dispatch over the read tools — the switch, with no gate, no notices, no |
no test coverage detected