(agentId: string, msg: Record<string, unknown>)
| 1394 | }; |
| 1395 | |
| 1396 | const handleChildCodexEvent = (agentId: string, msg: Record<string, unknown>): void => { |
| 1397 | const msgType = asString(msg.type); |
| 1398 | if (!msgType) return; |
| 1399 | childAgentActivityInCurrentTurn = true; |
| 1400 | const runtime = getChildRuntime(agentId); |
| 1401 | const isChildTerminalEvent = msgType === 'task_complete' || msgType === 'turn_aborted' || msgType === 'task_failed'; |
| 1402 | if (runtime.blockedNestedAgent && !isChildTerminalEvent) { |
| 1403 | return; |
| 1404 | } |
| 1405 | const updateActivity = ( |
| 1406 | activity: string, |
| 1407 | activityKind: string, |
| 1408 | extra?: Record<string, unknown> |
| 1409 | ): void => { |
| 1410 | if (runtime.terminal) { |
| 1411 | return; |
| 1412 | } |
| 1413 | emitAgentRunUpdate(agentId, { |
| 1414 | status: 'running', |
| 1415 | statusText: activity, |
| 1416 | activity, |
| 1417 | activityKind, |
| 1418 | ...extra |
| 1419 | }); |
| 1420 | }; |
| 1421 | |
| 1422 | if (msgType === 'token_count') { |
| 1423 | return; |
| 1424 | } |
| 1425 | |
| 1426 | if (msgType === 'context_compacted') { |
| 1427 | emitAgentRunTraceMessage(agentId, { |
| 1428 | type: 'context_compacted', |
| 1429 | id: randomUUID() |
| 1430 | }); |
| 1431 | updateActivity('Context compacted', 'compact'); |
| 1432 | return; |
| 1433 | } |
| 1434 | |
| 1435 | if (msgType === 'task_started') { |
| 1436 | runtime.reasoningPreview = ''; |
| 1437 | runtime.finalMessage = null; |
| 1438 | runtime.terminal = false; |
| 1439 | agentStatusByAgentId.delete(agentId); |
| 1440 | updateActivity('Starting task', 'starting'); |
| 1441 | return; |
| 1442 | } |
| 1443 | if (msgType === 'agent_reasoning_section_break') { |
| 1444 | runtime.reasoningProcessor.handleSectionBreak(); |
| 1445 | runtime.reasoningPreview = ''; |
| 1446 | updateActivity('Thinking', 'thinking'); |
| 1447 | return; |
| 1448 | } |
| 1449 | if (msgType === 'agent_reasoning_delta') { |
| 1450 | const delta = asString(msg.delta); |
| 1451 | if (delta) { |
| 1452 | runtime.reasoningProcessor.processDelta(delta); |
| 1453 | runtime.reasoningPreview = truncateText(`${runtime.reasoningPreview}${delta}`, 160); |
nothing calls this directly
no test coverage detected