* 完成解析 * exitCode 非 0 且没有解析到有效 JSON 消息时,将非 JSON 输出作为错误推送
(exitCode?: number)
| 801 | } |
| 802 | |
| 803 | /** |
| 804 | * 处理用户消息 |
| 805 | * 跳过 — 用户消息已由 session.service.ts 在收到请求时主动推送, |
| 806 | * 这里如果再处理 Claude Code 回显的 user message 会导致重复 |
| 807 | */ |
| 808 | private handleUserMessage(msg: ClaudeCodeMessage): void { |
| 809 | this.markTurnStarted() |
| 810 | // 用户文本已由 session.service.ts 主动写入 MsgStore,这里只消费 |
| 811 | // --replay-user-messages 回放的 tool_result block,用来关闭对应工具状态。 |
| 812 | for (const block of msg.message?.content ?? []) { |
| 813 | if (block.type === 'tool_result' && block.tool_use_id) { |
| 814 | this.updateToolResultStatus(block.tool_use_id, block.is_error) |
| 815 | const resultText = typeof block.content === 'string' |
| 816 | ? block.content |
| 817 | : Array.isArray(block.content) |
| 818 | ? (block.content as Array<{ type?: string; text?: string }>) |
| 819 | .filter(c => c.type === 'text' && c.text) |
| 820 | .map(c => c.text) |
| 821 | .join('\n') |
| 822 | : undefined |
| 823 | this.appendToolResultContent(block.tool_use_id, resultText) |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 |
nothing calls this directly
no test coverage detected