@bastani/atomic 0.9.38-alpha.10 → 0.9.38-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  7. package/dist/builtin/workflows/package.json +1 -1
  8. package/dist/builtin/workflows/src/extension/index.bundle.mjs +5 -0
  9. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  10. package/dist/core/agent-session-prompt.js +57 -15
  11. package/dist/core/agent-session-prompt.js.map +1 -1
  12. package/dist/core/queued-input-admission.d.ts +20 -0
  13. package/dist/core/queued-input-admission.d.ts.map +1 -0
  14. package/dist/core/queued-input-admission.js +55 -0
  15. package/dist/core/queued-input-admission.js.map +1 -0
  16. package/dist/extensions/mcp/client/transports/streamable-http.js +9 -8
  17. package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
  18. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +4 -0
  19. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  20. package/dist/modes/interactive/components/chat-session-host-actions.js +104 -30
  21. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  22. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  23. package/dist/modes/interactive/components/chat-session-host-events.js +1 -0
  24. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  25. package/dist/modes/interactive/components/chat-session-host-state.d.ts +4 -0
  26. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  27. package/dist/modes/interactive/components/chat-session-host-state.js +4 -0
  28. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  29. package/dist/modes/interactive/interactive-input-handling.js +8 -2
  30. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  31. package/dist/modes/interactive/interactive-mode-base.d.ts +4 -0
  32. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  33. package/dist/modes/interactive/interactive-mode-base.js +4 -0
  34. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  35. package/dist/modes/interactive/interactive-process-lifecycle.js +8 -2
  36. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  37. package/dist/modes/interactive/interactive-queueing.js +94 -73
  38. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  39. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  40. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  41. package/docs/usage.md +2 -0
  42. package/npm-shrinkwrap.json +32 -32
  43. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-actions.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-actions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,EAC/B,4BAA4B,GAC5B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGlG,SAAS,0BAA0B,CAClC,OAAkD;IAElD,OAAO,OAAO,OAAO,EAAE,mBAAmB,KAAK,UAAU,IAAI,OAAO,OAAO,CAAC,oBAAoB,KAAK,UAAU,CAAC;AACjH,CAAC;AAED,MAAM,UAAU,oBAAoB,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AM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC;IAC/C,IAAI,YAAY,EAAE,WAAW,IAAI,YAAY,EAAE,oBAAoB,EAAE,CAAC;QACrE,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC;QAChE,OAAO;IACR,CAAC;IACD,MAAM,0BAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,KAAK,UAAU,wBAAwB,CACtC,KAAwC,EACxC,IAAY;IAEZ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC/E,MAAM,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzD,OAAO;IACR,CAAC;IACD,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC;IAC/C,IAAI,YAAY,EAAE,WAAW,IAAI,YAAY,EAAE,oBAAoB,EAAE,CAAC;QACrE,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE,OAAO;IACR,CAAC;IACD,MAAM,0BAA0B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import type { AgentSessionQueuePauseControl } from \"../../../core/agent-session-methods.ts\";\nimport type { BashExecutionMessage } from \"../../../core/messages.ts\";\nimport { combineQueuedMessagesForEditor } from \"../chat-input-actions.ts\";\nimport { classifyChatCommand } from \"../skill-command-autocomplete.ts\";\nimport type { ChatMessageEntry } from \"./chat-message-renderer.ts\";\nimport { setChatSessionEditorText } from \"./chat-session-host-editor.ts\";\nimport {\n\tdecrementOptimisticUserSignature,\n\tincrementOptimisticUserSignature,\n\tisChatSessionBashRunning,\n\tisChatSessionStreaming,\n\tnotifyChatSessionStatus,\n\tnotifyChatSessionWarning,\n\trequiredChatSessionCommand,\n\trequiredChatSessionPromptCommand,\n\tsettleChatSessionPromptLifecycle,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n\tsyncChatSessionAnimationTick,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport type { ChatSessionSubmitMode } from \"./chat-session-host-types.ts\";\nimport { errorMessage, parseBashInput, userMessageSignature } from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nfunction supportsQueuedMessagePause(\n\tsession: AgentSessionQueuePauseControl | undefined,\n): session is AgentSessionQueuePauseControl {\n\treturn typeof session?.pauseQueuedMessages === \"function\" && typeof session.resumeQueuedMessages === \"function\";\n}\n\nexport function interruptChatSession<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\toptions?: { restoreQueuedMessages?: boolean },\n): Promise<void> {\n\tconst active = state.interruptSettlement;\n\tif (active !== undefined) return active;\n\tstate.interruptFailureMessage = undefined;\n\tconst settlement = (async (): Promise<void> => {\n\t\ttry {\n\t\t\tconst session = state.getAgentSession?.();\n\t\t\tif (supportsQueuedMessagePause(session)) session.pauseQueuedMessages();\n\t\t\tif (options?.restoreQueuedMessages) {\n\t\t\t\trestoreQueuedMessagesToEditor(state, {\n\t\t\t\t\tsuppressEmptyNotice: true,\n\t\t\t\t\tpreserveUnprotectedCustomMessages: true,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state, false);\n\t\t\tawait state.commands.interrupt?.();\n\t\t} catch (err) {\n\t\t\tstate.interruptFailureMessage = errorMessage(err);\n\t\t\tstate.statusMessage = state.interruptFailureMessage;\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t}\n\t})();\n\tstate.interruptSettlement = settlement;\n\tvoid settlement\n\t\t.finally(() => {\n\t\t\tif (state.interruptSettlement === settlement) state.interruptSettlement = undefined;\n\t\t})\n\t\t.catch(() => {});\n\treturn settlement;\n}\n\nasync function submitAfterInterruptSettlement<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tsettlement: Promise<void>,\n\ttext: string,\n\tmode: ChatSessionSubmitMode,\n): Promise<void> {\n\tconst editorText = state.inputBuffer;\n\ttry {\n\t\tstate.sdkBusy = true;\n\t\tstate.statusMessage = \"resuming…\";\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t\tawait settlement;\n\t\tawait requiredChatSessionCommand(state, \"resume\")(text, mode);\n\t\tif (state.inputBuffer === editorText) setChatSessionEditorText(state, \"\");\n\t\tstate.sdkBusy = false;\n\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t} catch (err) {\n\t\tstate.sdkBusy = false;\n\t\tstate.statusMessage = errorMessage(err);\n\t\tstate.interruptFailureMessage = undefined;\n\t} finally {\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport async function submitChatSession<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tmode: ChatSessionSubmitMode = \"auto\",\n\tsubmittedText?: string,\n): Promise<void> {\n\tif (state.disposed) return;\n\tconst text = (submittedText ?? state.inputBuffer).trim();\n\tif (!text) return;\n\tif (state.statusMessage === state.lastWarningMessage) state.statusMessage = \"\";\n\tstate.lastWarningMessage = undefined;\n\t// Task inspection is local even while Escape is settling. It must never release\n\t// the pause or fall through to model delivery; other slash commands keep their order.\n\tif (classifyChatCommand(text) === \"tasks\") {\n\t\ttry {\n\t\t\tif (!(await state.commands.handleSlashCommand?.(text))) {\n\t\t\t\tnotifyChatSessionWarning(state, \"Task inspection is unavailable in this host.\");\n\t\t\t}\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t} catch (err) {\n\t\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t\t} finally {\n\t\t\tstate.requestRender?.();\n\t\t}\n\t\treturn;\n\t}\n\tconst interruptSettlement = state.interruptSettlement;\n\tif (interruptSettlement !== undefined) {\n\t\tawait submitAfterInterruptSettlement(state, interruptSettlement, text, mode);\n\t\treturn;\n\t}\n\tif (state.interruptFailureMessage !== undefined) {\n\t\tstate.statusMessage = state.interruptFailureMessage;\n\t\tstate.interruptFailureMessage = undefined;\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t\treturn;\n\t}\n\tif (text.startsWith(\"/\") && state.commands.handleSlashCommand) {\n\t\tconst handled = await state.commands.handleSlashCommand(text);\n\t\tif (handled) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tstate.requestRender?.();\n\t\t\treturn;\n\t\t}\n\t}\n\tif (state.compacting) {\n\t\tsetChatSessionEditorText(state, \"\");\n\t\tstate.compactionQueuedMessages = [...state.compactionQueuedMessages, { text, mode }];\n\t\tnotifyChatSessionStatus(state, \"Queued message until compaction completes\");\n\t\treturn;\n\t}\n\tconst bash = parseBashInput(text);\n\tif (bash?.command) {\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tnotifyChatSessionWarning(state, \"A bash command is already running. esc cancel first.\");\n\t\t\tsetChatSessionEditorText(state, text);\n\t\t\treturn;\n\t\t}\n\t\tsetChatSessionEditorText(state, \"\");\n\t\tawait runChatSessionBashCommand(state, bash.command, bash.excludeFromContext);\n\t\treturn;\n\t}\n\tsetChatSessionEditorText(state, \"\");\n\tconst isPaused = state.isPaused?.() === true;\n\tconst agentSession = state.getAgentSession?.();\n\tconst nativeQueuePaused = supportsQueuedMessagePause(agentSession) && agentSession.queuedMessagesPaused;\n\tconst isStreaming = isChatSessionStreaming(state);\n\t// The session publishes the expanded skill block; a raw optimistic signature cannot reconcile with it.\n\tconst shouldAppendOptimisticUser = mode === \"auto\" && !isStreaming && classifyChatCommand(text) !== \"skill\";\n\tconst optimisticSignature = shouldAppendOptimisticUser ? userMessageSignature(text) : undefined;\n\tif (optimisticSignature !== undefined) {\n\t\tstate.liveChat.appendUserText(text);\n\t\tstate.bodyViewport.scrollToBottom();\n\t\tincrementOptimisticUserSignature(state, optimisticSignature);\n\t}\n\tstate.requestRender?.();\n\tlet submittedPromptLifecycleGeneration: number | undefined;\n\ttry {\n\t\tif (isPaused) {\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"resuming…\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait requiredChatSessionCommand(state, \"resume\")(text, mode);\n\t\t\tstate.sdkBusy = false;\n\t\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\treturn;\n\t\t}\n\t\tif (nativeQueuePaused) {\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"resuming…\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait agentSession.resumeQueuedMessages();\n\t\t\tawait state.commands.ensureAttached?.();\n\t\t\tawait requiredChatSessionPromptCommand(state)(text, mode);\n\t\t\tstate.sdkBusy = false;\n\t\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\treturn;\n\t\t}\n\t\tif (mode === \"followUp\" && isStreaming) {\n\t\t\tawait queueChatSessionFollowUp(state, text);\n\t\t\treturn;\n\t\t}\n\t\tif (isStreaming) {\n\t\t\tawait queueChatSessionSteer(state, text);\n\t\t} else {\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.sdkBusy = true;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tsubmittedPromptLifecycleGeneration = state.workingLifecycleGeneration;\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait state.commands.ensureAttached?.();\n\t\t\tawait requiredChatSessionPromptCommand(state)(text, mode);\n\t\t\tsettleSubmittedPromptLifecycle(state, submittedPromptLifecycleGeneration);\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t}\n\t} catch (err) {\n\t\tif (optimisticSignature !== undefined) {\n\t\t\tdecrementOptimisticUserSignature(state, optimisticSignature);\n\t\t}\n\t\tsettleSubmittedPromptLifecycle(state, submittedPromptLifecycleGeneration);\n\t\tstate.statusMessage = errorMessage(err);\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t}\n}\n\nconst settleSubmittedPromptLifecycle = settleChatSessionPromptLifecycle;\n\nexport async function abortChatSessionCompaction<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\ttry {\n\t\tif (state.commands.abortCompaction === undefined) {\n\t\t\t// A host without an abort command also has no engine completion to clear\n\t\t\t// this local indicator.\n\t\t\tstate.compacting = false;\n\t\t\tstate.sdkBusy = false;\n\t\t} else {\n\t\t\tawait state.commands.abortCompaction();\n\t\t\t// Keep new input behind prompts already queued for this compaction. The\n\t\t\t// matching compaction_end event owns the release and the state reset.\n\t\t}\n\t\tnotifyChatSessionStatus(state, \"Compaction cancelled\");\n\t} catch (err) {\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t} finally {\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport async function abortChatSessionBash<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\ttry {\n\t\tawait state.commands.abortBash?.();\n\t\tstate.localBashRunning = false;\n\t\tnotifyChatSessionStatus(state, \"Bash command cancelled\");\n\t} catch (err) {\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t} finally {\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport async function flushChatSessionCompactionQueue<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\tconst queued = [...state.compactionQueuedMessages];\n\tstate.compactionQueuedMessages = [];\n\tif (queued.length === 0) return;\n\tconst agentSession = state.getAgentSession?.();\n\tconst queueOnly = isChatSessionStreaming(state) || state.isPaused?.() === true || agentSession?.queuedMessagesPaused;\n\tconst deliveries = queued.map((message, index) => {\n\t\tconst delivery =\n\t\t\t!queueOnly && index === 0\n\t\t\t\t? requiredChatSessionPromptCommand(state)(message.text, message.mode)\n\t\t\t\t: message.mode === \"followUp\"\n\t\t\t\t\t? queueChatSessionFollowUp(state, message.text)\n\t\t\t\t\t: queueChatSessionSteer(state, message.text);\n\t\treturn delivery.catch((err) => {\n\t\t\tconst pending = [...state.compactionQueuedMessages, message];\n\t\t\tstate.compactionQueuedMessages = [\n\t\t\t\t...queued.filter((item) => pending.includes(item)),\n\t\t\t\t...pending.filter((item) => !queued.includes(item)),\n\t\t\t];\n\t\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t\t\tstate.requestRender?.();\n\t\t});\n\t});\n\tawait Promise.all(deliveries);\n}\n\nexport function restoreQueuedMessagesToEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\toptions?: { suppressEmptyNotice?: boolean; preserveUnprotectedCustomMessages?: boolean },\n): boolean {\n\tconst queuedMessages = [\n\t\t...state.pendingSteeringMessages,\n\t\t...state.pendingFollowUpMessages,\n\t\t...state.compactionQueuedMessages.map((message) => message.text),\n\t];\n\tif (queuedMessages.length === 0) {\n\t\tif (!options?.suppressEmptyNotice) notifyChatSessionStatus(state, \"No queued messages to restore\");\n\t\treturn false;\n\t}\n\tconst restoredText = combineQueuedMessagesForEditor(queuedMessages, state.inputBuffer);\n\tstate.pendingSteeringMessages = [];\n\tstate.pendingFollowUpMessages = [];\n\tstate.compactionQueuedMessages = [];\n\tsetChatSessionEditorText(state, restoredText);\n\tstate\n\t\t.getAgentSession?.()\n\t\t?.clearQueue(\n\t\t\toptions?.preserveUnprotectedCustomMessages ? { preserveUnprotectedCustomMessages: true } : undefined,\n\t\t);\n\tstate.requestRender?.();\n\treturn true;\n}\n\nasync function runChatSessionBashCommand<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tcommand: string,\n\texcludeFromContext: boolean,\n): Promise<void> {\n\tconst runBash = state.commands.runBash;\n\tif (!runBash) {\n\t\tnotifyChatSessionWarning(state, \"no bash command configured for this chat session\");\n\t\treturn;\n\t}\n\tconst bashMessage: BashExecutionMessage = {\n\t\trole: \"bashExecution\",\n\t\tcommand,\n\t\toutput: \"\",\n\t\texitCode: undefined,\n\t\tcancelled: false,\n\t\ttruncated: false,\n\t\ttimestamp: Date.now(),\n\t\t...(excludeFromContext ? { excludeFromContext: true } : {}),\n\t};\n\tconst bashEntry: ChatMessageEntry = {\n\t\trole: \"tool\",\n\t\tkind: \"bashExecution\",\n\t\tmessage: bashMessage,\n\t\tisPartial: true,\n\t};\n\tstate.transcript.push(bashEntry);\n\tstate.localBashRunning = true;\n\tstate.bodyViewport.scrollToBottom();\n\tstate.requestRender?.();\n\ttry {\n\t\tconst result = await runBash({\n\t\t\tcommand,\n\t\t\texcludeFromContext,\n\t\t\tonChunk: (chunk) => {\n\t\t\t\tbashMessage.output += chunk;\n\t\t\t\tstate.requestRender?.();\n\t\t\t},\n\t\t});\n\t\tbashMessage.output = result.output;\n\t\tbashMessage.exitCode = result.exitCode;\n\t\tbashMessage.cancelled = result.cancelled;\n\t\tbashMessage.truncated = result.truncated;\n\t\tif (result.fullOutputPath !== undefined) {\n\t\t\tbashMessage.fullOutputPath = result.fullOutputPath;\n\t\t}\n\t} catch (err) {\n\t\tbashMessage.output = errorMessage(err);\n\t\tbashMessage.exitCode = undefined;\n\t\tbashMessage.cancelled = false;\n\t\tbashMessage.truncated = false;\n\t} finally {\n\t\tbashEntry.isPartial = false;\n\t\tstate.localBashRunning = false;\n\t\tstate.requestRender?.();\n\t}\n}\n\nasync function queueChatSessionSteer<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): Promise<void> {\n\tif (classifyChatCommand(text) === \"skill\" && state.commands.submitUserMessage) {\n\t\tawait state.commands.submitUserMessage(text, \"auto\");\n\t\treturn;\n\t}\n\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming || agentSession?.queuedMessagesPaused) {\n\t\tawait agentSession.prompt(text, { streamingBehavior: \"steer\" });\n\t\treturn;\n\t}\n\tawait requiredChatSessionCommand(state, \"steer\")(text);\n}\n\nasync function queueChatSessionFollowUp<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): Promise<void> {\n\tif (classifyChatCommand(text) === \"skill\" && state.commands.submitUserMessage) {\n\t\tawait state.commands.submitUserMessage(text, \"followUp\");\n\t\treturn;\n\t}\n\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming || agentSession?.queuedMessagesPaused) {\n\t\tawait agentSession.prompt(text, { streamingBehavior: \"followUp\" });\n\t\treturn;\n\t}\n\tawait requiredChatSessionCommand(state, \"followUp\")(text);\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-actions.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-actions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,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AAE,CAAC,CAAC;QACnE,OAAO;IACR,CAAC;IACD,MAAM,0BAA0B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import type { AgentSessionQueuePauseControl } from \"../../../core/agent-session-methods.ts\";\nimport type { BashExecutionMessage } from \"../../../core/messages.ts\";\nimport { combineQueuedMessagesForEditor } from \"../chat-input-actions.ts\";\nimport { classifyChatCommand } from \"../skill-command-autocomplete.ts\";\nimport type { ChatMessageEntry } from \"./chat-message-renderer.ts\";\nimport { setChatSessionEditorText } from \"./chat-session-host-editor.ts\";\nimport {\n\tdecrementOptimisticUserSignature,\n\tincrementOptimisticUserSignature,\n\tisChatSessionBashRunning,\n\tisChatSessionStreaming,\n\tnotifyChatSessionStatus,\n\tnotifyChatSessionWarning,\n\trequiredChatSessionCommand,\n\trequiredChatSessionPromptCommand,\n\tsettleChatSessionPromptLifecycle,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n\tsyncChatSessionAnimationTick,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport type { ChatSessionSubmitMode } from \"./chat-session-host-types.ts\";\nimport { errorMessage, parseBashInput, userMessageSignature } from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nfunction supportsQueuedMessagePause(\n\tsession: AgentSessionQueuePauseControl | undefined,\n): session is AgentSessionQueuePauseControl {\n\treturn typeof session?.pauseQueuedMessages === \"function\" && typeof session.resumeQueuedMessages === \"function\";\n}\n\nexport function interruptChatSession<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\toptions?: { restoreQueuedMessages?: boolean },\n): Promise<void> {\n\tconst active = state.interruptSettlement;\n\tif (active !== undefined) return active;\n\tstate.interruptFailureMessage = undefined;\n\tconst settlement = (async (): Promise<void> => {\n\t\ttry {\n\t\t\tconst session = state.getAgentSession?.();\n\t\t\tif (supportsQueuedMessagePause(session)) session.pauseQueuedMessages();\n\t\t\tif (options?.restoreQueuedMessages) {\n\t\t\t\trestoreQueuedMessagesToEditor(state, {\n\t\t\t\t\tsuppressEmptyNotice: true,\n\t\t\t\t\tpreserveUnprotectedCustomMessages: true,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state, false);\n\t\t\tawait state.commands.interrupt?.();\n\t\t} catch (err) {\n\t\t\tstate.interruptFailureMessage = errorMessage(err);\n\t\t\tstate.statusMessage = state.interruptFailureMessage;\n\t\t\tthrow err;\n\t\t} finally {\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t}\n\t})();\n\tstate.interruptSettlement = settlement;\n\tvoid settlement\n\t\t.finally(() => {\n\t\t\tif (state.interruptSettlement === settlement) state.interruptSettlement = undefined;\n\t\t})\n\t\t.catch(() => {});\n\treturn settlement;\n}\n\nasync function submitAfterInterruptSettlement<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tsettlement: Promise<void>,\n\ttext: string,\n\tmode: ChatSessionSubmitMode,\n): Promise<void> {\n\tconst editorText = state.inputBuffer;\n\ttry {\n\t\tstate.sdkBusy = true;\n\t\tstate.statusMessage = \"resuming…\";\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t\tawait settlement;\n\t\tawait requiredChatSessionCommand(state, \"resume\")(text, mode);\n\t\tif (state.inputBuffer === editorText) setChatSessionEditorText(state, \"\");\n\t\tstate.sdkBusy = false;\n\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t} catch (err) {\n\t\tstate.sdkBusy = false;\n\t\tstate.statusMessage = errorMessage(err);\n\t\tstate.interruptFailureMessage = undefined;\n\t} finally {\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport async function submitChatSession<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tmode: ChatSessionSubmitMode = \"auto\",\n\tsubmittedText?: string,\n): Promise<void> {\n\tif (state.disposed) return;\n\tconst text = (submittedText ?? state.inputBuffer).trim();\n\tif (!text) return;\n\tif (state.statusMessage === state.lastWarningMessage) state.statusMessage = \"\";\n\tstate.lastWarningMessage = undefined;\n\t// Task inspection is local even while Escape is settling. It must never release\n\t// the pause or fall through to model delivery; other slash commands keep their order.\n\tif (classifyChatCommand(text) === \"tasks\") {\n\t\ttry {\n\t\t\tif (!(await state.commands.handleSlashCommand?.(text))) {\n\t\t\t\tnotifyChatSessionWarning(state, \"Task inspection is unavailable in this host.\");\n\t\t\t}\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t} catch (err) {\n\t\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t\t} finally {\n\t\t\tstate.requestRender?.();\n\t\t}\n\t\treturn;\n\t}\n\tconst interruptSettlement = state.interruptSettlement;\n\tif (interruptSettlement !== undefined) {\n\t\tawait submitAfterInterruptSettlement(state, interruptSettlement, text, mode);\n\t\treturn;\n\t}\n\tif (state.interruptFailureMessage !== undefined) {\n\t\tstate.statusMessage = state.interruptFailureMessage;\n\t\tstate.interruptFailureMessage = undefined;\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t\treturn;\n\t}\n\tif (text.startsWith(\"/\") && state.commands.handleSlashCommand) {\n\t\tconst handled = await state.commands.handleSlashCommand(text);\n\t\tif (handled) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tstate.requestRender?.();\n\t\t\treturn;\n\t\t}\n\t}\n\tif (state.compacting) {\n\t\tsetChatSessionEditorText(state, \"\");\n\t\tstate.compactionQueuedMessages = [...state.compactionQueuedMessages, { text, mode }];\n\t\tnotifyChatSessionStatus(state, \"Queued message until compaction completes\");\n\t\treturn;\n\t}\n\tconst bash = parseBashInput(text);\n\tif (bash?.command) {\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tnotifyChatSessionWarning(state, \"A bash command is already running. esc cancel first.\");\n\t\t\tsetChatSessionEditorText(state, text);\n\t\t\treturn;\n\t\t}\n\t\tsetChatSessionEditorText(state, \"\");\n\t\tawait runChatSessionBashCommand(state, bash.command, bash.excludeFromContext);\n\t\treturn;\n\t}\n\tsetChatSessionEditorText(state, \"\");\n\tconst isPaused = state.isPaused?.() === true;\n\tconst agentSession = state.getAgentSession?.();\n\tconst nativeQueuePaused = supportsQueuedMessagePause(agentSession) && agentSession.queuedMessagesPaused;\n\tconst heldBehindCompactionQueue = state.compactionFlushPending || state.compactionQueuedMessages.length > 0;\n\tif (heldBehindCompactionQueue && !isPaused && !nativeQueuePaused) {\n\t\tstate.compactionQueuedMessages = [...state.compactionQueuedMessages, { text, mode }];\n\t\tstate.requestRender?.();\n\t\tif (!state.compactionFlushPending) await flushChatSessionCompactionQueue(state);\n\t\treturn;\n\t}\n\t// Resuming a pause sends one message. Send the oldest held one; the rest, then this\n\t// submission, follow in order when that turn ends.\n\tconst resumeHeld = heldBehindCompactionQueue && !state.compactionFlushPending;\n\tif (resumeHeld) state.compactionQueuedMessages = [...state.compactionQueuedMessages, { text, mode }];\n\tconst submission = resumeHeld ? takeNextCompactionMessage(state) : undefined;\n\tconst submitText = submission?.text ?? text;\n\tconst submitMode = submission?.mode ?? mode;\n\tlet submissionStarted = false;\n\tif (submission) {\n\t\tstate.compactionPromptStarted = () => {\n\t\t\tsubmissionStarted = true;\n\t\t};\n\t}\n\tconst isStreaming = isChatSessionStreaming(state);\n\t// The session publishes the expanded skill block; a raw optimistic signature cannot reconcile with it.\n\tconst shouldAppendOptimisticUser =\n\t\tsubmitMode === \"auto\" && !isStreaming && classifyChatCommand(submitText) !== \"skill\";\n\tconst optimisticSignature = shouldAppendOptimisticUser ? userMessageSignature(submitText) : undefined;\n\tif (optimisticSignature !== undefined) {\n\t\tstate.liveChat.appendUserText(submitText);\n\t\tstate.bodyViewport.scrollToBottom();\n\t\tincrementOptimisticUserSignature(state, optimisticSignature);\n\t}\n\tstate.requestRender?.();\n\tlet submittedPromptLifecycleGeneration: number | undefined;\n\ttry {\n\t\tif (isPaused) {\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"resuming…\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait requiredChatSessionCommand(state, \"resume\")(submitText, submitMode);\n\t\t\tstate.sdkBusy = false;\n\t\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\treturn;\n\t\t}\n\t\tif (nativeQueuePaused) {\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"resuming…\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait agentSession.resumeQueuedMessages();\n\t\t\tawait state.commands.ensureAttached?.();\n\t\t\tawait requiredChatSessionPromptCommand(state)(submitText, submitMode);\n\t\t\tstate.sdkBusy = false;\n\t\t\tif (state.statusMessage === \"resuming…\") state.statusMessage = \"\";\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\treturn;\n\t\t}\n\t\tif (submitMode === \"followUp\" && isStreaming) {\n\t\t\tawait queueChatSessionFollowUp(state, submitText);\n\t\t\treturn;\n\t\t}\n\t\tif (isStreaming) {\n\t\t\tawait queueChatSessionSteer(state, submitText);\n\t\t} else {\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.sdkBusy = true;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tsubmittedPromptLifecycleGeneration = state.workingLifecycleGeneration;\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t\tawait state.commands.ensureAttached?.();\n\t\t\tawait requiredChatSessionPromptCommand(state)(submitText, submitMode);\n\t\t\tsettleSubmittedPromptLifecycle(state, submittedPromptLifecycleGeneration);\n\t\t\tsyncChatSessionAnimationTick(state);\n\t\t\tstate.requestRender?.();\n\t\t}\n\t} catch (err) {\n\t\tif (optimisticSignature !== undefined) {\n\t\t\tdecrementOptimisticUserSignature(state, optimisticSignature);\n\t\t}\n\t\tif (submission && !submissionStarted) {\n\t\t\tstate.compactionQueuedMessages = [submission, ...state.compactionQueuedMessages];\n\t\t}\n\t\tsettleSubmittedPromptLifecycle(state, submittedPromptLifecycleGeneration);\n\t\tstate.statusMessage = errorMessage(err);\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t} finally {\n\t\tif (submission) state.compactionPromptStarted = undefined;\n\t}\n}\n\nconst settleSubmittedPromptLifecycle = settleChatSessionPromptLifecycle;\n\nexport async function abortChatSessionCompaction<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\ttry {\n\t\tif (state.commands.abortCompaction === undefined) {\n\t\t\t// A host without an abort command also has no engine completion to clear\n\t\t\t// this local indicator.\n\t\t\tstate.compacting = false;\n\t\t\tstate.sdkBusy = false;\n\t\t} else {\n\t\t\tawait state.commands.abortCompaction();\n\t\t\t// Keep new input behind prompts already queued for this compaction. The\n\t\t\t// matching compaction_end event owns the release and the state reset.\n\t\t}\n\t\tnotifyChatSessionStatus(state, \"Compaction cancelled\");\n\t} catch (err) {\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t} finally {\n\t\tsyncChatSessionAnimationTick(state);\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport async function abortChatSessionBash<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\ttry {\n\t\tawait state.commands.abortBash?.();\n\t\tstate.localBashRunning = false;\n\t\tnotifyChatSessionStatus(state, \"Bash command cancelled\");\n\t} catch (err) {\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t} finally {\n\t\tstate.requestRender?.();\n\t}\n}\n\ntype CompactionQueuedMessage = ChatSessionHostState<never>[\"compactionQueuedMessages\"][number];\n\n/**\n * Send compaction-queued messages one at a time from the front of the queue. Input submitted\n * meanwhile joins the back, so a failed message returns to the front ahead of everything after it.\n */\nexport async function flushChatSessionCompactionQueue<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\tif (state.compactionFlushPending || state.compactionQueuedMessages.length === 0) return;\n\tstate.compactionFlushPending = true;\n\ttry {\n\t\tconst agentSession = state.getAgentSession?.();\n\t\tconst queueOnly =\n\t\t\tisChatSessionStreaming(state) || state.isPaused?.() === true || agentSession?.queuedMessagesPaused;\n\t\tif (!queueOnly && !(await startChatSessionCompactionPrompt(state))) return;\n\t\tfor (let message = takeNextCompactionMessage(state); message; message = takeNextCompactionMessage(state)) {\n\t\t\ttry {\n\t\t\t\tif (message.mode === \"followUp\") await queueChatSessionFollowUp(state, message.text);\n\t\t\t\telse await queueChatSessionSteer(state, message.text);\n\t\t\t} catch (err) {\n\t\t\t\treturnCompactionMessage(state, message, err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tstate.compactionFlushPending = false;\n\t\tstate.requestRender?.();\n\t}\n}\n\nfunction takeNextCompactionMessage<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = state.compactionQueuedMessages;\n\tstate.compactionQueuedMessages = rest;\n\tstate.requestRender?.();\n\treturn next;\n}\n\nfunction returnCompactionMessage<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tmessage: CompactionQueuedMessage,\n\terr: unknown,\n): void {\n\tstate.compactionQueuedMessages = [message, ...state.compactionQueuedMessages];\n\tnotifyChatSessionWarning(state, errorMessage(err));\n\tstate.requestRender?.();\n}\n\n/**\n * Start the first queued prompt. The rest of the batch stays queued until the prompt is accepted,\n * which the host observes as its run starting or the command settling, so a rejected prompt is\n * restored ahead of it.\n */\nasync function startChatSessionCompactionPrompt<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<boolean> {\n\tconst first = takeNextCompactionMessage(state);\n\tif (!first) return false;\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tstate.compactionPromptStarted = () => accept(true);\n\tconst prompt = requiredChatSessionPromptCommand(state)(first.text, first.mode);\n\tprompt.then(\n\t\t() => accept(true),\n\t\t() => accept(false),\n\t);\n\ttry {\n\t\tif (await accepted) {\n\t\t\tprompt.catch((err) => notifyChatSessionWarning(state, errorMessage(err)));\n\t\t\treturn true;\n\t\t}\n\t\treturnCompactionMessage(\n\t\t\tstate,\n\t\t\tfirst,\n\t\t\tawait prompt.then(\n\t\t\t\t() => undefined,\n\t\t\t\t(err: unknown) => err,\n\t\t\t),\n\t\t);\n\t\treturn false;\n\t} finally {\n\t\tstate.compactionPromptStarted = undefined;\n\t}\n}\n\nexport function restoreQueuedMessagesToEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\toptions?: { suppressEmptyNotice?: boolean; preserveUnprotectedCustomMessages?: boolean },\n): boolean {\n\tconst queuedMessages = [\n\t\t...state.pendingSteeringMessages,\n\t\t...state.pendingFollowUpMessages,\n\t\t...state.compactionQueuedMessages.map((message) => message.text),\n\t];\n\tif (queuedMessages.length === 0) {\n\t\tif (!options?.suppressEmptyNotice) notifyChatSessionStatus(state, \"No queued messages to restore\");\n\t\treturn false;\n\t}\n\tconst restoredText = combineQueuedMessagesForEditor(queuedMessages, state.inputBuffer);\n\tstate.pendingSteeringMessages = [];\n\tstate.pendingFollowUpMessages = [];\n\tstate.compactionQueuedMessages = [];\n\tsetChatSessionEditorText(state, restoredText);\n\tstate\n\t\t.getAgentSession?.()\n\t\t?.clearQueue(\n\t\t\toptions?.preserveUnprotectedCustomMessages ? { preserveUnprotectedCustomMessages: true } : undefined,\n\t\t);\n\tstate.requestRender?.();\n\treturn true;\n}\n\nasync function runChatSessionBashCommand<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tcommand: string,\n\texcludeFromContext: boolean,\n): Promise<void> {\n\tconst runBash = state.commands.runBash;\n\tif (!runBash) {\n\t\tnotifyChatSessionWarning(state, \"no bash command configured for this chat session\");\n\t\treturn;\n\t}\n\tconst bashMessage: BashExecutionMessage = {\n\t\trole: \"bashExecution\",\n\t\tcommand,\n\t\toutput: \"\",\n\t\texitCode: undefined,\n\t\tcancelled: false,\n\t\ttruncated: false,\n\t\ttimestamp: Date.now(),\n\t\t...(excludeFromContext ? { excludeFromContext: true } : {}),\n\t};\n\tconst bashEntry: ChatMessageEntry = {\n\t\trole: \"tool\",\n\t\tkind: \"bashExecution\",\n\t\tmessage: bashMessage,\n\t\tisPartial: true,\n\t};\n\tstate.transcript.push(bashEntry);\n\tstate.localBashRunning = true;\n\tstate.bodyViewport.scrollToBottom();\n\tstate.requestRender?.();\n\ttry {\n\t\tconst result = await runBash({\n\t\t\tcommand,\n\t\t\texcludeFromContext,\n\t\t\tonChunk: (chunk) => {\n\t\t\t\tbashMessage.output += chunk;\n\t\t\t\tstate.requestRender?.();\n\t\t\t},\n\t\t});\n\t\tbashMessage.output = result.output;\n\t\tbashMessage.exitCode = result.exitCode;\n\t\tbashMessage.cancelled = result.cancelled;\n\t\tbashMessage.truncated = result.truncated;\n\t\tif (result.fullOutputPath !== undefined) {\n\t\t\tbashMessage.fullOutputPath = result.fullOutputPath;\n\t\t}\n\t} catch (err) {\n\t\tbashMessage.output = errorMessage(err);\n\t\tbashMessage.exitCode = undefined;\n\t\tbashMessage.cancelled = false;\n\t\tbashMessage.truncated = false;\n\t} finally {\n\t\tbashEntry.isPartial = false;\n\t\tstate.localBashRunning = false;\n\t\tstate.requestRender?.();\n\t}\n}\n\nasync function queueChatSessionSteer<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): Promise<void> {\n\tif (classifyChatCommand(text) === \"skill\" && state.commands.submitUserMessage) {\n\t\tawait state.commands.submitUserMessage(text, \"auto\");\n\t\treturn;\n\t}\n\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming || agentSession?.queuedMessagesPaused) {\n\t\tawait agentSession.prompt(text, { streamingBehavior: \"steer\" });\n\t\treturn;\n\t}\n\tawait requiredChatSessionCommand(state, \"steer\")(text);\n}\n\nasync function queueChatSessionFollowUp<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): Promise<void> {\n\tif (classifyChatCommand(text) === \"skill\" && state.commands.submitUserMessage) {\n\t\tawait state.commands.submitUserMessage(text, \"followUp\");\n\t\treturn;\n\t}\n\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming || agentSession?.queuedMessagesPaused) {\n\t\tawait agentSession.prompt(text, { streamingBehavior: \"followUp\" });\n\t\treturn;\n\t}\n\tawait requiredChatSessionCommand(state, \"followUp\")(text);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-events.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAqB7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAWxE;AAiGD,wBAAgB,0BAA0B,CAAC,WAAW,SAAS,uBAAuB,EACrF,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACxC,KAAK,EAAE,iBAAiB,GACtB,OAAO,CAoMT"}
1
+ {"version":3,"file":"chat-session-host-events.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAqB7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAWxE;AAiGD,wBAAgB,0BAA0B,CAAC,WAAW,SAAS,uBAAuB,EACrF,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACxC,KAAK,EAAE,iBAAiB,GACtB,OAAO,CAqMT"}
@@ -120,6 +120,7 @@ export function applyChatSessionAgentEvent(state, event) {
120
120
  state.liveChat.clearPendingTools();
121
121
  state.statusMessage = "";
122
122
  changed = true;
123
+ state.compactionPromptStarted?.();
123
124
  break;
124
125
  case "agent_end": {
125
126
  const manualTakeoverPending = state.manualCompactionTakeoverPending;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-events.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,kCAAkC,EAClC,4BAA4B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,+BAA+B,EAC/B,2BAA2B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAA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AAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC;IACpG,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,OAAO;QACN,IAAI,EAAE,oBAAoB;QAC1B,UAAU;QACV,QAAQ;QACR,MAAM,EACL,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;YACnE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QACnF,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI;KACjC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAwB;IAIpD,MAAM,KAAK,GAAG,MAAM,CAAE,KAA6B,CAAC,KAAK,IAAK,KAA4B,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvG,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,qBAAqB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE;KACzE,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.js\";\nimport type { CompactionReason } from \"../../../core/agent-session-types.js\";\nimport {\n\ttype CompactionRung,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionResult,\n} from \"../../../core/compaction/index.ts\";\nimport {\n\ttype CustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tisVerbatimCompactionMessage,\n} from \"../../../core/messages.ts\";\nimport { pickWhimsicalWorkingMessage } from \"../whimsical-messages.ts\";\nimport { flushChatSessionCompactionQueue } from \"./chat-session-host-actions.ts\";\nimport {\n\tafterChatSessionEvent,\n\tdecrementOptimisticUserSignature,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport {\n\textractMessageText,\n\tisMessageLike,\n\tisUserMessageLike,\n\tuserMessageSignature,\n} from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nexport type { CompactionReason } from \"../../../core/agent-session-types.js\";\n\nexport function compactionStatusMessage(reason: CompactionReason): string {\n\tswitch (reason) {\n\t\tcase \"manual\":\n\t\t\treturn \"Compacting context...\";\n\t\tcase \"threshold\":\n\t\t\treturn \"Auto-compacting...\";\n\t\tcase \"overflow\":\n\t\t\treturn \"Context overflow detected. Auto-compacting...\";\n\t\tcase \"branchSummary\":\n\t\t\treturn \"summarizing branch…\";\n\t}\n}\n\nfunction hasVerbatimCompactionMessage(messages: AgentSession[\"messages\"]): boolean {\n\treturn messages.some((message) => message.role === \"custom\" && isVerbatimCompactionMessage(message));\n}\n\n/**\n * Every durable rung, derived from the union so a new member cannot be silently\n * rejected here. The event-only path (no session snapshot) is the one place a\n * `fresh` boundary would otherwise be dropped.\n */\nconst COMPACTION_RUNGS: ReadonlySet<CompactionRung> = new Set([\n\t\"planned\",\n\t\"extension\",\n\t\"fresh\",\n] as const satisfies readonly CompactionRung[]);\n\nfunction isCompleteCompactionResult(result: VerbatimCompactionResult): boolean {\n\treturn (\n\t\ttypeof result.compactedText === \"string\" &&\n\t\ttypeof result.tokensBefore === \"number\" &&\n\t\tresult.stats !== undefined &&\n\t\tresult.parameters !== undefined &&\n\t\tresult.promptVersion === VERBATIM_COMPACTION_PROMPT_VERSION &&\n\t\tCOMPACTION_RUNGS.has(result.rung)\n\t);\n}\n\nfunction boundaryMessageFromResult(\n\tresult: VerbatimCompactionResult,\n): CustomMessage<VerbatimCompactionDetails> | undefined {\n\tif (!isCompleteCompactionResult(result)) return undefined;\n\tconst details = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: result.promptVersion,\n\t\tparameters: result.parameters,\n\t\tstats: result.stats,\n\t\trung: result.rung,\n\t\t// Preserve the borrowed-planner identity; the event-only path is otherwise\n\t\t// the one place it is lost.\n\t\t...(result.plannerModel === undefined ? {} : { plannerModel: result.plannerModel }),\n\t\t...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),\n\t} satisfies VerbatimCompactionDetails;\n\treturn createVerbatimCompactionMessage(\n\t\tresult.compactedText,\n\t\tresult.tokensBefore,\n\t\tnew Date().toISOString(),\n\t\tdetails,\n\t) as CustomMessage<VerbatimCompactionDetails>;\n}\n\nfunction customMessageText(message: CustomMessage): string {\n\tif (typeof message.content === \"string\") return message.content;\n\treturn message.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction transcriptHasBoundaryForResult(\n\ttranscript: readonly ChatTranscriptEntryLike[],\n\tresult: VerbatimCompactionResult,\n): boolean {\n\treturn transcript.some((entry) => {\n\t\tconst candidate = entry as ChatTranscriptEntryLike & {\n\t\t\treadonly kind?: string;\n\t\t\treadonly message?: CustomMessage<VerbatimCompactionDetails>;\n\t\t};\n\t\tif (\n\t\t\tcandidate.kind !== \"custom\" ||\n\t\t\tcandidate.message?.role !== \"custom\" ||\n\t\t\t!isVerbatimCompactionMessage(candidate.message)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// The rung is part of the identity, not decoration. A planned and a fresh\n\t\t// boundary can carry identical text, and treating them as the same result\n\t\t// silently swallows the fresh event — the one the user is meant to see.\n\t\tif (candidate.message?.details?.rung !== result.rung) return false;\n\t\treturn customMessageText(candidate.message).endsWith(result.compactedText);\n\t});\n}\n\nfunction refreshCompactedTranscript<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tresult: VerbatimCompactionResult,\n): void {\n\tconst compactedMessages = state.getAgentSession?.()?.messages;\n\tif (compactedMessages && hasVerbatimCompactionMessage(compactedMessages)) {\n\t\tstate.liveChat.replaceMessages(compactedMessages, state.extraEntries);\n\t\treturn;\n\t}\n\tif (transcriptHasBoundaryForResult(state.transcript, result)) return;\n\tconst boundary = boundaryMessageFromResult(result);\n\tif (boundary) state.liveChat.appendMessages([boundary]);\n}\n\nexport function applyChatSessionAgentEvent<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tevent: AgentSessionEvent,\n): boolean {\n\tif (state.disposed) return false;\n\tconst type = String((event as { type?: unknown }).type ?? \"\");\n\tif (type === \"message_start\") {\n\t\tconst message = (event as { message?: unknown }).message;\n\t\tif (isUserMessageLike(message)) {\n\t\t\tconst signature = userMessageSignature(extractMessageText(message.content));\n\t\t\tconst count = state.optimisticUserSignatureCounts.get(signature) ?? 0;\n\t\t\tif (count > 0) {\n\t\t\t\tdecrementOptimisticUserSignature(state, signature);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tif (isSharedLiveChatEvent(type)) {\n\t\tconst changed = state.liveChat.applyEvent(event);\n\t\tconst toolCallEvent = assistantToolCallEvent(event);\n\t\tconst changedByToolCall = toolCallEvent !== undefined ? state.liveChat.applyEvent(toolCallEvent) : false;\n\t\tafterChatSessionEvent(state, changed || changedByToolCall);\n\t\treturn changed || changedByToolCall;\n\t}\n\tlet changed = false;\n\tswitch (type) {\n\t\tcase \"agent_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"agent_end\": {\n\t\t\tconst manualTakeoverPending = state.manualCompactionTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending;\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tif (!manualTakeoverPending) state.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tconst idle = state.getAgentSession?.()?.agent.waitForIdle() ?? Promise.resolve();\n\t\t\t\tvoid idle.then(() => flushChatSessionCompactionQueue(state));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"turn_start\":\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.workingMessage = pickWhimsicalWorkingMessage();\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"turn_end\":\n\t\t\tstate.compacting = state.manualCompactionTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"queue_update\": {\n\t\t\tconst queue = event as { steering?: unknown; followUp?: unknown };\n\t\t\tstate.pendingSteeringMessages = Array.isArray(queue.steering)\n\t\t\t\t? queue.steering.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tstate.pendingFollowUpMessages = Array.isArray(queue.followUp)\n\t\t\t\t? queue.followUp.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"tool_call\":\n\t\tcase \"tool_use\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolStartEvent(event));\n\t\t\tbreak;\n\t\tcase \"tool_result\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolResultEvent(event));\n\t\t\tbreak;\n\t\tcase \"thinking_delta\":\n\t\tcase \"thinking\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyThinkingEvent(event));\n\t\t\tbreak;\n\t\tcase \"compaction_start\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_start\" }>;\n\t\t\tstate.compacting = true;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(compaction.reason);\n\t\t\t// The animation timer this event starts would otherwise swallow the\n\t\t\t// event's own paint request, delaying the factual status by a frame.\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"compaction_end\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_end\" }>;\n\t\t\tconst manualTakeoverPending =\n\t\t\t\tcompaction.reason !== \"manual\" &&\n\t\t\t\t(compaction.manualTakeoverPending === true || state.manualCompactionTakeoverPending);\n\t\t\tif (manualTakeoverPending) {\n\t\t\t\tstate.manualCompactionTakeoverPending = true;\n\t\t\t} else if (compaction.reason === \"manual\") {\n\t\t\t\tstate.manualCompactionTakeoverPending = false;\n\t\t\t}\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending || compaction.midTurn === true;\n\t\t\tif (!manualTakeoverPending) state.statusMessage = compaction.errorMessage ?? \"\";\n\t\t\tif (compaction.midTurn !== true || compaction.aborted || compaction.errorMessage) {\n\t\t\t\tstate.workingMessage = undefined;\n\t\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\t} else if (!state.workingLifecycleActive) {\n\t\t\t\t// A successful no-op ends before the next turn_start, so nothing else\n\t\t\t\t// would restart ordinary Working for the continuing stream.\n\t\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\t}\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\t// `result` and `errorMessage` are independent facts. The post-tool gate can\n\t\t\t// report a hard-input-limit failure *after* the boundary was already\n\t\t\t// committed, and skipping the refresh there hid a durable context\n\t\t\t// destruction behind an error line. Show the boundary, then the status.\n\t\t\tif (!compaction.aborted && compaction.result) {\n\t\t\t\trefreshCompactedTranscript(state, compaction.result);\n\t\t\t}\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tvoid flushChatSessionCompactionQueue(state);\n\t\t\t}\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_scheduled\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"retrying summary…\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"summarization_retry_attempt_start\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"summarization_retry_attempt_start\" }>;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(\n\t\t\t\tretry.source === \"branchSummary\" ? \"branchSummary\" : retry.reason,\n\t\t\t);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_finished\":\n\t\t\tstate.statusMessage = state.compacting ? compactionStatusMessage(\"manual\") : \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"auto_retry_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"retrying…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"switching model…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_end\": {\n\t\t\tconst fallback = event as Extract<AgentSessionEvent, { type: \"model_fallback_end\" }>;\n\t\t\tstate.statusMessage = fallback.success ? \"\" : (fallback.finalError ?? \"model fallback failed\");\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!fallback.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"auto_retry_end\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"auto_retry_end\" }>;\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!retry.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"agent_continue_error\": {\n\t\t\tconst continueError = event as Extract<AgentSessionEvent, { type: \"agent_continue_error\" }>;\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.statusMessage = continueError.errorMessage;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tchanged = false;\n\t}\n\tafterChatSessionEvent(state, changed);\n\treturn changed;\n}\n\nfunction isSharedLiveChatEvent(type: string): boolean {\n\treturn (\n\t\ttype === \"message_start\" ||\n\t\ttype === \"message_update\" ||\n\t\ttype === \"message_end\" ||\n\t\ttype === \"tool_execution_start\" ||\n\t\ttype === \"tool_execution_update\" ||\n\t\ttype === \"tool_execution_end\"\n\t);\n}\n\nfunction assistantToolCallEvent(event: AgentSessionEvent):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tconst assistantEvent = (\n\t\tevent as {\n\t\t\tassistantMessageEvent?: {\n\t\t\t\ttype?: unknown;\n\t\t\t\tcontentIndex?: unknown;\n\t\t\t\tpartial?: unknown;\n\t\t\t\ttoolCall?: unknown;\n\t\t\t};\n\t\t}\n\t).assistantMessageEvent;\n\tconst streamType = String(assistantEvent?.type ?? \"\");\n\tif (!streamType.startsWith(\"toolcall_\")) return undefined;\n\tconst explicit = toolCallPayload(assistantEvent?.toolCall);\n\tif (explicit) return explicit;\n\tconst contentIndex = typeof assistantEvent?.contentIndex === \"number\" ? assistantEvent.contentIndex : undefined;\n\tif (contentIndex === undefined) return undefined;\n\tconst partial = assistantEvent?.partial;\n\tif (!isMessageLike(partial) || partial.role !== \"assistant\") return undefined;\n\tconst content = partial.content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn toolCallPayload(content[contentIndex]);\n}\n\nfunction toolCallPayload(value: unknown):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tif (value === null || typeof value !== \"object\") return undefined;\n\tconst candidate = value as { type?: unknown; id?: unknown; name?: unknown; arguments?: unknown };\n\tif (candidate.type !== \"toolCall\") return undefined;\n\tif (typeof candidate.id !== \"string\" || typeof candidate.name !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId: candidate.id,\n\t\ttoolName: candidate.name,\n\t\targs: candidate.arguments ?? {},\n\t};\n}\n\nfunction legacyToolStartEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_start\";\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: unknown;\n} {\n\tconst payload = event as { toolCallId?: unknown; name?: unknown; input?: unknown; args?: unknown };\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\targs: payload.input ?? payload.args ?? {},\n\t};\n}\n\nfunction legacyToolResultEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_end\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: unknown;\n\tisError: boolean;\n} {\n\tconst payload = event as {\n\t\ttoolCallId?: unknown;\n\t\tname?: unknown;\n\t\toutput?: unknown;\n\t\tisError?: unknown;\n\t};\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\tconst output = payload.output;\n\treturn {\n\t\ttype: \"tool_execution_end\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\tresult:\n\t\t\toutput !== null && typeof output === \"object\" && \"content\" in output\n\t\t\t\t? output\n\t\t\t\t: { content: typeof output === \"string\" ? [{ type: \"text\", text: output }] : [] },\n\t\tisError: payload.isError === true,\n\t};\n}\n\nfunction legacyThinkingEvent(event: AgentSessionEvent): {\n\ttype: \"message_update\";\n\tassistantMessageEvent: { type: \"thinking_delta\"; contentIndex: number; delta: string };\n} {\n\tconst delta = String((event as { delta?: unknown }).delta ?? (event as { text?: unknown }).text ?? \"\");\n\treturn {\n\t\ttype: \"message_update\",\n\t\tassistantMessageEvent: { type: \"thinking_delta\", contentIndex: 0, delta },\n\t};\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-events.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,kCAAkC,EAClC,4BAA4B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,+BAA+B,EAC/B,2BAA2B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACN,qBAAqB,EACrB,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,GAC/B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,UAAU,uBAAuB,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AAM,EACL,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;YACnE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QACnF,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI;KACjC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAwB;IAIpD,MAAM,KAAK,GAAG,MAAM,CAAE,KAA6B,CAAC,KAAK,IAAK,KAA4B,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvG,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,qBAAqB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE;KACzE,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.js\";\nimport type { CompactionReason } from \"../../../core/agent-session-types.js\";\nimport {\n\ttype CompactionRung,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionResult,\n} from \"../../../core/compaction/index.ts\";\nimport {\n\ttype CustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tisVerbatimCompactionMessage,\n} from \"../../../core/messages.ts\";\nimport { pickWhimsicalWorkingMessage } from \"../whimsical-messages.ts\";\nimport { flushChatSessionCompactionQueue } from \"./chat-session-host-actions.ts\";\nimport {\n\tafterChatSessionEvent,\n\tdecrementOptimisticUserSignature,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport {\n\textractMessageText,\n\tisMessageLike,\n\tisUserMessageLike,\n\tuserMessageSignature,\n} from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nexport type { CompactionReason } from \"../../../core/agent-session-types.js\";\n\nexport function compactionStatusMessage(reason: CompactionReason): string {\n\tswitch (reason) {\n\t\tcase \"manual\":\n\t\t\treturn \"Compacting context...\";\n\t\tcase \"threshold\":\n\t\t\treturn \"Auto-compacting...\";\n\t\tcase \"overflow\":\n\t\t\treturn \"Context overflow detected. Auto-compacting...\";\n\t\tcase \"branchSummary\":\n\t\t\treturn \"summarizing branch…\";\n\t}\n}\n\nfunction hasVerbatimCompactionMessage(messages: AgentSession[\"messages\"]): boolean {\n\treturn messages.some((message) => message.role === \"custom\" && isVerbatimCompactionMessage(message));\n}\n\n/**\n * Every durable rung, derived from the union so a new member cannot be silently\n * rejected here. The event-only path (no session snapshot) is the one place a\n * `fresh` boundary would otherwise be dropped.\n */\nconst COMPACTION_RUNGS: ReadonlySet<CompactionRung> = new Set([\n\t\"planned\",\n\t\"extension\",\n\t\"fresh\",\n] as const satisfies readonly CompactionRung[]);\n\nfunction isCompleteCompactionResult(result: VerbatimCompactionResult): boolean {\n\treturn (\n\t\ttypeof result.compactedText === \"string\" &&\n\t\ttypeof result.tokensBefore === \"number\" &&\n\t\tresult.stats !== undefined &&\n\t\tresult.parameters !== undefined &&\n\t\tresult.promptVersion === VERBATIM_COMPACTION_PROMPT_VERSION &&\n\t\tCOMPACTION_RUNGS.has(result.rung)\n\t);\n}\n\nfunction boundaryMessageFromResult(\n\tresult: VerbatimCompactionResult,\n): CustomMessage<VerbatimCompactionDetails> | undefined {\n\tif (!isCompleteCompactionResult(result)) return undefined;\n\tconst details = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: result.promptVersion,\n\t\tparameters: result.parameters,\n\t\tstats: result.stats,\n\t\trung: result.rung,\n\t\t// Preserve the borrowed-planner identity; the event-only path is otherwise\n\t\t// the one place it is lost.\n\t\t...(result.plannerModel === undefined ? {} : { plannerModel: result.plannerModel }),\n\t\t...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),\n\t} satisfies VerbatimCompactionDetails;\n\treturn createVerbatimCompactionMessage(\n\t\tresult.compactedText,\n\t\tresult.tokensBefore,\n\t\tnew Date().toISOString(),\n\t\tdetails,\n\t) as CustomMessage<VerbatimCompactionDetails>;\n}\n\nfunction customMessageText(message: CustomMessage): string {\n\tif (typeof message.content === \"string\") return message.content;\n\treturn message.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction transcriptHasBoundaryForResult(\n\ttranscript: readonly ChatTranscriptEntryLike[],\n\tresult: VerbatimCompactionResult,\n): boolean {\n\treturn transcript.some((entry) => {\n\t\tconst candidate = entry as ChatTranscriptEntryLike & {\n\t\t\treadonly kind?: string;\n\t\t\treadonly message?: CustomMessage<VerbatimCompactionDetails>;\n\t\t};\n\t\tif (\n\t\t\tcandidate.kind !== \"custom\" ||\n\t\t\tcandidate.message?.role !== \"custom\" ||\n\t\t\t!isVerbatimCompactionMessage(candidate.message)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// The rung is part of the identity, not decoration. A planned and a fresh\n\t\t// boundary can carry identical text, and treating them as the same result\n\t\t// silently swallows the fresh event — the one the user is meant to see.\n\t\tif (candidate.message?.details?.rung !== result.rung) return false;\n\t\treturn customMessageText(candidate.message).endsWith(result.compactedText);\n\t});\n}\n\nfunction refreshCompactedTranscript<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tresult: VerbatimCompactionResult,\n): void {\n\tconst compactedMessages = state.getAgentSession?.()?.messages;\n\tif (compactedMessages && hasVerbatimCompactionMessage(compactedMessages)) {\n\t\tstate.liveChat.replaceMessages(compactedMessages, state.extraEntries);\n\t\treturn;\n\t}\n\tif (transcriptHasBoundaryForResult(state.transcript, result)) return;\n\tconst boundary = boundaryMessageFromResult(result);\n\tif (boundary) state.liveChat.appendMessages([boundary]);\n}\n\nexport function applyChatSessionAgentEvent<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tevent: AgentSessionEvent,\n): boolean {\n\tif (state.disposed) return false;\n\tconst type = String((event as { type?: unknown }).type ?? \"\");\n\tif (type === \"message_start\") {\n\t\tconst message = (event as { message?: unknown }).message;\n\t\tif (isUserMessageLike(message)) {\n\t\t\tconst signature = userMessageSignature(extractMessageText(message.content));\n\t\t\tconst count = state.optimisticUserSignatureCounts.get(signature) ?? 0;\n\t\t\tif (count > 0) {\n\t\t\t\tdecrementOptimisticUserSignature(state, signature);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tif (isSharedLiveChatEvent(type)) {\n\t\tconst changed = state.liveChat.applyEvent(event);\n\t\tconst toolCallEvent = assistantToolCallEvent(event);\n\t\tconst changedByToolCall = toolCallEvent !== undefined ? state.liveChat.applyEvent(toolCallEvent) : false;\n\t\tafterChatSessionEvent(state, changed || changedByToolCall);\n\t\treturn changed || changedByToolCall;\n\t}\n\tlet changed = false;\n\tswitch (type) {\n\t\tcase \"agent_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tchanged = true;\n\t\t\tstate.compactionPromptStarted?.();\n\t\t\tbreak;\n\t\tcase \"agent_end\": {\n\t\t\tconst manualTakeoverPending = state.manualCompactionTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending;\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tif (!manualTakeoverPending) state.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tconst idle = state.getAgentSession?.()?.agent.waitForIdle() ?? Promise.resolve();\n\t\t\t\tvoid idle.then(() => flushChatSessionCompactionQueue(state));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"turn_start\":\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.workingMessage = pickWhimsicalWorkingMessage();\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"turn_end\":\n\t\t\tstate.compacting = state.manualCompactionTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"queue_update\": {\n\t\t\tconst queue = event as { steering?: unknown; followUp?: unknown };\n\t\t\tstate.pendingSteeringMessages = Array.isArray(queue.steering)\n\t\t\t\t? queue.steering.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tstate.pendingFollowUpMessages = Array.isArray(queue.followUp)\n\t\t\t\t? queue.followUp.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"tool_call\":\n\t\tcase \"tool_use\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolStartEvent(event));\n\t\t\tbreak;\n\t\tcase \"tool_result\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolResultEvent(event));\n\t\t\tbreak;\n\t\tcase \"thinking_delta\":\n\t\tcase \"thinking\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyThinkingEvent(event));\n\t\t\tbreak;\n\t\tcase \"compaction_start\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_start\" }>;\n\t\t\tstate.compacting = true;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(compaction.reason);\n\t\t\t// The animation timer this event starts would otherwise swallow the\n\t\t\t// event's own paint request, delaying the factual status by a frame.\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"compaction_end\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_end\" }>;\n\t\t\tconst manualTakeoverPending =\n\t\t\t\tcompaction.reason !== \"manual\" &&\n\t\t\t\t(compaction.manualTakeoverPending === true || state.manualCompactionTakeoverPending);\n\t\t\tif (manualTakeoverPending) {\n\t\t\t\tstate.manualCompactionTakeoverPending = true;\n\t\t\t} else if (compaction.reason === \"manual\") {\n\t\t\t\tstate.manualCompactionTakeoverPending = false;\n\t\t\t}\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending || compaction.midTurn === true;\n\t\t\tif (!manualTakeoverPending) state.statusMessage = compaction.errorMessage ?? \"\";\n\t\t\tif (compaction.midTurn !== true || compaction.aborted || compaction.errorMessage) {\n\t\t\t\tstate.workingMessage = undefined;\n\t\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\t} else if (!state.workingLifecycleActive) {\n\t\t\t\t// A successful no-op ends before the next turn_start, so nothing else\n\t\t\t\t// would restart ordinary Working for the continuing stream.\n\t\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\t}\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\t// `result` and `errorMessage` are independent facts. The post-tool gate can\n\t\t\t// report a hard-input-limit failure *after* the boundary was already\n\t\t\t// committed, and skipping the refresh there hid a durable context\n\t\t\t// destruction behind an error line. Show the boundary, then the status.\n\t\t\tif (!compaction.aborted && compaction.result) {\n\t\t\t\trefreshCompactedTranscript(state, compaction.result);\n\t\t\t}\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tvoid flushChatSessionCompactionQueue(state);\n\t\t\t}\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_scheduled\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"retrying summary…\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"summarization_retry_attempt_start\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"summarization_retry_attempt_start\" }>;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(\n\t\t\t\tretry.source === \"branchSummary\" ? \"branchSummary\" : retry.reason,\n\t\t\t);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_finished\":\n\t\t\tstate.statusMessage = state.compacting ? compactionStatusMessage(\"manual\") : \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"auto_retry_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"retrying…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"switching model…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_end\": {\n\t\t\tconst fallback = event as Extract<AgentSessionEvent, { type: \"model_fallback_end\" }>;\n\t\t\tstate.statusMessage = fallback.success ? \"\" : (fallback.finalError ?? \"model fallback failed\");\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!fallback.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"auto_retry_end\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"auto_retry_end\" }>;\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!retry.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"agent_continue_error\": {\n\t\t\tconst continueError = event as Extract<AgentSessionEvent, { type: \"agent_continue_error\" }>;\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.statusMessage = continueError.errorMessage;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tchanged = false;\n\t}\n\tafterChatSessionEvent(state, changed);\n\treturn changed;\n}\n\nfunction isSharedLiveChatEvent(type: string): boolean {\n\treturn (\n\t\ttype === \"message_start\" ||\n\t\ttype === \"message_update\" ||\n\t\ttype === \"message_end\" ||\n\t\ttype === \"tool_execution_start\" ||\n\t\ttype === \"tool_execution_update\" ||\n\t\ttype === \"tool_execution_end\"\n\t);\n}\n\nfunction assistantToolCallEvent(event: AgentSessionEvent):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tconst assistantEvent = (\n\t\tevent as {\n\t\t\tassistantMessageEvent?: {\n\t\t\t\ttype?: unknown;\n\t\t\t\tcontentIndex?: unknown;\n\t\t\t\tpartial?: unknown;\n\t\t\t\ttoolCall?: unknown;\n\t\t\t};\n\t\t}\n\t).assistantMessageEvent;\n\tconst streamType = String(assistantEvent?.type ?? \"\");\n\tif (!streamType.startsWith(\"toolcall_\")) return undefined;\n\tconst explicit = toolCallPayload(assistantEvent?.toolCall);\n\tif (explicit) return explicit;\n\tconst contentIndex = typeof assistantEvent?.contentIndex === \"number\" ? assistantEvent.contentIndex : undefined;\n\tif (contentIndex === undefined) return undefined;\n\tconst partial = assistantEvent?.partial;\n\tif (!isMessageLike(partial) || partial.role !== \"assistant\") return undefined;\n\tconst content = partial.content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn toolCallPayload(content[contentIndex]);\n}\n\nfunction toolCallPayload(value: unknown):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tif (value === null || typeof value !== \"object\") return undefined;\n\tconst candidate = value as { type?: unknown; id?: unknown; name?: unknown; arguments?: unknown };\n\tif (candidate.type !== \"toolCall\") return undefined;\n\tif (typeof candidate.id !== \"string\" || typeof candidate.name !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId: candidate.id,\n\t\ttoolName: candidate.name,\n\t\targs: candidate.arguments ?? {},\n\t};\n}\n\nfunction legacyToolStartEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_start\";\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: unknown;\n} {\n\tconst payload = event as { toolCallId?: unknown; name?: unknown; input?: unknown; args?: unknown };\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\targs: payload.input ?? payload.args ?? {},\n\t};\n}\n\nfunction legacyToolResultEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_end\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: unknown;\n\tisError: boolean;\n} {\n\tconst payload = event as {\n\t\ttoolCallId?: unknown;\n\t\tname?: unknown;\n\t\toutput?: unknown;\n\t\tisError?: unknown;\n\t};\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\tconst output = payload.output;\n\treturn {\n\t\ttype: \"tool_execution_end\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\tresult:\n\t\t\toutput !== null && typeof output === \"object\" && \"content\" in output\n\t\t\t\t? output\n\t\t\t\t: { content: typeof output === \"string\" ? [{ type: \"text\", text: output }] : [] },\n\t\tisError: payload.isError === true,\n\t};\n}\n\nfunction legacyThinkingEvent(event: AgentSessionEvent): {\n\ttype: \"message_update\";\n\tassistantMessageEvent: { type: \"thinking_delta\"; contentIndex: number; delta: string };\n} {\n\tconst delta = String((event as { delta?: unknown }).delta ?? (event as { text?: unknown }).text ?? \"\");\n\treturn {\n\t\ttype: \"message_update\",\n\t\tassistantMessageEvent: { type: \"thinking_delta\", contentIndex: 0, delta },\n\t};\n}\n"]}
@@ -55,6 +55,10 @@ export declare class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntr
55
55
  text: string;
56
56
  mode: ChatSessionSubmitMode;
57
57
  }[];
58
+ /** True while compaction-queued messages are being sent one at a time. */
59
+ compactionFlushPending: boolean;
60
+ /** Resolves the pending compaction-queue prompt when its run starts. */
61
+ compactionPromptStarted: (() => void) | undefined;
58
62
  compacting: boolean;
59
63
  /** Keeps input queued while automatic compaction hands off to a manual request. */
60
64
  manualCompactionTakeoverPending: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-state.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACX,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAA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AE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,SAAK;IACjB,sBAAsB,EAAE,OAAO,CAAC;IAChC,0BAA0B,SAAK;IAC/B,2BAA2B,UAAS;IACpC,QAAQ,UAAS;IACjB,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAM;IAChD,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAM;IAChD,wBAAwB,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,qBAAqB,CAAA;KAAE,EAAE,CAAM;IACxF,UAAU,UAAS;IACnB,mFAAmF;IACnF,+BAA+B,UAAS;IACxC,cAAc,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC;IAC3D,mBAAmB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IAC/D,YAAY,EAAE,2BAA2B,CAAC;IAC1C,mBAAmB,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;IAChF,2BAA2B,SAAM;IACjC,iBAAiB,0BAAiC;IAClD,oBAAoB,SAAK;IACzB,QAAQ,EAAE,yBAAyB,CAAC;IACpC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,6BAA6B,sBAA6B;IAC1D;;;;;;OAMG;IACH,0BAA0B,UAAQ;IAElC,YAAY,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,6BAA6B,CAAC,WAAW,CAAC,EA2BxG;CACD"}
1
+ {"version":3,"file":"chat-session-host-state.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,M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 @@ export class ChatSessionHostState {
43
43
  pendingSteeringMessages = [];
44
44
  pendingFollowUpMessages = [];
45
45
  compactionQueuedMessages = [];
46
+ /** True while compaction-queued messages are being sent one at a time. */
47
+ compactionFlushPending = false;
48
+ /** Resolves the pending compaction-queue prompt when its run starts. */
49
+ compactionPromptStarted;
46
50
  compacting = false;
47
51
  /** Keeps input queued while automatic compaction hands off to a manual request. */
48
52
  manualCompactionTakeoverPending = false;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAQvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAG,EAAE,CAAC;IACnB,+FAA+F;IAC/F,kBAAkB,CAAqB;IACvC,UAAU,GAAG,KAAK,CAAC;IACnB,gBAAgB,GAAG,KAAK,CAAC;IACzB,OAAO,GAAG,KAAK,CAAC;IAChB,yEAAyE;IACzE,mBAAm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AQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,IAAI,CAAC,UAAU,EACf,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n\tChatSessionSubmitMode,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly { text: string; mode: ChatSessionSubmitMode }[] = [];\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAQvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD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AAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,IAAI,CAAC,UAAU,EACf,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n\tChatSessionSubmitMode,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly { text: string; mode: ChatSessionSubmitMode }[] = [];\n\t/** True while compaction-queued messages are being sent one at a time. */\n\tcompactionFlushPending = false;\n\t/** Resolves the pending compaction-queue prompt when its run starts. */\n\tcompactionPromptStarted: (() => void) | undefined;\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
@@ -399,8 +399,9 @@ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
399
399
  return;
400
400
  }
401
401
  }
402
- // Queue input during compaction (extension commands execute immediately)
403
- if (this.compactionActive) {
402
+ // Queue input behind compaction-queued messages (extension commands execute immediately)
403
+ if (this.compactionActive ||
404
+ (!this.session.queuedMessagesPaused && (this.compactionFlushPending || this.compactionSendFailed))) {
404
405
  if (this.isExtensionCommand(text)) {
405
406
  this.editor.addToHistory?.(text);
406
407
  this.editor.setText("");
@@ -411,6 +412,11 @@ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
411
412
  }
412
413
  return;
413
414
  }
415
+ // A paused submission releases the session queue before its own turn, so move held
416
+ // messages there first to keep them ahead of this one.
417
+ if (this.session.queuedMessagesPaused && this.compactionSendFailed && !this.compactionFlushPending) {
418
+ await this.flushCompactionQueue({ willRetry: false });
419
+ }
414
420
  // If streaming, use prompt() with steer behavior
415
421
  // This handles extension commands (execute immediately), prompt template expansion, and queueing
416
422
  if (this.session.isStreaming && !this.session.queuedMessagesPaused) {