( toolCall: ToolCallState, toolCallId: string, completion: AsyncTerminalCompletionSnapshot | null )
| 192 | * Shared by both main and subagent scopes. |
| 193 | */ |
| 194 | export function handleClientCompletion( |
| 195 | toolCall: ToolCallState, |
| 196 | toolCallId: string, |
| 197 | completion: AsyncTerminalCompletionSnapshot | null |
| 198 | ): void { |
| 199 | if (completion?.status === ASYNC_TOOL_CONFIRMATION_STATUS.background) { |
| 200 | setTerminalToolCallState(toolCall, { |
| 201 | status: MothershipStreamV1ToolOutcome.skipped, |
| 202 | ...(completion.data !== undefined ? { output: completion.data } : {}), |
| 203 | }) |
| 204 | markToolResultSeen(toolCallId) |
| 205 | return |
| 206 | } |
| 207 | if (completion?.status === MothershipStreamV1ToolOutcome.cancelled) { |
| 208 | setTerminalToolCallState(toolCall, { |
| 209 | status: MothershipStreamV1ToolOutcome.cancelled, |
| 210 | ...(completion.data !== undefined ? { output: completion.data } : {}), |
| 211 | error: completion.message || 'Tool cancelled', |
| 212 | }) |
| 213 | markToolResultSeen(toolCallId) |
| 214 | return |
| 215 | } |
| 216 | const success = completion?.status === MothershipStreamV1ToolOutcome.success |
| 217 | setTerminalToolCallState(toolCall, { |
| 218 | status: success ? MothershipStreamV1ToolOutcome.success : MothershipStreamV1ToolOutcome.error, |
| 219 | ...(completion?.data !== undefined ? { output: completion.data } : {}), |
| 220 | ...(success ? {} : { error: completion?.message || 'Tool failed' }), |
| 221 | }) |
| 222 | markToolResultSeen(toolCallId) |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Emit a synthetic tool_result SSE event to the client after a client-executable |
no test coverage detected