@bastani/atomic 0.10.1 → 0.10.2-alpha.1
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 +27 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/watchdog.ts +4 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +16 -0
- package/dist/builtin/subagents/README.md +2 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/index.bundle.mjs +9 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -14
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +13 -9
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +6 -3
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -0
- 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-nested-tools.d.ts.map +1 -1
- package/dist/core/agent-session-nested-tools.js +2 -1
- package/dist/core/agent-session-nested-tools.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +12 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +6 -0
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +71 -4
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +9 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -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 +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +15 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +40 -2
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +2 -1
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/export-html/template.js +14 -4
- package/dist/core/extensions/context-types.d.ts +6 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +100 -7
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +194 -4
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +32 -0
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
- package/dist/core/resume-cache-checkpoint.js +67 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -0
- package/dist/core/sdk-types.d.ts +37 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +57 -28
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +12 -3
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +13 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +38 -6
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +2 -1
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
- package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
- package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
- package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +72 -2
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +216 -15
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
- package/dist/core/storage/session/entry-structure.js +39 -2
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/storage/session/session-resume.d.ts.map +1 -1
- package/dist/core/storage/session/session-resume.js +1 -0
- package/dist/core/storage/session/session-resume.js.map +1 -1
- package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
- package/dist/core/storage/session/session-search-index.js +56 -9
- package/dist/core/storage/session/session-search-index.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +36 -0
- package/dist/core/storage/statement-sequence.d.ts.map +1 -0
- package/dist/core/storage/statement-sequence.js +22 -0
- package/dist/core/storage/statement-sequence.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +13 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +2 -1
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +4 -2
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +27 -5
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +2 -1
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +22 -22
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +7 -0
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/transformed-system-prompt.d.ts +92 -0
- package/dist/core/transformed-system-prompt.d.ts.map +1 -0
- package/dist/core/transformed-system-prompt.js +240 -0
- package/dist/core/transformed-system-prompt.js.map +1 -0
- package/dist/extensions/codemode/execute.js +1 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +16 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +13 -8
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +2 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +5 -0
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +289 -64
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +2 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +58 -0
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-records.js +129 -0
- package/dist/extensions/mcp/tool-records.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +65 -80
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +35 -28
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +16 -0
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +7 -0
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +8 -4
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +0 -1
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +6 -14
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +7 -6
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/token-segment.d.ts +2 -1
- package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
- package/dist/modes/interactive/components/token-segment.js +2 -4
- package/dist/modes/interactive/components/token-segment.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -2
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.js +0 -9
- package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
- package/dist/modes/interactive/extension-command-hold.js +45 -0
- package/dist/modes/interactive/extension-command-hold.js.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +2 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +18 -10
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +54 -13
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +15 -9
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +47 -1
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +165 -65
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/screen-hold.d.ts +3 -0
- package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
- package/dist/modes/interactive/screen-hold.js +9 -1
- package/dist/modes/interactive/screen-hold.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js +5 -4
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +0 -13
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +74 -10
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +27 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +81 -5
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +9 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +16 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +10 -2
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +2 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.js +1 -0
- package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts.map +1 -1
- package/dist/utils/interactive-engine-env.js +1 -0
- package/dist/utils/interactive-engine-env.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +2 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/token-count.d.ts +8 -0
- package/dist/utils/token-count.d.ts.map +1 -0
- package/dist/utils/token-count.js +25 -0
- package/dist/utils/token-count.js.map +1 -0
- package/dist/utils/worker-threads.d.ts +18 -0
- package/dist/utils/worker-threads.d.ts.map +1 -0
- package/dist/utils/worker-threads.js +28 -0
- package/dist/utils/worker-threads.js.map +1 -0
- package/docs/background-tasks.md +13 -12
- package/docs/compaction.md +2 -2
- package/docs/development.md +1 -1
- package/docs/extensions/api-reference.md +5 -3
- package/docs/extensions/events.md +2 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/storage.md +3 -1
- package/docs/subagents.md +6 -2
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-prompt-turn.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-prompt-turn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,oBAAoB,EAA+B,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAA8B,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAElG,mBAAmB,CAAC,SAAS,CAAC,iBAAiB,GAAG,KAAK,WAEtD,KAAqC;IAErC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IACtD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACvB,MAAM,cAAc,GAAG,GAAS,EAAE;QACjC,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,IAAI,CAAC,wBAAwB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxE,KAAK,IAAI,CAAC,oBAAoB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;IACF,CAAC,CAAC;IACF,4EAA4E;IAC5E,wEAAwE;IACxE,sEAAsE;IACtE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAA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,CAAC;QACnF,2EAA2E;QAC3E,8EAA8E;QAC9E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC;QACnF,CAAC;IACF,CAAC;YAAS,CAAC;QACV,oBAAoB,EAAE,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE,CAAC;QACd,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI;YAAE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC1D,IAAI,CAAC,OAAO,IAAI,WAAW;YAAE,cAAc,EAAE,CAAC;QAC9C,IAAI,CAAC,6BAA6B,GAAG,KAAK,CAAC;QAC3C,oEAAoE;QACpE,yEAAyE;QACzE,2EAA2E;QAC3E,4EAA4E;QAC5E,4DAA4D;QAC5D,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,SAAS,EAAE,CAAC;YAC/G,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["import type { AgentSessionInternalSurface } from \"../../core/agent-session-methods.ts\";\nimport { tryExecuteSessionSlashCommand } from \"../../core/agent-session-prompt.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { restoreFailedSubmissionDraft, restoreRefusedSubmission } from \"./interactive-prompt-restore.ts\";\nimport { followStartedRunEcho, type StartedRunEchoFollower } from \"./interactive-render-chat.ts\";\nimport { type InteractiveSubmission, toInteractiveSubmission } from \"./interactive-submission.ts\";\n\nInteractiveModeBase.prototype.runUserPromptTurn = async function (\n\tthis: InteractiveModeBase,\n\tinput: InteractiveSubmission | string,\n): Promise<void> {\n\tconst { text: userInput, draft } = toInteractiveSubmission(input);\n\tconst turn = this.promptTurn ?? { dispatched: false };\n\tthis.promptTurn = turn;\n\tconst settleDispatch = (): void => {\n\t\tif (turn.dispatched) return;\n\t\tturn.dispatched = true;\n\t\tif (this.compactionQueuedMessages.length > 0 && !this.compactionActive) {\n\t\t\tvoid this.flushCompactionQueue({ afterPrompt: true });\n\t\t}\n\t};\n\t// Show the working spinner immediately on submit so there is no visible gap\n\t// while prompt preflight runs before the agent emits `agent_start`. The\n\t// ownership flag keeps deferred startup from tearing it down mid-way.\n\tif (!this.session.isStreaming) {\n\t\tthis.workingRunMeter.stop();\n\t}\n\tthis.promptTurnWorkingLoaderActive = true;\n\tthis.showWorkingLoaderNow();\n\tconst deferredStartupNeedsPromptGate = this.deferredStartupPending || this.deferredStartupPromise !== undefined;\n\t// Yield once so the freshly-mounted spinner paints before synchronous\n\t// preflight work can block the event loop.\n\tawait yieldToEventLoop();\n\t// A submission that never reaches an agent turn stays user-owned, so track\n\t// whether the turn actually started before deciding to restore the draft.\n\tlet turnStarted = false;\n\tlet refused = false;\n\t// The session answered that it started a run for this prompt, and the prompt call returned.\n\tlet runStarted = false;\n\tconst unsubscribeTurnStart = this.session.subscribe((event) => {\n\t\tif (event.type === \"agent_start\") turnStarted = true;\n\t});\n\tlet echo: StartedRunEchoFollower | undefined;\n\ttry {\n\t\tif (deferredStartupNeedsPromptGate) {\n\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t}\n\t\tconst handledSlashCommand =\n\t\t\t!(this.runtimeHost instanceof IsolatedInteractiveRuntime) &&\n\t\t\t(await tryExecuteSessionSlashCommand(\n\t\t\t\tthis.session as typeof this.session & Pick<AgentSessionInternalSurface, \"_tryExecuteExtensionCommand\">,\n\t\t\t\tuserInput,\n\t\t\t));\n\t\tif (!handledSlashCommand) {\n\t\t\tif (!(this.runtimeHost instanceof IsolatedInteractiveRuntime) || !this.isExtensionCommand(userInput)) {\n\t\t\t\tawait this.session.resumeQueuedMessages();\n\t\t\t}\n\t\t\tconst shownBefore = this.userMessagesShownBySession;\n\t\t\tconst startedEcho = followStartedRunEcho(this, userInput, { sendShowsWorkingRow: true });\n\t\t\techo = startedEcho;\n\t\t\tlet started = false;\n\t\t\tawait this.session.prompt(userInput, {\n\t\t\t\tstreamingBehavior: \"steer\",\n\t\t\t\tpreflightResult: (success, disposition) => {\n\t\t\t\t\trefused = !success;\n\t\t\t\t\t// A queued message is listed as queued, and one an `input` hook handled is not sent at all (#4285).\n\t\t\t\t\tif (success && (disposition === \"queued\" || disposition === \"handled\"))\n\t\t\t\t\t\tthis.discardDeferredRenderedUserInput(userInput);\n\t\t\t\t\tif (success && disposition === \"started\") {\n\t\t\t\t\t\tstarted = true;\n\t\t\t\t\t\tthis.expectStartedUserInput(userInput, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t\t// The run's own events decide its echo (#5135), however they and this answer are ordered.\n\t\t\t\t\tif (success) startedEcho.answer(disposition === \"started\");\n\t\t\t\t\tif (success) settleDispatch();\n\t\t\t\t},\n\t\t\t});\n\t\t\trunStarted = started;\n\t\t}\n\t} catch (error) {\n\t\techo?.close();\n\t\tthis.discardDeferredRenderedUserInput(userInput);\n\t\tif (refused && !turnStarted) {\n\t\t\trestoreRefusedSubmission(this, error, draft);\n\t\t\treturn;\n\t\t}\n\t\tconst restored = restoreFailedSubmissionDraft(this, error, draft, { turnStarted });\n\t\t// A restored draft already tells the user the submission did not land, and\n\t\t// the recovery status explains why. A red transport error beside it is noise.\n\t\tif (!restored) {\n\t\t\tthis.showError(error instanceof Error ? error.message : \"Unknown error occurred\");\n\t\t}\n\t} finally {\n\t\tunsubscribeTurnStart();\n\t\techo?.close();\n\t\tif (this.promptTurn === turn) this.promptTurn = undefined;\n\t\tif (!refused || turnStarted) settleDispatch();\n\t\tthis.promptTurnWorkingLoaderActive = false;\n\t\t// A submission that resolves without starting an agent turn (e.g. a\n\t\t// handled slash command) never emits `agent_end`, so clear the pre-shown\n\t\t// spinner here when idle to avoid a lingering indicator. A run the session\n\t\t// answered as started, whose events have not arrived yet, takes the spinner\n\t\t// over at its `agent_start` and ends it at its `agent_end`.\n\t\tif (!turnStarted && !runStarted && !this.session.isStreaming && this.workingRunMeter.snapshot() === undefined) {\n\t\t\tthis.workingRunMeter.stop();\n\t\t\tthis.stopWorkingLoader();\n\t\t}\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-prompt-turn.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-prompt-turn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,oBAAoB,EAA+B,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAA8B,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAElG,mBAAmB,CAAC,SAAS,CAAC,iBAAiB,GAAG,KAAK,WAEtD,KAAqC;IAErC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAClE,qFAAqF;IACrF,MAAM,oBAAoB,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAC9G,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,UAAU,E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EAAE,CAAC;YAC/G,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC;IACF,CAAC;AACF,CAAC,CAAC","sourcesContent":["import type { AgentSessionInternalSurface } from \"../../core/agent-session-methods.ts\";\nimport { tryExecuteSessionSlashCommand } from \"../../core/agent-session-prompt.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { takeSubmittedExtensionCommandHold } from \"./extension-command-hold.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { restoreFailedSubmissionDraft, restoreRefusedSubmission } from \"./interactive-prompt-restore.ts\";\nimport { followStartedRunEcho, type StartedRunEchoFollower } from \"./interactive-render-chat.ts\";\nimport { type InteractiveSubmission, toInteractiveSubmission } from \"./interactive-submission.ts\";\n\nInteractiveModeBase.prototype.runUserPromptTurn = async function (\n\tthis: InteractiveModeBase,\n\tinput: InteractiveSubmission | string,\n): Promise<void> {\n\tconst { text: userInput, draft } = toInteractiveSubmission(input);\n\t// An extension command's hold of the prompt's slot ends with the turn at the latest.\n\tconst extensionCommandHold = typeof input === \"string\" ? undefined : takeSubmittedExtensionCommandHold(input);\n\tconst turn = this.promptTurn ?? { dispatched: false };\n\tthis.promptTurn = turn;\n\tconst settleDispatch = (): void => {\n\t\tif (turn.dispatched) return;\n\t\tturn.dispatched = true;\n\t\tif (this.compactionQueuedMessages.length > 0 && !this.compactionActive) {\n\t\t\tvoid this.flushCompactionQueue({ afterPrompt: true });\n\t\t}\n\t};\n\t// Show the working spinner immediately on submit so there is no visible gap\n\t// while prompt preflight runs before the agent emits `agent_start`. The\n\t// ownership flag keeps deferred startup from tearing it down mid-way.\n\tif (!this.session.isStreaming) {\n\t\tthis.workingRunMeter.stop();\n\t}\n\tthis.promptTurnWorkingLoaderActive = true;\n\tthis.showWorkingLoaderNow();\n\tconst deferredStartupNeedsPromptGate = this.deferredStartupPending || this.deferredStartupPromise !== undefined;\n\t// Yield once so the freshly-mounted spinner paints before synchronous\n\t// preflight work can block the event loop.\n\tawait yieldToEventLoop();\n\t// A submission that never reaches an agent turn stays user-owned, so track\n\t// whether the turn actually started before deciding to restore the draft.\n\tlet turnStarted = false;\n\tlet refused = false;\n\t// The session answered that it started a run for this prompt, and the prompt call returned.\n\tlet runStarted = false;\n\tconst unsubscribeTurnStart = this.session.subscribe((event) => {\n\t\tif (event.type === \"agent_start\") turnStarted = true;\n\t});\n\tlet echo: StartedRunEchoFollower | undefined;\n\ttry {\n\t\tif (deferredStartupNeedsPromptGate) {\n\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t}\n\t\tconst handledSlashCommand =\n\t\t\t!(this.runtimeHost instanceof IsolatedInteractiveRuntime) &&\n\t\t\t(await tryExecuteSessionSlashCommand(\n\t\t\t\tthis.session as typeof this.session & Pick<AgentSessionInternalSurface, \"_tryExecuteExtensionCommand\">,\n\t\t\t\tuserInput,\n\t\t\t));\n\t\tif (!handledSlashCommand) {\n\t\t\tif (!(this.runtimeHost instanceof IsolatedInteractiveRuntime) || !this.isExtensionCommand(userInput)) {\n\t\t\t\tawait this.session.resumeQueuedMessages();\n\t\t\t}\n\t\t\tconst shownBefore = this.userMessagesShownBySession;\n\t\t\tconst startedEcho = followStartedRunEcho(this, userInput, { sendShowsWorkingRow: true });\n\t\t\techo = startedEcho;\n\t\t\tlet started = false;\n\t\t\tawait this.session.prompt(userInput, {\n\t\t\t\tstreamingBehavior: \"steer\",\n\t\t\t\tpreflightResult: (success, disposition) => {\n\t\t\t\t\trefused = !success;\n\t\t\t\t\t// A queued message is listed as queued, and one an `input` hook handled is not sent at all (#4285).\n\t\t\t\t\tif (success && (disposition === \"queued\" || disposition === \"handled\"))\n\t\t\t\t\t\tthis.discardDeferredRenderedUserInput(userInput);\n\t\t\t\t\tif (success && disposition === \"started\") {\n\t\t\t\t\t\tstarted = true;\n\t\t\t\t\t\tthis.expectStartedUserInput(userInput, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t\t// The run's own events decide its echo (#5135), however they and this answer are ordered.\n\t\t\t\t\tif (success) startedEcho.answer(disposition === \"started\");\n\t\t\t\t\tif (success) settleDispatch();\n\t\t\t\t},\n\t\t\t});\n\t\t\trunStarted = started;\n\t\t}\n\t} catch (error) {\n\t\techo?.close();\n\t\tthis.discardDeferredRenderedUserInput(userInput);\n\t\tif (refused && !turnStarted) {\n\t\t\trestoreRefusedSubmission(this, error, draft);\n\t\t\treturn;\n\t\t}\n\t\tconst restored = restoreFailedSubmissionDraft(this, error, draft, { turnStarted });\n\t\t// A restored draft already tells the user the submission did not land, and\n\t\t// the recovery status explains why. A red transport error beside it is noise.\n\t\tif (!restored) {\n\t\t\tthis.showError(error instanceof Error ? error.message : \"Unknown error occurred\");\n\t\t}\n\t} finally {\n\t\textensionCommandHold?.settle();\n\t\tunsubscribeTurnStart();\n\t\techo?.close();\n\t\tif (this.promptTurn === turn) this.promptTurn = undefined;\n\t\tif (!refused || turnStarted) settleDispatch();\n\t\tthis.promptTurnWorkingLoaderActive = false;\n\t\t// A submission that resolves without starting an agent turn (e.g. a\n\t\t// handled slash command) never emits `agent_end`, so clear the pre-shown\n\t\t// spinner here when idle to avoid a lingering indicator. A run the session\n\t\t// answered as started, whose events have not arrived yet, takes the spinner\n\t\t// over at its `agent_start` and ends it at its `agent_end`.\n\t\tif (!turnStarted && !runStarted && !this.session.isStreaming && this.workingRunMeter.snapshot() === undefined) {\n\t\t\tthis.workingRunMeter.stop();\n\t\t\tthis.stopWorkingLoader();\n\t\t}\n\t}\n};\n"]}
|
|
@@ -3,6 +3,13 @@ import { InteractiveModeBase } from "./interactive-mode-base.ts";
|
|
|
3
3
|
import type { CompactionQueuedMessage } from "./interactive-mode-types.ts";
|
|
4
4
|
import { SteeringQueueController, type SteeringQueueLists } from "./steering-queue-controller.ts";
|
|
5
5
|
export declare function mainSteering(mode: InteractiveModeBase): SteeringQueueController;
|
|
6
|
+
/**
|
|
7
|
+
* Build the main chat's rows again when a message they draw as being delivered is no longer delivered, without an
|
|
8
|
+
* event that builds them: a delivery that ended without its `message_start` (a hook failed, or the session already
|
|
9
|
+
* shows the input). Its row goes with the next event the session sends. A delivery that begins needs nothing here: the
|
|
10
|
+
* rows drawn before it still list it as queued, and the `queue_update` it brings builds them again.
|
|
11
|
+
*/
|
|
12
|
+
export declare function redrawMainQueuedDeliveries(mode: InteractiveModeBase): void;
|
|
6
13
|
/** Report a restore the session could not answer; nothing was removed, so every message is still queued. */
|
|
7
14
|
export declare function showQueueRestoreFailure(mode: InteractiveModeBase, error: unknown): void;
|
|
8
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-queueing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive-queueing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAiBnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAGN,uBAAuB,EACvB,KAAK,kBAAkB,EAEvB,MAAM,gCAAgC,CAAC;AAaxC,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,CAO/E;AAwFD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAQ1E;AAuDD,4GAA4G;AAC5G,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAEvF;AAsGD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,GACnC,uBAAuB,CAEzB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAElG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAGlG;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAErG;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CA2BtE;AA6HD,mGAAmG;AACnG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,qGAAqG;AACrG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAQrF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NO_QUEUED_MESSAGES, queuedMessagesUnderWay, } from "../../core/queued-message-delivery.js";
|
|
1
2
|
import { parseSlashCommand } from "../../core/slash-commands.js";
|
|
2
3
|
import { clearInteractiveEngineQueue, getInteractiveEngineRemoteCommands, } from "../interactive-engine/extension-ui-bridge.js";
|
|
3
4
|
import { IsolatedInteractiveRuntime } from "../interactive-engine/isolated-runtime.js";
|
|
@@ -83,11 +84,44 @@ InteractiveModeBase.prototype.getAllQueuedMessages = function () {
|
|
|
83
84
|
InteractiveModeBase.prototype.clearAllQueues = async function (options) {
|
|
84
85
|
return mainSteering(this).clearAll(options);
|
|
85
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* The messages the main chat's session took from its queue whose own row the transcript does not show yet. Its queue
|
|
89
|
+
* no longer lists them; the chat draws them as queued ahead of their lane until their `message_start` arrives. In
|
|
90
|
+
* process they are read from the session with its queue; an isolated engine tells the host about them with its events.
|
|
91
|
+
*/
|
|
92
|
+
function mainQueuedDeliveries(mode) {
|
|
93
|
+
const runtime = mode.runtimeHost;
|
|
94
|
+
return runtime instanceof IsolatedInteractiveRuntime
|
|
95
|
+
? runtime.queuedMessagesUnderWay()
|
|
96
|
+
: queuedMessagesUnderWay(mode.session);
|
|
97
|
+
}
|
|
98
|
+
/** The messages being delivered that the main chat's rows drew when they were last built. */
|
|
99
|
+
const drawnDeliveries = new WeakMap();
|
|
100
|
+
/**
|
|
101
|
+
* Build the main chat's rows again when a message they draw as being delivered is no longer delivered, without an
|
|
102
|
+
* event that builds them: a delivery that ended without its `message_start` (a hook failed, or the session already
|
|
103
|
+
* shows the input). Its row goes with the next event the session sends. A delivery that begins needs nothing here: the
|
|
104
|
+
* rows drawn before it still list it as queued, and the `queue_update` it brings builds them again.
|
|
105
|
+
*/
|
|
106
|
+
export function redrawMainQueuedDeliveries(mode) {
|
|
107
|
+
const drawn = drawnDeliveries.get(mode);
|
|
108
|
+
if (drawn === undefined || drawn === NO_QUEUED_MESSAGES)
|
|
109
|
+
return;
|
|
110
|
+
// While a subagent is shown, the rows are its queue.
|
|
111
|
+
if (mode.agentView?.viewed?.kind === "agent")
|
|
112
|
+
return;
|
|
113
|
+
if (drawn === mainQueuedDeliveries(mode))
|
|
114
|
+
return;
|
|
115
|
+
mode.updatePendingMessagesDisplay();
|
|
116
|
+
mode.ui.requestRender();
|
|
117
|
+
}
|
|
86
118
|
InteractiveModeBase.prototype.updatePendingMessagesDisplay = function () {
|
|
87
119
|
this.pendingMessagesContainer.clear();
|
|
88
120
|
// While a subagent is shown, the rows above the prompt are its queue, drawn as the main chat draws its own.
|
|
89
121
|
const viewed = viewedSteering(this);
|
|
90
122
|
if (viewed !== undefined) {
|
|
123
|
+
// The main chat's rows are not drawn meanwhile: keep none of their texts.
|
|
124
|
+
drawnDeliveries.delete(this);
|
|
91
125
|
const shown = this.agentView?.viewed;
|
|
92
126
|
const rows = queuedMessageRows(viewed.allQueued(), shown?.kind === "agent" ? shown.port.status().delivering : undefined);
|
|
93
127
|
if (rows.length === 0)
|
|
@@ -99,7 +133,13 @@ InteractiveModeBase.prototype.updatePendingMessagesDisplay = function () {
|
|
|
99
133
|
for (const component of this.pendingBashComponents) {
|
|
100
134
|
this.pendingMessagesContainer.addChild(component);
|
|
101
135
|
}
|
|
102
|
-
|
|
136
|
+
// Drawing only: Alt+Up, Esc and engine recovery use the session's own queue, which no longer lists these.
|
|
137
|
+
const delivering = mainQueuedDeliveries(this);
|
|
138
|
+
if (delivering === NO_QUEUED_MESSAGES)
|
|
139
|
+
drawnDeliveries.delete(this);
|
|
140
|
+
else
|
|
141
|
+
drawnDeliveries.set(this, delivering);
|
|
142
|
+
const rows = queuedMessageRows(this.getAllQueuedMessages(), delivering);
|
|
103
143
|
if (rows.length > 0) {
|
|
104
144
|
const dequeueKey = this.getAppKeyDisplay("app.message.dequeue");
|
|
105
145
|
this.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg("dim", text)));
|
|
@@ -444,6 +484,11 @@ InteractiveModeBase.prototype.attachSteeringEngineRecovery = function () {
|
|
|
444
484
|
this.updatePendingMessagesDisplay();
|
|
445
485
|
this.ui.requestRender();
|
|
446
486
|
});
|
|
487
|
+
// The engine was lost or retired its session: what it was delivering never shows here.
|
|
488
|
+
const stopForgotten = runtime.onQueuedDeliveriesForgotten(() => {
|
|
489
|
+
this.updatePendingMessagesDisplay();
|
|
490
|
+
this.ui.requestRender();
|
|
491
|
+
});
|
|
447
492
|
const stopRecovered = runtime.onEngineRecovered((replaced) => {
|
|
448
493
|
const known = knownAtLoss;
|
|
449
494
|
knownAtLoss = undefined;
|
|
@@ -472,6 +517,7 @@ InteractiveModeBase.prototype.attachSteeringEngineRecovery = function () {
|
|
|
472
517
|
});
|
|
473
518
|
return () => {
|
|
474
519
|
stopEnded();
|
|
520
|
+
stopForgotten();
|
|
475
521
|
stopRecovered();
|
|
476
522
|
};
|
|
477
523
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,GAClC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EACN,aAAa,EAEb,uBAAuB,GAGvB,MAAM,gCAAgC,CAAC;AAExC,kGAAkG;AAClG,MAAM,YAAY,GAAG,IAAI,OAAO,EAAmC,CAAC;AACpE,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;;GAIG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAgD,CAAC;AAEpF,MAAM,UAAU,YAAY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,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,wFAAwF;gBACzF,CAAC;YACF,CAAC;YACD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO;YACnC,gFAAgF;YAChF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;YACnF,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { PromptDisposition, UserMessageWithRawText } from \"../../core/agent-session-types.js\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport {\n\tclearInteractiveEngineQueue,\n\tgetInteractiveEngineRemoteCommands,\n} from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { viewedSteering } from \"./agent-view/viewed-submit.ts\";\nimport { combineQueuedMessagesForEditor } from \"./chat-input-actions.ts\";\nimport { QueuedMessagesView, queuedMessageRows } from \"./components/queued-messages-view.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\nimport {\n\trestoredQueue,\n\ttype SteeringEditorQueue,\n\tSteeringQueueController,\n\ttype SteeringQueueLists,\n\ttype SteeringTarget,\n} from \"./steering-queue-controller.ts\";\n\n/** Typing order of messages handed to the session, so one it refuses returns to its own place. */\nconst handOffOrder = new WeakMap<CompactionQueuedMessage, number>();\nlet nextHandOff = 0;\n\n/**\n * The main chat's steering controller. Messages handed to the session that it has not confirmed yet stay shown as\n * queued until the session reports it took them; from then on the session lists them itself. They are the session's\n * from the moment they are sent, so a restore takes them from the session's own answer and never from this copy.\n */\nconst mainControllers = new WeakMap<InteractiveModeBase, SteeringQueueController>();\n\nexport function mainSteering(mode: InteractiveModeBase): SteeringQueueController {\n\tlet controller = mainControllers.get(mode);\n\tif (controller === undefined) {\n\t\tcontroller = new SteeringQueueController(mainSteeringTarget(mode), mainEditorQueue(mode));\n\t\tmainControllers.set(mode, controller);\n\t}\n\treturn controller;\n}\n\n/** The main chat's session, read at each call, so a session the chat switched to is the one steered. */\nfunction mainSteeringTarget(mode: InteractiveModeBase): SteeringTarget {\n\treturn {\n\t\tget busy() {\n\t\t\treturn mode.session.isStreaming || mode.promptTurn !== undefined;\n\t\t},\n\t\tget paused() {\n\t\t\treturn mode.session.queuedMessagesPaused;\n\t\t},\n\t\t// An isolated engine can crash with what it queued; the chat then gives those messages back.\n\t\tcanBeLost: true,\n\t\tqueued: () => ({\n\t\t\tsteering: mode.session.getSteeringMessages(),\n\t\t\tfollowUp: mode.session.getFollowUpMessages(),\n\t\t}),\n\t\tprompt: (text, options) => mode.session.prompt(text, options),\n\t\tclearQueue: (options) =>\n\t\t\tclearInteractiveEngineQueue(mode.runtimeHost) ?? Promise.resolve(mode.session.clearQueue(options)),\n\t};\n}\n\n/** The messages the main editor holds while compaction runs, listed after the session's own. */\nfunction mainEditorQueue(mode: InteractiveModeBase): SteeringEditorQueue {\n\treturn {\n\t\theld: () => mode.compactionQueuedMessages,\n\t\ttakeHeld: () => {\n\t\t\tconst held = mode.compactionQueuedMessages;\n\t\t\tconst heldSendFailed = mode.compactionSendFailed;\n\t\t\tmode.compactionQueuedMessages = [];\n\t\t\tmode.compactionSendFailed = false;\n\t\t\treturn {\n\t\t\t\tmessages: held,\n\t\t\t\tputBack: () => {\n\t\t\t\t\tmode.compactionQueuedMessages = [...held, ...mode.compactionQueuedMessages];\n\t\t\t\t\t// If compaction ended meanwhile, its flush found the queue empty and nothing else will send these.\n\t\t\t\t\t// Marked as unsent, they go out in order ahead of the next submission, as a batch whose first send\n\t\t\t\t\t// failed does.\n\t\t\t\t\tmode.compactionSendFailed ||= heldSendFailed || (held.length > 0 && !mode.compactionActive);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tchanged: () => mode.updatePendingMessagesDisplay(),\n\t\trequestRender: () => mode.ui.requestRender(),\n\t};\n}\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn mainSteering(this).allQueued();\n};\n\n/**\n * Take every queued message back from the session and this editor, so the caller can restore them.\n *\n * What the session removed is its own answer, not this editor's copy of its queue. An engine child lists its queue\n * by `queue_update` events that trail it by a round trip, so a message it queued meanwhile is missing from the copy\n * and one it already took into a turn is still in it (#4257). The messages only this editor holds follow them.\n * When the session cannot be reached nothing is removed and the held messages stay queued.\n */\nInteractiveModeBase.prototype.clearAllQueues = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): Promise<{\n\tsteering: string[];\n\tfollowUp: string[];\n}> {\n\treturn mainSteering(this).clearAll(options);\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\t// While a subagent is shown, the rows above the prompt are its queue, drawn as the main chat draws its own.\n\tconst viewed = viewedSteering(this);\n\tif (viewed !== undefined) {\n\t\tconst shown = this.agentView?.viewed;\n\t\tconst rows = queuedMessageRows(\n\t\t\tviewed.allQueued(),\n\t\t\tshown?.kind === \"agent\" ? shown.port.status().delivering : undefined,\n\t\t);\n\t\tif (rows.length === 0) return;\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t\treturn;\n\t}\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.addChild(component);\n\t}\n\tconst rows = queuedMessageRows(this.getAllQueuedMessages());\n\tif (rows.length > 0) {\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): Promise<number> {\n\t// Main's prompt, also once the screen shows a subagent before the session answers.\n\tconst prompt = promptHandle(this, \"main\");\n\tconst restored = restoredQueue(\n\t\tawait this.clearAllQueues(options),\n\t\t() => options?.currentText ?? prompt.getExpandedText(),\n\t);\n\tif (restored !== undefined) prompt.setText(restored.text);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn restored?.messages.length ?? 0;\n};\n\n/** Report a restore the session could not answer; nothing was removed, so every message is still queued. */\nexport function showQueueRestoreFailure(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to restore queued messages: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst commandName = parseSlashCommand(text).name;\n\tif (extensionRunner.getCommand(commandName)) return true;\n\treturn getInteractiveEngineRemoteCommands(this.runtimeHost).some(\n\t\t(command) => command.source === \"extension\" && command.name === commandName,\n\t);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction returnHandedOffMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tconst rank = handOffOrder.get(message) ?? -1;\n\tconst queue = mode.compactionQueuedMessages;\n\tconst index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);\n\tmode.compactionQueuedMessages =\n\t\tindex === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction confirmHandOff(mode: InteractiveModeBase, message: CompactionQueuedMessage): boolean {\n\treturn mainSteering(mode).settle(message);\n}\n\n/**\n * Show a message sent while the agent works as queued at once, before the session confirms it (#4696). Delivery waits\n * on the session: in an isolated engine that is a round trip through a process whose event loop the agent's own work,\n * such as a running subagent, shares. The editor shows the message until `settleSubmission()` or a `queue_update` that\n * lists it, whichever comes first.\n */\nexport function showSubmissionAsQueued(\n\tmode: InteractiveModeBase,\n\ttext: string,\n\tlane: CompactionQueuedMessage[\"mode\"],\n): CompactionQueuedMessage {\n\treturn mainSteering(mode).showAsQueued({ text, mode: lane });\n}\n\n/**\n * Stop showing a submission once the session answered it: queued, it lists the message itself; started or handled, it\n * is no longer queued; refused, the caller gives it back to the editor and reports why.\n */\nexport function settleSubmission(mode: InteractiveModeBase, message: CompactionQueuedMessage): void {\n\tif (confirmHandOff(mode, message)) mode.ui.requestRender();\n}\n\n/**\n * The session saved a user message: a message sent while the chat showed the turn running, which the session started\n * its next turn with, is delivered from here on, so an engine crash no longer gives it back.\n */\nexport function noteSteeringSaved(mode: InteractiveModeBase, message: UserMessageWithRawText): void {\n\tconst text = mode.getUserMessageText(message);\n\tmainSteering(mode).noteSaved(message.rawText === undefined ? [text] : [text, message.rawText]);\n}\n\n/**\n * Stop showing editor copies of messages the session's queue now lists, so a confirmed message is never shown twice\n * (#4696). Only a message this update added confirms a copy, oldest copy first, so an identical message queued\n * earlier does not.\n */\nexport function reconcileQueuedSubmissions(mode: InteractiveModeBase, queue: SteeringQueueLists): void {\n\tmainSteering(mode).reconcile(queue);\n}\n\n/**\n * Hand the editor's held messages to the session before an extension command runs during compaction (#4251).\n * The session registers input as it arrives and holds it until compaction ends, so a message the command sends\n * goes out after them, in typing order. Each message stays shown here until the session confirms it took it, and\n * from then on the session lists it as queued. The session's clearQueue() returns it for Alt+Up and Ctrl+C, also\n * when the confirmation is still on its way. A message the session refuses returns to the editor queue.\n */\nexport function handOffCompactionQueue(mode: InteractiveModeBase): void {\n\tconst messages = mode.compactionQueuedMessages;\n\tif (messages.length === 0) return;\n\tmode.compactionQueuedMessages = [];\n\tmainSteering(mode).track(messages);\n\tfor (const message of messages) {\n\t\thandOffOrder.set(message, nextHandOff++);\n\t\tlet accepted = false;\n\t\tvoid mode.session\n\t\t\t.prompt(message.text, {\n\t\t\t\tstreamingBehavior: message.mode,\n\t\t\t\tpreflightResult: (success) => {\n\t\t\t\t\taccepted = success;\n\t\t\t\t\tif (success) confirmHandOff(mode, message);\n\t\t\t\t},\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (accepted || isRpcRequestAcceptedFailure(error)) {\n\t\t\t\t\tconfirmHandOff(mode, message);\n\t\t\t\t\tshowCompactionQueueError(mode, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.\n\t\t\t\tif (confirmHandOff(mode, message)) returnHandedOffMessage(mode, message, error);\n\t\t\t});\n\t}\n\tmode.updatePendingMessagesDisplay();\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonAccepted?: (disposition: PromptDisposition | undefined) => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success) onAccepted?.(disposition);\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst shownBefore = mode.userMessagesShownBySession;\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed\n\t\t\t\t? (disposition) => {\n\t\t\t\t\t\tif (disposition === \"queued\" || disposition === \"handled\")\n\t\t\t\t\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t\t\t\t\t\tif (disposition === \"started\") mode.expectStartedUserInput(message.text, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t\t// #5135: a run that repeats input the chat already shows as unsaved shows no message of its own.\n\t\tif (\n\t\t\techoed &&\n\t\t\tmode.startedDeferredUserInput === message.text &&\n\t\t\tmode.deferredRenderedUserInputs?.includes(message.text) === true\n\t\t)\n\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n\n/** `count` queued message(s), with the verb agreeing. */\nfunction queuedMessagesPhrase(count: number): string {\n\treturn count === 1 ? \"1 queued message\" : `${count} queued messages`;\n}\n\n/** The notice the main chat shows when a lost engine's queued messages come back to its editor. */\nexport function engineLossRestoredNotice(count: number): string {\n\treturn `Engine restarted; ${queuedMessagesPhrase(count)} ${count === 1 ? \"wasn't\" : \"weren't\"} sent and ${count === 1 ? \"is\" : \"are\"} back in the editor`;\n}\n\n/** What a subagent had queued, or had on its way, when the engine that runs it was lost. */\nexport interface LostSubagentQueue {\n\treadonly agent: string;\n\treadonly steering: readonly string[];\n\treadonly followUp: readonly string[];\n}\n\n/** The notice listing, in full and in order, what a subagent had queued when the engine was lost. */\nexport function engineLossSubagentNotice(queue: LostSubagentQueue): string | undefined {\n\tconst messages = [...queue.steering, ...queue.followUp];\n\tif (messages.length === 0) return undefined;\n\tconst verb = messages.length === 1 ? \"wasn't\" : \"weren't\";\n\treturn [\n\t\t`Engine restarted; ${queuedMessagesPhrase(messages.length)} to ${queue.agent} ${verb} sent:`,\n\t\t...messages,\n\t].join(\"\\n\");\n}\n\nfunction textOfUserMessage(content: unknown): string | undefined {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn content\n\t\t.flatMap((part: { type?: unknown; text?: unknown }) =>\n\t\t\tpart.type === \"text\" && typeof part.text === \"string\" ? [part.text] : [],\n\t\t)\n\t\t.join(\"\");\n}\n\n/** The user messages `messages` holds, as text. */\nfunction userMessageTexts(messages: readonly { readonly role: string; readonly content?: unknown }[]): string[] {\n\treturn messages.flatMap((message) => {\n\t\tconst text = message.role === \"user\" ? textOfUserMessage(message.content) : undefined;\n\t\treturn text === undefined ? [] : [text];\n\t});\n}\n\n/** `after` without one copy of each text of `before`: what was added. */\nfunction withoutEach(after: readonly string[], before: readonly string[]): string[] {\n\tconst remaining = new Map<string, number>();\n\tfor (const text of before) remaining.set(text, (remaining.get(text) ?? 0) + 1);\n\treturn after.filter((text) => {\n\t\tconst count = remaining.get(text) ?? 0;\n\t\tif (count === 0) return true;\n\t\tremaining.set(text, count - 1);\n\t\treturn false;\n\t});\n}\n\n/**\n * An isolated engine that is lost and replaced takes its queue with it. The messages the main chat showed as queued\n * come back to its editor, as Alt+Up would restore them, with a notice, unless the replacement's history shows the\n * lost engine delivered them. (What a shown subagent had queued is listed by `attachLostAgentQueueNotices`.) Nothing is\n * sent again. A deliberate replacement or stop changes nothing.\n */\nInteractiveModeBase.prototype.attachSteeringEngineRecovery = function (this: InteractiveModeBase): () => void {\n\tconst runtime = this.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\t/** The user messages the chat knew when the engine was lost, while its replacement is pending. */\n\tlet knownAtLoss: string[] | undefined;\n\tconst stopEnded = runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tmainSteering(this).loseTarget();\n\t\truntime.discardLostQueue();\n\t\tknownAtLoss ??= userMessageTexts(this.session.messages);\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.ui.requestRender();\n\t});\n\tconst stopRecovered = runtime.onEngineRecovered((replaced) => {\n\t\tconst known = knownAtLoss;\n\t\tknownAtLoss = undefined;\n\t\tif (known === undefined) return;\n\t\tvoid (async () => {\n\t\t\tlet delivered: string[] = [];\n\t\t\tif (replaced) {\n\t\t\t\ttry {\n\t\t\t\t\tdelivered = withoutEach(await runtime.engineUserMessages(), known);\n\t\t\t\t} catch {\n\t\t\t\t\t// The replacement could not say what it holds: give everything back, nothing is resent.\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst messages = mainSteering(this).recoverTarget(delivered);\n\t\t\tif (messages === undefined) return;\n\t\t\t// Main's prompt, whatever the screen shows by the time the replacement answers.\n\t\t\tconst prompt = promptHandle(this, \"main\");\n\t\t\tprompt.setText(combineQueuedMessagesForEditor(messages, prompt.getExpandedText()));\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.showWarning(engineLossRestoredNotice(messages.length));\n\t\t\tthis.ui.requestRender();\n\t\t})();\n\t});\n\treturn () => {\n\t\tstopEnded();\n\t\tstopRecovered();\n\t};\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AACA,OAAO,EACN,kBAAkB,EAElB,sBAAsB,GACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,GAClC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EACN,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AW,CAAC;QAC1B,WAAW,GAAG,SAAS,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,KAAK,CAAC,KAAK,IAAI,EAAE;YAChB,IAAI,SAAS,GAAa,EAAE,CAAC;YAC7B,IAAI,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC;oBACJ,SAAS,GAAG,WAAW,CAAC,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,wFAAwF;gBACzF,CAAC;YACF,CAAC;YACD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO;YACnC,gFAAgF;YAChF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;YACnF,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { PromptDisposition, UserMessageWithRawText } from \"../../core/agent-session-types.js\";\nimport {\n\tNO_QUEUED_MESSAGES,\n\ttype QueuedMessageLanes,\n\tqueuedMessagesUnderWay,\n} from \"../../core/queued-message-delivery.ts\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport {\n\tclearInteractiveEngineQueue,\n\tgetInteractiveEngineRemoteCommands,\n} from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { viewedSteering } from \"./agent-view/viewed-submit.ts\";\nimport { combineQueuedMessagesForEditor } from \"./chat-input-actions.ts\";\nimport { QueuedMessagesView, queuedMessageRows } from \"./components/queued-messages-view.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\nimport {\n\trestoredQueue,\n\ttype SteeringEditorQueue,\n\tSteeringQueueController,\n\ttype SteeringQueueLists,\n\ttype SteeringTarget,\n} from \"./steering-queue-controller.ts\";\n\n/** Typing order of messages handed to the session, so one it refuses returns to its own place. */\nconst handOffOrder = new WeakMap<CompactionQueuedMessage, number>();\nlet nextHandOff = 0;\n\n/**\n * The main chat's steering controller. Messages handed to the session that it has not confirmed yet stay shown as\n * queued until the session reports it took them; from then on the session lists them itself. They are the session's\n * from the moment they are sent, so a restore takes them from the session's own answer and never from this copy.\n */\nconst mainControllers = new WeakMap<InteractiveModeBase, SteeringQueueController>();\n\nexport function mainSteering(mode: InteractiveModeBase): SteeringQueueController {\n\tlet controller = mainControllers.get(mode);\n\tif (controller === undefined) {\n\t\tcontroller = new SteeringQueueController(mainSteeringTarget(mode), mainEditorQueue(mode));\n\t\tmainControllers.set(mode, controller);\n\t}\n\treturn controller;\n}\n\n/** The main chat's session, read at each call, so a session the chat switched to is the one steered. */\nfunction mainSteeringTarget(mode: InteractiveModeBase): SteeringTarget {\n\treturn {\n\t\tget busy() {\n\t\t\treturn mode.session.isStreaming || mode.promptTurn !== undefined;\n\t\t},\n\t\tget paused() {\n\t\t\treturn mode.session.queuedMessagesPaused;\n\t\t},\n\t\t// An isolated engine can crash with what it queued; the chat then gives those messages back.\n\t\tcanBeLost: true,\n\t\tqueued: () => ({\n\t\t\tsteering: mode.session.getSteeringMessages(),\n\t\t\tfollowUp: mode.session.getFollowUpMessages(),\n\t\t}),\n\t\tprompt: (text, options) => mode.session.prompt(text, options),\n\t\tclearQueue: (options) =>\n\t\t\tclearInteractiveEngineQueue(mode.runtimeHost) ?? Promise.resolve(mode.session.clearQueue(options)),\n\t};\n}\n\n/** The messages the main editor holds while compaction runs, listed after the session's own. */\nfunction mainEditorQueue(mode: InteractiveModeBase): SteeringEditorQueue {\n\treturn {\n\t\theld: () => mode.compactionQueuedMessages,\n\t\ttakeHeld: () => {\n\t\t\tconst held = mode.compactionQueuedMessages;\n\t\t\tconst heldSendFailed = mode.compactionSendFailed;\n\t\t\tmode.compactionQueuedMessages = [];\n\t\t\tmode.compactionSendFailed = false;\n\t\t\treturn {\n\t\t\t\tmessages: held,\n\t\t\t\tputBack: () => {\n\t\t\t\t\tmode.compactionQueuedMessages = [...held, ...mode.compactionQueuedMessages];\n\t\t\t\t\t// If compaction ended meanwhile, its flush found the queue empty and nothing else will send these.\n\t\t\t\t\t// Marked as unsent, they go out in order ahead of the next submission, as a batch whose first send\n\t\t\t\t\t// failed does.\n\t\t\t\t\tmode.compactionSendFailed ||= heldSendFailed || (held.length > 0 && !mode.compactionActive);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tchanged: () => mode.updatePendingMessagesDisplay(),\n\t\trequestRender: () => mode.ui.requestRender(),\n\t};\n}\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn mainSteering(this).allQueued();\n};\n\n/**\n * Take every queued message back from the session and this editor, so the caller can restore them.\n *\n * What the session removed is its own answer, not this editor's copy of its queue. An engine child lists its queue\n * by `queue_update` events that trail it by a round trip, so a message it queued meanwhile is missing from the copy\n * and one it already took into a turn is still in it (#4257). The messages only this editor holds follow them.\n * When the session cannot be reached nothing is removed and the held messages stay queued.\n */\nInteractiveModeBase.prototype.clearAllQueues = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): Promise<{\n\tsteering: string[];\n\tfollowUp: string[];\n}> {\n\treturn mainSteering(this).clearAll(options);\n};\n\n/**\n * The messages the main chat's session took from its queue whose own row the transcript does not show yet. Its queue\n * no longer lists them; the chat draws them as queued ahead of their lane until their `message_start` arrives. In\n * process they are read from the session with its queue; an isolated engine tells the host about them with its events.\n */\nfunction mainQueuedDeliveries(mode: InteractiveModeBase): QueuedMessageLanes {\n\tconst runtime = mode.runtimeHost;\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.queuedMessagesUnderWay()\n\t\t: queuedMessagesUnderWay(mode.session);\n}\n\n/** The messages being delivered that the main chat's rows drew when they were last built. */\nconst drawnDeliveries = new WeakMap<InteractiveModeBase, QueuedMessageLanes>();\n\n/**\n * Build the main chat's rows again when a message they draw as being delivered is no longer delivered, without an\n * event that builds them: a delivery that ended without its `message_start` (a hook failed, or the session already\n * shows the input). Its row goes with the next event the session sends. A delivery that begins needs nothing here: the\n * rows drawn before it still list it as queued, and the `queue_update` it brings builds them again.\n */\nexport function redrawMainQueuedDeliveries(mode: InteractiveModeBase): void {\n\tconst drawn = drawnDeliveries.get(mode);\n\tif (drawn === undefined || drawn === NO_QUEUED_MESSAGES) return;\n\t// While a subagent is shown, the rows are its queue.\n\tif (mode.agentView?.viewed?.kind === \"agent\") return;\n\tif (drawn === mainQueuedDeliveries(mode)) return;\n\tmode.updatePendingMessagesDisplay();\n\tmode.ui.requestRender();\n}\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\t// While a subagent is shown, the rows above the prompt are its queue, drawn as the main chat draws its own.\n\tconst viewed = viewedSteering(this);\n\tif (viewed !== undefined) {\n\t\t// The main chat's rows are not drawn meanwhile: keep none of their texts.\n\t\tdrawnDeliveries.delete(this);\n\t\tconst shown = this.agentView?.viewed;\n\t\tconst rows = queuedMessageRows(\n\t\t\tviewed.allQueued(),\n\t\t\tshown?.kind === \"agent\" ? shown.port.status().delivering : undefined,\n\t\t);\n\t\tif (rows.length === 0) return;\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t\treturn;\n\t}\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.addChild(component);\n\t}\n\t// Drawing only: Alt+Up, Esc and engine recovery use the session's own queue, which no longer lists these.\n\tconst delivering = mainQueuedDeliveries(this);\n\tif (delivering === NO_QUEUED_MESSAGES) drawnDeliveries.delete(this);\n\telse drawnDeliveries.set(this, delivering);\n\tconst rows = queuedMessageRows(this.getAllQueuedMessages(), delivering);\n\tif (rows.length > 0) {\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): Promise<number> {\n\t// Main's prompt, also once the screen shows a subagent before the session answers.\n\tconst prompt = promptHandle(this, \"main\");\n\tconst restored = restoredQueue(\n\t\tawait this.clearAllQueues(options),\n\t\t() => options?.currentText ?? prompt.getExpandedText(),\n\t);\n\tif (restored !== undefined) prompt.setText(restored.text);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn restored?.messages.length ?? 0;\n};\n\n/** Report a restore the session could not answer; nothing was removed, so every message is still queued. */\nexport function showQueueRestoreFailure(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to restore queued messages: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst commandName = parseSlashCommand(text).name;\n\tif (extensionRunner.getCommand(commandName)) return true;\n\treturn getInteractiveEngineRemoteCommands(this.runtimeHost).some(\n\t\t(command) => command.source === \"extension\" && command.name === commandName,\n\t);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction returnHandedOffMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tconst rank = handOffOrder.get(message) ?? -1;\n\tconst queue = mode.compactionQueuedMessages;\n\tconst index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);\n\tmode.compactionQueuedMessages =\n\t\tindex === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction confirmHandOff(mode: InteractiveModeBase, message: CompactionQueuedMessage): boolean {\n\treturn mainSteering(mode).settle(message);\n}\n\n/**\n * Show a message sent while the agent works as queued at once, before the session confirms it (#4696). Delivery waits\n * on the session: in an isolated engine that is a round trip through a process whose event loop the agent's own work,\n * such as a running subagent, shares. The editor shows the message until `settleSubmission()` or a `queue_update` that\n * lists it, whichever comes first.\n */\nexport function showSubmissionAsQueued(\n\tmode: InteractiveModeBase,\n\ttext: string,\n\tlane: CompactionQueuedMessage[\"mode\"],\n): CompactionQueuedMessage {\n\treturn mainSteering(mode).showAsQueued({ text, mode: lane });\n}\n\n/**\n * Stop showing a submission once the session answered it: queued, it lists the message itself; started or handled, it\n * is no longer queued; refused, the caller gives it back to the editor and reports why.\n */\nexport function settleSubmission(mode: InteractiveModeBase, message: CompactionQueuedMessage): void {\n\tif (confirmHandOff(mode, message)) mode.ui.requestRender();\n}\n\n/**\n * The session saved a user message: a message sent while the chat showed the turn running, which the session started\n * its next turn with, is delivered from here on, so an engine crash no longer gives it back.\n */\nexport function noteSteeringSaved(mode: InteractiveModeBase, message: UserMessageWithRawText): void {\n\tconst text = mode.getUserMessageText(message);\n\tmainSteering(mode).noteSaved(message.rawText === undefined ? [text] : [text, message.rawText]);\n}\n\n/**\n * Stop showing editor copies of messages the session's queue now lists, so a confirmed message is never shown twice\n * (#4696). Only a message this update added confirms a copy, oldest copy first, so an identical message queued\n * earlier does not.\n */\nexport function reconcileQueuedSubmissions(mode: InteractiveModeBase, queue: SteeringQueueLists): void {\n\tmainSteering(mode).reconcile(queue);\n}\n\n/**\n * Hand the editor's held messages to the session before an extension command runs during compaction (#4251).\n * The session registers input as it arrives and holds it until compaction ends, so a message the command sends\n * goes out after them, in typing order. Each message stays shown here until the session confirms it took it, and\n * from then on the session lists it as queued. The session's clearQueue() returns it for Alt+Up and Ctrl+C, also\n * when the confirmation is still on its way. A message the session refuses returns to the editor queue.\n */\nexport function handOffCompactionQueue(mode: InteractiveModeBase): void {\n\tconst messages = mode.compactionQueuedMessages;\n\tif (messages.length === 0) return;\n\tmode.compactionQueuedMessages = [];\n\tmainSteering(mode).track(messages);\n\tfor (const message of messages) {\n\t\thandOffOrder.set(message, nextHandOff++);\n\t\tlet accepted = false;\n\t\tvoid mode.session\n\t\t\t.prompt(message.text, {\n\t\t\t\tstreamingBehavior: message.mode,\n\t\t\t\tpreflightResult: (success) => {\n\t\t\t\t\taccepted = success;\n\t\t\t\t\tif (success) confirmHandOff(mode, message);\n\t\t\t\t},\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (accepted || isRpcRequestAcceptedFailure(error)) {\n\t\t\t\t\tconfirmHandOff(mode, message);\n\t\t\t\t\tshowCompactionQueueError(mode, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.\n\t\t\t\tif (confirmHandOff(mode, message)) returnHandedOffMessage(mode, message, error);\n\t\t\t});\n\t}\n\tmode.updatePendingMessagesDisplay();\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonAccepted?: (disposition: PromptDisposition | undefined) => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success) onAccepted?.(disposition);\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst shownBefore = mode.userMessagesShownBySession;\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed\n\t\t\t\t? (disposition) => {\n\t\t\t\t\t\tif (disposition === \"queued\" || disposition === \"handled\")\n\t\t\t\t\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t\t\t\t\t\tif (disposition === \"started\") mode.expectStartedUserInput(message.text, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t\t// #5135: a run that repeats input the chat already shows as unsaved shows no message of its own.\n\t\tif (\n\t\t\techoed &&\n\t\t\tmode.startedDeferredUserInput === message.text &&\n\t\t\tmode.deferredRenderedUserInputs?.includes(message.text) === true\n\t\t)\n\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n\n/** `count` queued message(s), with the verb agreeing. */\nfunction queuedMessagesPhrase(count: number): string {\n\treturn count === 1 ? \"1 queued message\" : `${count} queued messages`;\n}\n\n/** The notice the main chat shows when a lost engine's queued messages come back to its editor. */\nexport function engineLossRestoredNotice(count: number): string {\n\treturn `Engine restarted; ${queuedMessagesPhrase(count)} ${count === 1 ? \"wasn't\" : \"weren't\"} sent and ${count === 1 ? \"is\" : \"are\"} back in the editor`;\n}\n\n/** What a subagent had queued, or had on its way, when the engine that runs it was lost. */\nexport interface LostSubagentQueue {\n\treadonly agent: string;\n\treadonly steering: readonly string[];\n\treadonly followUp: readonly string[];\n}\n\n/** The notice listing, in full and in order, what a subagent had queued when the engine was lost. */\nexport function engineLossSubagentNotice(queue: LostSubagentQueue): string | undefined {\n\tconst messages = [...queue.steering, ...queue.followUp];\n\tif (messages.length === 0) return undefined;\n\tconst verb = messages.length === 1 ? \"wasn't\" : \"weren't\";\n\treturn [\n\t\t`Engine restarted; ${queuedMessagesPhrase(messages.length)} to ${queue.agent} ${verb} sent:`,\n\t\t...messages,\n\t].join(\"\\n\");\n}\n\nfunction textOfUserMessage(content: unknown): string | undefined {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn content\n\t\t.flatMap((part: { type?: unknown; text?: unknown }) =>\n\t\t\tpart.type === \"text\" && typeof part.text === \"string\" ? [part.text] : [],\n\t\t)\n\t\t.join(\"\");\n}\n\n/** The user messages `messages` holds, as text. */\nfunction userMessageTexts(messages: readonly { readonly role: string; readonly content?: unknown }[]): string[] {\n\treturn messages.flatMap((message) => {\n\t\tconst text = message.role === \"user\" ? textOfUserMessage(message.content) : undefined;\n\t\treturn text === undefined ? [] : [text];\n\t});\n}\n\n/** `after` without one copy of each text of `before`: what was added. */\nfunction withoutEach(after: readonly string[], before: readonly string[]): string[] {\n\tconst remaining = new Map<string, number>();\n\tfor (const text of before) remaining.set(text, (remaining.get(text) ?? 0) + 1);\n\treturn after.filter((text) => {\n\t\tconst count = remaining.get(text) ?? 0;\n\t\tif (count === 0) return true;\n\t\tremaining.set(text, count - 1);\n\t\treturn false;\n\t});\n}\n\n/**\n * An isolated engine that is lost and replaced takes its queue with it. The messages the main chat showed as queued\n * come back to its editor, as Alt+Up would restore them, with a notice, unless the replacement's history shows the\n * lost engine delivered them. (What a shown subagent had queued is listed by `attachLostAgentQueueNotices`.) Nothing is\n * sent again. A deliberate replacement or stop changes nothing.\n */\nInteractiveModeBase.prototype.attachSteeringEngineRecovery = function (this: InteractiveModeBase): () => void {\n\tconst runtime = this.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\t/** The user messages the chat knew when the engine was lost, while its replacement is pending. */\n\tlet knownAtLoss: string[] | undefined;\n\tconst stopEnded = runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tmainSteering(this).loseTarget();\n\t\truntime.discardLostQueue();\n\t\tknownAtLoss ??= userMessageTexts(this.session.messages);\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.ui.requestRender();\n\t});\n\t// The engine was lost or retired its session: what it was delivering never shows here.\n\tconst stopForgotten = runtime.onQueuedDeliveriesForgotten(() => {\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.ui.requestRender();\n\t});\n\tconst stopRecovered = runtime.onEngineRecovered((replaced) => {\n\t\tconst known = knownAtLoss;\n\t\tknownAtLoss = undefined;\n\t\tif (known === undefined) return;\n\t\tvoid (async () => {\n\t\t\tlet delivered: string[] = [];\n\t\t\tif (replaced) {\n\t\t\t\ttry {\n\t\t\t\t\tdelivered = withoutEach(await runtime.engineUserMessages(), known);\n\t\t\t\t} catch {\n\t\t\t\t\t// The replacement could not say what it holds: give everything back, nothing is resent.\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst messages = mainSteering(this).recoverTarget(delivered);\n\t\t\tif (messages === undefined) return;\n\t\t\t// Main's prompt, whatever the screen shows by the time the replacement answers.\n\t\t\tconst prompt = promptHandle(this, \"main\");\n\t\t\tprompt.setText(combineQueuedMessagesForEditor(messages, prompt.getExpandedText()));\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.showWarning(engineLossRestoredNotice(messages.length));\n\t\t\tthis.ui.requestRender();\n\t\t})();\n\t});\n\treturn () => {\n\t\tstopEnded();\n\t\tstopForgotten();\n\t\tstopRecovered();\n\t};\n};\n"]}
|
|
@@ -13,6 +13,7 @@ import { clearChatForRerender } from "./interactive-render-chat.js";
|
|
|
13
13
|
import { onPreliminaryCatalogWithdrawn } from "./interactive-startup-trust.js";
|
|
14
14
|
import { setSummaryCancellable } from "./interactive-summarization-retry-events.js";
|
|
15
15
|
import { resolveResumeTarget } from "./resume-catalog.js";
|
|
16
|
+
import { screenHoldOf } from "./screen-hold.js";
|
|
16
17
|
import { showSessionNotices } from "./session-notices.js";
|
|
17
18
|
InteractiveModeBase.prototype.handleCloneCommand = async function () {
|
|
18
19
|
// The prompt the command was typed in: a subagent's, when the clone was asked for from its view.
|
|
@@ -90,6 +91,11 @@ InteractiveModeBase.prototype.showTrustSelector = async function () {
|
|
|
90
91
|
},
|
|
91
92
|
handleMouse: (event) => selector?.handleMouse(event),
|
|
92
93
|
};
|
|
94
|
+
// Until the saved decision is read the view draws nothing: the prompt's slot keeps its rows meanwhile. A key
|
|
95
|
+
// pressed since the view opened shows it live, as a key does with any held part of the screen.
|
|
96
|
+
const screen = screenHoldOf(this);
|
|
97
|
+
const keysAtOpen = screen.keyPresses;
|
|
98
|
+
awaitFirstContent(view, () => selector === undefined && screen.keyPresses === keysAtOpen);
|
|
93
99
|
trustData.then(([savedDecision, trustPath]) => {
|
|
94
100
|
if (closed)
|
|
95
101
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-session-routing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACN,QAAQ,EAGR,wBAAwB,EACxB,sCAAsC,EACtC,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,MAAM,EACN,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,GACL,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,uBAAuB,EAAE,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import { dirname } from \"node:path\";\nimport type { Focusable } from \"@bastani/atomic-tui\";\nimport { isResumeFailure } from \"../../core/resume/failure.ts\";\nimport type { SessionInfo } from \"../../core/session-manager.ts\";\nimport { worktreeRestoreNotices } from \"../../core/session-worktree-snapshots.ts\";\nimport { canonicalizePathAsync } from \"../../utils/paths.ts\";\nimport { withHostProjectTrustPrompt } from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { mountIdleStatus } from \"./components/idle-status.ts\";\nimport { awaitFirstContent } from \"./components/prompt-slot.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\tAPP_NAME,\n\ttype Component,\n\ttype ExtensionCommandContext,\n\tgetProjectTrustPathAsync,\n\thasTrustRequiringProjectResourcesAsync,\n\tkeyTextHint,\n\tLoader,\n\tMissingSessionCwdError,\n\tProjectTrustStore,\n\tSessionManager,\n\tSessionSelectorComponent,\n\tSpacer,\n\tTreeSelectorComponent,\n\tTrustSelectorComponent,\n\ttheme,\n} from \"./interactive-mode-deps.ts\";\nimport type { MissingCwdForkSource } from \"./interactive-mode-surface.ts\";\nimport { showQueueRestoreFailure } from \"./interactive-queueing.ts\";\nimport { clearChatForRerender } from \"./interactive-render-chat.ts\";\nimport { onPreliminaryCatalogWithdrawn } from \"./interactive-startup-trust.ts\";\nimport { setSummaryCancellable } from \"./interactive-summarization-retry-events.ts\";\nimport { resolveResumeTarget } from \"./resume-catalog.ts\";\nimport { showSessionNotices } from \"./session-notices.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function (this: InteractiveModeBase): Promise<void> {\n\t// The prompt the command was typed in: a subagent's, when the clone was asked for from its view.\n\tconst prompt = promptHandle(this, \"viewed\");\n\tawait this.ensureDeferredStartupComplete();\n\tconst leafId = this.sessionManager.getLeafId();\n\tif (!leafId) {\n\t\tthis.showStatus(\"Nothing to clone yet\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n\t\tif (result.cancelled) {\n\t\t\tthis.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.renderCurrentSessionState();\n\t\tprompt.setText(\"\");\n\t\tthis.showStatus(\"Cloned to new session\");\n\t} catch (error: unknown) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = async function (\n\tthis: InteractiveModeBase,\n): Promise<boolean> {\n\tconst cwd = this.sessionManager.getCwd();\n\tif (this.autoTrustOnReloadCwd !== cwd) {\n\t\treturn false;\n\t}\n\tif (!this.settingsManager.isProjectTrusted() || !(await hasTrustRequiringProjectResourcesAsync(cwd))) {\n\t\treturn false;\n\t}\n\n\tconst trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n\ttry {\n\t\tif ((await trustStore.getAsync(cwd)) !== null) {\n\t\t\tthis.autoTrustOnReloadCwd = undefined;\n\t\t\treturn false;\n\t\t}\n\t\tawait trustStore.setAsync(cwd, true);\n\t\tthis.autoTrustOnReloadCwd = undefined;\n\t\treturn true;\n\t} catch (error) {\n\t\tthis.showWarning(\n\t\t\t`Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t\treturn false;\n\t}\n};\n\nInteractiveModeBase.prototype.showTrustSelector = async function (this: InteractiveModeBase): Promise<void> {\n\tconst cwd = this.sessionManager.getCwd();\n\tconst trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n\tconst trustData = Promise.all([trustStore.getEntryAsync(cwd), getProjectTrustPathAsync(cwd)]);\n\tawait withHostProjectTrustPrompt(\n\t\tthis.runtimeHost,\n\t\t\"select\",\n\t\t\"Project trust\",\n\t\t() =>\n\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\tthis.showSelector((done) => {\n\t\t\t\t\tconst heldInput: string[] = [];\n\t\t\t\t\tlet selector: TrustSelectorComponent | undefined;\n\t\t\t\t\tlet focused = false;\n\t\t\t\t\tlet closed = false;\n\t\t\t\t\tconst view: Component & Focusable = {\n\t\t\t\t\t\tcapturesViewportInput: true,\n\t\t\t\t\t\tget focused() {\n\t\t\t\t\t\t\treturn focused;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tset focused(value: boolean) {\n\t\t\t\t\t\t\tfocused = value;\n\t\t\t\t\t\t\tif (selector) selector.focused = value;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trender: (width) => selector?.render(width) ?? [],\n\t\t\t\t\t\tinvalidate: () => selector?.invalidate(),\n\t\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t\tif (selector) selector.handleInput(data);\n\t\t\t\t\t\t\telse heldInput.push(data);\n\t\t\t\t\t\t},\n\t\t\t\t\t\thandleMouse: (event) => selector?.handleMouse(event),\n\t\t\t\t\t};\n\t\t\t\t\ttrustData.then(\n\t\t\t\t\t\t([savedDecision, trustPath]) => {\n\t\t\t\t\t\t\tif (closed) return;\n\t\t\t\t\t\t\tconst shown = new TrustSelectorComponent({\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\ttrustPath,\n\t\t\t\t\t\t\t\tsavedDecision,\n\t\t\t\t\t\t\t\tprojectTrusted: this.settingsManager.isProjectTrusted(),\n\t\t\t\t\t\t\t\tonSelect: (selection) => {\n\t\t\t\t\t\t\t\t\ttrustStore.setManyAsync(selection.updates).then(\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\t\t\t\t\tthis.showStatus(\n\t\t\t\t\t\t\t\t\t\t\t\t`Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\t\t\t\t\tshown.selector.retrySelection();\n\t\t\t\t\t\t\t\t\t\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonCancel: () => {\n\t\t\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tshown.focused = focused;\n\t\t\t\t\t\t\tselector = shown;\n\t\t\t\t\t\t\tfor (const data of heldInput.splice(0)) {\n\t\t\t\t\t\t\t\tif (closed) break;\n\t\t\t\t\t\t\t\tshown.handleInput(data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcomponent: view,\n\t\t\t\t\t\tfocus: view,\n\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\tclosed = true;\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}),\n\t).catch((error: Error) => this.showError(error.message));\n};\n\nInteractiveModeBase.prototype.showTreeSelector = async function (\n\tthis: InteractiveModeBase,\n\tinitialSelectedId?: string,\n): Promise<void> {\n\tawait this.ensureDeferredStartupComplete();\n\t// The navigation's text is for main's prompt, also when the tree was opened from a subagent's view.\n\tconst mainPrompt = promptHandle(this, \"main\");\n\tconst archived =\n\t\tthis.sessionManager.hasFullHistory?.() === false\n\t\t\t? await (await import(\"./components/stored-tree-view.js\")).StoredTreeView.open(this.sessionManager)\n\t\t\t: undefined;\n\tconst tree = archived?.tree ?? this.sessionManager.getTree();\n\tconst realLeafId = archived ? archived.leaf : this.sessionManager.getLeafId();\n\tif (archived) {\n\t\tarchived.view.onUpdate = () => this.ui.requestRender();\n\t\tarchived.view.onError = (error) => this.showError(error.message);\n\t}\n\tconst initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n\tif (tree.length === 0) {\n\t\tthis.showStatus(\"No entries in session\");\n\t\treturn;\n\t}\n\n\tthis.showSelector((done) => {\n\t\tconst selector = new TreeSelectorComponent(\n\t\t\ttree,\n\t\t\trealLeafId,\n\t\t\tthis.ui.terminal.rows,\n\t\t\tasync (entryId) => {\n\t\t\t\t// Compare against the live leaf: a response that was streaming while the\n\t\t\t\t// selector was open may have advanced it past the captured value.\n\t\t\t\tif (entryId === this.sessionManager.getLeafId()) {\n\t\t\t\t\tdone();\n\t\t\t\t\tthis.showStatus(\"Already at this point\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ask about summarization\n\t\t\t\tdone(); // Close selector first\n\n\t\t\t\t// Loop until user makes a complete choice or cancels to tree\n\t\t\t\tlet wantsSummary = false;\n\t\t\t\tlet customInstructions: string | undefined;\n\n\t\t\t\t// Check if we should skip the prompt (user preference to always default to no summary)\n\t\t\t\tif (!this.settingsManager.getBranchSummarySkipPrompt()) {\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst summaryChoice = await this.showExtensionSelector(\"Summarize branch?\", [\n\t\t\t\t\t\t\t\"No summary\",\n\t\t\t\t\t\t\t\"Summarize\",\n\t\t\t\t\t\t\t\"Summarize with custom prompt\",\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (summaryChoice === undefined) {\n\t\t\t\t\t\t\t// User pressed escape - re-show tree selector with same selection\n\t\t\t\t\t\t\tthis.showTreeSelector(entryId);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\twantsSummary = summaryChoice !== \"No summary\";\n\n\t\t\t\t\t\tif (summaryChoice === \"Summarize with custom prompt\") {\n\t\t\t\t\t\t\tcustomInstructions = await this.showExtensionEditor(\"Custom summarization instructions\");\n\t\t\t\t\t\t\tif (customInstructions === undefined) {\n\t\t\t\t\t\t\t\t// User cancelled - loop back to summary selector\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// User made a complete choice\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.session.isStreaming) {\n\t\t\t\t\t// The clear goes out before the abort. The editor fills when the session answers, so a clear that\n\t\t\t\t\t// stalls or fails cannot hold up the abort.\n\t\t\t\t\tvoid this.restoreQueuedMessagesToEditor().catch((error: unknown) =>\n\t\t\t\t\t\tshowQueueRestoreFailure(this, error),\n\t\t\t\t\t);\n\t\t\t\t\tawait this.session.abort();\n\t\t\t\t}\n\t\t\t\tif (this.session.isCompacting) {\n\t\t\t\t\tthis.showError(\n\t\t\t\t\t\t\"Wait for the current compaction or tree navigation to finish before navigating the session tree.\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Set up escape handler and loader if summarizing\n\t\t\t\tlet summaryLoader: Loader | undefined;\n\t\t\t\tconst originalOnEscape = this.defaultEditor.onEscape;\n\n\t\t\t\tif (wantsSummary) {\n\t\t\t\t\tthis.defaultEditor.onEscape = () => {\n\t\t\t\t\t\tthis.session.abortBranchSummary();\n\t\t\t\t\t};\n\t\t\t\t\tsetSummaryCancellable(this, true);\n\t\t\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\t\t\tsummaryLoader = new Loader(\n\t\t\t\t\t\tthis.ui,\n\t\t\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t`Summarizing branch... (${keyTextHint(\"app.interrupt\", \"Cancel\")})`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.statusContainer.addChild(summaryLoader);\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t\t\t\tconst result = await this.session.navigateTree(entryId, {\n\t\t\t\t\t\tsummarize: wantsSummary,\n\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (result.aborted) {\n\t\t\t\t\t\t// Summarization aborted - re-show tree selector with same selection\n\t\t\t\t\t\tthis.showStatus(\"Branch summarization cancelled\");\n\t\t\t\t\t\tthis.showTreeSelector(entryId);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tthis.showStatus(\"Navigation cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update UI\n\t\t\t\t\tclearChatForRerender(this);\n\t\t\t\t\tthis.renderInitialMessages();\n\t\t\t\t\tif (result.editorText && !mainPrompt.getText().trim()) {\n\t\t\t\t\t\tmainPrompt.setText(result.editorText);\n\t\t\t\t\t}\n\t\t\t\t\tthis.showStatus(\"Navigated to selected point\");\n\t\t\t\t\tvoid this.flushCompactionQueue({ willRetry: false });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t} finally {\n\t\t\t\t\tif (summaryLoader) {\n\t\t\t\t\t\tsummaryLoader.stop();\n\t\t\t\t\t\tthis.statusContainer.clear();\n\t\t\t\t\t\tmountIdleStatus(this.statusContainer, this.settingsManager.getClearOnShrink());\n\t\t\t\t\t}\n\t\t\t\t\tsetSummaryCancellable(this, false);\n\t\t\t\t\tthis.defaultEditor.onEscape = originalOnEscape;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tasync (entryId, label) => {\n\t\t\t\tawait this.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t\tinitialFilterMode,\n\t\t\tarchived?.view,\n\t\t);\n\t\tselector.onLabelError = (error) => this.showError(error.message);\n\t\tselector.onLabelUpdate = () => this.ui.requestRender();\n\t\tconst dispose = onPreliminaryCatalogWithdrawn(this, () => {\n\t\t\tselector.getTreeList().updateInitialFilter(this.settingsManager.getTreeFilterMode());\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\treturn {\n\t\t\tcomponent: selector,\n\t\t\tfocus: selector,\n\t\t\tdispose: () => {\n\t\t\t\tarchived?.view.dispose();\n\t\t\t\tdispose?.();\n\t\t\t},\n\t\t};\n\t});\n};\n\nInteractiveModeBase.prototype.showSessionSelector = function (this: InteractiveModeBase): void {\n\tthis.showSelector((done) => {\n\t\tconst selector = new SessionSelectorComponent(\n\t\t\t(onProgress) =>\n\t\t\t\tSessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionStore(), onProgress),\n\t\t\t(onProgress) => SessionManager.listAll(this.sessionManager.getSessionStore(), onProgress),\n\t\t\tasync (selected) => {\n\t\t\t\tdone();\n\t\t\t\tawait resumeCatalogSelection(this, selected);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tvoid this.shutdown();\n\t\t\t},\n\t\t\t() => this.ui.requestRender(),\n\t\t\t{\n\t\t\t\tvariant: \"mixed\",\n\t\t\t\ttitle: \"Resume\",\n\t\t\t\tdeleteSession:\n\t\t\t\t\tthis.sessionManager.getSessionStore().descriptor.adapter === \"jsonl\"\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: (id) => this.sessionManager.deleteSession(id),\n\t\t\t\trenameSession: async (selected, nextName) => {\n\t\t\t\t\tconst next = (nextName ?? \"\").trim();\n\t\t\t\t\tif (!next) return;\n\t\t\t\t\tconst store = this.sessionManager.getSessionStore();\n\t\t\t\t\tconst directory = store.descriptor.adapter === \"jsonl\" ? dirname(selected.path) : undefined;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselected.id === this.sessionManager.getSessionId() &&\n\t\t\t\t\t\t(directory === undefined ||\n\t\t\t\t\t\t\t(await canonicalizePathAsync(directory)) ===\n\t\t\t\t\t\t\t\t(await canonicalizePathAsync(this.sessionManager.getSessionDir())))\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.session.setSessionName(next);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst mgr = await this.sessionManager.openSessionById(selected.id, undefined, directory, {\n\t\t\t\t\t\t\thistory: \"tail\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait mgr.appendSessionInfo(next);\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tif (mgr.getSessionStore() !== store) await mgr.getSessionStore().close();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshowRenameHint: true,\n\t\t\t\tkeybindings: this.keybindings,\n\t\t\t},\n\n\t\t\t{ id: this.sessionManager.getSessionId(), directory: this.sessionManager.getSessionDir() },\n\t\t);\n\t\tawaitFirstContent(selector, () => selector.awaitingFirstContent());\n\t\treturn {\n\t\t\tcomponent: selector,\n\t\t\tfocus: selector,\n\t\t\tdispose: () => selector.dispose(),\n\t\t};\n\t});\n};\n\nasync function resumeCatalogSelection(mode: InteractiveModeBase, selected: SessionInfo): Promise<void> {\n\tconst directory =\n\t\tmode.sessionManager.getSessionStore().descriptor.adapter === \"jsonl\" ? dirname(selected.path) : undefined;\n\tawait mode.handleResumeSession(selected.id, undefined, directory);\n}\n\nInteractiveModeBase.prototype.handleResumeTarget = async function (\n\tthis: InteractiveModeBase,\n\ttarget: string,\n): Promise<void> {\n\tif (/\\s/.test(target) || target.startsWith(\"-\")) {\n\t\tthis.showError(\"Usage: /resume [session-id].\");\n\t\treturn;\n\t}\n\ttry {\n\t\tconst sessions = await SessionManager.listAll(this.sessionManager.getSessionStore());\n\t\tconst resolution = resolveResumeTarget(target, sessions);\n\t\tif (resolution.kind === \"session\") {\n\t\t\tawait resumeCatalogSelection(this, resolution.session);\n\t\t} else if (resolution.kind === \"ambiguous\") {\n\t\t\tthis.showError(\n\t\t\t\t`Resume id \"${target}\" is ambiguous: ${resolution.matches.map((entry) => `session ${entry.id}`).join(\", \")}. Use /resume to choose an entry, or provide a unique full id.`,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.showError(\n\t\t\t\t`No session matches \"${target}\". Use /resume to choose an entry, or provide a full id or unique 8-character hexadecimal prefix.`,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.handleResumeSession = async function (\n\tthis: InteractiveModeBase,\n\tsessionId: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n\tsessionDirectory?: string,\n): Promise<{ cancelled: boolean }> {\n\tawait this.ensureDeferredStartupComplete();\n\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\tmountIdleStatus(this.statusContainer, this.settingsManager.getClearOnShrink());\n\tconst resumeStartedAt = new Date().toISOString();\n\ttry {\n\t\tconst result = await this.runtimeHost.switchSession(sessionId, {\n\t\t\twithSession: options?.withSession,\n\t\t\tsessionDirectory,\n\t\t\tprojectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n\t\t\thistory: \"tail\",\n\t\t});\n\t\tif (result.cancelled) {\n\t\t\treturn result;\n\t\t}\n\t\tthis.renderCurrentSessionState();\n\t\tif (this.firstRunNoticeVisible) {\n\t\t\tthis.clearFirstRunOnboardingUi();\n\t\t}\n\t\tthis.showStatus(\"Resumed session\");\n\t\tshowSessionNotices(this, [\n\t\t\t...worktreeRestoreNotices(this.sessionManager, resumeStartedAt),\n\t\t\t...this.runtimeHost.takeResumeNotices(),\n\t\t]);\n\t\tthis.startSessionRecovery(\"resume\");\n\t\treturn result;\n\t} catch (error: unknown) {\n\t\tif (isResumeFailure(error)) {\n\t\t\tthis.showError(error.message);\n\t\t\treturn { cancelled: true };\n\t\t}\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tswitch (await this.promptForMissingSessionCwd(error)) {\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst result = await this.runtimeHost.switchSession(sessionId, {\n\t\t\t\t\t\tcwdOverride: error.issue.fallbackCwd,\n\t\t\t\t\t\tsessionDirectory,\n\t\t\t\t\t\twithSession: options?.withSession,\n\t\t\t\t\t\tprojectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n\t\t\t\t\t\thistory: \"tail\",\n\t\t\t\t\t});\n\t\t\t\t\tif (!result.cancelled) finishMissingCwdResume(this, `Resumed session in ${error.issue.fallbackCwd}`);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tcase \"fork\":\n\t\t\t\t\treturn this.switchToForkedSession({ sessionId, sessionDirectory }, error.issue.fallbackCwd, options);\n\t\t\t\tcase undefined:\n\t\t\t\t\tthis.showStatus(\"Resume cancelled\");\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t}\n\t\t}\n\t\treturn this.handleFatalRuntimeError(\"Failed to resume session\", error);\n\t}\n};\n\nfunction finishMissingCwdResume(mode: InteractiveModeBase, status: string): void {\n\tmode.renderCurrentSessionState();\n\tif (mode.firstRunNoticeVisible) {\n\t\tmode.clearFirstRunOnboardingUi();\n\t}\n\tmode.showStatus(status);\n\tshowSessionNotices(mode, mode.runtimeHost.takeResumeNotices());\n\tmode.startSessionRecovery(\"resume\");\n}\n\nasync function forkIntoActiveStore(\n\tmode: InteractiveModeBase,\n\tsource: MissingCwdForkSource,\n\tcwd: string,\n): Promise<SessionManager> {\n\tconst store = mode.sessionManager.getSessionStore();\n\tif (\"exportPath\" in source) return SessionManager.forkFrom(source.exportPath, cwd, store);\n\tconst stored = await mode.sessionManager.openSessionById(source.sessionId, undefined, source.sessionDirectory);\n\ttry {\n\t\treturn await stored.forkTo(cwd, store);\n\t} finally {\n\t\tif (stored.getSessionStore() !== store) await stored.getSessionStore().close();\n\t}\n}\n\n/**\n * Fork a session whose stored cwd is gone into `cwd`, in the store the current session lives in, and switch to the\n * fork. An extension that cancels the switch leaves no copy behind.\n */\nInteractiveModeBase.prototype.switchToForkedSession = async function (\n\tthis: InteractiveModeBase,\n\tsource: MissingCwdForkSource,\n\tcwd: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n): Promise<{ cancelled: boolean }> {\n\tconst forkId = (await forkIntoActiveStore(this, source, cwd)).getSessionId();\n\tconst result = await this.runtimeHost.switchSession(forkId, {\n\t\twithSession: options?.withSession,\n\t\tprojectTrustContextFactory: (forkCwd) => this.createProjectTrustContext(forkCwd),\n\t\thistory: \"tail\",\n\t});\n\tif (result.cancelled) {\n\t\tawait this.sessionManager.deleteSession(forkId);\n\t\treturn result;\n\t}\n\tfinishMissingCwdResume(this, `Forked into new session ${forkId} in ${cwd}`);\n\treturn result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-session-routing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACN,QAAQ,EAGR,wBAAwB,EACxB,sCAAsC,EACtC,WAAW,EACX,MAAM,EACN,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EAC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EAAE,WAAW;QACjC,0BAA0B,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC;QAChF,OAAO,EAAE,MAAM;KACf,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC;IACf,CAAC;IACD,sBAAsB,CAAC,IAAI,EAAE,2BAA2B,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { dirname } from \"node:path\";\nimport type { Focusable } from \"@bastani/atomic-tui\";\nimport { isResumeFailure } from \"../../core/resume/failure.ts\";\nimport type { SessionInfo } from \"../../core/session-manager.ts\";\nimport { worktreeRestoreNotices } from \"../../core/session-worktree-snapshots.ts\";\nimport { canonicalizePathAsync } from \"../../utils/paths.ts\";\nimport { withHostProjectTrustPrompt } from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { mountIdleStatus } from \"./components/idle-status.ts\";\nimport { awaitFirstContent } from \"./components/prompt-slot.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\tAPP_NAME,\n\ttype Component,\n\ttype ExtensionCommandContext,\n\tgetProjectTrustPathAsync,\n\thasTrustRequiringProjectResourcesAsync,\n\tkeyTextHint,\n\tLoader,\n\tMissingSessionCwdError,\n\tProjectTrustStore,\n\tSessionManager,\n\tSessionSelectorComponent,\n\tSpacer,\n\tTreeSelectorComponent,\n\tTrustSelectorComponent,\n\ttheme,\n} from \"./interactive-mode-deps.ts\";\nimport type { MissingCwdForkSource } from \"./interactive-mode-surface.ts\";\nimport { showQueueRestoreFailure } from \"./interactive-queueing.ts\";\nimport { clearChatForRerender } from \"./interactive-render-chat.ts\";\nimport { onPreliminaryCatalogWithdrawn } from \"./interactive-startup-trust.ts\";\nimport { setSummaryCancellable } from \"./interactive-summarization-retry-events.ts\";\nimport { resolveResumeTarget } from \"./resume-catalog.ts\";\nimport { screenHoldOf } from \"./screen-hold.ts\";\nimport { showSessionNotices } from \"./session-notices.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function (this: InteractiveModeBase): Promise<void> {\n\t// The prompt the command was typed in: a subagent's, when the clone was asked for from its view.\n\tconst prompt = promptHandle(this, \"viewed\");\n\tawait this.ensureDeferredStartupComplete();\n\tconst leafId = this.sessionManager.getLeafId();\n\tif (!leafId) {\n\t\tthis.showStatus(\"Nothing to clone yet\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n\t\tif (result.cancelled) {\n\t\t\tthis.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.renderCurrentSessionState();\n\t\tprompt.setText(\"\");\n\t\tthis.showStatus(\"Cloned to new session\");\n\t} catch (error: unknown) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = async function (\n\tthis: InteractiveModeBase,\n): Promise<boolean> {\n\tconst cwd = this.sessionManager.getCwd();\n\tif (this.autoTrustOnReloadCwd !== cwd) {\n\t\treturn false;\n\t}\n\tif (!this.settingsManager.isProjectTrusted() || !(await hasTrustRequiringProjectResourcesAsync(cwd))) {\n\t\treturn false;\n\t}\n\n\tconst trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n\ttry {\n\t\tif ((await trustStore.getAsync(cwd)) !== null) {\n\t\t\tthis.autoTrustOnReloadCwd = undefined;\n\t\t\treturn false;\n\t\t}\n\t\tawait trustStore.setAsync(cwd, true);\n\t\tthis.autoTrustOnReloadCwd = undefined;\n\t\treturn true;\n\t} catch (error) {\n\t\tthis.showWarning(\n\t\t\t`Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t\treturn false;\n\t}\n};\n\nInteractiveModeBase.prototype.showTrustSelector = async function (this: InteractiveModeBase): Promise<void> {\n\tconst cwd = this.sessionManager.getCwd();\n\tconst trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n\tconst trustData = Promise.all([trustStore.getEntryAsync(cwd), getProjectTrustPathAsync(cwd)]);\n\tawait withHostProjectTrustPrompt(\n\t\tthis.runtimeHost,\n\t\t\"select\",\n\t\t\"Project trust\",\n\t\t() =>\n\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\tthis.showSelector((done) => {\n\t\t\t\t\tconst heldInput: string[] = [];\n\t\t\t\t\tlet selector: TrustSelectorComponent | undefined;\n\t\t\t\t\tlet focused = false;\n\t\t\t\t\tlet closed = false;\n\t\t\t\t\tconst view: Component & Focusable = {\n\t\t\t\t\t\tcapturesViewportInput: true,\n\t\t\t\t\t\tget focused() {\n\t\t\t\t\t\t\treturn focused;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tset focused(value: boolean) {\n\t\t\t\t\t\t\tfocused = value;\n\t\t\t\t\t\t\tif (selector) selector.focused = value;\n\t\t\t\t\t\t},\n\t\t\t\t\t\trender: (width) => selector?.render(width) ?? [],\n\t\t\t\t\t\tinvalidate: () => selector?.invalidate(),\n\t\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t\tif (selector) selector.handleInput(data);\n\t\t\t\t\t\t\telse heldInput.push(data);\n\t\t\t\t\t\t},\n\t\t\t\t\t\thandleMouse: (event) => selector?.handleMouse(event),\n\t\t\t\t\t};\n\t\t\t\t\t// Until the saved decision is read the view draws nothing: the prompt's slot keeps its rows meanwhile. A key\n\t\t\t\t\t// pressed since the view opened shows it live, as a key does with any held part of the screen.\n\t\t\t\t\tconst screen = screenHoldOf(this);\n\t\t\t\t\tconst keysAtOpen = screen.keyPresses;\n\t\t\t\t\tawaitFirstContent(view, () => selector === undefined && screen.keyPresses === keysAtOpen);\n\t\t\t\t\ttrustData.then(\n\t\t\t\t\t\t([savedDecision, trustPath]) => {\n\t\t\t\t\t\t\tif (closed) return;\n\t\t\t\t\t\t\tconst shown = new TrustSelectorComponent({\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\ttrustPath,\n\t\t\t\t\t\t\t\tsavedDecision,\n\t\t\t\t\t\t\t\tprojectTrusted: this.settingsManager.isProjectTrusted(),\n\t\t\t\t\t\t\t\tonSelect: (selection) => {\n\t\t\t\t\t\t\t\t\ttrustStore.setManyAsync(selection.updates).then(\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\t\t\t\t\tthis.showStatus(\n\t\t\t\t\t\t\t\t\t\t\t\t`Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\t\t\t\t\tshown.selector.retrySelection();\n\t\t\t\t\t\t\t\t\t\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonCancel: () => {\n\t\t\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tshown.focused = focused;\n\t\t\t\t\t\t\tselector = shown;\n\t\t\t\t\t\t\tfor (const data of heldInput.splice(0)) {\n\t\t\t\t\t\t\t\tif (closed) break;\n\t\t\t\t\t\t\t\tshown.handleInput(data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcomponent: view,\n\t\t\t\t\t\tfocus: view,\n\t\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\t\tclosed = true;\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}),\n\t).catch((error: Error) => this.showError(error.message));\n};\n\nInteractiveModeBase.prototype.showTreeSelector = async function (\n\tthis: InteractiveModeBase,\n\tinitialSelectedId?: string,\n): Promise<void> {\n\tawait this.ensureDeferredStartupComplete();\n\t// The navigation's text is for main's prompt, also when the tree was opened from a subagent's view.\n\tconst mainPrompt = promptHandle(this, \"main\");\n\tconst archived =\n\t\tthis.sessionManager.hasFullHistory?.() === false\n\t\t\t? await (await import(\"./components/stored-tree-view.js\")).StoredTreeView.open(this.sessionManager)\n\t\t\t: undefined;\n\tconst tree = archived?.tree ?? this.sessionManager.getTree();\n\tconst realLeafId = archived ? archived.leaf : this.sessionManager.getLeafId();\n\tif (archived) {\n\t\tarchived.view.onUpdate = () => this.ui.requestRender();\n\t\tarchived.view.onError = (error) => this.showError(error.message);\n\t}\n\tconst initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n\tif (tree.length === 0) {\n\t\tthis.showStatus(\"No entries in session\");\n\t\treturn;\n\t}\n\n\tthis.showSelector((done) => {\n\t\tconst selector = new TreeSelectorComponent(\n\t\t\ttree,\n\t\t\trealLeafId,\n\t\t\tthis.ui.terminal.rows,\n\t\t\tasync (entryId) => {\n\t\t\t\t// Compare against the live leaf: a response that was streaming while the\n\t\t\t\t// selector was open may have advanced it past the captured value.\n\t\t\t\tif (entryId === this.sessionManager.getLeafId()) {\n\t\t\t\t\tdone();\n\t\t\t\t\tthis.showStatus(\"Already at this point\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ask about summarization\n\t\t\t\tdone(); // Close selector first\n\n\t\t\t\t// Loop until user makes a complete choice or cancels to tree\n\t\t\t\tlet wantsSummary = false;\n\t\t\t\tlet customInstructions: string | undefined;\n\n\t\t\t\t// Check if we should skip the prompt (user preference to always default to no summary)\n\t\t\t\tif (!this.settingsManager.getBranchSummarySkipPrompt()) {\n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tconst summaryChoice = await this.showExtensionSelector(\"Summarize branch?\", [\n\t\t\t\t\t\t\t\"No summary\",\n\t\t\t\t\t\t\t\"Summarize\",\n\t\t\t\t\t\t\t\"Summarize with custom prompt\",\n\t\t\t\t\t\t]);\n\n\t\t\t\t\t\tif (summaryChoice === undefined) {\n\t\t\t\t\t\t\t// User pressed escape - re-show tree selector with same selection\n\t\t\t\t\t\t\tthis.showTreeSelector(entryId);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\twantsSummary = summaryChoice !== \"No summary\";\n\n\t\t\t\t\t\tif (summaryChoice === \"Summarize with custom prompt\") {\n\t\t\t\t\t\t\tcustomInstructions = await this.showExtensionEditor(\"Custom summarization instructions\");\n\t\t\t\t\t\t\tif (customInstructions === undefined) {\n\t\t\t\t\t\t\t\t// User cancelled - loop back to summary selector\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// User made a complete choice\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.session.isStreaming) {\n\t\t\t\t\t// The clear goes out before the abort. The editor fills when the session answers, so a clear that\n\t\t\t\t\t// stalls or fails cannot hold up the abort.\n\t\t\t\t\tvoid this.restoreQueuedMessagesToEditor().catch((error: unknown) =>\n\t\t\t\t\t\tshowQueueRestoreFailure(this, error),\n\t\t\t\t\t);\n\t\t\t\t\tawait this.session.abort();\n\t\t\t\t}\n\t\t\t\tif (this.session.isCompacting) {\n\t\t\t\t\tthis.showError(\n\t\t\t\t\t\t\"Wait for the current compaction or tree navigation to finish before navigating the session tree.\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Set up escape handler and loader if summarizing\n\t\t\t\tlet summaryLoader: Loader | undefined;\n\t\t\t\tconst originalOnEscape = this.defaultEditor.onEscape;\n\n\t\t\t\tif (wantsSummary) {\n\t\t\t\t\tthis.defaultEditor.onEscape = () => {\n\t\t\t\t\t\tthis.session.abortBranchSummary();\n\t\t\t\t\t};\n\t\t\t\t\tsetSummaryCancellable(this, true);\n\t\t\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\t\t\tsummaryLoader = new Loader(\n\t\t\t\t\t\tthis.ui,\n\t\t\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t`Summarizing branch... (${keyTextHint(\"app.interrupt\", \"Cancel\")})`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.statusContainer.addChild(summaryLoader);\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t\t\t\tconst result = await this.session.navigateTree(entryId, {\n\t\t\t\t\t\tsummarize: wantsSummary,\n\t\t\t\t\t\tcustomInstructions,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (result.aborted) {\n\t\t\t\t\t\t// Summarization aborted - re-show tree selector with same selection\n\t\t\t\t\t\tthis.showStatus(\"Branch summarization cancelled\");\n\t\t\t\t\t\tthis.showTreeSelector(entryId);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (result.cancelled) {\n\t\t\t\t\t\tthis.showStatus(\"Navigation cancelled\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update UI\n\t\t\t\t\tclearChatForRerender(this);\n\t\t\t\t\tthis.renderInitialMessages();\n\t\t\t\t\tif (result.editorText && !mainPrompt.getText().trim()) {\n\t\t\t\t\t\tmainPrompt.setText(result.editorText);\n\t\t\t\t\t}\n\t\t\t\t\tthis.showStatus(\"Navigated to selected point\");\n\t\t\t\t\tvoid this.flushCompactionQueue({ willRetry: false });\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t\t\t\t} finally {\n\t\t\t\t\tif (summaryLoader) {\n\t\t\t\t\t\tsummaryLoader.stop();\n\t\t\t\t\t\tthis.statusContainer.clear();\n\t\t\t\t\t\tmountIdleStatus(this.statusContainer, this.settingsManager.getClearOnShrink());\n\t\t\t\t\t}\n\t\t\t\t\tsetSummaryCancellable(this, false);\n\t\t\t\t\tthis.defaultEditor.onEscape = originalOnEscape;\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tasync (entryId, label) => {\n\t\t\t\tawait this.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tinitialSelectedId,\n\t\t\tinitialFilterMode,\n\t\t\tarchived?.view,\n\t\t);\n\t\tselector.onLabelError = (error) => this.showError(error.message);\n\t\tselector.onLabelUpdate = () => this.ui.requestRender();\n\t\tconst dispose = onPreliminaryCatalogWithdrawn(this, () => {\n\t\t\tselector.getTreeList().updateInitialFilter(this.settingsManager.getTreeFilterMode());\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\treturn {\n\t\t\tcomponent: selector,\n\t\t\tfocus: selector,\n\t\t\tdispose: () => {\n\t\t\t\tarchived?.view.dispose();\n\t\t\t\tdispose?.();\n\t\t\t},\n\t\t};\n\t});\n};\n\nInteractiveModeBase.prototype.showSessionSelector = function (this: InteractiveModeBase): void {\n\tthis.showSelector((done) => {\n\t\tconst selector = new SessionSelectorComponent(\n\t\t\t(onProgress) =>\n\t\t\t\tSessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionStore(), onProgress),\n\t\t\t(onProgress) => SessionManager.listAll(this.sessionManager.getSessionStore(), onProgress),\n\t\t\tasync (selected) => {\n\t\t\t\tdone();\n\t\t\t\tawait resumeCatalogSelection(this, selected);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tdone();\n\t\t\t\tvoid this.shutdown();\n\t\t\t},\n\t\t\t() => this.ui.requestRender(),\n\t\t\t{\n\t\t\t\tvariant: \"mixed\",\n\t\t\t\ttitle: \"Resume\",\n\t\t\t\tdeleteSession:\n\t\t\t\t\tthis.sessionManager.getSessionStore().descriptor.adapter === \"jsonl\"\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: (id) => this.sessionManager.deleteSession(id),\n\t\t\t\trenameSession: async (selected, nextName) => {\n\t\t\t\t\tconst next = (nextName ?? \"\").trim();\n\t\t\t\t\tif (!next) return;\n\t\t\t\t\tconst store = this.sessionManager.getSessionStore();\n\t\t\t\t\tconst directory = store.descriptor.adapter === \"jsonl\" ? dirname(selected.path) : undefined;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselected.id === this.sessionManager.getSessionId() &&\n\t\t\t\t\t\t(directory === undefined ||\n\t\t\t\t\t\t\t(await canonicalizePathAsync(directory)) ===\n\t\t\t\t\t\t\t\t(await canonicalizePathAsync(this.sessionManager.getSessionDir())))\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.session.setSessionName(next);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst mgr = await this.sessionManager.openSessionById(selected.id, undefined, directory, {\n\t\t\t\t\t\t\thistory: \"tail\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait mgr.appendSessionInfo(next);\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\tif (mgr.getSessionStore() !== store) await mgr.getSessionStore().close();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshowRenameHint: true,\n\t\t\t\tkeybindings: this.keybindings,\n\t\t\t},\n\n\t\t\t{ id: this.sessionManager.getSessionId(), directory: this.sessionManager.getSessionDir() },\n\t\t);\n\t\tawaitFirstContent(selector, () => selector.awaitingFirstContent());\n\t\treturn {\n\t\t\tcomponent: selector,\n\t\t\tfocus: selector,\n\t\t\tdispose: () => selector.dispose(),\n\t\t};\n\t});\n};\n\nasync function resumeCatalogSelection(mode: InteractiveModeBase, selected: SessionInfo): Promise<void> {\n\tconst directory =\n\t\tmode.sessionManager.getSessionStore().descriptor.adapter === \"jsonl\" ? dirname(selected.path) : undefined;\n\tawait mode.handleResumeSession(selected.id, undefined, directory);\n}\n\nInteractiveModeBase.prototype.handleResumeTarget = async function (\n\tthis: InteractiveModeBase,\n\ttarget: string,\n): Promise<void> {\n\tif (/\\s/.test(target) || target.startsWith(\"-\")) {\n\t\tthis.showError(\"Usage: /resume [session-id].\");\n\t\treturn;\n\t}\n\ttry {\n\t\tconst sessions = await SessionManager.listAll(this.sessionManager.getSessionStore());\n\t\tconst resolution = resolveResumeTarget(target, sessions);\n\t\tif (resolution.kind === \"session\") {\n\t\t\tawait resumeCatalogSelection(this, resolution.session);\n\t\t} else if (resolution.kind === \"ambiguous\") {\n\t\t\tthis.showError(\n\t\t\t\t`Resume id \"${target}\" is ambiguous: ${resolution.matches.map((entry) => `session ${entry.id}`).join(\", \")}. Use /resume to choose an entry, or provide a unique full id.`,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.showError(\n\t\t\t\t`No session matches \"${target}\". Use /resume to choose an entry, or provide a full id or unique 8-character hexadecimal prefix.`,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tthis.showError(error instanceof Error ? error.message : String(error));\n\t}\n};\n\nInteractiveModeBase.prototype.handleResumeSession = async function (\n\tthis: InteractiveModeBase,\n\tsessionId: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n\tsessionDirectory?: string,\n): Promise<{ cancelled: boolean }> {\n\tawait this.ensureDeferredStartupComplete();\n\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\tmountIdleStatus(this.statusContainer, this.settingsManager.getClearOnShrink());\n\tconst resumeStartedAt = new Date().toISOString();\n\ttry {\n\t\tconst result = await this.runtimeHost.switchSession(sessionId, {\n\t\t\twithSession: options?.withSession,\n\t\t\tsessionDirectory,\n\t\t\tprojectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n\t\t\thistory: \"tail\",\n\t\t});\n\t\tif (result.cancelled) {\n\t\t\treturn result;\n\t\t}\n\t\tthis.renderCurrentSessionState();\n\t\tif (this.firstRunNoticeVisible) {\n\t\t\tthis.clearFirstRunOnboardingUi();\n\t\t}\n\t\tthis.showStatus(\"Resumed session\");\n\t\tshowSessionNotices(this, [\n\t\t\t...worktreeRestoreNotices(this.sessionManager, resumeStartedAt),\n\t\t\t...this.runtimeHost.takeResumeNotices(),\n\t\t]);\n\t\tthis.startSessionRecovery(\"resume\");\n\t\treturn result;\n\t} catch (error: unknown) {\n\t\tif (isResumeFailure(error)) {\n\t\t\tthis.showError(error.message);\n\t\t\treturn { cancelled: true };\n\t\t}\n\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\tswitch (await this.promptForMissingSessionCwd(error)) {\n\t\t\t\tcase \"continue\": {\n\t\t\t\t\tconst result = await this.runtimeHost.switchSession(sessionId, {\n\t\t\t\t\t\tcwdOverride: error.issue.fallbackCwd,\n\t\t\t\t\t\tsessionDirectory,\n\t\t\t\t\t\twithSession: options?.withSession,\n\t\t\t\t\t\tprojectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n\t\t\t\t\t\thistory: \"tail\",\n\t\t\t\t\t});\n\t\t\t\t\tif (!result.cancelled) finishMissingCwdResume(this, `Resumed session in ${error.issue.fallbackCwd}`);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tcase \"fork\":\n\t\t\t\t\treturn this.switchToForkedSession({ sessionId, sessionDirectory }, error.issue.fallbackCwd, options);\n\t\t\t\tcase undefined:\n\t\t\t\t\tthis.showStatus(\"Resume cancelled\");\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t}\n\t\t}\n\t\treturn this.handleFatalRuntimeError(\"Failed to resume session\", error);\n\t}\n};\n\nfunction finishMissingCwdResume(mode: InteractiveModeBase, status: string): void {\n\tmode.renderCurrentSessionState();\n\tif (mode.firstRunNoticeVisible) {\n\t\tmode.clearFirstRunOnboardingUi();\n\t}\n\tmode.showStatus(status);\n\tshowSessionNotices(mode, mode.runtimeHost.takeResumeNotices());\n\tmode.startSessionRecovery(\"resume\");\n}\n\nasync function forkIntoActiveStore(\n\tmode: InteractiveModeBase,\n\tsource: MissingCwdForkSource,\n\tcwd: string,\n): Promise<SessionManager> {\n\tconst store = mode.sessionManager.getSessionStore();\n\tif (\"exportPath\" in source) return SessionManager.forkFrom(source.exportPath, cwd, store);\n\tconst stored = await mode.sessionManager.openSessionById(source.sessionId, undefined, source.sessionDirectory);\n\ttry {\n\t\treturn await stored.forkTo(cwd, store);\n\t} finally {\n\t\tif (stored.getSessionStore() !== store) await stored.getSessionStore().close();\n\t}\n}\n\n/**\n * Fork a session whose stored cwd is gone into `cwd`, in the store the current session lives in, and switch to the\n * fork. An extension that cancels the switch leaves no copy behind.\n */\nInteractiveModeBase.prototype.switchToForkedSession = async function (\n\tthis: InteractiveModeBase,\n\tsource: MissingCwdForkSource,\n\tcwd: string,\n\toptions?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1],\n): Promise<{ cancelled: boolean }> {\n\tconst forkId = (await forkIntoActiveStore(this, source, cwd)).getSessionId();\n\tconst result = await this.runtimeHost.switchSession(forkId, {\n\t\twithSession: options?.withSession,\n\t\tprojectTrustContextFactory: (forkCwd) => this.createProjectTrustContext(forkCwd),\n\t\thistory: \"tail\",\n\t});\n\tif (result.cancelled) {\n\t\tawait this.sessionManager.deleteSession(forkId);\n\t\treturn result;\n\t}\n\tfinishMissingCwdResume(this, `Forked into new session ${forkId} in ${cwd}`);\n\treturn result;\n};\n"]}
|