| 91 | } |
| 92 | |
| 93 | function buildRequiresActionDetails( |
| 94 | tool: Tool, |
| 95 | input: Record<string, unknown>, |
| 96 | toolUseID: string, |
| 97 | requestId: string, |
| 98 | ): RequiresActionDetails { |
| 99 | // Per-tool summary methods may throw on malformed input; permission |
| 100 | // handling must not break because of a bad description. |
| 101 | let description: string |
| 102 | try { |
| 103 | description = |
| 104 | tool.getActivityDescription?.(input) ?? |
| 105 | tool.getToolUseSummary?.(input) ?? |
| 106 | tool.userFacingName(input) |
| 107 | } catch { |
| 108 | description = tool.name |
| 109 | } |
| 110 | return { |
| 111 | tool_name: tool.name, |
| 112 | action_description: description, |
| 113 | tool_use_id: toolUseID, |
| 114 | request_id: requestId, |
| 115 | input, |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | type PendingRequest<T> = { |
| 120 | resolve: (result: T) => void |