* 处理错误事件(type: error / turn.failed) * - 重试类消息(Reconnecting... N/M):原地更新同一个 entry * - 普通错误:去重后创建新 entry
(message: string)
| 419 | content: typeof t?.text === 'string' ? stripAnsiSequences(t.text) : '', |
| 420 | status: t?.completed ? 'completed' : 'pending', |
| 421 | })); |
| 422 | |
| 423 | const summary = todos.length > 0 |
| 424 | ? todos.map((t) => `${t.status === 'completed' ? '[x]' : '[ ]'} ${t.content}`).join('\n') |
| 425 | : 'Todo list'; |
| 426 | |
| 427 | const entry = createToolUse('update_plan', summary, 'todo_management', item.id, item.id); |
| 428 | this.upsertItemEntry(item.id, { |
| 429 | ...entry, |
| 430 | metadata: { |
| 431 | ...entry.metadata, |
| 432 | ...(todos.length > 0 ? { todos } : {}), |
| 433 | }, |
| 434 | }); |
| 435 | } |
| 436 | |
| 437 | private createMcpToolEntry(item: CodexItem, status: ToolStatus): NormalizedEntry { |
| 438 | const toolName = item.tool || 'mcp'; |
| 439 | const content = this.formatMcpToolContent(item); |
| 440 | const entry = createToolUse(toolName, content, 'tool', item.id, item.id); |
| 441 | |
| 442 | return { |
| 443 | ...entry, |
| 444 | metadata: { |
| 445 | ...entry.metadata, |
| 446 | status, |
| 447 | }, |
| 448 | }; |
| 449 | } |
| 450 | |
| 451 | private formatMcpToolContent(item: CodexItem): string { |
| 452 | const target = item.server && item.tool ? `${item.server}/${item.tool}` : item.tool || item.server || 'mcp'; |
| 453 | const lines = [`MCP tool call: ${target}`]; |
| 454 | |
| 455 | if (item.server) lines.push(`Server: ${item.server}`); |
| 456 | if (item.tool) lines.push(`Tool: ${item.tool}`); |
| 457 | if (item.status) lines.push(`Status: ${item.status}`); |
| 458 | if (item.arguments !== undefined) lines.push(`Arguments: ${this.formatJsonValue(item.arguments)}`); |
| 459 | if (item.result !== undefined && item.result !== null) lines.push(`Result: ${this.formatJsonValue(item.result)}`); |
| 460 | if (item.error !== undefined && item.error !== null) lines.push(`Error: ${this.formatJsonValue(item.error)}`); |
| 461 |
no test coverage detected