@bastani/atomic 0.9.11-alpha.10 → 0.9.11-alpha.12
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.
- package/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/subagent-relay.ts +8 -5
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/notification-content.ts +14 -9
- package/dist/builtin/subagents/src/runs/background/notify.ts +20 -4
- package/dist/builtin/web-access/CHANGELOG.md +13 -0
- package/dist/builtin/web-access/content-tools.ts +1 -0
- package/dist/builtin/web-access/flat-string.ts +37 -0
- package/dist/builtin/web-access/github-api.ts +2 -1
- package/dist/builtin/web-access/github-extract.ts +3 -2
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +10 -0
- package/dist/builtin/workflows/builtin/goal-ledger.ts +6 -4
- package/dist/builtin/workflows/builtin/goal-runner.ts +2 -1
- package/dist/builtin/workflows/builtin/goal.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +8 -9
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +2 -4
- package/dist/builtin/workflows/builtin/ralph-runner.ts +5 -8
- package/dist/builtin/workflows/builtin/ralph.ts +2 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +14 -8
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +10 -11
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +1 -1
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +42 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +36 -37
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +10 -2
- package/dist/builtin/workflows/src/engine/run.ts +1 -0
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +12 -8
- package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +5 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1962 -876
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +6 -3
- package/dist/builtin/workflows/src/extension/postmortem-deps.ts +3 -2
- package/dist/builtin/workflows/src/extension/render-result.ts +4 -11
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +17 -20
- package/dist/builtin/workflows/src/extension/runtime.ts +3 -3
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +3 -7
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +21 -24
- package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +38 -26
- package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +2 -1
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +56 -64
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +2 -2
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +0 -5
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +17 -20
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +24 -51
- package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +7 -29
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +5 -13
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +4 -13
- package/dist/builtin/workflows/src/runs/background/quit.ts +4 -3
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +8 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +2 -1
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +2 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +5 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +23 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +6 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +5 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +56 -10
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +6 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +137 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +2 -0
- package/dist/builtin/workflows/src/shared/expanded-workflow-graph.ts +159 -10
- package/dist/builtin/workflows/src/shared/flat-string.ts +33 -0
- package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +144 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +2 -3
- package/dist/builtin/workflows/src/shared/run-id.ts +36 -0
- package/dist/builtin/workflows/src/shared/store-internal.ts +32 -3
- package/dist/builtin/workflows/src/shared/store-observation.ts +10 -0
- package/dist/builtin/workflows/src/shared/store-public-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +14 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +4 -0
- package/dist/builtin/workflows/src/shared/types.ts +2 -0
- package/dist/builtin/workflows/src/shared/workflow-artifacts.ts +261 -0
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +39 -23
- package/dist/builtin/workflows/src/tui/graph-canvas.ts +26 -9
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +95 -98
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +7 -20
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +160 -13
- package/dist/builtin/workflows/src/tui/layout.ts +8 -2
- package/dist/builtin/workflows/src/tui/node-card.ts +57 -45
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +4 -2
- package/dist/builtin/workflows/src/tui/prompt-card-render.ts +291 -21
- package/dist/builtin/workflows/src/tui/prompt-card.ts +1 -1
- package/dist/builtin/workflows/src/tui/renderers.ts +0 -1
- package/dist/builtin/workflows/src/tui/run-detail.ts +52 -35
- package/dist/builtin/workflows/src/tui/run-identity-rows.ts +97 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +24 -3
- package/dist/builtin/workflows/src/tui/session-picker.ts +94 -41
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +190 -26
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +52 -18
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +9 -5
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +44 -4
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +3 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +67 -45
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +7 -6
- package/dist/builtin/workflows/src/tui/widget.ts +49 -40
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +15 -10
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +21 -8
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +5 -0
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +5 -0
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +3 -0
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +3 -7
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +27 -13
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +5 -3
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +6 -3
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +11 -2
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +4 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +4 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bounded-model-refresh.d.ts +14 -0
- package/dist/core/bounded-model-refresh.d.ts.map +1 -0
- package/dist/core/bounded-model-refresh.js +38 -0
- package/dist/core/bounded-model-refresh.js.map +1 -0
- package/dist/core/messages.d.ts +5 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +2 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +2 -2
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +2 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +2 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -0
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +7 -2
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +13 -4
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts +3 -1
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.js +2 -2
- package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +3 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +5 -4
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +16 -2
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +31 -4
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +0 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +23 -45
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -1
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +1 -1
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +4 -1
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-pause.d.ts +3 -1
- package/dist/modes/interactive/interactive-pause.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-pause.js +5 -1
- package/dist/modes/interactive/interactive-pause.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +3 -3
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +5 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +1 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/index.md +10 -0
- package/docs/keybindings.md +1 -1
- package/docs/models.md +1 -1
- package/docs/quickstart.md +7 -1
- package/docs/termux.md +3 -1
- package/docs/usage.md +3 -2
- package/docs/workflows.md +82 -46
- package/npm-shrinkwrap.json +59 -27
- package/package.json +3 -3
- package/dist/builtin/workflows/src/tui/toast.ts +0 -107
|
@@ -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;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,0B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-session-methods.ts\";\nimport type { BashExecutionMessage } from \"../../../core/messages.ts\";\nimport { combineQueuedMessagesForEditor } from \"../chat-input-actions.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.ts\";\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): 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\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): 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);\n\t\tif (state.inputBuffer === editorText) setChatSessionEditorText(state, \"\");\n\t\tstate.sdkBusy = false;\n\t\tstate.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\tconst text = (submittedText ?? state.inputBuffer).trim();\n\tif (!text) return;\n\tconst interruptSettlement = state.interruptSettlement;\n\tif (interruptSettlement !== undefined) {\n\t\tawait submitAfterInterruptSettlement(state, interruptSettlement, text);\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];\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\tconst shouldAppendOptimisticUser = mode === \"auto\" && !isStreaming;\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);\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.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\tstate.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\tawait state.commands.abortCompaction?.();\n\t\tstate.compacting = false;\n\t\tstate.sdkBusy = false;\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\tlet nextIndex = 0;\n\ttry {\n\t\tconst first = queued[0];\n\t\tif (first !== undefined) {\n\t\t\t// A message parked during compaction resumes the ordinary Enter path.\n\t\t\tawait requiredChatSessionPromptCommand(state)(first, \"auto\");\n\t\t\tnextIndex = 1;\n\t\t}\n\t\tfor (; nextIndex < queued.length; nextIndex++) {\n\t\t\tawait queueChatSessionFollowUp(state, queued[nextIndex]!);\n\t\t}\n\t} catch (err) {\n\t\tstate.compactionQueuedMessages = [...queued.slice(nextIndex), ...state.compactionQueuedMessages];\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t\tstate.requestRender?.();\n\t}\n}\n\nexport function restoreQueuedMessagesToEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): boolean {\n\tconst queuedMessages = [\n\t\t...state.pendingSteeringMessages,\n\t\t...state.pendingFollowUpMessages,\n\t\t...state.compactionQueuedMessages,\n\t];\n\tif (queuedMessages.length === 0) {\n\t\tnotifyChatSessionStatus(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.getAgentSession?.()?.clearQueue();\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\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming) {\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\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming) {\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;AAE1E,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,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I,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 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.ts\";\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): 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);\n\t\tif (state.inputBuffer === editorText) setChatSessionEditorText(state, \"\");\n\t\tstate.sdkBusy = false;\n\t\tstate.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\tconst text = (submittedText ?? state.inputBuffer).trim();\n\tif (!text) return;\n\tconst interruptSettlement = state.interruptSettlement;\n\tif (interruptSettlement !== undefined) {\n\t\tawait submitAfterInterruptSettlement(state, interruptSettlement, text);\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];\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\tconst shouldAppendOptimisticUser = mode === \"auto\" && !isStreaming;\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);\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.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\tstate.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\tawait state.commands.abortCompaction?.();\n\t\tstate.compacting = false;\n\t\tstate.sdkBusy = false;\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\tlet nextIndex = 0;\n\ttry {\n\t\tconst first = queued[0];\n\t\tif (first !== undefined) {\n\t\t\t// A message parked during compaction resumes the ordinary Enter path.\n\t\t\tawait requiredChatSessionPromptCommand(state)(first, \"auto\");\n\t\t\tnextIndex = 1;\n\t\t}\n\t\tfor (; nextIndex < queued.length; nextIndex++) {\n\t\t\tawait queueChatSessionFollowUp(state, queued[nextIndex]!);\n\t\t}\n\t} catch (err) {\n\t\tstate.compactionQueuedMessages = [...queued.slice(nextIndex), ...state.compactionQueuedMessages];\n\t\tnotifyChatSessionWarning(state, errorMessage(err));\n\t\tstate.requestRender?.();\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,\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\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming) {\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\tconst agentSession = state.getAgentSession?.();\n\tif (agentSession?.isStreaming) {\n\t\tawait agentSession.prompt(text, { streamingBehavior: \"followUp\" });\n\t\treturn;\n\t}\n\tawait requiredChatSessionCommand(state, \"followUp\")(text);\n}\n"]}
|
|
@@ -6,7 +6,9 @@ export interface ChatSessionEditorCallbacks {
|
|
|
6
6
|
submit: (mode: ChatSessionSubmitMode, submittedText?: string) => void | Promise<void>;
|
|
7
7
|
restoreQueuedMessagesToEditor: () => boolean;
|
|
8
8
|
abortCompaction: () => void | Promise<void>;
|
|
9
|
-
interrupt: (
|
|
9
|
+
interrupt: (options?: {
|
|
10
|
+
restoreQueuedMessages?: boolean;
|
|
11
|
+
}) => void | Promise<void>;
|
|
10
12
|
abortBash: () => void | Promise<void>;
|
|
11
13
|
}
|
|
12
14
|
export declare function createChatSessionEditor<TExtraEntry extends ChatTranscriptEntryLike>(state: ChatSessionHostState<TExtraEntry>, tui: TUI | undefined, keybindings: unknown, editorTheme: EditorTheme, editorFactory: ChatSessionHostOpts<TExtraEntry>["editorFactory"], callbacks: ChatSessionEditorCallbacks): EditorComponent | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-host-editor.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAa,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAQ3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,WAAW,0BAA0B;IAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,qBAAqB,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,6BAA6B,EAAE,MAAM,OAAO,CAAC;IAC7C,eAAe,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"chat-session-host-editor.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAa,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAQ3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,WAAW,0BAA0B;IAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,qBAAqB,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,6BAA6B,EAAE,MAAM,OAAO,CAAC;IAC7C,eAAe,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,wBAAgB,uBAAuB,CAAC,WAAW,SAAS,uBAAuB,EAClF,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACxC,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,WAAW,EAAE,OAAO,EACpB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,EAChE,SAAS,EAAE,0BAA0B,GACnC,eAAe,GAAG,SAAS,CAiE7B;AAED,wBAAgB,sBAAsB,CAAC,WAAW,SAAS,uBAAuB,EACjF,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACxC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,0BAA0B,GACnC,OAAO,CA8CT;AAED,wBAAgB,wBAAwB,CAAC,WAAW,SAAS,uBAAuB,EACnF,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACxC,IAAI,EAAE,MAAM,GACV,IAAI,CAIN;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAKnG;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAKzG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAGhF"}
|
|
@@ -48,7 +48,7 @@ export function createChatSessionEditor(state, tui, keybindings, editorTheme, ed
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
if (isChatSessionStreaming(state)) {
|
|
51
|
-
void callbacks.interrupt();
|
|
51
|
+
void callbacks.interrupt({ restoreQueuedMessages: true });
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
if (isChatSessionBashRunning(state)) {
|
|
@@ -81,7 +81,7 @@ export function handleChatSessionInput(state, data, callbacks) {
|
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
if (isChatSessionStreaming(state)) {
|
|
84
|
-
void callbacks.interrupt();
|
|
84
|
+
void callbacks.interrupt({ restoreQueuedMessages: true });
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
if (isChatSessionBashRunning(state)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-host-editor.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/ch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,KAAK,UAAU,6BAA6B,CAC3C,KAAwC;IAExC,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO;IAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC;IACvB,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/E,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAAC,WAAW,EAAE,IAAI,EAAE;QAClE,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC;KAClE,CAAC,CAAC;IACH,IAAI,OAAO,KAAK,SAAS;QAAE,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import type { EditorComponent, EditorTheme, Focusable, TUI } from \"@earendil-works/pi-tui\";\nimport { openExternalEditorForText, pasteClipboardImageToEditor } from \"../chat-input-actions.ts\";\nimport {\n\tisChatSessionBashRunning,\n\tisChatSessionStreaming,\n\tnotifyChatSessionStatus,\n\tnotifyChatSessionWarning,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport type { ChatSessionHostOpts, ChatSessionSubmitMode } from \"./chat-session-host-types.ts\";\nimport { matchesKey } from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.ts\";\nimport { CustomEditor } from \"./custom-editor.ts\";\n\nexport interface ChatSessionEditorCallbacks {\n\tsubmit: (mode: ChatSessionSubmitMode, submittedText?: string) => void | Promise<void>;\n\trestoreQueuedMessagesToEditor: () => boolean;\n\tabortCompaction: () => void | Promise<void>;\n\tinterrupt: () => void | Promise<void>;\n\tabortBash: () => void | Promise<void>;\n}\n\nexport function createChatSessionEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttui: TUI | undefined,\n\tkeybindings: unknown,\n\teditorTheme: EditorTheme,\n\teditorFactory: ChatSessionHostOpts<TExtraEntry>[\"editorFactory\"],\n\tcallbacks: ChatSessionEditorCallbacks,\n): EditorComponent | undefined {\n\tif (!tui || !keybindings) return undefined;\n\tconst editor =\n\t\tcreateInheritedEditor(tui, editorTheme, keybindings, editorFactory) ??\n\t\tnew CustomEditor(tui, editorTheme, keybindings as ConstructorParameters<typeof CustomEditor>[2], {\n\t\t\tpaddingX: 0,\n\t\t\tautocompleteMaxVisible: 5,\n\t\t});\n\teditor.onChange = (text) => {\n\t\tstate.inputBuffer = text;\n\t\tstate.isBashMode = text.trimStart().startsWith(\"!\");\n\t};\n\teditor.onSubmit = (text) => {\n\t\tvoid callbacks.submit(\"auto\", text);\n\t};\n\tconst actionEditor = editor as EditorComponent & {\n\t\tonAction?: (action: string, handler: () => void) => void;\n\t\tonEscape?: () => void;\n\t\tonPasteImage?: () => void;\n\t};\n\tactionEditor.onAction?.(\"app.message.followUp\", () => {\n\t\tvoid callbacks.submit(\"followUp\");\n\t});\n\tactionEditor.onAction?.(\"app.message.dequeue\", () => {\n\t\tcallbacks.restoreQueuedMessagesToEditor();\n\t});\n\tactionEditor.onAction?.(\"app.editor.external\", () => {\n\t\tvoid openChatSessionExternalEditor(state);\n\t});\n\tif (state.actions) {\n\t\tfor (const [action, handler] of Object.entries(state.actions)) {\n\t\t\tactionEditor.onAction?.(action, () => {\n\t\t\t\tvoid handler();\n\t\t\t});\n\t\t}\n\t}\n\tconst previousPasteImage = actionEditor.onPasteImage;\n\tactionEditor.onPasteImage = () => {\n\t\tpreviousPasteImage?.();\n\t\tvoid pasteClipboardImageToEditor(chatSessionEditorAccess(state), () => state.requestRender?.(), {\n\t\t\tshowWarning: (message) => notifyChatSessionWarning(state, message),\n\t\t});\n\t};\n\tconst previousEscape = actionEditor.onEscape;\n\tactionEditor.onEscape = () => {\n\t\tif (state.compacting) {\n\t\t\tvoid callbacks.abortCompaction();\n\t\t\treturn;\n\t\t}\n\t\tif (isChatSessionStreaming(state)) {\n\t\t\tvoid callbacks.interrupt();\n\t\t\treturn;\n\t\t}\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tvoid callbacks.abortBash();\n\t\t\treturn;\n\t\t}\n\t\tif (state.isBashMode) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tnotifyChatSessionStatus(state, \"Bash mode cleared\");\n\t\t\treturn;\n\t\t}\n\t\tpreviousEscape?.();\n\t};\n\treturn editor;\n}\n\nexport function handleChatSessionInput<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tdata: string,\n\tcallbacks: ChatSessionEditorCallbacks,\n): boolean {\n\tif (state.bodyViewport.handleInput(data)) return true;\n\tif (matchesKey(data, \"alt+up\")) {\n\t\tcallbacks.restoreQueuedMessagesToEditor();\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"ctrl+f\")) {\n\t\tvoid callbacks.submit(\"followUp\");\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"escape\")) {\n\t\tif (state.compacting) {\n\t\t\tvoid callbacks.abortCompaction();\n\t\t\treturn true;\n\t\t}\n\t\tif (isChatSessionStreaming(state)) {\n\t\t\tvoid callbacks.interrupt();\n\t\t\treturn true;\n\t\t}\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tvoid callbacks.abortBash();\n\t\t\treturn true;\n\t\t}\n\t\tif (state.isBashMode) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tnotifyChatSessionStatus(state, \"Bash mode cleared\");\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (state.editor) {\n\t\tstate.editor.handleInput(data);\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"enter\")) {\n\t\tvoid callbacks.submit(\"auto\");\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"backspace\")) {\n\t\tsetChatSessionEditorText(state, state.inputBuffer.slice(0, -1));\n\t\treturn true;\n\t}\n\tif (data.length === 1 && data >= \" \" && data <= \"~\") {\n\t\tsetChatSessionEditorText(state, `${state.inputBuffer}${data}`);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport function setChatSessionEditorText<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): void {\n\tstate.inputBuffer = text;\n\tstate.isBashMode = text.trimStart().startsWith(\"!\");\n\tstate.editor?.setText(text);\n}\n\nexport function setEditorPlaceholder(editor: EditorComponent, placeholder: string | undefined): void {\n\tconst candidate = editor as EditorComponent & {\n\t\tsetPlaceholder?: (value: string | undefined) => void;\n\t};\n\tcandidate.setPlaceholder?.(placeholder);\n}\n\nexport function setEditorBorderColor(editor: EditorComponent, borderColor: (text: string) => string): void {\n\tconst candidate = editor as EditorComponent & {\n\t\tborderColor?: (text: string) => string;\n\t};\n\tif (candidate.borderColor !== undefined) candidate.borderColor = borderColor;\n}\n\nexport function setEditorFocused(editor: EditorComponent, focused: boolean): void {\n\tconst candidate = editor as EditorComponent & Partial<Focusable>;\n\tif (\"focused\" in candidate) candidate.focused = focused;\n}\n\nfunction createInheritedEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\ttui: TUI,\n\teditorTheme: EditorTheme,\n\tkeybindings: unknown,\n\teditorFactory: ChatSessionHostOpts<TExtraEntry>[\"editorFactory\"],\n): EditorComponent | undefined {\n\tif (!editorFactory) return undefined;\n\ttry {\n\t\treturn editorFactory(tui, editorTheme, keybindings);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction chatSessionEditorAccess<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): {\n\tinsertTextAtCursor: (text: string) => void;\n\tgetText: () => string;\n\tsetText: (text: string) => void;\n} {\n\treturn {\n\t\tinsertTextAtCursor: (text: string) => {\n\t\t\tif (state.editor?.insertTextAtCursor) {\n\t\t\t\tstate.editor.insertTextAtCursor(text);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetChatSessionEditorText(state, `${state.inputBuffer}${text}`);\n\t\t},\n\t\tgetText: () => state.inputBuffer,\n\t\tsetText: (text: string) => setChatSessionEditorText(state, text),\n\t};\n}\n\nasync function openChatSessionExternalEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\tif (!state.editor) return;\n\tconst host = state.tui;\n\tif (!host) return;\n\tconst currentText = state.editor.getExpandedText?.() ?? state.editor.getText();\n\tconst updated = await openExternalEditorForText(currentText, host, {\n\t\tshowWarning: (message) => notifyChatSessionWarning(state, message),\n\t});\n\tif (updated !== undefined) setChatSessionEditorText(state, updated);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-session-host-editor.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAUlD,MAAM,UAAU,uBAAuB,CACtC,KAAwC,EACxC,GAAoB,EACpB,WAAoB,EACpB,WAAwB,EACxB,aAAgE,EAChE,SAAqC;IAErC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,MAAM,GACX,qBAAqB,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC;QACnE,IAAI,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,WAA4D,EAAE;YAChG,QAAQ,EAAE,CAAC;YACX,sBAAsB,EAAE,CAAC;SACzB,CAAC,CAAC;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tui\";\nimport { openExternalEditorForText, pasteClipboardImageToEditor } from \"../chat-input-actions.ts\";\nimport {\n\tisChatSessionBashRunning,\n\tisChatSessionStreaming,\n\tnotifyChatSessionStatus,\n\tnotifyChatSessionWarning,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport type { ChatSessionHostOpts, ChatSessionSubmitMode } from \"./chat-session-host-types.ts\";\nimport { matchesKey } from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.ts\";\nimport { CustomEditor } from \"./custom-editor.ts\";\n\nexport interface ChatSessionEditorCallbacks {\n\tsubmit: (mode: ChatSessionSubmitMode, submittedText?: string) => void | Promise<void>;\n\trestoreQueuedMessagesToEditor: () => boolean;\n\tabortCompaction: () => void | Promise<void>;\n\tinterrupt: (options?: { restoreQueuedMessages?: boolean }) => void | Promise<void>;\n\tabortBash: () => void | Promise<void>;\n}\n\nexport function createChatSessionEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttui: TUI | undefined,\n\tkeybindings: unknown,\n\teditorTheme: EditorTheme,\n\teditorFactory: ChatSessionHostOpts<TExtraEntry>[\"editorFactory\"],\n\tcallbacks: ChatSessionEditorCallbacks,\n): EditorComponent | undefined {\n\tif (!tui || !keybindings) return undefined;\n\tconst editor =\n\t\tcreateInheritedEditor(tui, editorTheme, keybindings, editorFactory) ??\n\t\tnew CustomEditor(tui, editorTheme, keybindings as ConstructorParameters<typeof CustomEditor>[2], {\n\t\t\tpaddingX: 0,\n\t\t\tautocompleteMaxVisible: 5,\n\t\t});\n\teditor.onChange = (text) => {\n\t\tstate.inputBuffer = text;\n\t\tstate.isBashMode = text.trimStart().startsWith(\"!\");\n\t};\n\teditor.onSubmit = (text) => {\n\t\tvoid callbacks.submit(\"auto\", text);\n\t};\n\tconst actionEditor = editor as EditorComponent & {\n\t\tonAction?: (action: string, handler: () => void) => void;\n\t\tonEscape?: () => void;\n\t\tonPasteImage?: () => void;\n\t};\n\tactionEditor.onAction?.(\"app.message.followUp\", () => {\n\t\tvoid callbacks.submit(\"followUp\");\n\t});\n\tactionEditor.onAction?.(\"app.message.dequeue\", () => {\n\t\tcallbacks.restoreQueuedMessagesToEditor();\n\t});\n\tactionEditor.onAction?.(\"app.editor.external\", () => {\n\t\tvoid openChatSessionExternalEditor(state);\n\t});\n\tif (state.actions) {\n\t\tfor (const [action, handler] of Object.entries(state.actions)) {\n\t\t\tactionEditor.onAction?.(action, () => {\n\t\t\t\tvoid handler();\n\t\t\t});\n\t\t}\n\t}\n\tconst previousPasteImage = actionEditor.onPasteImage;\n\tactionEditor.onPasteImage = () => {\n\t\tpreviousPasteImage?.();\n\t\tvoid pasteClipboardImageToEditor(chatSessionEditorAccess(state), () => state.requestRender?.(), {\n\t\t\tshowWarning: (message) => notifyChatSessionWarning(state, message),\n\t\t});\n\t};\n\tconst previousEscape = actionEditor.onEscape;\n\tactionEditor.onEscape = () => {\n\t\tif (state.compacting) {\n\t\t\tvoid callbacks.abortCompaction();\n\t\t\treturn;\n\t\t}\n\t\tif (isChatSessionStreaming(state)) {\n\t\t\tvoid callbacks.interrupt({ restoreQueuedMessages: true });\n\t\t\treturn;\n\t\t}\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tvoid callbacks.abortBash();\n\t\t\treturn;\n\t\t}\n\t\tif (state.isBashMode) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tnotifyChatSessionStatus(state, \"Bash mode cleared\");\n\t\t\treturn;\n\t\t}\n\t\tpreviousEscape?.();\n\t};\n\treturn editor;\n}\n\nexport function handleChatSessionInput<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tdata: string,\n\tcallbacks: ChatSessionEditorCallbacks,\n): boolean {\n\tif (state.bodyViewport.handleInput(data)) return true;\n\tif (matchesKey(data, \"alt+up\")) {\n\t\tcallbacks.restoreQueuedMessagesToEditor();\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"ctrl+f\")) {\n\t\tvoid callbacks.submit(\"followUp\");\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"escape\")) {\n\t\tif (state.compacting) {\n\t\t\tvoid callbacks.abortCompaction();\n\t\t\treturn true;\n\t\t}\n\t\tif (isChatSessionStreaming(state)) {\n\t\t\tvoid callbacks.interrupt({ restoreQueuedMessages: true });\n\t\t\treturn true;\n\t\t}\n\t\tif (isChatSessionBashRunning(state)) {\n\t\t\tvoid callbacks.abortBash();\n\t\t\treturn true;\n\t\t}\n\t\tif (state.isBashMode) {\n\t\t\tsetChatSessionEditorText(state, \"\");\n\t\t\tnotifyChatSessionStatus(state, \"Bash mode cleared\");\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (state.editor) {\n\t\tstate.editor.handleInput(data);\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"enter\")) {\n\t\tvoid callbacks.submit(\"auto\");\n\t\treturn true;\n\t}\n\tif (matchesKey(data, \"backspace\")) {\n\t\tsetChatSessionEditorText(state, state.inputBuffer.slice(0, -1));\n\t\treturn true;\n\t}\n\tif (data.length === 1 && data >= \" \" && data <= \"~\") {\n\t\tsetChatSessionEditorText(state, `${state.inputBuffer}${data}`);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport function setChatSessionEditorText<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\ttext: string,\n): void {\n\tstate.inputBuffer = text;\n\tstate.isBashMode = text.trimStart().startsWith(\"!\");\n\tstate.editor?.setText(text);\n}\n\nexport function setEditorPlaceholder(editor: EditorComponent, placeholder: string | undefined): void {\n\tconst candidate = editor as EditorComponent & {\n\t\tsetPlaceholder?: (value: string | undefined) => void;\n\t};\n\tcandidate.setPlaceholder?.(placeholder);\n}\n\nexport function setEditorBorderColor(editor: EditorComponent, borderColor: (text: string) => string): void {\n\tconst candidate = editor as EditorComponent & {\n\t\tborderColor?: (text: string) => string;\n\t};\n\tif (candidate.borderColor !== undefined) candidate.borderColor = borderColor;\n}\n\nexport function setEditorFocused(editor: EditorComponent, focused: boolean): void {\n\tconst candidate = editor as EditorComponent & Partial<Focusable>;\n\tif (\"focused\" in candidate) candidate.focused = focused;\n}\n\nfunction createInheritedEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\ttui: TUI,\n\teditorTheme: EditorTheme,\n\tkeybindings: unknown,\n\teditorFactory: ChatSessionHostOpts<TExtraEntry>[\"editorFactory\"],\n): EditorComponent | undefined {\n\tif (!editorFactory) return undefined;\n\ttry {\n\t\treturn editorFactory(tui, editorTheme, keybindings);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction chatSessionEditorAccess<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): {\n\tinsertTextAtCursor: (text: string) => void;\n\tgetText: () => string;\n\tsetText: (text: string) => void;\n} {\n\treturn {\n\t\tinsertTextAtCursor: (text: string) => {\n\t\t\tif (state.editor?.insertTextAtCursor) {\n\t\t\t\tstate.editor.insertTextAtCursor(text);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetChatSessionEditorText(state, `${state.inputBuffer}${text}`);\n\t\t},\n\t\tgetText: () => state.inputBuffer,\n\t\tsetText: (text: string) => setChatSessionEditorText(state, text),\n\t};\n}\n\nasync function openChatSessionExternalEditor<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n): Promise<void> {\n\tif (!state.editor) return;\n\tconst host = state.tui;\n\tif (!host) return;\n\tconst currentText = state.editor.getExpandedText?.() ?? state.editor.getText();\n\tconst updated = await openExternalEditorForText(currentText, host, {\n\t\tshowWarning: (message) => notifyChatSessionWarning(state, message),\n\t});\n\tif (updated !== undefined) setChatSessionEditorText(state, updated);\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AgentSessionEvent } from "../../../core/agent-session.ts";
|
|
2
|
+
import type { CompactionReason } from "../../../core/agent-session-types.ts";
|
|
2
3
|
import type { ChatSessionHostState } from "./chat-session-host-state.ts";
|
|
3
4
|
import type { ChatTranscriptEntryLike } from "./chat-transcript.ts";
|
|
5
|
+
export type { CompactionReason } from "../../../core/agent-session-types.ts";
|
|
6
|
+
export declare function compactionStatusMessage(reason: CompactionReason): string;
|
|
4
7
|
export declare function applyChatSessionAgentEvent<TExtraEntry extends ChatTranscriptEntryLike>(state: ChatSessionHostState<TExtraEntry>, event: AgentSessionEvent): boolean;
|
|
5
8
|
//# sourceMappingURL=chat-session-host-events.d.ts.map
|
|
@@ -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;
|
|
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,CA+LT"}
|
|
@@ -4,7 +4,7 @@ import { pickWhimsicalWorkingMessage } from "../whimsical-messages.js";
|
|
|
4
4
|
import { flushChatSessionCompactionQueue } from "./chat-session-host-actions.js";
|
|
5
5
|
import { afterChatSessionEvent, decrementOptimisticUserSignature, startChatSessionWorkingLifecycle, stopChatSessionWorkingLifecycle, } from "./chat-session-host-runtime.js";
|
|
6
6
|
import { extractMessageText, isMessageLike, isUserMessageLike, userMessageSignature, } from "./chat-session-host-utils.js";
|
|
7
|
-
function compactionStatusMessage(reason) {
|
|
7
|
+
export function compactionStatusMessage(reason) {
|
|
8
8
|
switch (reason) {
|
|
9
9
|
case "manual":
|
|
10
10
|
return "Compacting context...";
|
|
@@ -12,6 +12,8 @@ function compactionStatusMessage(reason) {
|
|
|
12
12
|
return "Auto-compacting...";
|
|
13
13
|
case "overflow":
|
|
14
14
|
return "Context overflow detected. Auto-compacting...";
|
|
15
|
+
case "branchSummary":
|
|
16
|
+
return "summarizing branch…";
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
function hasVerbatimCompactionMessage(messages) {
|
|
@@ -215,13 +217,12 @@ export function applyChatSessionAgentEvent(state, event) {
|
|
|
215
217
|
case "summarization_retry_attempt_start": {
|
|
216
218
|
const retry = event;
|
|
217
219
|
state.sdkBusy = true;
|
|
218
|
-
state.statusMessage =
|
|
219
|
-
retry.source === "branchSummary" ? "summarizing branch…" : compactionStatusMessage(retry.reason);
|
|
220
|
+
state.statusMessage = compactionStatusMessage(retry.source === "branchSummary" ? "branchSummary" : retry.reason);
|
|
220
221
|
changed = true;
|
|
221
222
|
break;
|
|
222
223
|
}
|
|
223
224
|
case "summarization_retry_finished":
|
|
224
|
-
state.statusMessage = state.compacting ? "
|
|
225
|
+
state.statusMessage = state.compacting ? compactionStatusMessage("manual") : "";
|
|
225
226
|
changed = true;
|
|
226
227
|
break;
|
|
227
228
|
case "auto_retry_start":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-host-events.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],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ACR,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;IAKpD,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,KAAK,EAAE;QACxD,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;KAC3C,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.ts\";\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.ts\";\n\ntype CompactionReason = \"manual\" | \"threshold\" | \"overflow\";\n\nfunction 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}\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\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (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\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 = false;\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\tstate.compacting = false;\n\t\t\tstate.sdkBusy = compaction.midTurn === true;\n\t\t\tstate.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 (\n\t\t\t\t!compaction.midTurn &&\n\t\t\t\t!compaction.aborted &&\n\t\t\t\t!compaction.errorMessage &&\n\t\t\t\tstate.compactionQueuedMessages.length > 0\n\t\t\t) {\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 =\n\t\t\t\tretry.source === \"branchSummary\" ? \"summarizing branch…\" : compactionStatusMessage(retry.reason);\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 ? \"Compacting context...\" : \"\";\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\"; delta: string };\n\tmessage: { role: \"assistant\"; content: [] };\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\", delta },\n\t\tmessage: { role: \"assistant\", content: [] },\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,CAAC,MAAwB;IAC/D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,QAAQ;YACZ,OAAO,uBAAuB,CAAC;QAChC,KAAK,WAAW;YACf,OAAO,oBAAoB,CAAC;QAC7B,KAAK,UAAU;YACd,OAAO,+CAA+C,CAAC;QACxD,KAAK,eAAe;YACnB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;AACF,CAAC;AAED,SAAS,4BAA4B,CAAC,QAAkC;IACvE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;AACtG,CAAC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IAC7D,SAAS;IACT,WAAW;IACX,OAAO;CACsC,CAAC,CAAC;AAEhD,SAAS,0BAA0B,CAAC,MAAgC;IACnE,OAAO,CACN,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;QACxC,OAAO,MAAM,CAAC,YAAY,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,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;IAKpD,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,KAAK,EAAE;QACxD,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;KAC3C,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.ts\";\nimport type { CompactionReason } from \"../../../core/agent-session-types.ts\";\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.ts\";\n\nexport type { CompactionReason } from \"../../../core/agent-session-types.ts\";\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\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (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\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 = false;\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\tstate.compacting = false;\n\t\t\tstate.sdkBusy = compaction.midTurn === true;\n\t\t\tstate.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 (\n\t\t\t\t!compaction.midTurn &&\n\t\t\t\t!compaction.aborted &&\n\t\t\t\t!compaction.errorMessage &&\n\t\t\t\tstate.compactionQueuedMessages.length > 0\n\t\t\t) {\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\"; delta: string };\n\tmessage: { role: \"assistant\"; content: [] };\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\", delta },\n\t\tmessage: { role: \"assistant\", content: [] },\n\t};\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Component, Focusable } from "@earendil-works/pi-tui";
|
|
2
|
-
import type { AgentSessionEvent } from "../../../core/agent-session.ts";
|
|
2
|
+
import type { AgentSessionEvent, CompactionReason } from "../../../core/agent-session.ts";
|
|
3
3
|
import type { AgentSnapshotMessage, ChatSessionHostEntry, ChatSessionHostOpts, ChatSessionSubmitMode } from "./chat-session-host-types.ts";
|
|
4
4
|
import type { ChatTranscriptEntryLike } from "./chat-transcript.ts";
|
|
5
5
|
export type { ChatSessionHostBashRequest, ChatSessionHostCommands, ChatSessionHostEntry, ChatSessionHostOpts, ChatSessionHostStyle, ChatSessionSubmitMode, } from "./chat-session-host-types.ts";
|
|
@@ -12,6 +12,18 @@ export declare class ChatSessionHost<TExtraEntry extends ChatTranscriptEntryLike
|
|
|
12
12
|
appendExtraEntry(entry: TExtraEntry): void;
|
|
13
13
|
entries(): readonly ChatSessionHostEntry<TExtraEntry>[];
|
|
14
14
|
applyAgentEvent(event: AgentSessionEvent): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Restore the factual compaction indicator on a host mounted after the
|
|
17
|
+
* `compaction_start` it never saw. The label resolves through the same
|
|
18
|
+
* mapping the live event path uses, so the two cannot drift.
|
|
19
|
+
*
|
|
20
|
+
* Branch summaries deliberately do not paint here: their label belongs to
|
|
21
|
+
* a retry lifecycle this re-attached host is not inside, and no event exists
|
|
22
|
+
* to clear it after the summary finishes. An absent paintable reason is a
|
|
23
|
+
* no-op unless this host is actively showing a compaction label, so unrelated
|
|
24
|
+
* workflow delivery busy state is preserved.
|
|
25
|
+
*/
|
|
26
|
+
hydrateCompactionStatus(reason: CompactionReason | undefined): void;
|
|
15
27
|
render(width: number): string[];
|
|
16
28
|
invalidate(): void;
|
|
17
29
|
renderBody(width: number, budget: number): string[];
|
|
@@ -22,7 +34,9 @@ export declare class ChatSessionHost<TExtraEntry extends ChatTranscriptEntryLike
|
|
|
22
34
|
renderFooter(width: number): string[];
|
|
23
35
|
handleScrollInput(data: string): boolean;
|
|
24
36
|
handleInput(data: string): boolean;
|
|
25
|
-
interrupt(
|
|
37
|
+
interrupt(options?: {
|
|
38
|
+
restoreQueuedMessages?: boolean;
|
|
39
|
+
}): Promise<void>;
|
|
26
40
|
submit(mode?: ChatSessionSubmitMode, submittedText?: string): Promise<void>;
|
|
27
41
|
isStreaming(): boolean;
|
|
28
42
|
isBashRunning(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-host.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-session-host.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAqC1F,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,YAAY,EACX,0BAA0B,EAC1B,uBAAuB,EACvB,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,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjC;IAEK,SAAS,CAAC,OAAO,CAAC,EAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;IAEK,MAAM,CAAC,IAAI,GAAE,qBAA8B,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;IAED,WAAW,IAAI,OAAO,CAErB;IAED,aAAa,IAAI,OAAO,CAEvB;IAED,oBAAoB,IAAI,OAAO,CAE9B;IAED,YAAY,IAAI,OAAO,CAEtB;IAED,YAAY,IAAI,OAAO,CAEtB;IAED,gBAAgB,IAAI,OAAO,CAE1B;IAED,oBAAoB,IAAI,MAAM,CAE7B;IAED,aAAa,IAAI,MAAM,CAEtB;IAED,SAAS,IAAI,MAAM,CAElB;IACD,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE/B;IAED,UAAU,IAAI,MAAM,CAEnB;IAED,cAAc,IAAI,IAAI,CAErB;IAED,iBAAiB,IAAI,IAAI,CAExB;IAED,iCAAiC,IAAI,IAAI,CAExC;IAED;;;;OAIG;IACH,4BAA4B,IAAI,MAAM,GAAG,SAAS,CAEjD;IAED;;;OAGG;IACH,+BAA+B,IAAI,MAAM,GAAG,SAAS,CAEpD;IAED,kFAAkF;IAClF,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAIlE;IAED,OAAO,IAAI,IAAI,CAEd;IAED,6BAA6B,IAAI,OAAO,CAEvC;IAED,OAAO,CAAC,eAAe;CAevB"}
|
|
@@ -2,7 +2,7 @@ import { repairOrphanToolResults } from "../../../core/messages.js";
|
|
|
2
2
|
import { SessionManager } from "../../../core/session-manager.js";
|
|
3
3
|
import { abortChatSessionBash, abortChatSessionCompaction, interruptChatSession, restoreQueuedMessagesToEditor, submitChatSession, } from "./chat-session-host-actions.js";
|
|
4
4
|
import { createChatSessionEditor, handleChatSessionInput, setChatSessionEditorText, } from "./chat-session-host-editor.js";
|
|
5
|
-
import { applyChatSessionAgentEvent } from "./chat-session-host-events.js";
|
|
5
|
+
import { applyChatSessionAgentEvent, compactionStatusMessage } from "./chat-session-host-events.js";
|
|
6
6
|
import { renderChatSessionBody, renderChatSessionEditor, renderChatSessionEntry, renderChatSessionFooter, renderChatSessionPendingMessages, renderChatSessionUsage, renderChatSessionWorkingStatus, transcriptCacheKey, } from "./chat-session-host-rendering.js";
|
|
7
7
|
import { clearChatSessionBusyForTerminalWorkflowStage, disposeChatSession, isChatSessionBashRunning, isChatSessionStreaming, reassertChatSessionExternalPromptLifecycle, settleChatSessionPromptLifecycle, startChatSessionExternalPromptLifecycle, syncChatSessionAnimationTick, } from "./chat-session-host-runtime.js";
|
|
8
8
|
import { ChatSessionHostState } from "./chat-session-host-state.js";
|
|
@@ -43,6 +43,33 @@ export class ChatSessionHost {
|
|
|
43
43
|
applyAgentEvent(event) {
|
|
44
44
|
return applyChatSessionAgentEvent(this.state, event);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Restore the factual compaction indicator on a host mounted after the
|
|
48
|
+
* `compaction_start` it never saw. The label resolves through the same
|
|
49
|
+
* mapping the live event path uses, so the two cannot drift.
|
|
50
|
+
*
|
|
51
|
+
* Branch summaries deliberately do not paint here: their label belongs to
|
|
52
|
+
* a retry lifecycle this re-attached host is not inside, and no event exists
|
|
53
|
+
* to clear it after the summary finishes. An absent paintable reason is a
|
|
54
|
+
* no-op unless this host is actively showing a compaction label, so unrelated
|
|
55
|
+
* workflow delivery busy state is preserved.
|
|
56
|
+
*/
|
|
57
|
+
hydrateCompactionStatus(reason) {
|
|
58
|
+
const compactionReason = reason === "branchSummary" ? undefined : reason;
|
|
59
|
+
if (compactionReason === undefined) {
|
|
60
|
+
if (!this.state.compacting)
|
|
61
|
+
return;
|
|
62
|
+
this.state.compacting = false;
|
|
63
|
+
this.state.statusMessage = "";
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.state.compacting = true;
|
|
67
|
+
this.state.sdkBusy = true;
|
|
68
|
+
this.state.statusMessage = compactionStatusMessage(compactionReason);
|
|
69
|
+
}
|
|
70
|
+
this.syncAnimationTick();
|
|
71
|
+
this.state.requestRender?.();
|
|
72
|
+
}
|
|
46
73
|
render(width) {
|
|
47
74
|
return this.renderBody(width, 1);
|
|
48
75
|
}
|
|
@@ -75,8 +102,8 @@ export class ChatSessionHost {
|
|
|
75
102
|
handleInput(data) {
|
|
76
103
|
return handleChatSessionInput(this.state, data, this.editorCallbacks());
|
|
77
104
|
}
|
|
78
|
-
async interrupt() {
|
|
79
|
-
await interruptChatSession(this.state);
|
|
105
|
+
async interrupt(options) {
|
|
106
|
+
await interruptChatSession(this.state, options);
|
|
80
107
|
}
|
|
81
108
|
async submit(mode = "auto", submittedText) {
|
|
82
109
|
await submitChatSession(this.state, mode, submittedText);
|
|
@@ -155,7 +182,7 @@ export class ChatSessionHost {
|
|
|
155
182
|
submit: (mode, submittedText) => this.submit(mode, submittedText),
|
|
156
183
|
restoreQueuedMessagesToEditor: () => this.restoreQueuedMessagesToEditor(),
|
|
157
184
|
abortCompaction: () => abortChatSessionCompaction(this.state),
|
|
158
|
-
interrupt: () => this.interrupt(),
|
|
185
|
+
interrupt: (options) => this.interrupt(options),
|
|
159
186
|
abortBash: () => abortChatSessionBash(this.state),
|
|
160
187
|
};
|
|
161
188
|
}
|