(message: SdkUserMessage)
| 292 | } |
| 293 | |
| 294 | function* handleUser(message: SdkUserMessage): Generator<StreamChunk> { |
| 295 | const content = message.message.content |
| 296 | if (typeof content === 'string') return |
| 297 | for (const block of content) { |
| 298 | if (block.type !== 'tool_result') continue |
| 299 | const toolResult = block as { |
| 300 | tool_use_id: string |
| 301 | content?: SdkToolResultContent |
| 302 | is_error?: boolean |
| 303 | } |
| 304 | unresolvedToolCalls.delete(toolResult.tool_use_id) |
| 305 | yield { |
| 306 | type: EventType.TOOL_CALL_RESULT, |
| 307 | toolCallId: toolResult.tool_use_id, |
| 308 | messageId: genId(), |
| 309 | model, |
| 310 | timestamp: now(), |
| 311 | content: stringifyToolResultContent(toolResult.content), |
| 312 | ...(toolResult.is_error === true && { state: 'output-error' as const }), |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | function* handleResult(message: SdkResultMessage): Generator<StreamChunk> { |
| 318 | yield* closePartialText() |
no test coverage detected