(sessionId: string, turn: AppInFlightTurn)
| 542 | } |
| 543 | |
| 544 | function seedInFlight(sessionId: string, turn: AppInFlightTurn): AppEvent[] { |
| 545 | reset(sessionId); |
| 546 | const s = getOrCreate(sessionId); |
| 547 | |
| 548 | const promptId = turn.promptId ?? ulid('pr_'); |
| 549 | s.currentPromptId = promptId; |
| 550 | s.turnPromptId.set(turn.turnId, promptId); |
| 551 | |
| 552 | const msg = startAssistantMessage(s, sessionId, promptId); |
| 553 | if (turn.thinkingText.length > 0) { |
| 554 | msg.content.push({ type: 'thinking', thinking: turn.thinkingText }); |
| 555 | } |
| 556 | if (turn.assistantText.length > 0) { |
| 557 | msg.content.push({ type: 'text', text: turn.assistantText }); |
| 558 | } |
| 559 | for (const tool of turn.runningTools) { |
| 560 | const outputLines = |
| 561 | typeof tool.lastProgress?.text === 'string' && tool.lastProgress.text.length > 0 |
| 562 | ? [tool.lastProgress.text] |
| 563 | : undefined; |
| 564 | msg.content.push({ |
| 565 | type: 'toolUse', |
| 566 | toolCallId: tool.toolCallId, |
| 567 | toolName: tool.name, |
| 568 | input: tool.args ?? {}, |
| 569 | outputLines, |
| 570 | }); |
| 571 | s.toolStartTimes.set(tool.toolCallId, Date.now()); |
| 572 | } |
| 573 | s.currentAssistantMsgId = msg.id; |
| 574 | s.turnTextLen = turn.assistantText.length; |
| 575 | s.turnThinkLen = turn.thinkingText.length; |
| 576 | |
| 577 | return [ |
| 578 | { |
| 579 | type: 'sessionStatusChanged', |
| 580 | sessionId, |
| 581 | status: 'running', |
| 582 | previousStatus: 'idle', |
| 583 | currentPromptId: promptId, |
| 584 | }, |
| 585 | { type: 'messageCreated', message: cloneMessage(msg) }, |
| 586 | ]; |
| 587 | } |
| 588 | |
| 589 | function project( |
| 590 | rawType: string, |
nothing calls this directly
no test coverage detected