@bastani/atomic 0.10.4-alpha.2 → 0.10.5-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 +238 -0
- package/dist/_shared/chunk-CDOYTDYM.js +4 -0
- package/dist/_shared/chunk-CDOYTDYM.js.map +1 -0
- package/dist/_shared/compile-cache-warmup-host-RU5L7I7A.js +1 -1
- package/dist/_shared/dist-KOELCESV.js +48 -3
- package/dist/_shared/fork-row-index-UAUAQRD5.js +47 -2
- package/dist/_shared/http-YFAPTIZD.js +16 -4
- package/dist/_shared/http-YFAPTIZD.js.map +1 -1
- package/dist/_shared/lib-4PES5P4V.js +59 -14
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +1706 -258
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +317 -64
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/{mode-shared-HP7GUA7J.js → mode-shared-2QJSCUM6.js} +432 -81
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js +3482 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -0
- package/dist/_shared/p0-cli-GUFK7TPN.js +2 -2838
- package/dist/_shared/p0-cli-GUFK7TPN.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-YK3KDTLN.js → p1a-prewarm-UQY3X2UK.js} +270 -73
- package/dist/_shared/p1a-prewarm-UQY3X2UK.js.map +1 -0
- package/dist/_shared/{p1b-elig-PXQA2FYP.js → p1b-elig-ENCUPKKJ.js} +190 -121
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +1 -0
- package/dist/_shared/p2-common-YLSYXMDQ.js +1 -3
- package/dist/_shared/p2-common-YLSYXMDQ.js.map +1 -1
- package/dist/_shared/p2-shell-TJBYQMCJ.js +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +500 -127
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +4 -4
- package/dist/_shared/sdk-WQIOHVKO.js +56 -11
- package/dist/_shared/session-data-AHTU7IS6.js +48 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +2 -2
- package/dist/_shared/settings-startup-65YEWRV2.js.map +1 -1
- package/dist/_shared/sql-session-store-5FD3WBMZ.js +57 -12
- package/dist/_shared/{startup-0-0-X4NF3GKM.js → startup-0-0-TYUFUOJZ.js} +528 -321
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +1 -0
- package/dist/_shared/{startup-0-1-7QTG6VJZ.js → startup-0-1-D4LGGINF.js} +284 -81
- package/dist/_shared/startup-0-1-D4LGGINF.js.map +1 -0
- package/dist/_shared/{startup-0-2-KFDYPDJK.js → startup-0-2-SZGQIWHI.js} +483 -154
- package/dist/_shared/startup-0-2-SZGQIWHI.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +340 -110
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js +261 -59
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +1 -1
- package/dist/_shared/startup-0-5-OHJNE6JH.js +421 -148
- package/dist/_shared/startup-0-5-OHJNE6JH.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +62 -11
- package/dist/_shared/startup-10-0-TDQNBDDL.js.map +1 -1
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +12 -11
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +53 -158
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +231 -46
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +115 -35
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-KQJBDKRU.js → startup-8-1-SJW2GMAM.js} +203 -62
- package/dist/_shared/startup-8-1-SJW2GMAM.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +55 -10
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +47 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +48 -3
- package/dist/builtin/intercom/CHANGELOG.md +59 -0
- package/dist/builtin/intercom/README.md +0 -1
- package/dist/builtin/intercom/broker/broker-instance.ts +13 -57
- package/dist/builtin/intercom/broker/broker-process.ts +30 -10
- package/dist/builtin/intercom/broker/broker-routing.ts +12 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +2557 -498
- package/dist/builtin/intercom/broker/broker.ts +164 -55
- package/dist/builtin/intercom/broker/client.ts +36 -16
- package/dist/builtin/intercom/broker/control.ts +83 -20
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +65 -19
- package/dist/builtin/intercom/broker/host-command-environment.ts +7 -2
- package/dist/builtin/intercom/broker/multinode-router.ts +1675 -387
- package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
- package/dist/builtin/intercom/broker/paths.ts +68 -6
- package/dist/builtin/intercom/broker/pending-send-registry.ts +5 -0
- package/dist/builtin/intercom/broker/registration-bounds.ts +38 -0
- package/dist/builtin/intercom/broker/retiring-broker-check.ts +178 -0
- package/dist/builtin/intercom/broker/return-paths.ts +268 -7
- package/dist/builtin/intercom/broker/send-handler.ts +253 -28
- package/dist/builtin/intercom/broker/send-order-gate.ts +410 -0
- package/dist/builtin/intercom/broker/spawn.ts +950 -202
- package/dist/builtin/intercom/broker/sql-lease-store.ts +37 -0
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +7 -0
- package/dist/builtin/intercom/broker/windows-cwd.ts +546 -0
- package/dist/builtin/intercom/index.bundle.mjs +3506 -2328
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +4 -0
- package/dist/builtin/intercom/types.ts +2 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +46 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +336 -86
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/index.bundle.mjs +23 -38
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/cli.js +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/internal-intercom-broker.js +119 -4
- package/dist/bun/internal-intercom-broker.js.map +1 -1
- package/dist/bun/register-theme-validator.js +6 -0
- package/dist/bun/register-theme-validator.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +1102 -0
- package/dist/cli/auth-cli.code.js.map +1 -0
- package/dist/cli/auth-cli.impl.js +36 -0
- package/dist/cli/auth-cli.impl.js.map +1 -0
- package/dist/cli/auth-cli.js +30 -1096
- package/dist/cli/auth-cli.js.map +1 -1
- package/dist/cli/blueprint-command.code.js +906 -0
- package/dist/cli/blueprint-command.code.js.map +1 -0
- package/dist/cli/blueprint-command.impl.js +36 -0
- package/dist/cli/blueprint-command.impl.js.map +1 -0
- package/dist/cli/blueprint-command.js +30 -900
- package/dist/cli/blueprint-command.js.map +1 -1
- package/dist/cli/intercom-command.code.js +153 -0
- package/dist/cli/intercom-command.code.js.map +1 -0
- package/dist/cli/intercom-command.impl.js +36 -0
- package/dist/cli/intercom-command.impl.js.map +1 -0
- package/dist/cli/intercom-command.js +33 -105
- package/dist/cli/intercom-command.js.map +1 -1
- package/dist/cli/list-models.code.js +60 -0
- package/dist/cli/list-models.code.js.map +1 -0
- package/dist/cli/list-models.impl.js +36 -0
- package/dist/cli/list-models.impl.js.map +1 -0
- package/dist/cli/list-models.js +33 -57
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.code.js +55 -0
- package/dist/cli/session-picker.code.js.map +1 -0
- package/dist/cli/session-picker.impl.js +36 -0
- package/dist/cli/session-picker.impl.js.map +1 -0
- package/dist/cli/session-picker.js +33 -52
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.code.js +5 -0
- package/dist/cli/startup-ui.code.js.map +1 -0
- package/dist/cli/startup-ui.impl.js +36 -0
- package/dist/cli/startup-ui.impl.js.map +1 -0
- package/dist/cli/startup-ui.js +35 -4
- package/dist/cli/storage-command.code.js +3 -0
- package/dist/cli/storage-command.code.js.map +1 -0
- package/dist/cli/storage-command.impl.js +36 -0
- package/dist/cli/storage-command.impl.js.map +1 -0
- package/dist/cli/storage-command.js +35 -2
- package/dist/cli/storage-search-session.code.js +189 -0
- package/dist/cli/storage-search-session.code.js.map +1 -0
- package/dist/cli/storage-search-session.impl.js +36 -0
- package/dist/cli/storage-search-session.impl.js.map +1 -0
- package/dist/cli/storage-search-session.js +33 -186
- package/dist/cli/storage-search-session.js.map +1 -1
- package/dist/cli/team-command.code.js +217 -0
- package/dist/cli/team-command.code.js.map +1 -0
- package/dist/cli/team-command.impl.js +36 -0
- package/dist/cli/team-command.impl.js.map +1 -0
- package/dist/cli/team-command.js +32 -213
- package/dist/cli/team-command.js.map +1 -1
- package/dist/cli.js +60 -11
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -3
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts +6 -0
- package/dist/core/compaction/model-resolver.d.ts +1 -1
- package/dist/core/debug.code.js +3 -0
- package/dist/core/debug.code.js.map +1 -0
- package/dist/core/debug.impl.js +36 -0
- package/dist/core/debug.impl.js.map +1 -0
- package/dist/core/debug.js +35 -2
- package/dist/core/default-model-api-prewarm.d.ts +5 -0
- package/dist/core/export-html/card-projection.code.js +257 -0
- package/dist/core/export-html/card-projection.code.js.map +1 -0
- package/dist/core/export-html/card-projection.impl.js +36 -0
- package/dist/core/export-html/card-projection.impl.js.map +1 -0
- package/dist/core/export-html/card-projection.js +34 -255
- package/dist/core/export-html/card-projection.js.map +1 -1
- package/dist/core/export-html/index.code.js +655 -0
- package/dist/core/export-html/index.code.js.map +1 -0
- package/dist/core/export-html/index.impl.js +36 -0
- package/dist/core/export-html/index.impl.js.map +1 -0
- package/dist/core/export-html/index.js +30 -604
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/json-spans.code.js +3 -0
- package/dist/core/export-html/json-spans.code.js.map +1 -0
- package/dist/core/export-html/json-spans.impl.js +36 -0
- package/dist/core/export-html/json-spans.impl.js.map +1 -0
- package/dist/core/export-html/json-spans.js +35 -2
- package/dist/core/export-html/oversized-render-inputs.code.js +125 -0
- package/dist/core/export-html/oversized-render-inputs.code.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js +36 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.js +31 -120
- package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
- package/dist/core/export-html/tool-renderer.code.js +350 -0
- package/dist/core/export-html/tool-renderer.code.js.map +1 -0
- package/dist/core/export-html/tool-renderer.impl.js +36 -0
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
- package/dist/core/export-html/tool-renderer.js +33 -347
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/jiti-loader.code.js +3 -0
- package/dist/core/extensions/jiti-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-loader.impl.js +36 -0
- package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-loader.js +35 -2
- package/dist/core/extensions/jiti-static-loader.code.js +3 -0
- package/dist/core/extensions/jiti-static-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.impl.js +36 -0
- package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +35 -2
- package/dist/core/extensions/loader-host-modules.code.js +3 -0
- package/dist/core/extensions/loader-host-modules.code.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.impl.js +36 -0
- package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.js +35 -2
- package/dist/core/extensions/loader-virtual-modules.d.ts +1 -6
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +3 -3
- package/dist/core/extensions/session-events.d.ts +4 -0
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +5 -0
- package/dist/core/intercom-broker-control-host.code.js.map +1 -0
- package/dist/core/intercom-broker-control-host.impl.js +36 -0
- package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
- package/dist/core/intercom-broker-control-host.js +35 -4
- package/dist/core/intercom-broker-control.code.js +63 -0
- package/dist/core/intercom-broker-control.code.js.map +1 -0
- package/dist/core/intercom-broker-control.d.ts +21 -0
- package/dist/core/intercom-broker-control.impl.js +36 -0
- package/dist/core/intercom-broker-control.impl.js.map +1 -0
- package/dist/core/intercom-broker-control.js +35 -17
- package/dist/core/intercom-broker-control.js.map +1 -1
- package/dist/core/package-manager-storage-adapters.code.js +3 -0
- package/dist/core/package-manager-storage-adapters.code.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.impl.js +36 -0
- package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.js +35 -2
- package/dist/core/process-start-token.d.ts +8 -2
- package/dist/core/process-tree-containment.d.ts +27 -0
- package/dist/core/queued-message-delivery.d.ts +5 -2
- package/dist/core/resume/blueprint/process.d.ts +3 -1
- package/dist/core/sdk.code.js +9 -0
- package/dist/core/sdk.code.js.map +1 -0
- package/dist/core/sdk.impl.js +36 -0
- package/dist/core/sdk.impl.js.map +1 -0
- package/dist/core/sdk.js +35 -8
- package/dist/core/session-manager-core.d.ts +15 -5
- package/dist/core/session-manager-core.js +195 -38
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.code.js +3 -0
- package/dist/core/session-manager-list.code.js.map +1 -0
- package/dist/core/session-manager-list.impl.js +36 -0
- package/dist/core/session-manager-list.impl.js.map +1 -0
- package/dist/core/session-manager-list.js +35 -2
- package/dist/core/session-manager-types.d.ts +20 -0
- package/dist/core/session-manager.code.js +8 -0
- package/dist/core/session-manager.code.js.map +1 -0
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.impl.js +36 -0
- package/dist/core/session-manager.impl.js.map +1 -0
- package/dist/core/session-manager.js +35 -7
- package/dist/core/session-storage.code.js +3 -0
- package/dist/core/session-storage.code.js.map +1 -0
- package/dist/core/session-storage.impl.js +36 -0
- package/dist/core/session-storage.impl.js.map +1 -0
- package/dist/core/session-storage.js +35 -2
- package/dist/core/storage/file-identity.d.ts +3 -0
- package/dist/core/storage/file-identity.js +296 -86
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.js +52 -7
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +47 -2
- package/dist/core/storage/node-sqlite.js +49 -4
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.code.js +37 -0
- package/dist/core/storage/offline-snapshot-file.code.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.impl.js +36 -0
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.js +33 -34
- package/dist/core/storage/offline-snapshot-file.js.map +1 -1
- package/dist/core/storage/provider.js +52 -7
- package/dist/core/storage/selection.js +49 -4
- package/dist/core/storage/session/branch-fork-source.code.js +146 -0
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.impl.js +36 -0
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.js +32 -97
- package/dist/core/storage/session/branch-fork-source.js.map +1 -1
- package/dist/core/storage/session/card-view.code.js +60 -0
- package/dist/core/storage/session/card-view.code.js.map +1 -0
- package/dist/core/storage/session/card-view.impl.js +36 -0
- package/dist/core/storage/session/card-view.impl.js.map +1 -0
- package/dist/core/storage/session/card-view.js +34 -58
- package/dist/core/storage/session/card-view.js.map +1 -1
- package/dist/core/storage/session/child-reader.code.js +139 -0
- package/dist/core/storage/session/child-reader.code.js.map +1 -0
- package/dist/core/storage/session/child-reader.d.ts +1 -0
- package/dist/core/storage/session/child-reader.impl.js +36 -0
- package/dist/core/storage/session/child-reader.impl.js.map +1 -0
- package/dist/core/storage/session/child-reader.js +33 -91
- package/dist/core/storage/session/child-reader.js.map +1 -1
- package/dist/core/storage/session/chunked-resume-projection.code.js +3 -0
- package/dist/core/storage/session/chunked-resume-projection.code.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js +36 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.js +35 -2
- package/dist/core/storage/session/expanded-child-details.code.js +684 -0
- package/dist/core/storage/session/expanded-child-details.code.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.impl.js +36 -0
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.js +31 -634
- package/dist/core/storage/session/expanded-child-details.js.map +1 -1
- package/dist/core/storage/session/fork-row-bytes.code.js +3 -0
- package/dist/core/storage/session/fork-row-bytes.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js +36 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.js +35 -2
- package/dist/core/storage/session/fork-row-index.code.js +3 -0
- package/dist/core/storage/session/fork-row-index.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.impl.js +36 -0
- package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.js +35 -2
- package/dist/core/storage/session/fork-staging.code.js +580 -0
- package/dist/core/storage/session/fork-staging.code.js.map +1 -0
- package/dist/core/storage/session/fork-staging.impl.js +36 -0
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
- package/dist/core/storage/session/fork-staging.js +30 -574
- package/dist/core/storage/session/fork-staging.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +522 -0
- package/dist/core/storage/session/fork-window.code.js.map +1 -0
- package/dist/core/storage/session/fork-window.impl.js +36 -0
- package/dist/core/storage/session/fork-window.impl.js.map +1 -0
- package/dist/core/storage/session/fork-window.js +30 -471
- package/dist/core/storage/session/fork-window.js.map +1 -1
- package/dist/core/storage/session/history-pages.code.js +3 -0
- package/dist/core/storage/session/history-pages.code.js.map +1 -0
- package/dist/core/storage/session/history-pages.impl.js +36 -0
- package/dist/core/storage/session/history-pages.impl.js.map +1 -0
- package/dist/core/storage/session/history-pages.js +35 -2
- package/dist/core/storage/session/jsonl-entry-projection.code.js +3 -0
- package/dist/core/storage/session/jsonl-entry-projection.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +36 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.js +35 -2
- package/dist/core/storage/session/jsonl-session-store.code.js +3 -0
- package/dist/core/storage/session/jsonl-session-store.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js +36 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.js +35 -2
- package/dist/core/storage/session/memory-session-store.code.js +3 -0
- package/dist/core/storage/session/memory-session-store.code.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.impl.js +36 -0
- package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.js +35 -2
- package/dist/core/storage/session/pinned-branch-resume.code.js +117 -0
- package/dist/core/storage/session/pinned-branch-resume.code.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js +36 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.js +33 -69
- package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
- package/dist/core/storage/session/released-history-files.code.js +465 -0
- package/dist/core/storage/session/released-history-files.code.js.map +1 -0
- package/dist/core/storage/session/released-history-files.impl.js +36 -0
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
- package/dist/core/storage/session/released-history-files.js +32 -461
- package/dist/core/storage/session/released-history-files.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.code.js +57 -0
- package/dist/core/storage/session/resident-fork-rows.code.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js +36 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.js +32 -53
- package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
- package/dist/core/storage/session/session-resume.code.js +3 -0
- package/dist/core/storage/session/session-resume.code.js.map +1 -0
- package/dist/core/storage/session/session-resume.impl.js +36 -0
- package/dist/core/storage/session/session-resume.impl.js.map +1 -0
- package/dist/core/storage/session/session-resume.js +35 -2
- package/dist/core/storage/session/snapshot-cut.code.js +3 -0
- package/dist/core/storage/session/snapshot-cut.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.impl.js +36 -0
- package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.js +35 -2
- package/dist/core/storage/session/snapshot-history.code.js +107 -0
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.impl.js +36 -0
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.js +34 -60
- package/dist/core/storage/session/snapshot-history.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.code.js +3 -0
- package/dist/core/storage/session/sql-session-store.code.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.impl.js +36 -0
- package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.js +35 -2
- package/dist/core/storage/session/tree-outline.code.js +3 -0
- package/dist/core/storage/session/tree-outline.code.js.map +1 -0
- package/dist/core/storage/session/tree-outline.impl.js +36 -0
- package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
- package/dist/core/storage/session/tree-outline.js +35 -2
- package/dist/core/storage/session/tree-presentation.code.js +342 -0
- package/dist/core/storage/session/tree-presentation.code.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.impl.js +36 -0
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.js +31 -337
- package/dist/core/storage/session/tree-presentation.js.map +1 -1
- package/dist/core/storage/session/types.d.ts +26 -0
- package/dist/core/storage/storage-status.code.js +3 -0
- package/dist/core/storage/storage-status.code.js.map +1 -0
- package/dist/core/storage/storage-status.impl.js +36 -0
- package/dist/core/storage/storage-status.impl.js.map +1 -0
- package/dist/core/storage/storage-status.js +35 -2
- package/dist/core/storage/team.code.js +3 -0
- package/dist/core/storage/team.code.js.map +1 -0
- package/dist/core/storage/team.impl.js +36 -0
- package/dist/core/storage/team.impl.js.map +1 -0
- package/dist/core/storage/team.js +35 -2
- package/dist/core/structured-output/index.code.js +3 -0
- package/dist/core/structured-output/index.code.js.map +1 -0
- package/dist/core/structured-output/index.impl.js +36 -0
- package/dist/core/structured-output/index.impl.js.map +1 -0
- package/dist/core/structured-output/index.js +35 -2
- package/dist/core/tasks/command-output.d.ts +4 -1
- package/dist/core/tasks/supervisor.d.ts +2 -0
- package/dist/core/tasks/task-completion-entry.code.js +254 -0
- package/dist/core/tasks/task-completion-entry.code.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.impl.js +36 -0
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.js +33 -251
- package/dist/core/tasks/task-completion-entry.js.map +1 -1
- package/dist/core/tasks/task-file-history.code.js +424 -0
- package/dist/core/tasks/task-file-history.code.js.map +1 -0
- package/dist/core/tasks/task-file-history.impl.js +36 -0
- package/dist/core/tasks/task-file-history.impl.js.map +1 -0
- package/dist/core/tasks/task-file-history.js +32 -375
- package/dist/core/tasks/task-file-history.js.map +1 -1
- package/dist/core/tasks/task-reference-archive.code.js +514 -0
- package/dist/core/tasks/task-reference-archive.code.js.map +1 -0
- package/dist/core/tasks/task-reference-archive.js +34 -467
- package/dist/core/tasks/task-reference-archive.js.map +1 -1
- package/dist/core/tasks/task-reference-identity.code.js +164 -0
- package/dist/core/tasks/task-reference-identity.code.js.map +1 -0
- package/dist/core/tasks/task-reference-identity.js +32 -160
- package/dist/core/tasks/task-reference-identity.js.map +1 -1
- package/dist/core/tasks/task-reference-stream.code.js +3 -0
- package/dist/core/tasks/task-reference-stream.code.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.impl.js +36 -0
- package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.js +35 -2
- package/dist/core/tasks/task-unsaved-answer.code.js +3 -0
- package/dist/core/tasks/task-unsaved-answer.code.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js +36 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.js +35 -2
- package/dist/core/tasks/task-view-source.code.js +3 -0
- package/dist/core/tasks/task-view-source.code.js.map +1 -0
- package/dist/core/tasks/task-view-source.d.ts +9 -0
- package/dist/core/tasks/task-view-source.impl.js +36 -0
- package/dist/core/tasks/task-view-source.impl.js.map +1 -0
- package/dist/core/tasks/task-view-source.js +35 -2
- package/dist/core/tools/read-url.code.js +1530 -0
- package/dist/core/tools/read-url.code.js.map +1 -0
- package/dist/core/tools/read-url.impl.js +36 -0
- package/dist/core/tools/read-url.impl.js.map +1 -0
- package/dist/core/tools/read-url.js +30 -1524
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/core/worktree-snapshot/blob-store.js +50 -5
- package/dist/core/worktree-snapshot/errors.code.js +6 -0
- package/dist/core/worktree-snapshot/errors.code.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.impl.js +36 -0
- package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.js +35 -5
- package/dist/core/worktree-snapshot/session-index-reset.code.js +136 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +36 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.js +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
- package/dist/extensions/codemode/execute.code.js +618 -0
- package/dist/extensions/codemode/execute.code.js.map +1 -0
- package/dist/extensions/codemode/execute.impl.js +36 -0
- package/dist/extensions/codemode/execute.impl.js.map +1 -0
- package/dist/extensions/codemode/execute.js +30 -612
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.code.js +110 -0
- package/dist/extensions/codemode/renderer.code.js.map +1 -0
- package/dist/extensions/codemode/renderer.impl.js +36 -0
- package/dist/extensions/codemode/renderer.impl.js.map +1 -0
- package/dist/extensions/codemode/renderer.js +33 -107
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/mcp/cli.code.js +565 -0
- package/dist/extensions/mcp/cli.code.js.map +1 -0
- package/dist/extensions/mcp/cli.impl.js +36 -0
- package/dist/extensions/mcp/cli.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.js +32 -561
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.code.js +52 -0
- package/dist/extensions/mcp/cli.lazy.code.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.impl.js +36 -0
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +36 -7
- package/dist/extensions/mcp/cli.lazy.js.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.d.ts +2 -0
- package/dist/extensions/mcp/runtime.code.js +5 -0
- package/dist/extensions/mcp/runtime.code.js.map +1 -0
- package/dist/extensions/mcp/runtime.impl.js +36 -0
- package/dist/extensions/mcp/runtime.impl.js.map +1 -0
- package/dist/extensions/mcp/runtime.js +35 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/main-first-time-setup.code.js +12 -0
- package/dist/main-first-time-setup.code.js.map +1 -0
- package/dist/main-first-time-setup.impl.js +36 -0
- package/dist/main-first-time-setup.impl.js.map +1 -0
- package/dist/main-first-time-setup.js +35 -11
- package/dist/main-first-time-setup.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +2 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +6 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +4 -0
- package/dist/modes/interactive/chat-reader-records.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +338 -0
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js +36 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.js +33 -290
- package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
- package/dist/modes/interactive/components/task-selection-state.d.ts +8 -3
- package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +191 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +36 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.js +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode-deps.js +4 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +4 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts +22 -0
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/program-status-reporter.d.ts +2 -1
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive/steering-queue-controller.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-schema-factory.d.ts +26 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +4 -5
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +30 -5
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts +32 -1
- package/dist/modes/rpc/agent-view-rpc-types.d.ts +12 -1
- package/dist/modes/rpc/agent-view-rpc-types.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +3 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/package-manager-cli.code.js +1140 -0
- package/dist/package-manager-cli.code.js.map +1 -0
- package/dist/package-manager-cli.impl.js +36 -0
- package/dist/package-manager-cli.impl.js.map +1 -0
- package/dist/package-manager-cli.js +36 -1067
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.js +2 -2
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/13.js +1 -0
- package/dist/startup-stages/2.js +1 -7
- package/dist/startup-stages/3.js +6 -2
- package/dist/startup-stages/4.js +2 -1
- package/dist/startup-stages/5.js +1 -7
- package/dist/startup-stages/6.js +7 -10
- package/dist/startup-stages/7.js +10 -3
- package/dist/startup-stages/8.js +3 -6
- package/dist/startup-stages/9.js +6 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/canonical-path.js +2 -0
- package/dist/utils/canonical-path.js.map +1 -1
- package/dist/utils/child-process.d.ts +41 -1
- package/dist/utils/compile-cache-warmup-host.js +63 -18
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/credential-redaction.d.ts +50 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/memoize-async.d.ts +32 -0
- package/dist/utils/memoize-async.js +91 -0
- package/dist/utils/memoize-async.js.map +1 -0
- package/dist/utils/photon.js +19 -29
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +7 -4
- package/dist/utils/startup-database-spare.code.js +108 -0
- package/dist/utils/startup-database-spare.code.js.map +1 -0
- package/dist/utils/startup-database-spare.impl.js +36 -0
- package/dist/utils/startup-database-spare.impl.js.map +1 -0
- package/dist/utils/startup-database-spare.js +33 -105
- package/dist/utils/startup-database-spare.js.map +1 -1
- package/dist/utils/tools-manager.code.js +3 -0
- package/dist/utils/tools-manager.code.js.map +1 -0
- package/dist/utils/tools-manager.impl.js +36 -0
- package/dist/utils/tools-manager.impl.js.map +1 -0
- package/dist/utils/tools-manager.js +35 -2
- package/dist/utils/windows-cwd.js +585 -0
- package/dist/utils/windows-cwd.js.map +1 -0
- package/docs/extensions.md +1 -1
- package/docs/getting-started/installation.md +2 -0
- package/docs/intercom/operations.md +1 -0
- package/docs/reference/cli.md +2 -2
- package/package.json +24 -24
- package/dist/_shared/mode-shared-HP7GUA7J.js.map +0 -1
- package/dist/_shared/p1a-prewarm-YK3KDTLN.js.map +0 -1
- package/dist/_shared/p1b-elig-PXQA2FYP.js.map +0 -1
- package/dist/_shared/startup-0-0-X4NF3GKM.js.map +0 -1
- package/dist/_shared/startup-0-1-7QTG6VJZ.js.map +0 -1
- package/dist/_shared/startup-0-2-KFDYPDJK.js.map +0 -1
- package/dist/_shared/startup-8-1-KQJBDKRU.js.map +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { __name } from "./rolldown-runtime-BGM3D5V3.js";
|
|
2
|
-
import { APP_NAME, APP_TITLE, CHANGELOG_URL, CONFIG_DIR_NAME, ENV_OFFLINE, UpdatedInstallError, VERSION, VERSION_ADOPTION_ENDPOINT, canonicalizePathAsync, createChildProcessEnvironment, createModuleRequire, detectInstallChangeAsync, engineHeapRuntimeArgsForHost, findHelperExecutableAsync, getAgentDir, getAuthPath, getChangelogPath, getCwdRelativePath, getDebugLogPath, getDocsPath, getEnvValue, getShareViewerUrl, helperLaunchAsync, isModuleLoadFailure, loadOnDemand, markLifecycleTiming, missingHelperOptions, processCompileCacheDeferral, setDebugSetting, shortenHomePath, updatedInstallError } from "./p0-cli-
|
|
3
|
-
import { BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, CountdownTimer, DynamicBorder, MissingSessionCwdError, NO_QUEUED_MESSAGES, TrustDecisionSelector, asyncScope, carryRowSource, chatPosition, chatReceipt, deduplicateDiagnostics, defaultModelPerProvider, formatMissingSessionCwdPrompt, formatNoModelsAvailableMessage, getEngineSessionStats, getMissingSessionCwdOptions, getPiUserAgent, isGitUnavailableError, isInstallTelemetryEnabled, isInteractiveEngineResourceReadinessError, isPathInside, isTrustDecision, isUnknownModel, keepDroppedQueuedMessages, markEventLoopShutdown, markEventLoopStartupComplete, noteRowSource, noteSavedSeq, parseSlashCommand, placeTranscriptFrame, projectTrustWarningVisible, queuedMessagesUnderWay, quitAsInteractiveApp, recordStartupThinkingLevel, rowSource, safeTrustChoiceIndex, savedRowKey, savedSeqOf, setDeprecationWarningSink, setMarkitDiagnosticSink, shouldRenderEngineDiagnosticAsChatError, takeQueuedMessagesDroppedAt, usageCostBreakdown, yieldToEventLoop } from "./startup-0-0-
|
|
4
|
-
import { ExtensionInputComponent, ExtensionSelectorComponent, ReopenedCompletionHeaders, cancelInitialBinding, createCustomMessage, ensurePngTranscoder, ensureTool, formatResumeTimings, formatToolStatus, getBuiltinExtensionEntryLabel, getPromptCacheTtlMs as getPromptCacheTtlMs$1, initialBindScope, isOfflineModeEnabled, isVerbatimCompactionMessage, isWorkspaceError, latestResumeTimings, prewarmModelApi, readHostInputFormRequest, registerInitialBindings, stripVerbatimCompactionPrefix, taskPromptHost, thinkingLevelForModelSwitch } from "./startup-0-1-
|
|
2
|
+
import { APP_NAME, APP_TITLE, CHANGELOG_URL, CONFIG_DIR_NAME, ENV_OFFLINE, UpdatedInstallError, VERSION, VERSION_ADOPTION_ENDPOINT, canonicalizePathAsync, createChildProcessEnvironment, createModuleRequire, detectInstallChangeAsync, engineHeapRuntimeArgsForHost, findHelperExecutableAsync, getAgentDir, getAuthPath, getChangelogPath, getCwdRelativePath, getDebugLogPath, getDocsPath, getEnvValue, getShareViewerUrl, helperLaunchAsync, isModuleLoadFailure, loadOnDemand, markLifecycleTiming, missingHelperOptions, processCompileCacheDeferral, setDebugSetting, shortenHomePath, updatedInstallError } from "./p0-cli-BB45ZQY6.js";
|
|
3
|
+
import { BUILTIN_SLASH_COMMANDS, BUNDLED_EXTENSION_SLASH_COMMANDS, CountdownTimer, DynamicBorder, MissingSessionCwdError, NO_QUEUED_MESSAGES, TrustDecisionSelector, asyncScope, carryRowSource, chatPosition, chatReceipt, deduplicateDiagnostics, defaultModelPerProvider, formatMissingSessionCwdPrompt, formatNoModelsAvailableMessage, getEngineSessionStats, getMissingSessionCwdOptions, getPiUserAgent, isGitUnavailableError, isInstallTelemetryEnabled, isInteractiveEngineResourceReadinessError, isPathInside, isTrustDecision, isUnknownModel, keepDroppedQueuedMessages, markEventLoopShutdown, markEventLoopStartupComplete, noteRowSource, noteSavedSeq, onSessionProviderRequestDispatched, parseSlashCommand, placeTranscriptFrame, projectTrustWarningVisible, queuedMessagesUnderWay, quitAsInteractiveApp, recordStartupThinkingLevel, rowSource, safeTrustChoiceIndex, savedRowKey, savedSeqOf, setDeprecationWarningSink, setMarkitDiagnosticSink, shouldRenderEngineDiagnosticAsChatError, takeQueuedMessagesDroppedAt, usageCostBreakdown, userMessageOrigin, yieldToEventLoop, yieldToTimerTurn } from "./startup-0-0-TYUFUOJZ.js";
|
|
4
|
+
import { ExtensionInputComponent, ExtensionSelectorComponent, ReopenedCompletionHeaders, cancelInitialBinding, createCustomMessage, ensurePngTranscoder, ensureTool, formatResumeTimings, formatToolStatus, getBuiltinExtensionEntryLabel, getPromptCacheTtlMs as getPromptCacheTtlMs$1, initialBindScope, isOfflineModeEnabled, isVerbatimCompactionMessage, isWorkspaceError, latestResumeTimings, normalizeMessageContent, prewarmModelApi, readHostInputFormRequest, registerInitialBindings, stripVerbatimCompactionPrefix, taskPromptHost, thinkingLevelForModelSwitch } from "./startup-0-1-D4LGGINF.js";
|
|
5
5
|
import { KeybindingsManager as KeybindingsManager$1, OVERLAY_ACTIVE_ROW_MARKER, Theme, clickableKeyTextHint, consumeStartupInput, formatKeyText, getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, isNavHelpKey, keyDisplayText, keyHint, keyText, keyTextHint, loadAllHighlightLanguages, navEntryKeyParts, onThemeChange, recordTimeSinceReset, refreshCustomThemes, renderNavKeyOverlay, setRegisteredThemes, slashCommandHint, stopThemeWatcher, theme } from "./p2-shell-main-B2WIALFD.js";
|
|
6
|
-
import { ProjectTrustStore, failureDebugFields, getProjectTrustPathAsync, hasTrustRequiringProjectResourcesAsync, reportDebugAsync } from "./p1b-elig-
|
|
7
|
-
import { WorkingRunMeter, compactionMeta, findExactModelReferenceMatch, getPowerShellConfigAsync, killSupervisedProcessTrees, killTrackedDetachedChildren, runInProgress, sessionLifetime, showStartupInput, showStartupSelector, taskTranscriptSource } from "./startup-0-2-
|
|
6
|
+
import { ProjectTrustStore, failureDebugFields, getProjectTrustPathAsync, hasTrustRequiringProjectResourcesAsync, reportDebugAsync } from "./p1b-elig-ENCUPKKJ.js";
|
|
7
|
+
import { WorkingRunMeter, compactionMeta, findExactModelReferenceMatch, getPowerShellConfigAsync, killSupervisedProcessTrees, killTrackedDetachedChildren, runInProgress, sessionLifetime, showStartupInput, showStartupSelector, taskTranscriptSource } from "./startup-0-2-SZGQIWHI.js";
|
|
8
8
|
import { AtomicWorkedStatusComponent, AtomicWorkingLoader, DEFAULT_WORKING_MESSAGE, buildContextEntries, getOwnerTaskStore, isResumeFailure, parseGitUrl, resolveModelScopeFromModels, resolveModelScopeWithDiagnostics, sessionEntryToDisplayMessages, watchAtomicWorkingClock, watchOwnerTaskStoreBinding } from "./startup-0-3-T4DVFYWX.js";
|
|
9
9
|
import { SESSION_HISTORY_SCAN_ENTRIES, exitOnDecisionConfigError, findDecisionError, isDecisionConfigError, isRpcRequestAcceptedFailure, isRpcTransportFailure } from "./settings-startup-65YEWRV2.js";
|
|
10
10
|
import { readAhead } from "./startup-8-0-34CBHPZH.js";
|
|
11
11
|
import { CredentialSynchronizationError, DefaultPackageManager, chunkedToolResult, chunkedToolResultEntry, findInitialModel, firstSubagentAttempt, getSkillCatalog, isOAuthLoginCancelled, resolveRestoredModelReference, uncachedCopilotModelHint } from "./startup-0-5-OHJNE6JH.js";
|
|
12
12
|
import { formatModelLabel } from "./startup-0-4-HN5EB4K7.js";
|
|
13
|
-
import { ENGINE_SHUTDOWN_GRACE_MS, FooterDataProvider, appendBoundedStderr, compareWorktreeSnapshot, currentWorktreeSnapshots, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeWorktreeRestoreStatus, describeWorktreeSnapshot, dismissedAgentPanelItems, ownerTaskViewSource, sourceError, subscribeAgentPanel, worktreeRestoreNotices } from "./startup-8-1-
|
|
13
|
+
import { ENGINE_SHUTDOWN_GRACE_MS, FooterDataProvider, appendBoundedStderr, compareWorktreeSnapshot, currentWorktreeSnapshots, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeWorktreeRestoreStatus, describeWorktreeSnapshot, dismissedAgentPanelItems, ownerTaskViewSource, sourceError, subscribeAgentPanel, worktreeRestoreNotices } from "./startup-8-1-SJW2GMAM.js";
|
|
14
14
|
import { tryExecuteSessionSlashCommand } from "./startup-15-0-YUKGAC63.js";
|
|
15
15
|
import { SessionManager } from "./startup-10-0-TDQNBDDL.js";
|
|
16
16
|
import { IsolatedInteractiveRuntime, SessionImportFileNotFoundError, parseSkillBlock, sessionCloseReason } from "./startup-15-1-4S7FLMNG.js";
|
|
17
17
|
import { configureHttpDispatcher } from "./http-YFAPTIZD.js";
|
|
18
|
-
import { AGENT_PANEL_WIDGET_KEY, ANTHROPIC_SUBSCRIPTION_AUTH_WARNING, AgentViewSwitcher, ArminComponent, AssistantMessageComponent, BUILTIN_SLASH_COMMAND_NAMES, BashExecutionComponent, BorderedLoader, BranchSummaryMessageComponent, CONSOLE_CLOSED_EXIT_CODE, CONSOLE_CLOSED_SHUTDOWN_MS, ChatSessionHost, CombinedAutocompleteProvider as CombinedAutocompleteProvider$1, CompactionBoundaryMessageComponent, Container as Container$1, CustomMessageComponent, EarendilAnnouncementComponent, ExpandableText, ExtensionEditorComponent, FooterComponent, InteractiveThemeController, KeybindingsReloadCoordinator, Loader as Loader$1, LoginDialogComponent, Markdown as Markdown$1, ModelSelectorComponent, OAuthSelectorComponent, PromptHistorySelectorComponent, QueuedMessagesView, RemoteCustomMessageComponent, RemoteFrameWidthClamp, RemoteToolExecutionComponent, STARTUP_ASSEMBLY_GAPS, STOP_ALL_STATUS_KEY, SavedRendererInstances, ScopedModelsSelectorComponent, SessionSelectorComponent, SettingsSelectorComponent, SkillInvocationMessageComponent, Spacer as Spacer$1, SteeringQueueController, Text as Text$1, ThinkingSelectorComponent, ToolExecutionComponent, ToolGroupTracker, TranscriptTaskRow, TreeSelectorComponent, TrustSelectorComponent, UsageMeterComponent, UserMessageSelectorComponent, WorkingStatusComponent, addChatTranscriptEntry, agentPanelBoardSource, agentPanelCounts, agentPanelHasRows, applyAssistantMessageDelta, applyToolEntryState, assistantCallBreaks, atomicWordmark, beginStreamingAssistantMessage, bindAgentPanel, blockRows, boundedInteractiveModelRefresh, callsAwaitingLaterResults, chalk, chatEntriesFromAgentMessages, chatRecordsChanged, checkForNewPiVersion, clickableBlocksView, combineQueuedMessagesForEditor, compareProviders, composeStartupIdentity, countTasksBy, createChatAutocompleteProvider, createRemoteAgentSteering, createStopAllChord, createStopAllNotices, decisionSettingScopes, declaresHistoryReplayable, discardChatMount, disposeRemoteRenderers, disposeRenderer, endsAwaitedResults, exitWithStatus, formatAuthSelectorProviderType, formatCrashExtensionHint, formatResumeCommand, fs, fuzzyFilter as fuzzyFilter$1, getAutocompleteSourceTag, getCachedChangelog, getCapabilities as getCapabilities$1, getChangelogHighlights, getEntriesForVersion, getModelSearchText, getNewEntries, getSessionSkillCommands, handleTranscriptBlockClick, hasAssistantVisibleContent, hasDefaultModelProvider, hyperlink as hyperlink$1, interruptedNotice, isAnthropicSubscriptionAuthKey, isChatSessionWorking, isClickExpandableBlock, isDeadTerminalError, isEngineHintRoute, isExpandable, isResultWithoutCall, isSingleLeftClick, loadEarendilAnnouncementImage, matchesKey as matchesKey$1, needsChangelogPreload, normalizeChangelogLinks, observeClickExpansion, openExternalEditorForText, openLocalAgentViewPort, openWaitedShellOf, os, panelHintParts, panelHintSegments, parkedRun, parseChangelogAsync, pasteClipboardImageToEditor, path as path$1, pickWhimsicalWorkingMessage, prefixAutocompleteDescription, preloadChangelog, promptHistoryEntries, queuedMessageRows, readMountedAnchors, readTaskCompletionHistory, refreshModelCatalogs, remoteAgentCommands, remoteAgentPrompts, renderAtomicAssemblyBanner, renderChatMessageEntry, renderStartupManifesto, restoredQueue, retainChatRecords, retryCancelHint, retryWaitFromEvent, retryWaitMessage, rowsFrom, runHintRoute, sessionChatMount, sessionPromptsFromEntries, setAgentViewBridge, setKeybindings as setKeybindings$1, setRendererClickTarget, settleUnansweredCalls, showAgentPanel, showTaskInspector, spawn, stopAllBackgroundWork, supersedeBlockClicks, supportsAtomicBanner, taskNameAndTitle, taskSiblings, themedChatHostStyle, toolResultGroupState, viewedAgentCommand, visibleWidth as visibleWidth$1 } from "./mode-shared-
|
|
19
|
-
import { CustomEditor, TRANSCRIPT_JUMP_TO_END_URL, UserMessageComponent, abortStartupShell, copyToClipboard, createInteractiveTui, createInteractiveTuiReference, createMarkdownTransform, handOverStartupShell, handleFocusedOverlayInternalUiAction, isMouseWheelInput, isOverlayMounted, isPhysicalCtrlC, isPhysicalEscape, isSafetyKeyRelease, readClipboardText, releaseStartupShellSignals, replayableMarkdownTransform, startupShellTerminal, stripAnsi$1 as stripAnsi, stripTerminalControls, whenStartupShellCanHandOver } from "./p2-shell-TJBYQMCJ.js";
|
|
18
|
+
import { AGENT_PANEL_WIDGET_KEY, ANTHROPIC_SUBSCRIPTION_AUTH_WARNING, AgentViewSwitcher, ArminComponent, AssistantMessageComponent, BUILTIN_SLASH_COMMAND_NAMES, BashExecutionComponent, BorderedLoader, BranchSummaryMessageComponent, COMMITTED_WIDGET_PREVIEW_GATE, CONSOLE_CLOSED_EXIT_CODE, CONSOLE_CLOSED_SHUTDOWN_MS, ChatSessionHost, CombinedAutocompleteProvider as CombinedAutocompleteProvider$1, CompactionBoundaryMessageComponent, Container as Container$1, CustomMessageComponent, EarendilAnnouncementComponent, ExpandableText, ExtensionEditorComponent, FooterComponent, InteractiveThemeController, KeybindingsReloadCoordinator, Loader as Loader$1, LoginDialogComponent, Markdown as Markdown$1, ModelSelectorComponent, OAuthSelectorComponent, PromptHistorySelectorComponent, QueuedMessagesView, RemoteCustomMessageComponent, RemoteFrameWidthClamp, RemoteToolExecutionComponent, STARTUP_ASSEMBLY_GAPS, STOP_ALL_STATUS_KEY, SavedRendererInstances, ScopedModelsSelectorComponent, SessionSelectorComponent, SettingsSelectorComponent, SkillInvocationMessageComponent, Spacer as Spacer$1, SteeringQueueController, Text as Text$1, ThinkingSelectorComponent, ToolExecutionComponent, ToolGroupTracker, TranscriptTaskRow, TreeSelectorComponent, TrustSelectorComponent, UsageMeterComponent, UserMessageSelectorComponent, WorkingStatusComponent, addChatTranscriptEntry, agentPanelBoardSource, agentPanelCounts, agentPanelHasRows, applyAssistantMessageDelta, applyToolEntryState, assistantCallBreaks, atomicWordmark, beginStreamingAssistantMessage, bindAgentPanel, blockRows, boundedInteractiveModelRefresh, callsAwaitingLaterResults, canPaintWidgetFrame, chalk, chatEntriesFromAgentMessages, chatRecordsChanged, checkForNewPiVersion, classifyWidgetFrame, clickableBlocksView, combineQueuedMessagesForEditor, compareProviders, composeStartupIdentity, countTasksBy, createChatAutocompleteProvider, createRemoteAgentSteering, createStopAllChord, createStopAllNotices, decisionSettingScopes, declaresHistoryReplayable, discardChatMount, disposeRemoteRenderers, disposeRenderer, endsAwaitedResults, exitWithStatus, formatAuthSelectorProviderType, formatCrashExtensionHint, formatResumeCommand, fs, fuzzyFilter as fuzzyFilter$1, getAutocompleteSourceTag, getCachedChangelog, getCapabilities as getCapabilities$1, getChangelogHighlights, getEntriesForVersion, getModelSearchText, getNewEntries, getSessionSkillCommands, handleTranscriptBlockClick, hasAssistantVisibleContent, hasDefaultModelProvider, hyperlink as hyperlink$1, initialHostEngineViewSyncState, interruptedNotice, isAnthropicSubscriptionAuthKey, isChatSessionWorking, isClickExpandableBlock, isDeadTerminalError, isEngineHintRoute, isExpandable, isResultWithoutCall, isSingleLeftClick, isUnansweredCancelMatch, loadEarendilAnnouncementImage, matchesKey as matchesKey$1, needsChangelogPreload, normalizeChangelogLinks, observeClickExpansion, openExternalEditorForText, openLocalAgentViewPort, openWaitedShellOf, os, panelHintParts, panelHintSegments, parkedRun, parseChangelogAsync, pasteClipboardImageToEditor, path as path$1, pickWhimsicalWorkingMessage, planPreViewCancelAck, prefixAutocompleteDescription, preloadChangelog, promptHistoryEntries, queuedMessageRows, readMountedAnchors, readTaskCompletionHistory, refreshModelCatalogs, remoteAgentCommands, remoteAgentPrompts, renderAtomicAssemblyBanner, renderChatMessageEntry, renderStartupManifesto, restoredQueue, retainChatRecords, retryCancelHint, retryWaitFromEvent, retryWaitMessage, rowsFrom, runHintRoute, sessionChatMount, sessionPromptsFromEntries, setAgentViewBridge, setKeybindings as setKeybindings$1, setRendererClickTarget, settleUnansweredCalls, shouldCancelEngineViewOnArrival, showAgentPanel, showTaskInspector, spawn, stopAllBackgroundWork, supersedeBlockClicks, supportsAtomicBanner, taskNameAndTitle, taskSiblings, themedChatHostStyle, toolResultGroupState, viewedAgentCommand, visibleWidth as visibleWidth$1 } from "./mode-shared-2QJSCUM6.js";
|
|
19
|
+
import { CustomEditor, TRANSCRIPT_JUMP_TO_END_URL, UserMessageComponent, abortStartupShell, copyToClipboard, createInteractiveTui, createInteractiveTuiReference, createMarkdownTransform, extractMessageText, handOverStartupShell, handleFocusedOverlayInternalUiAction, isMouseWheelInput, isOverlayMounted, isPhysicalCtrlC, isPhysicalEscape, isSafetyKeyRelease, readClipboardText, releaseStartupShellSignals, replayableMarkdownTransform, startupShellTerminal, stripAnsi$1 as stripAnsi, stripTerminalControls, whenStartupShellCanHandOver } from "./p2-shell-TJBYQMCJ.js";
|
|
20
20
|
import { dirname } from "node:path";
|
|
21
21
|
import { normalizeProviderId } from "@bastani/atomic-ai";
|
|
22
22
|
import { Box, CURSOR_MARKER, Container, Editor, Input, Key, Marked, ScrollView, Spacer, Text, TuiAltScreen, VStack, WindowedContainer, bindBundledHintCommands, clickableKeysHint, decodePrintableKey, editorDraftText, emptyEditorDraft, fuzzyFilter, getCapabilities, isHintActivation, isKeyRelease, isViewportTUI, matchesKey, replaceControlCharacters, setCapabilityOverrides, setKeybindings, stripHintMarkers, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
|
|
23
|
-
import { createHash } from "node:crypto";
|
|
23
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
24
24
|
import { setImmediate as setImmediate$1 } from "node:timers/promises";
|
|
25
25
|
import { clampThinkingLevel, modelsAreEqual } from "@bastani/atomic-ai/compat";
|
|
26
26
|
import { createInterface } from "node:readline";
|
|
@@ -1306,6 +1306,13 @@ var RemoteComponent = class {
|
|
|
1306
1306
|
pendingInputs = /* @__PURE__ */ new Map();
|
|
1307
1307
|
/** Handled keys whose frame has not arrived yet. */
|
|
1308
1308
|
answeredInputs = /* @__PURE__ */ new Set();
|
|
1309
|
+
/** Highest `inputRequestId` sent when a host-level cancel (`Esc`) was consumed while this component was mounted. */
|
|
1310
|
+
cancelUpToInputId = 0;
|
|
1311
|
+
/** Monotonic ack id for in-flight click commands when the engine supports `engine_custom_click_result`. */
|
|
1312
|
+
clickAckId = 0;
|
|
1313
|
+
/** In-flight `engine_custom_click` / `engine_custom_click_settle` commands awaiting `engine_custom_click_result`. */
|
|
1314
|
+
inFlightClicks = /* @__PURE__ */ new Map();
|
|
1315
|
+
acksClicks;
|
|
1309
1316
|
frameClamp = new RemoteFrameWidthClamp();
|
|
1310
1317
|
componentId;
|
|
1311
1318
|
runtime;
|
|
@@ -1317,7 +1324,7 @@ var RemoteComponent = class {
|
|
|
1317
1324
|
renderSettingsKey = "";
|
|
1318
1325
|
/** The frame request sent with the latest key; the frame answering it paints at once, as a local key does. */
|
|
1319
1326
|
keyFrameRequestId = 0;
|
|
1320
|
-
constructor(componentId, runtime, requestRender, getRows, getHostMode, handlesInternalUiAction = false, getRenderSettings = () => void 0, paintNow = requestRender) {
|
|
1327
|
+
constructor(componentId, runtime, requestRender, getRows, getHostMode, handlesInternalUiAction = false, getRenderSettings = () => void 0, paintNow = requestRender, acksClicks = false) {
|
|
1321
1328
|
this.componentId = componentId;
|
|
1322
1329
|
this.runtime = runtime;
|
|
1323
1330
|
this.requestRender = requestRender;
|
|
@@ -1326,6 +1333,7 @@ var RemoteComponent = class {
|
|
|
1326
1333
|
this.getHostMode = getHostMode;
|
|
1327
1334
|
this.handlesInternalUiAction = handlesInternalUiAction;
|
|
1328
1335
|
this.getRenderSettings = getRenderSettings;
|
|
1336
|
+
this.acksClicks = acksClicks;
|
|
1329
1337
|
}
|
|
1330
1338
|
/**
|
|
1331
1339
|
* Frames up to this request may draw what the screen was about to show and no longer does: they are not shown, and a
|
|
@@ -1333,10 +1341,66 @@ var RemoteComponent = class {
|
|
|
1333
1341
|
*/
|
|
1334
1342
|
hiddenUpTo;
|
|
1335
1343
|
hiddenTimer;
|
|
1344
|
+
/** Speculative preview gate for engine widgets (the agent panel during `panelOnView`). */
|
|
1345
|
+
previewGate = COMMITTED_WIDGET_PREVIEW_GATE;
|
|
1346
|
+
/** Preview sequence number that produced the currently buffered `lines`, when staged/unpromoted. */
|
|
1347
|
+
framePreviewSeq;
|
|
1348
|
+
clearBufferedFrame() {
|
|
1349
|
+
this.lines = [];
|
|
1350
|
+
this.frame = void 0;
|
|
1351
|
+
this.rowKeys = void 0;
|
|
1352
|
+
this.layout = void 0;
|
|
1353
|
+
this.scrollRequest = void 0;
|
|
1354
|
+
this.framePreviewSeq = void 0;
|
|
1355
|
+
}
|
|
1356
|
+
/** Stage a speculative preview so matching frames buffer for `watchWidgetFrames` without painting live until commit. */
|
|
1357
|
+
stagePreview(previewSeq, tagged) {
|
|
1358
|
+
if (this.disposed) return;
|
|
1359
|
+
this.showFramesAgain();
|
|
1360
|
+
if (this.framePreviewSeq !== void 0 && this.framePreviewSeq !== previewSeq) {
|
|
1361
|
+
this.clearBufferedFrame();
|
|
1362
|
+
this.dirty = true;
|
|
1363
|
+
}
|
|
1364
|
+
this.previewGate = {
|
|
1365
|
+
kind: "staged",
|
|
1366
|
+
previewSeq,
|
|
1367
|
+
tagged
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
/** Promote a staged preview buffer to live visibility on commit (0-frame gap). */
|
|
1371
|
+
commitPreview(previewSeq) {
|
|
1372
|
+
if (this.disposed) return;
|
|
1373
|
+
this.showFramesAgain();
|
|
1374
|
+
this.previewGate = {
|
|
1375
|
+
kind: "committed",
|
|
1376
|
+
promotedSeq: previewSeq
|
|
1377
|
+
};
|
|
1378
|
+
if (this.framePreviewSeq === previewSeq) this.framePreviewSeq = void 0;
|
|
1379
|
+
else if (this.framePreviewSeq !== void 0) {
|
|
1380
|
+
this.clearBufferedFrame();
|
|
1381
|
+
this.dirty = true;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
/** Cancel/revoke a staged speculative preview so its buffered and late frames can never paint. */
|
|
1385
|
+
cancelPreview(legacyHideCapMs) {
|
|
1386
|
+
if (this.disposed) return;
|
|
1387
|
+
this.previewGate = COMMITTED_WIDGET_PREVIEW_GATE;
|
|
1388
|
+
if (this.framePreviewSeq !== void 0 || legacyHideCapMs !== void 0) {
|
|
1389
|
+
this.clearBufferedFrame();
|
|
1390
|
+
this.dirty = true;
|
|
1391
|
+
}
|
|
1392
|
+
if (legacyHideCapMs !== void 0) this.hideFramesUntilFresh(legacyHideCapMs);
|
|
1393
|
+
else this.requestRender();
|
|
1394
|
+
}
|
|
1395
|
+
/** Stop accepting late preview frames after leaving the view that promoted a preview. */
|
|
1396
|
+
clearPromotedPreview() {
|
|
1397
|
+
if (this.previewGate.kind === "committed" && this.previewGate.promotedSeq !== void 0) this.previewGate = COMMITTED_WIDGET_PREVIEW_GATE;
|
|
1398
|
+
}
|
|
1336
1399
|
/** Shows nothing until a frame asked for from now on comes, or `capMs` passes. */
|
|
1337
1400
|
hideFramesUntilFresh(capMs) {
|
|
1338
1401
|
if (this.disposed) return;
|
|
1339
1402
|
this.hiddenUpTo = this.requestId;
|
|
1403
|
+
this.clearBufferedFrame();
|
|
1340
1404
|
this.dirty = true;
|
|
1341
1405
|
clearTimeout(this.hiddenTimer);
|
|
1342
1406
|
this.hiddenTimer = setTimeout(() => {
|
|
@@ -1360,7 +1424,7 @@ var RemoteComponent = class {
|
|
|
1360
1424
|
const renderSettings = this.getRenderSettings();
|
|
1361
1425
|
const renderSettingsKey = renderSettingsCacheKey(renderSettings);
|
|
1362
1426
|
if (!this.disposed && (this.dirty || width !== this.width || rows !== this.rows || hostMode !== this.hostMode || renderSettingsKey !== this.renderSettingsKey)) this.requestFrame(width, rows, hostMode, renderSettings, renderSettingsKey);
|
|
1363
|
-
if (this.hiddenUpTo !== void 0) {
|
|
1427
|
+
if (!canPaintWidgetFrame(this.previewGate, this.framePreviewSeq, this.hiddenUpTo !== void 0)) {
|
|
1364
1428
|
this.paintedFrame = void 0;
|
|
1365
1429
|
this.paintedRowKeys = void 0;
|
|
1366
1430
|
this.paintedFrameLayout = void 0;
|
|
@@ -1394,27 +1458,51 @@ var RemoteComponent = class {
|
|
|
1394
1458
|
if (this.paintedFrame === void 0) return void 0;
|
|
1395
1459
|
const rowKey = this.paintedRowKeys?.[Math.floor(event.y)];
|
|
1396
1460
|
const clickId = ++this.clickId;
|
|
1397
|
-
this.
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
...rowKey === void 0 ? {} : { rowKey },
|
|
1402
|
-
clickId,
|
|
1403
|
-
cancelsClicks: true,
|
|
1404
|
-
x: Math.max(0, Math.floor(event.x)),
|
|
1405
|
-
y: Math.max(0, Math.floor(event.y)),
|
|
1406
|
-
width: Math.max(0, Math.floor(event.width)),
|
|
1407
|
-
height: Math.max(0, Math.floor(event.height))
|
|
1461
|
+
const clickAckId = this.acksClicks ? ++this.clickAckId : void 0;
|
|
1462
|
+
if (clickAckId !== void 0) this.inFlightClicks.set(clickAckId, {
|
|
1463
|
+
afterInputId: this.inputRequestId,
|
|
1464
|
+
cancelled: false
|
|
1408
1465
|
});
|
|
1466
|
+
try {
|
|
1467
|
+
this.runtime.sendEngineCommand({
|
|
1468
|
+
type: "engine_custom_click",
|
|
1469
|
+
componentId: this.componentId,
|
|
1470
|
+
frame: this.paintedFrame,
|
|
1471
|
+
...rowKey === void 0 ? {} : { rowKey },
|
|
1472
|
+
clickId,
|
|
1473
|
+
cancelsClicks: true,
|
|
1474
|
+
...clickAckId === void 0 ? {} : { ackId: clickAckId },
|
|
1475
|
+
x: Math.max(0, Math.floor(event.x)),
|
|
1476
|
+
y: Math.max(0, Math.floor(event.y)),
|
|
1477
|
+
width: Math.max(0, Math.floor(event.width)),
|
|
1478
|
+
height: Math.max(0, Math.floor(event.height))
|
|
1479
|
+
});
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
if (clickAckId !== void 0) this.inFlightClicks.delete(clickAckId);
|
|
1482
|
+
throw error;
|
|
1483
|
+
}
|
|
1409
1484
|
const finish = (type) => {
|
|
1410
1485
|
if (this.disposed || this.retiredShowing !== void 0) return;
|
|
1486
|
+
const settleAckId = type === "engine_custom_click_settle" && this.acksClicks ? ++this.clickAckId : void 0;
|
|
1487
|
+
if (settleAckId !== void 0) this.inFlightClicks.set(settleAckId, {
|
|
1488
|
+
afterInputId: this.inputRequestId,
|
|
1489
|
+
cancelled: false
|
|
1490
|
+
});
|
|
1411
1491
|
try {
|
|
1412
|
-
this.runtime.sendEngineCommand({
|
|
1492
|
+
if (type === "engine_custom_click_settle") this.runtime.sendEngineCommand({
|
|
1493
|
+
type,
|
|
1494
|
+
componentId: this.componentId,
|
|
1495
|
+
clickId,
|
|
1496
|
+
...settleAckId === void 0 ? {} : { ackId: settleAckId }
|
|
1497
|
+
});
|
|
1498
|
+
else this.runtime.sendEngineCommand({
|
|
1413
1499
|
type,
|
|
1414
1500
|
componentId: this.componentId,
|
|
1415
1501
|
clickId
|
|
1416
1502
|
});
|
|
1417
|
-
} catch {
|
|
1503
|
+
} catch {
|
|
1504
|
+
if (settleAckId !== void 0) this.inFlightClicks.delete(settleAckId);
|
|
1505
|
+
}
|
|
1418
1506
|
};
|
|
1419
1507
|
return {
|
|
1420
1508
|
handled: true,
|
|
@@ -1432,7 +1520,8 @@ var RemoteComponent = class {
|
|
|
1432
1520
|
this.pendingInputs.set(requestId, {
|
|
1433
1521
|
resolve,
|
|
1434
1522
|
timer,
|
|
1435
|
-
frameRequestId
|
|
1523
|
+
frameRequestId,
|
|
1524
|
+
data
|
|
1436
1525
|
});
|
|
1437
1526
|
});
|
|
1438
1527
|
try {
|
|
@@ -1473,6 +1562,9 @@ var RemoteComponent = class {
|
|
|
1473
1562
|
...renderSettings === void 0 ? {} : { renderSettings }
|
|
1474
1563
|
});
|
|
1475
1564
|
}
|
|
1565
|
+
resolveClick(ackId) {
|
|
1566
|
+
this.inFlightClicks.delete(ackId);
|
|
1567
|
+
}
|
|
1476
1568
|
resolveInput(requestId, handled) {
|
|
1477
1569
|
const pending = this.pendingInputs.get(requestId);
|
|
1478
1570
|
if (!pending) return;
|
|
@@ -1493,6 +1585,35 @@ var RemoteComponent = class {
|
|
|
1493
1585
|
clearTimeout(pending.timer);
|
|
1494
1586
|
pending.resolve(handled);
|
|
1495
1587
|
}
|
|
1588
|
+
/** Record that a host-level cancel key (`Esc`) was consumed while this component had inputs/clicks in flight. */
|
|
1589
|
+
noteHostCancel() {
|
|
1590
|
+
if (this.disposed || this.retiredShowing !== void 0) return;
|
|
1591
|
+
if (this.inputRequestId > this.cancelUpToInputId) this.cancelUpToInputId = this.inputRequestId;
|
|
1592
|
+
for (const click of this.inFlightClicks.values()) click.cancelled = true;
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* True when this component has an unanswered cancel input strictly after the triggering input (`minUnansweredId`),
|
|
1596
|
+
* an unanswered input predating a consumed host-level cancel, a physical `Esc`, or a cancel/host-cancel on an
|
|
1597
|
+
* unacknowledged in-flight click. Excludes `minUnansweredId` by identity so overlapping keybindings never
|
|
1598
|
+
* self-cancel, and removes finished clicks on `engine_custom_click_result` so non-opening clicks never arm cancels.
|
|
1599
|
+
*/
|
|
1600
|
+
hasUnansweredCancelInput(isCancel, isPhysicalEsc) {
|
|
1601
|
+
if (this.disposed || this.retiredShowing !== void 0) return false;
|
|
1602
|
+
for (const click of this.inFlightClicks.values()) if (click.cancelled) return true;
|
|
1603
|
+
let minUnansweredId;
|
|
1604
|
+
for (const requestId of this.pendingInputs.keys()) if (!this.answeredInputs.has(requestId)) {
|
|
1605
|
+
minUnansweredId = requestId;
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
if (minUnansweredId === void 0) return false;
|
|
1609
|
+
let inFlightClickBeforeOldest = false;
|
|
1610
|
+
for (const click of this.inFlightClicks.values()) if (click.afterInputId < minUnansweredId) {
|
|
1611
|
+
inFlightClickBeforeOldest = true;
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
for (const [requestId, pending] of this.pendingInputs) if (isUnansweredCancelMatch(this.answeredInputs.has(requestId), isCancel(pending.data), isPhysicalEsc(pending.data), requestId, minUnansweredId, this.cancelUpToInputId, inFlightClickBeforeOldest)) return true;
|
|
1615
|
+
return false;
|
|
1616
|
+
}
|
|
1496
1617
|
invalidate() {
|
|
1497
1618
|
this.dirty = true;
|
|
1498
1619
|
}
|
|
@@ -1511,6 +1632,8 @@ var RemoteComponent = class {
|
|
|
1511
1632
|
this.paintedFrame = void 0;
|
|
1512
1633
|
this.paintedRowKeys = void 0;
|
|
1513
1634
|
this.clickId++;
|
|
1635
|
+
this.cancelUpToInputId = 0;
|
|
1636
|
+
this.inFlightClicks.clear();
|
|
1514
1637
|
for (const requestId of [...this.pendingInputs.keys()]) this.resolveInput(requestId, void 0);
|
|
1515
1638
|
return true;
|
|
1516
1639
|
}
|
|
@@ -1531,15 +1654,34 @@ var RemoteComponent = class {
|
|
|
1531
1654
|
const renderSettings = this.getRenderSettings();
|
|
1532
1655
|
this.requestFrame(width, rows, this.getHostMode(), renderSettings, renderSettingsCacheKey(renderSettings));
|
|
1533
1656
|
}
|
|
1534
|
-
applyFrame(requestId, lines, scrollRequest, frame, rowKeys, layout) {
|
|
1657
|
+
applyFrame(requestId, lines, scrollRequest, frame, rowKeys, layout, previewSeq) {
|
|
1535
1658
|
if (this.disposed || requestId < this.appliedRequestId) return;
|
|
1659
|
+
const decision = classifyWidgetFrame(this.previewGate, previewSeq);
|
|
1660
|
+
if (decision === "drop") {
|
|
1661
|
+
if (requestId === this.requestId) {
|
|
1662
|
+
this.dirty = true;
|
|
1663
|
+
this.requestRender();
|
|
1664
|
+
}
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1536
1667
|
this.appliedRequestId = requestId;
|
|
1668
|
+
if (decision === "accept-staged") {
|
|
1669
|
+
this.lines = lines;
|
|
1670
|
+
this.frame = frame;
|
|
1671
|
+
this.rowKeys = rowKeys;
|
|
1672
|
+
this.layout = layout;
|
|
1673
|
+
this.scrollRequest = scrollRequest;
|
|
1674
|
+
this.framePreviewSeq = this.previewGate.kind === "staged" ? this.previewGate.previewSeq : previewSeq;
|
|
1675
|
+
this.onFrame?.();
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1537
1678
|
if (this.hiddenUpTo !== void 0 && requestId > this.hiddenUpTo) this.showFramesAgain();
|
|
1538
1679
|
this.lines = lines;
|
|
1539
1680
|
this.frame = frame;
|
|
1540
1681
|
this.rowKeys = rowKeys;
|
|
1541
1682
|
this.layout = layout;
|
|
1542
1683
|
this.scrollRequest = scrollRequest;
|
|
1684
|
+
this.framePreviewSeq = void 0;
|
|
1543
1685
|
this.onFrame?.();
|
|
1544
1686
|
let answeredKey = false;
|
|
1545
1687
|
for (const inputId of [...this.answeredInputs]) {
|
|
@@ -1569,6 +1711,8 @@ var RemoteComponent = class {
|
|
|
1569
1711
|
dispose(notifyEngine = true) {
|
|
1570
1712
|
if (this.disposed) return;
|
|
1571
1713
|
this.disposed = true;
|
|
1714
|
+
this.cancelUpToInputId = 0;
|
|
1715
|
+
this.inFlightClicks.clear();
|
|
1572
1716
|
clearTimeout(this.hiddenTimer);
|
|
1573
1717
|
for (const requestId of [...this.pendingInputs.keys()]) this.resolveInput(requestId, void 0);
|
|
1574
1718
|
if (notifyEngine) this.runtime.sendEngineCommand({
|
|
@@ -1637,15 +1781,37 @@ function remoteTranscriptMount(runtime, viewId) {
|
|
|
1637
1781
|
return transcriptMounts.get(runtime)?.get(viewId);
|
|
1638
1782
|
}
|
|
1639
1783
|
const widgetFrameWatches = /* @__PURE__ */ new WeakMap();
|
|
1640
|
-
const controllers = /* @__PURE__ */ new WeakMap();
|
|
1784
|
+
const controllers$1 = /* @__PURE__ */ new WeakMap();
|
|
1785
|
+
/** Stage a speculative preview gate for `widgetKey` until commit or cancel. */
|
|
1786
|
+
function stageWidgetPreview(runtime, widgetKey, previewSeq, tagged) {
|
|
1787
|
+
controllers$1.get(runtime)?.stageWidgetPreview(widgetKey, previewSeq, tagged);
|
|
1788
|
+
}
|
|
1789
|
+
/** Promote a staged preview buffer for `widgetKey` so it paints immediately on commit. */
|
|
1790
|
+
function commitWidgetPreview(runtime, widgetKey, previewSeq) {
|
|
1791
|
+
controllers$1.get(runtime)?.commitWidgetPreview(widgetKey, previewSeq);
|
|
1792
|
+
}
|
|
1793
|
+
/** Revoke a staged speculative preview for `widgetKey` so its buffered and late frames never paint. */
|
|
1794
|
+
function cancelWidgetPreview(runtime, widgetKey, legacyHideCapMs) {
|
|
1795
|
+
controllers$1.get(runtime)?.cancelWidgetPreview(widgetKey, legacyHideCapMs);
|
|
1796
|
+
}
|
|
1797
|
+
/** Clear `promotedSeq` for `widgetKey` once the screen leaves the view that promoted a preview. */
|
|
1798
|
+
function clearPromotedWidgetPreview(runtime, widgetKey) {
|
|
1799
|
+
controllers$1.get(runtime)?.clearPromotedWidgetPreview(widgetKey);
|
|
1800
|
+
}
|
|
1801
|
+
/** Reset preview gate and hide state for `widgetKey` across engine generation replacement. */
|
|
1802
|
+
function resetWidgetPreview(runtime, widgetKey) {
|
|
1803
|
+
controllers$1.get(runtime)?.resetWidgetPreview(widgetKey);
|
|
1804
|
+
}
|
|
1641
1805
|
/**
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
* one that replaced it is waited for in turn. A widget open before the watch began does not count as opened.
|
|
1806
|
+
* True when the topmost live interactive component on `runtime` is a navigation view (`/tasks`) that already has an
|
|
1807
|
+
* unanswered cancel key in flight (or had an unanswered input in flight when a host-level cancel consumed `Esc`).
|
|
1645
1808
|
*/
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1809
|
+
function hasUnansweredNavigationCancelInput(runtime, isCancel, isPhysicalEsc) {
|
|
1810
|
+
return controllers$1.get(runtime)?.hasUnansweredNavigationCancelInput(isCancel, isPhysicalEsc) === true;
|
|
1811
|
+
}
|
|
1812
|
+
/** Record that a host-level `Esc` cancelled a pending open while the topmost live navigation component was mounted. */
|
|
1813
|
+
function noteNavigationHostCancel(runtime) {
|
|
1814
|
+
controllers$1.get(runtime)?.noteNavigationHostCancel();
|
|
1649
1815
|
}
|
|
1650
1816
|
function watchWidgetFrames(runtime, widgetKey) {
|
|
1651
1817
|
let watches = widgetFrameWatches.get(runtime);
|
|
@@ -1664,7 +1830,7 @@ function watchWidgetFrames(runtime, widgetKey) {
|
|
|
1664
1830
|
return {
|
|
1665
1831
|
drawn: async () => {
|
|
1666
1832
|
while (!stopped) {
|
|
1667
|
-
if (watch.opened && controllers.get(runtime)?.widgetWithoutFrame(widgetKey) !== true) return;
|
|
1833
|
+
if (watch.opened && controllers$1.get(runtime)?.widgetWithoutFrame(widgetKey) !== true) return;
|
|
1668
1834
|
await new Promise((resolve) => watch.waiters.push(resolve));
|
|
1669
1835
|
}
|
|
1670
1836
|
},
|
|
@@ -1714,11 +1880,11 @@ var RemoteComponentController = class {
|
|
|
1714
1880
|
this.terminalModes = new TerminalModeController(() => tuiRendererLifecycle.isFullscreen());
|
|
1715
1881
|
this.unsubscribeTuiRendererReplaced = tuiRendererLifecycle.onRendererReplaced(() => this.terminalModes.rebindTui());
|
|
1716
1882
|
this.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));
|
|
1717
|
-
controllers.set(runtime, this);
|
|
1883
|
+
controllers$1.set(runtime, this);
|
|
1718
1884
|
this.unsubscribeGenerationEnded = runtime.onGenerationEnded(() => this.disposeAll("generation-lost"));
|
|
1719
1885
|
}
|
|
1720
1886
|
dispose() {
|
|
1721
|
-
if (controllers.get(this.runtime) === this) controllers.delete(this.runtime);
|
|
1887
|
+
if (controllers$1.get(this.runtime) === this) controllers$1.delete(this.runtime);
|
|
1722
1888
|
this.unsubscribeTuiRendererReplaced();
|
|
1723
1889
|
this.unsubscribe();
|
|
1724
1890
|
this.unsubscribeGenerationEnded();
|
|
@@ -1780,7 +1946,55 @@ var RemoteComponentController = class {
|
|
|
1780
1946
|
this.hideOpening.set(widgetKey, performance.now() + capMs);
|
|
1781
1947
|
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.hideFramesUntilFresh(capMs);
|
|
1782
1948
|
}
|
|
1949
|
+
stageWidgetPreview(widgetKey, previewSeq, tagged) {
|
|
1950
|
+
this.hideOpening.delete(widgetKey);
|
|
1951
|
+
this.previewGates.set(widgetKey, {
|
|
1952
|
+
kind: "staged",
|
|
1953
|
+
previewSeq,
|
|
1954
|
+
tagged
|
|
1955
|
+
});
|
|
1956
|
+
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.stagePreview(previewSeq, tagged);
|
|
1957
|
+
}
|
|
1958
|
+
commitWidgetPreview(widgetKey, previewSeq) {
|
|
1959
|
+
this.hideOpening.delete(widgetKey);
|
|
1960
|
+
this.previewGates.set(widgetKey, {
|
|
1961
|
+
kind: "committed",
|
|
1962
|
+
promotedSeq: previewSeq
|
|
1963
|
+
});
|
|
1964
|
+
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.commitPreview(previewSeq);
|
|
1965
|
+
}
|
|
1966
|
+
cancelWidgetPreview(widgetKey, legacyHideCapMs) {
|
|
1967
|
+
this.previewGates.delete(widgetKey);
|
|
1968
|
+
if (legacyHideCapMs !== void 0) this.hideOpening.set(widgetKey, performance.now() + legacyHideCapMs);
|
|
1969
|
+
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.cancelPreview(legacyHideCapMs);
|
|
1970
|
+
}
|
|
1971
|
+
clearPromotedWidgetPreview(widgetKey) {
|
|
1972
|
+
const gate = this.previewGates.get(widgetKey);
|
|
1973
|
+
if (gate?.kind === "committed" && gate.promotedSeq !== void 0) this.previewGates.delete(widgetKey);
|
|
1974
|
+
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.clearPromotedPreview();
|
|
1975
|
+
}
|
|
1976
|
+
resetWidgetPreview(widgetKey) {
|
|
1977
|
+
this.previewGates.delete(widgetKey);
|
|
1978
|
+
this.hideOpening.delete(widgetKey);
|
|
1979
|
+
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey) record.component.cancelPreview();
|
|
1980
|
+
}
|
|
1981
|
+
topmostLiveNavigationComponent() {
|
|
1982
|
+
const records = [...this.mounted.values()];
|
|
1983
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
1984
|
+
const record = records[i];
|
|
1985
|
+
if (record.widgetKey !== void 0 || record.transcript !== void 0) continue;
|
|
1986
|
+
if (record.purpose !== "navigation" || record.engineDone) return void 0;
|
|
1987
|
+
return record.component;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
hasUnansweredNavigationCancelInput(isCancel, isPhysicalEsc) {
|
|
1991
|
+
return this.topmostLiveNavigationComponent()?.hasUnansweredCancelInput(isCancel, isPhysicalEsc) === true;
|
|
1992
|
+
}
|
|
1993
|
+
noteNavigationHostCancel() {
|
|
1994
|
+
this.topmostLiveNavigationComponent()?.noteHostCancel();
|
|
1995
|
+
}
|
|
1783
1996
|
hideOpening = /* @__PURE__ */ new Map();
|
|
1997
|
+
previewGates = /* @__PURE__ */ new Map();
|
|
1784
1998
|
/** Whether a widget open under `widgetKey` has not drawn its first frame yet. */
|
|
1785
1999
|
widgetWithoutFrame(widgetKey) {
|
|
1786
2000
|
for (const record of this.mounted.values()) if (record.widgetKey === widgetKey && record.component.awaitingFirstContent()) return true;
|
|
@@ -1814,6 +2028,8 @@ var RemoteComponentController = class {
|
|
|
1814
2028
|
* host mounts alone: the TUI is already stopping and must not repaint.
|
|
1815
2029
|
*/
|
|
1816
2030
|
disposeAll(reason) {
|
|
2031
|
+
this.previewGates.clear();
|
|
2032
|
+
this.hideOpening.clear();
|
|
1817
2033
|
for (const stop of [...this.panelReturns]) stop();
|
|
1818
2034
|
this.releaseRetiredPanel(void 0, false);
|
|
1819
2035
|
const records = [...this.mounted.entries()].reverse();
|
|
@@ -1836,14 +2052,14 @@ var RemoteComponentController = class {
|
|
|
1836
2052
|
this.disposeAll("generation-lost");
|
|
1837
2053
|
break;
|
|
1838
2054
|
case "engine_custom_open":
|
|
1839
|
-
this.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement, message.handlesCtrlC === true, message.handlesInternalUiAction === true, message.reserveTranscriptRows === true, message.purpose, message.widgetScroll, message.blocked, message.placement === "transcript" ? message.viewId : void 0);
|
|
2055
|
+
this.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement, message.handlesCtrlC === true, message.handlesInternalUiAction === true, message.reserveTranscriptRows === true, message.purpose, message.widgetScroll, message.blocked, message.placement === "transcript" ? message.viewId : void 0, message.acksClicks === true);
|
|
1840
2056
|
break;
|
|
1841
2057
|
case "engine_custom_close":
|
|
1842
2058
|
this.close(message.componentId);
|
|
1843
2059
|
break;
|
|
1844
2060
|
case "engine_custom_frame": {
|
|
1845
2061
|
const record = this.mounted.get(message.componentId);
|
|
1846
|
-
record?.component.applyFrame(message.requestId, message.lines, message.scrollRequest, message.frame, message.rowKeys, message.layout);
|
|
2062
|
+
record?.component.applyFrame(message.requestId, message.lines, message.scrollRequest, message.frame, message.rowKeys, message.layout, message.previewSeq);
|
|
1847
2063
|
if (record?.widgetKey !== void 0) this.checkWidgetFrames();
|
|
1848
2064
|
else if (this.retiredPanel !== void 0) this.releaseRetiredPanelWhenDrawn();
|
|
1849
2065
|
break;
|
|
@@ -1851,6 +2067,9 @@ var RemoteComponentController = class {
|
|
|
1851
2067
|
case "engine_custom_input_result":
|
|
1852
2068
|
this.mounted.get(message.componentId)?.component.resolveInput(message.requestId, message.handled);
|
|
1853
2069
|
break;
|
|
2070
|
+
case "engine_custom_click_result":
|
|
2071
|
+
this.mounted.get(message.componentId)?.component.resolveClick(message.ackId);
|
|
2072
|
+
break;
|
|
1854
2073
|
case "engine_custom_invalidate":
|
|
1855
2074
|
this.mounted.get(message.componentId)?.component.requestRemoteRender();
|
|
1856
2075
|
break;
|
|
@@ -1887,7 +2106,7 @@ var RemoteComponentController = class {
|
|
|
1887
2106
|
case "engine_custom_control": this.control(message.componentId, message.action);
|
|
1888
2107
|
}
|
|
1889
2108
|
}
|
|
1890
|
-
open(componentId, overlay, deferInlineCustomUiFocus, options, widgetKey, widgetPlacement, handlesCtrlC = false, handlesInternalUiAction = false, reserveTranscriptRows = false, purpose, widgetScroll, blocked, transcriptViewId) {
|
|
2109
|
+
open(componentId, overlay, deferInlineCustomUiFocus, options, widgetKey, widgetPlacement, handlesCtrlC = false, handlesInternalUiAction = false, reserveTranscriptRows = false, purpose, widgetScroll, blocked, transcriptViewId, acksClicks = false) {
|
|
1891
2110
|
if (this.mounted.has(componentId)) return;
|
|
1892
2111
|
if (transcriptViewId !== void 0) {
|
|
1893
2112
|
this.openTranscript(componentId, transcriptViewId);
|
|
@@ -1908,6 +2127,9 @@ var RemoteComponentController = class {
|
|
|
1908
2127
|
unsubscribeWidgetRelease
|
|
1909
2128
|
});
|
|
1910
2129
|
for (const watch of widgetFrameWatches.get(this.runtime) ?? []) if (watch.widgetKey === widgetKey) watch.opened = true;
|
|
2130
|
+
const previewGate = this.previewGates.get(widgetKey);
|
|
2131
|
+
if (previewGate?.kind === "staged") component.stagePreview(previewGate.previewSeq, previewGate.tagged);
|
|
2132
|
+
else if (previewGate?.kind === "committed" && previewGate.promotedSeq !== void 0) component.commitPreview(previewGate.promotedSeq);
|
|
1911
2133
|
const hideFor = (this.hideOpening.get(widgetKey) ?? 0) - performance.now();
|
|
1912
2134
|
if (hideFor > 0) component.hideFramesUntilFresh(hideFor);
|
|
1913
2135
|
if (widgetKey === "atomic.agent-panel" && this.retiredPanel !== void 0) {
|
|
@@ -1929,7 +2151,7 @@ var RemoteComponentController = class {
|
|
|
1929
2151
|
}
|
|
1930
2152
|
let mounted;
|
|
1931
2153
|
this.ui.custom((tui, _theme, _keybindings, done) => {
|
|
1932
|
-
const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows, () => this.hostMode(), handlesInternalUiAction, () => this.tuiRendererLifecycle.chatRenderSettings?.(), () => tui.requestImmediateRender());
|
|
2154
|
+
const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows, () => this.hostMode(), handlesInternalUiAction, () => this.tuiRendererLifecycle.chatRenderSettings?.(), () => tui.requestImmediateRender(), acksClicks);
|
|
1933
2155
|
component.hostColorDepth = tui.terminal?.colorDepth;
|
|
1934
2156
|
if (!overlay) awaitFirstContent(component, () => component.awaitingFirstContent());
|
|
1935
2157
|
mounted = {
|
|
@@ -1937,7 +2159,8 @@ var RemoteComponentController = class {
|
|
|
1937
2159
|
done,
|
|
1938
2160
|
engineDone: false,
|
|
1939
2161
|
handlesCtrlC,
|
|
1940
|
-
handlesInternalUiAction
|
|
2162
|
+
handlesInternalUiAction,
|
|
2163
|
+
purpose
|
|
1941
2164
|
};
|
|
1942
2165
|
this.mounted.set(componentId, mounted);
|
|
1943
2166
|
this.terminalModes.onMount(componentId, hostTerminal(tui));
|
|
@@ -12485,6 +12708,9 @@ const markdownParser = new Marked();
|
|
|
12485
12708
|
function isMermaid(token) {
|
|
12486
12709
|
return token.type === "code" && token.lang?.trim().split(/\s+/, 1)[0]?.toLowerCase() === "mermaid";
|
|
12487
12710
|
}
|
|
12711
|
+
function mightContainMermaidFence(markdown) {
|
|
12712
|
+
return (markdown.includes("```") || markdown.includes("~~~")) && markdown.toLowerCase().includes("mermaid");
|
|
12713
|
+
}
|
|
12488
12714
|
function codeSpan(line) {
|
|
12489
12715
|
const content = line || "\xA0";
|
|
12490
12716
|
const longestBacktickRun = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));
|
|
@@ -12518,7 +12744,7 @@ function themedLines(art, theme) {
|
|
|
12518
12744
|
function createMermaidMarkdownTransformer(options) {
|
|
12519
12745
|
return replayableMarkdownTransform((markdown, context) => {
|
|
12520
12746
|
const mode = options.getMode();
|
|
12521
|
-
if (mode === "off" || context.messageType !== "user" && context.messageType !== "assistant" && context.messageType !== "summary" || context.isStreaming && mode !== "streaming") return markdown;
|
|
12747
|
+
if (mode === "off" || context.messageType !== "user" && context.messageType !== "assistant" && context.messageType !== "summary" || context.isStreaming && mode !== "streaming" || !mightContainMermaidFence(markdown)) return markdown;
|
|
12522
12748
|
return markdownParser.lexer(markdown).map((token) => {
|
|
12523
12749
|
if (!isMermaid(token)) return token.raw;
|
|
12524
12750
|
let art;
|
|
@@ -12869,9 +13095,11 @@ var ProgramStatusReporter = class {
|
|
|
12869
13095
|
lastReport;
|
|
12870
13096
|
getTerminal;
|
|
12871
13097
|
getSessionName;
|
|
12872
|
-
|
|
13098
|
+
canReport;
|
|
13099
|
+
constructor(getTerminal, getSessionName, canReport = () => true) {
|
|
12873
13100
|
this.getTerminal = getTerminal;
|
|
12874
13101
|
this.getSessionName = getSessionName;
|
|
13102
|
+
this.canReport = canReport;
|
|
12875
13103
|
}
|
|
12876
13104
|
handleEvent(event) {
|
|
12877
13105
|
switch (event.type) {
|
|
@@ -12935,6 +13163,7 @@ var ProgramStatusReporter = class {
|
|
|
12935
13163
|
this.report();
|
|
12936
13164
|
}
|
|
12937
13165
|
report() {
|
|
13166
|
+
if (!this.canReport()) return;
|
|
12938
13167
|
const status = {
|
|
12939
13168
|
...this.currentStatus(),
|
|
12940
13169
|
app: APP_NAME
|
|
@@ -13070,7 +13299,7 @@ var InteractiveModeBase = class {
|
|
|
13070
13299
|
runtimeHost;
|
|
13071
13300
|
ui;
|
|
13072
13301
|
renderer;
|
|
13073
|
-
programStatus = new ProgramStatusReporter(() => this.ui.terminal, () => this.sessionManager.getSessionName());
|
|
13302
|
+
programStatus = new ProgramStatusReporter(() => this.ui.terminal, () => this.sessionManager.getSessionName(), () => !this.isShuttingDown && !this.terminalStopped);
|
|
13074
13303
|
resetTranscriptSelection() {
|
|
13075
13304
|
if (this.renderer.mode === "fullscreen") this.renderer.resetTextSelection();
|
|
13076
13305
|
}
|
|
@@ -13130,6 +13359,12 @@ var InteractiveModeBase = class {
|
|
|
13130
13359
|
disposeDeprecationWarningSink = () => {};
|
|
13131
13360
|
version;
|
|
13132
13361
|
isInitialized = false;
|
|
13362
|
+
/** Set while the TUI has started drawing and has not yet been stopped. */
|
|
13363
|
+
tuiStarted = false;
|
|
13364
|
+
/** Set once {@link stopInteractiveTui} has stopped the terminal, until a later start re-opens it. */
|
|
13365
|
+
terminalStopped = false;
|
|
13366
|
+
/** Set when an extension replaced the terminal title via `ctx.ui.setTitle`, until the default title is restored. */
|
|
13367
|
+
extensionTitleActive = false;
|
|
13133
13368
|
onInputCallback;
|
|
13134
13369
|
pendingUserInputs = [];
|
|
13135
13370
|
startupReplayInputs = [];
|
|
@@ -13371,6 +13606,8 @@ var InteractiveModeBase = class {
|
|
|
13371
13606
|
preserveScreen: isFullscreen && fullscreenExitOutput === "resume-hint",
|
|
13372
13607
|
writeInSlices: this.writeExitOutputInSlices
|
|
13373
13608
|
});
|
|
13609
|
+
this.tuiStarted = false;
|
|
13610
|
+
this.terminalStopped = true;
|
|
13374
13611
|
if (this.writeExitOutputInSlices) this.exitOutputWritten = this.ui.whenStopped();
|
|
13375
13612
|
this.disposeMarkitDiagnosticSink();
|
|
13376
13613
|
this.disposeDeprecationWarningSink();
|
|
@@ -13483,7 +13720,16 @@ var InteractiveModeBase = class {
|
|
|
13483
13720
|
};
|
|
13484
13721
|
}, this.keybindings, (event) => this.programStatus.handleUIPrompt(event));
|
|
13485
13722
|
const disposeSteeringRecovery = typeof this.attachSteeringEngineRecovery === "function" ? this.attachSteeringEngineRecovery() : () => {};
|
|
13723
|
+
const disposePostCrashRecovery = runtimeHost instanceof IsolatedInteractiveRuntime ? runtimeHost.onEngineRecovered((replaced) => {
|
|
13724
|
+
if (!replaced || this.isShuttingDown) return;
|
|
13725
|
+
const session = this.session;
|
|
13726
|
+
const generation = runtimeHost.getEngineGeneration();
|
|
13727
|
+
runtimeHost.startPendingRecoveryRestore("resume").catch(() => {
|
|
13728
|
+
if (this.session !== session || this.isShuttingDown || runtimeHost.getEngineGeneration() !== generation) return;
|
|
13729
|
+
});
|
|
13730
|
+
}) : () => {};
|
|
13486
13731
|
this.disposeInteractiveEngineHost = () => {
|
|
13732
|
+
disposePostCrashRecovery();
|
|
13487
13733
|
disposeSteeringRecovery();
|
|
13488
13734
|
disposeEngineHost();
|
|
13489
13735
|
};
|
|
@@ -14019,19 +14265,23 @@ async function openPort(runtime, taskId, frame, panelDrawn) {
|
|
|
14019
14265
|
let timer;
|
|
14020
14266
|
let panelTimer;
|
|
14021
14267
|
let settled = false;
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14268
|
+
let framed;
|
|
14269
|
+
try {
|
|
14270
|
+
framed = await Promise.race([mount.firstFrame().then(async (first) => {
|
|
14271
|
+
if (first && panelDrawn !== void 0 && !settled) await Promise.race([panelDrawn(), new Promise((resolve) => {
|
|
14272
|
+
panelTimer = setTimeout(resolve, 250);
|
|
14273
|
+
panelTimer.unref?.();
|
|
14274
|
+
})]);
|
|
14275
|
+
return first;
|
|
14276
|
+
}), new Promise((resolve) => {
|
|
14277
|
+
timer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);
|
|
14278
|
+
timer.unref?.();
|
|
14026
14279
|
})]);
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
timer
|
|
14030
|
-
|
|
14031
|
-
}
|
|
14032
|
-
settled = true;
|
|
14033
|
-
clearTimeout(timer);
|
|
14034
|
-
clearTimeout(panelTimer);
|
|
14280
|
+
} finally {
|
|
14281
|
+
settled = true;
|
|
14282
|
+
clearTimeout(timer);
|
|
14283
|
+
clearTimeout(panelTimer);
|
|
14284
|
+
}
|
|
14035
14285
|
if (!framed) {
|
|
14036
14286
|
port.retain()();
|
|
14037
14287
|
return;
|
|
@@ -15203,6 +15453,9 @@ var ChatReaderLayout = class {
|
|
|
15203
15453
|
atComponent = /* @__PURE__ */ new WeakMap();
|
|
15204
15454
|
byId;
|
|
15205
15455
|
original;
|
|
15456
|
+
plannedFrom = 0;
|
|
15457
|
+
indexedFrom = Number.POSITIVE_INFINITY;
|
|
15458
|
+
onChunkPlanned;
|
|
15206
15459
|
pendingMoves = /* @__PURE__ */ new Map();
|
|
15207
15460
|
queried = /* @__PURE__ */ new Set();
|
|
15208
15461
|
live = /* @__PURE__ */ new Set();
|
|
@@ -15236,29 +15489,75 @@ var ChatReaderLayout = class {
|
|
|
15236
15489
|
orderTargets() {
|
|
15237
15490
|
return [...new Set([...this.index().values()].flatMap((p) => p.orderTarget ? [p.orderTarget] : []))];
|
|
15238
15491
|
}
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15492
|
+
/** Record that only `source[from..]` has been planned so far; earlier slices call `advancePlannedFrom`. */
|
|
15493
|
+
beginSlicedPlan(from) {
|
|
15494
|
+
this.plannedFrom = Math.max(0, from);
|
|
15495
|
+
}
|
|
15496
|
+
/** Record that an earlier backward slice `[nextFrom, prevFrom)` has been planned and bound. */
|
|
15497
|
+
advancePlannedFrom(nextFrom) {
|
|
15498
|
+
const prev = this.plannedFrom;
|
|
15499
|
+
const clamped = Math.max(0, nextFrom);
|
|
15500
|
+
if (clamped >= prev) return;
|
|
15501
|
+
this.plannedFrom = clamped;
|
|
15502
|
+
if (this.onChunkPlanned) {
|
|
15503
|
+
const target = this.byId ?? /* @__PURE__ */ new Map();
|
|
15504
|
+
const added = this.indexSlice(clamped, prev, target);
|
|
15505
|
+
this.byId = target;
|
|
15506
|
+
this.indexedFrom = Math.min(this.indexedFrom, clamped);
|
|
15507
|
+
this.onChunkPlanned(clamped, added);
|
|
15508
|
+
if (clamped === 0) {
|
|
15509
|
+
this.original = void 0;
|
|
15510
|
+
this.onChunkPlanned = void 0;
|
|
15511
|
+
}
|
|
15512
|
+
}
|
|
15513
|
+
}
|
|
15514
|
+
indexSlice(from, to, target) {
|
|
15515
|
+
const source = this.original ?? [];
|
|
15516
|
+
const added = [];
|
|
15242
15517
|
let group;
|
|
15243
|
-
for (
|
|
15518
|
+
for (let i = from; i < to && i < source.length; i++) {
|
|
15519
|
+
const entry = source[i];
|
|
15244
15520
|
group = this.groups.get(entry.id) ?? group;
|
|
15245
|
-
|
|
15521
|
+
const pos = {
|
|
15246
15522
|
...chatPosition(entry),
|
|
15247
15523
|
group
|
|
15248
|
-
}
|
|
15524
|
+
};
|
|
15525
|
+
target.set(entry.id, pos);
|
|
15526
|
+
added.push(pos);
|
|
15249
15527
|
}
|
|
15250
|
-
this.original = void 0;
|
|
15251
15528
|
let next;
|
|
15252
|
-
for (
|
|
15529
|
+
for (let i = added.length - 1; i >= 0; i--) {
|
|
15530
|
+
const p = added[i];
|
|
15253
15531
|
if (p.role === "notice" && next?.parentId === p.id) p.orderTarget = next.role === "prompt" ? next.id : next.orderTarget;
|
|
15254
15532
|
if (p.orderTarget && next?.role === "prompt") next.orderTarget = next.id;
|
|
15255
15533
|
next = p;
|
|
15256
15534
|
}
|
|
15257
|
-
|
|
15535
|
+
return added;
|
|
15536
|
+
}
|
|
15537
|
+
index() {
|
|
15538
|
+
const positions = this.byId ?? /* @__PURE__ */ new Map();
|
|
15539
|
+
const len = this.original?.length ?? 0;
|
|
15540
|
+
if (!this.byId) {
|
|
15541
|
+
const start = this.plannedFrom;
|
|
15542
|
+
this.indexSlice(start, len, positions);
|
|
15543
|
+
this.byId = positions;
|
|
15544
|
+
this.indexedFrom = start;
|
|
15545
|
+
if (start === 0) this.original = void 0;
|
|
15546
|
+
return positions;
|
|
15547
|
+
}
|
|
15548
|
+
if (this.indexedFrom > this.plannedFrom) {
|
|
15549
|
+
this.indexSlice(this.plannedFrom, Math.min(this.indexedFrom, len), positions);
|
|
15550
|
+
this.indexedFrom = this.plannedFrom;
|
|
15551
|
+
}
|
|
15258
15552
|
return positions;
|
|
15259
15553
|
}
|
|
15260
15554
|
anchors() {
|
|
15261
|
-
return [...this.hasRoot ? [""] : [], ...this.
|
|
15555
|
+
if (this.byId && this.plannedFrom === 0 && this.indexedFrom === 0) return [...this.hasRoot ? [""] : [], ...this.byId.keys()];
|
|
15556
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15557
|
+
if (this.hasRoot) seen.add("");
|
|
15558
|
+
for (const entry of this.original ?? []) seen.add(entry.id);
|
|
15559
|
+
if (this.byId) for (const id of this.byId.keys()) seen.add(id);
|
|
15560
|
+
return [...seen];
|
|
15262
15561
|
}
|
|
15263
15562
|
observeWindowWhenPresent(chat, mount, request) {
|
|
15264
15563
|
if (typeof mount.present === "boolean") {
|
|
@@ -15275,18 +15574,45 @@ var ChatReaderLayout = class {
|
|
|
15275
15574
|
}
|
|
15276
15575
|
observeWindow(chat, mount, request) {
|
|
15277
15576
|
const groups = /* @__PURE__ */ new Map();
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15577
|
+
let leading = this.hasRoot ? [""] : [];
|
|
15578
|
+
let earliestGroup;
|
|
15579
|
+
const registerPositions = (positions, isEarliestPrefix) => {
|
|
15580
|
+
const localLeading = [];
|
|
15581
|
+
let firstInSlice;
|
|
15582
|
+
for (const p of positions) {
|
|
15583
|
+
if (p.group === void 0) {
|
|
15584
|
+
localLeading.push(p.id);
|
|
15585
|
+
continue;
|
|
15586
|
+
}
|
|
15587
|
+
if (firstInSlice === void 0) firstInSlice = p.group;
|
|
15588
|
+
const ids = groups.get(p.group);
|
|
15589
|
+
if (ids) ids.push(p.id);
|
|
15590
|
+
else groups.set(p.group, [p.id]);
|
|
15283
15591
|
}
|
|
15284
|
-
|
|
15285
|
-
if (
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15592
|
+
if (firstInSlice !== void 0) earliestGroup = firstInSlice;
|
|
15593
|
+
if (isEarliestPrefix) {
|
|
15594
|
+
const allLeading = leading.concat(localLeading);
|
|
15595
|
+
leading = [];
|
|
15596
|
+
if (earliestGroup !== void 0 && allLeading.length) groups.set(earliestGroup, allLeading.concat(groups.get(earliestGroup)));
|
|
15597
|
+
else leading = allLeading;
|
|
15598
|
+
} else if (localLeading.length && earliestGroup !== void 0) groups.set(earliestGroup, localLeading.concat(groups.get(earliestGroup)));
|
|
15599
|
+
};
|
|
15600
|
+
const positions = this.index();
|
|
15601
|
+
const initialPositions = [];
|
|
15602
|
+
if (this.original) for (let i = this.plannedFrom; i < this.original.length; i++) {
|
|
15603
|
+
const p = positions.get(this.original[i].id);
|
|
15604
|
+
if (p) initialPositions.push(p);
|
|
15605
|
+
}
|
|
15606
|
+
else for (const p of positions.values()) initialPositions.push(p);
|
|
15607
|
+
registerPositions(initialPositions, this.plannedFrom === 0);
|
|
15608
|
+
if (this.plannedFrom > 0) this.onChunkPlanned = (from, added) => {
|
|
15609
|
+
registerPositions(added, from === 0);
|
|
15610
|
+
if (from === 0) {
|
|
15611
|
+
if (earliestGroup === void 0 && leading.length) submit(leading);
|
|
15612
|
+
request();
|
|
15613
|
+
}
|
|
15614
|
+
};
|
|
15615
|
+
else this.original = void 0;
|
|
15290
15616
|
const queued = /* @__PURE__ */ new Set();
|
|
15291
15617
|
const submit = (ids) => {
|
|
15292
15618
|
const schedule = !queued.size;
|
|
@@ -15314,7 +15640,7 @@ var ChatReaderLayout = class {
|
|
|
15314
15640
|
if (chat.onVisibleChild === consume && this.apply(chat, data)) request();
|
|
15315
15641
|
} });
|
|
15316
15642
|
chat.onVisibleChild = consume;
|
|
15317
|
-
if (
|
|
15643
|
+
if (this.plannedFrom === 0 && earliestGroup === void 0) submit(leading);
|
|
15318
15644
|
request();
|
|
15319
15645
|
}
|
|
15320
15646
|
/** A billing component follows the boundary row if the reader chose to show costs. If no component is drawn,
|
|
@@ -17126,10 +17452,124 @@ InteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(text)
|
|
|
17126
17452
|
if (index === -1) return false;
|
|
17127
17453
|
this.deferredRenderedUserInputs.splice(index, 1);
|
|
17128
17454
|
const trackedComponents = this.deferredRenderedUserInputComponents.get(text);
|
|
17129
|
-
|
|
17455
|
+
const consumed = trackedComponents?.shift();
|
|
17456
|
+
forgetOriginEcho(this, consumed);
|
|
17457
|
+
forgetStartedEcho(this, text, consumed);
|
|
17130
17458
|
if (trackedComponents && trackedComponents.length === 0) this.deferredRenderedUserInputComponents.delete(text);
|
|
17131
17459
|
return true;
|
|
17132
17460
|
};
|
|
17461
|
+
/** Per chat, pending deferred echoes indexed by their ephemeral host origin send id. */
|
|
17462
|
+
const originEchoes = /* @__PURE__ */ new WeakMap();
|
|
17463
|
+
/** Reverse mapping from a pending echo's component array to its origin send id. */
|
|
17464
|
+
const echoOrigins = /* @__PURE__ */ new WeakMap();
|
|
17465
|
+
/** `taggedUserMessagesShownCount` snapshot captured alongside `shownBefore` for an echo's send. */
|
|
17466
|
+
const echoTaggedBaselines = /* @__PURE__ */ new WeakMap();
|
|
17467
|
+
/** Per chat, count of newly appended user messages (no echo matched) that carried an origin send id. */
|
|
17468
|
+
const taggedUserMessagesShown = /* @__PURE__ */ new WeakMap();
|
|
17469
|
+
/** Per chat, in-flight sends without a pre-rendered echo awaiting their prompt answer, by origin send id. */
|
|
17470
|
+
const awaitingOriginSends = /* @__PURE__ */ new WeakMap();
|
|
17471
|
+
/** Count of unmatched user messages with an origin send id shown so far on `mode`. */
|
|
17472
|
+
function taggedUserMessagesShownCount(mode) {
|
|
17473
|
+
return taggedUserMessagesShown.get(mode) ?? 0;
|
|
17474
|
+
}
|
|
17475
|
+
/**
|
|
17476
|
+
* Number of untagged user messages shown as new since `(shownBefore, taggedBefore)`.
|
|
17477
|
+
* Equal to `userMessagesShownBySession - shownBefore` when talking to an older engine that sends no origin ids, and
|
|
17478
|
+
* unaffected by tagged messages from other sends on a current engine.
|
|
17479
|
+
*/
|
|
17480
|
+
function untaggedUserMessagesShownSince(mode, shownBefore, taggedBefore) {
|
|
17481
|
+
return mode.userMessagesShownBySession - shownBefore - (taggedUserMessagesShownCount(mode) - taggedBefore);
|
|
17482
|
+
}
|
|
17483
|
+
/** Bind a pending deferred `echo` of `text` to host prompt send `originSendId`. */
|
|
17484
|
+
function noteDeferredEchoOrigin(mode, text, echo, originSendId, taggedBefore) {
|
|
17485
|
+
if (mode.deferredRenderedUserInputComponents?.get(text)?.includes(echo) !== true) return;
|
|
17486
|
+
let byOrigin = originEchoes.get(mode);
|
|
17487
|
+
if (byOrigin === void 0) {
|
|
17488
|
+
byOrigin = /* @__PURE__ */ new Map();
|
|
17489
|
+
originEchoes.set(mode, byOrigin);
|
|
17490
|
+
}
|
|
17491
|
+
byOrigin.set(originSendId, {
|
|
17492
|
+
text,
|
|
17493
|
+
echo
|
|
17494
|
+
});
|
|
17495
|
+
echoOrigins.set(echo, originSendId);
|
|
17496
|
+
if (taggedBefore !== void 0) echoTaggedBaselines.set(echo, taggedBefore);
|
|
17497
|
+
}
|
|
17498
|
+
/** Record the `taggedUserMessagesShownCount` baseline captured with `shownBefore` for `echo`. */
|
|
17499
|
+
function noteDeferredEchoShownBaseline(mode, echo, taggedBefore = taggedUserMessagesShownCount(mode)) {
|
|
17500
|
+
echoTaggedBaselines.set(echo, taggedBefore);
|
|
17501
|
+
}
|
|
17502
|
+
/**
|
|
17503
|
+
* Track an in-flight send without a pre-rendered echo (the busy-steer path) so `onAnswered` learns whether its own
|
|
17504
|
+
* `message_start` already arrived before the answer. Dispose in `finally` to retain nothing once settled.
|
|
17505
|
+
*/
|
|
17506
|
+
function beginPendingOriginSend(mode, originSendId) {
|
|
17507
|
+
let awaiting = awaitingOriginSends.get(mode);
|
|
17508
|
+
if (awaiting === void 0) {
|
|
17509
|
+
awaiting = /* @__PURE__ */ new Map();
|
|
17510
|
+
awaitingOriginSends.set(mode, awaiting);
|
|
17511
|
+
}
|
|
17512
|
+
const entry = { shown: false };
|
|
17513
|
+
awaiting.set(originSendId, entry);
|
|
17514
|
+
return {
|
|
17515
|
+
wasShown: () => entry.shown,
|
|
17516
|
+
dispose: () => {
|
|
17517
|
+
const current = awaitingOriginSends.get(mode);
|
|
17518
|
+
if (current === void 0) return;
|
|
17519
|
+
if (current.get(originSendId) === entry) current.delete(originSendId);
|
|
17520
|
+
if (current.size === 0) awaitingOriginSends.delete(mode);
|
|
17521
|
+
}
|
|
17522
|
+
};
|
|
17523
|
+
}
|
|
17524
|
+
function forgetOriginEcho(mode, echo) {
|
|
17525
|
+
if (echo === void 0) return;
|
|
17526
|
+
const origin = echoOrigins.get(echo);
|
|
17527
|
+
echoOrigins.delete(echo);
|
|
17528
|
+
echoTaggedBaselines.delete(echo);
|
|
17529
|
+
if (origin === void 0) return;
|
|
17530
|
+
const byOrigin = originEchoes.get(mode);
|
|
17531
|
+
if (byOrigin === void 0) return;
|
|
17532
|
+
if (byOrigin.get(origin)?.echo === echo) byOrigin.delete(origin);
|
|
17533
|
+
if (byOrigin.size === 0) originEchoes.delete(mode);
|
|
17534
|
+
}
|
|
17535
|
+
function pendingEchoComponentSet(mode) {
|
|
17536
|
+
const pending = /* @__PURE__ */ new Set();
|
|
17537
|
+
for (const echoes of mode.deferredRenderedUserInputComponents.values()) for (const echo of echoes) for (const component of echo) pending.add(component);
|
|
17538
|
+
return pending;
|
|
17539
|
+
}
|
|
17540
|
+
/**
|
|
17541
|
+
* Whether any non-echo row appears after `echo` in `mode.chatContainer` (for example an assistant reply, tool block,
|
|
17542
|
+
* earlier user message, or compaction boundary). Returns false when `echo` has no rendered components (such as minimal
|
|
17543
|
+
* test doubles whose `addMessageToChat` does not attach children), and true when rendered components are no longer
|
|
17544
|
+
* attached.
|
|
17545
|
+
*/
|
|
17546
|
+
function hasNonEchoRowsAfter(mode, echo) {
|
|
17547
|
+
if (echo.length === 0) return false;
|
|
17548
|
+
const children = mode.chatContainer.children;
|
|
17549
|
+
let lastEchoIndex = -1;
|
|
17550
|
+
for (const component of echo) {
|
|
17551
|
+
const index = children.indexOf(component);
|
|
17552
|
+
if (index > lastEchoIndex) lastEchoIndex = index;
|
|
17553
|
+
}
|
|
17554
|
+
if (lastEchoIndex === -1) return true;
|
|
17555
|
+
if (lastEchoIndex === children.length - 1) return false;
|
|
17556
|
+
const pending = pendingEchoComponentSet(mode);
|
|
17557
|
+
for (let index = lastEchoIndex + 1; index < children.length; index++) if (!pending.has(children[index])) return true;
|
|
17558
|
+
return false;
|
|
17559
|
+
}
|
|
17560
|
+
/**
|
|
17561
|
+
* Earliest component in the contiguous trailing suffix of pending deferred echoes at the end of `mode.chatContainer`,
|
|
17562
|
+
* or undefined if the tail ends with a non-echo row (such as an assistant reply, tool block, or compaction boundary).
|
|
17563
|
+
*/
|
|
17564
|
+
function trailingDeferredEchoAnchor(mode) {
|
|
17565
|
+
const children = mode.chatContainer.children;
|
|
17566
|
+
if (children.length === 0 || mode.deferredRenderedUserInputs.length === 0) return void 0;
|
|
17567
|
+
const pending = pendingEchoComponentSet(mode);
|
|
17568
|
+
if (pending.size === 0) return void 0;
|
|
17569
|
+
let start = children.length;
|
|
17570
|
+
while (start > 0 && pending.has(children[start - 1])) start--;
|
|
17571
|
+
return start < children.length ? children[start] : void 0;
|
|
17572
|
+
}
|
|
17133
17573
|
/**
|
|
17134
17574
|
* Per chat, the echoes of the submissions that started runs, oldest first, each until its run shows its message. A run
|
|
17135
17575
|
* begins with the message, which may carry other text than the echo when an `input` hook rewrote it (#4277).
|
|
@@ -17175,6 +17615,7 @@ function forgetDeferredEcho(mode, text, echo) {
|
|
|
17175
17615
|
const index = nthIndexOf(mode.deferredRenderedUserInputs, text, rank);
|
|
17176
17616
|
if (index !== -1) mode.deferredRenderedUserInputs.splice(index, 1);
|
|
17177
17617
|
const components = trackedComponents?.splice(rank, 1)[0];
|
|
17618
|
+
forgetOriginEcho(mode, components ?? echo);
|
|
17178
17619
|
if (index !== -1 || components !== void 0) forgetStartedEcho(mode, text, components ?? echo);
|
|
17179
17620
|
if (trackedComponents && trackedComponents.length === 0) mode.deferredRenderedUserInputComponents.delete(text);
|
|
17180
17621
|
return components;
|
|
@@ -17188,17 +17629,22 @@ function takeDeferredEchoes(mode) {
|
|
|
17188
17629
|
return {
|
|
17189
17630
|
text,
|
|
17190
17631
|
epoch: components ? echoReadEpochs.get(components) : void 0,
|
|
17191
|
-
components
|
|
17632
|
+
components,
|
|
17633
|
+
origin: components ? echoOrigins.get(components) : void 0,
|
|
17634
|
+
taggedBefore: components ? echoTaggedBaselines.get(components) : void 0
|
|
17192
17635
|
};
|
|
17193
17636
|
});
|
|
17194
17637
|
mode.deferredRenderedUserInputs = [];
|
|
17195
17638
|
mode.deferredRenderedUserInputComponents.clear();
|
|
17639
|
+
originEchoes.delete(mode);
|
|
17196
17640
|
return echoes;
|
|
17197
17641
|
}
|
|
17198
17642
|
function restoreDeferredEchoes(mode, echoes) {
|
|
17199
|
-
for (const { text, epoch, components } of echoes) {
|
|
17643
|
+
for (const { text, epoch, components, origin, taggedBefore } of echoes) {
|
|
17200
17644
|
const echo = mode.renderDeferredUserInput(text, components);
|
|
17201
17645
|
if (epoch !== void 0) echoReadEpochs.set(echo, epoch);
|
|
17646
|
+
if (origin !== void 0) noteDeferredEchoOrigin(mode, text, echo, origin, taggedBefore);
|
|
17647
|
+
else if (taggedBefore !== void 0) echoTaggedBaselines.set(echo, taggedBefore);
|
|
17202
17648
|
}
|
|
17203
17649
|
}
|
|
17204
17650
|
InteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(text, echo) {
|
|
@@ -17220,14 +17666,17 @@ InteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(text,
|
|
|
17220
17666
|
* The session started a run for a submission this host echoed as `text`. The run begins with the submission's message,
|
|
17221
17667
|
* as sent: an `input` hook may have rewritten it, so its `message_start` need not match the echo (#4277). An engine's
|
|
17222
17668
|
* answer can reach the host after that `message_start`, which the session then showed itself (#4272): if it showed any
|
|
17223
|
-
* message of its own since `shownBefore`, the echo goes. Otherwise the session's next message
|
|
17224
|
-
*
|
|
17225
|
-
*
|
|
17669
|
+
* untagged message of its own since `shownBefore`, the echo goes. Otherwise the session's next matching message takes
|
|
17670
|
+
* the echo's place. A run starts only after the one before it showed its message, so an earlier run still waiting here
|
|
17671
|
+
* never got to show it, and its echo stays as it is.
|
|
17226
17672
|
*/
|
|
17227
17673
|
InteractiveModeBase.prototype.expectStartedUserInput = function(text, shownBefore, echo) {
|
|
17228
17674
|
if (!this.deferredRenderedUserInputs.includes(text)) return;
|
|
17229
17675
|
if (echo !== void 0 && this.deferredRenderedUserInputComponents.get(text)?.includes(echo) !== true) return;
|
|
17230
|
-
|
|
17676
|
+
const taggedBefore = echo !== void 0 ? echoTaggedBaselines.get(echo) : void 0;
|
|
17677
|
+
const untaggedDelta = taggedBefore === void 0 ? this.userMessagesShownBySession - shownBefore : untaggedUserMessagesShownSince(this, shownBefore, taggedBefore);
|
|
17678
|
+
const stalePosition = echo !== void 0 && this.chatContainer !== void 0 && hasNonEchoRowsAfter(this, echo);
|
|
17679
|
+
if (untaggedDelta !== 0 || stalePosition) this.discardDeferredRenderedUserInput(text, echo);
|
|
17231
17680
|
else startedEchoesOf(this).push({
|
|
17232
17681
|
text,
|
|
17233
17682
|
echo
|
|
@@ -17282,7 +17731,7 @@ function followStartedRunEcho(mode, text, options) {
|
|
|
17282
17731
|
}
|
|
17283
17732
|
const echoEvent = startedRunEchoEvent(event);
|
|
17284
17733
|
if (echoEvent === void 0 || earlierRun && echoEvent.type !== "user-message") return;
|
|
17285
|
-
if (echoEvent.type === "user-message" && event.type === "message_start" && !takeUserMessage(followers, event, text)) {
|
|
17734
|
+
if (echoEvent.type === "user-message" && event.type === "message_start" && !takeUserMessage(followers, event, text, options.originSendId)) {
|
|
17286
17735
|
if (state.kind === "awaiting-answer" && !state.userMessageShown) {
|
|
17287
17736
|
state = STARTED_RUN_ECHO_SENT;
|
|
17288
17737
|
earlierRun = true;
|
|
@@ -17308,20 +17757,76 @@ function followStartedRunEcho(mode, text, options) {
|
|
|
17308
17757
|
const echoFollowers = /* @__PURE__ */ new WeakMap();
|
|
17309
17758
|
/**
|
|
17310
17759
|
* Whether the follower of a message sent as `text` takes the user message `event` shows. A shown message is one sent
|
|
17311
|
-
* message's:
|
|
17312
|
-
*
|
|
17313
|
-
* that send's.
|
|
17760
|
+
* message's: when both carry an origin send id, only a matching origin takes it; otherwise the first follower still
|
|
17761
|
+
* waiting for it takes it, so another send of the same text, whose run may show no message of its own (#5135), still
|
|
17762
|
+
* decides its own echo (#6126). A message shown in place of another text's echo is that send's.
|
|
17314
17763
|
*/
|
|
17315
|
-
function takeUserMessage(followers, event, text) {
|
|
17764
|
+
function takeUserMessage(followers, event, text, originSendId) {
|
|
17765
|
+
const messageOrigin = userMessageOrigin(event.message);
|
|
17766
|
+
if (messageOrigin !== void 0 && originSendId !== void 0 && messageOrigin !== originSendId) return false;
|
|
17316
17767
|
const replaced = followers.echoes.get(event.message);
|
|
17317
17768
|
if (typeof replaced === "string" && replaced !== text) return false;
|
|
17318
17769
|
if (followers.taken.has(event)) return false;
|
|
17319
17770
|
followers.taken.add(event);
|
|
17320
17771
|
return true;
|
|
17321
17772
|
}
|
|
17322
|
-
/**
|
|
17773
|
+
/** Replace a pending deferred echo in place with `message`, keeping message-counter accounting intact. */
|
|
17774
|
+
function replaceDeferredEchoWithMessage(mode, message, echoText, echo, started) {
|
|
17775
|
+
echoFollowers.get(mode)?.echoes.set(message, echoText);
|
|
17776
|
+
const renderer = mode.ui;
|
|
17777
|
+
const following = renderer.isFollowingOutput !== false;
|
|
17778
|
+
const countedBefore = countChatMessages(mode.chatContainer);
|
|
17779
|
+
renderer.newMessages?.observe(following, countedBefore);
|
|
17780
|
+
const removed = forgetDeferredEcho(mode, echoText, echo);
|
|
17781
|
+
if (started !== void 0) {
|
|
17782
|
+
const waiting = startedEchoesOf(mode);
|
|
17783
|
+
if (waiting[0] === started) waiting.shift();
|
|
17784
|
+
}
|
|
17785
|
+
appendNewChildrenBeforeAttachedChild(mode.chatContainer, removed?.[0], () => mode.addMessageToChat(message));
|
|
17786
|
+
for (const component of removed ?? []) mode.chatContainer.removeChild(component);
|
|
17787
|
+
const counted = countChatMessages(mode.chatContainer);
|
|
17788
|
+
const counter = renderer.newMessages;
|
|
17789
|
+
if (!following && counter && removed && echoReadEpochs.get(removed) === counter.epoch) counter.retract(countedBefore - counted);
|
|
17790
|
+
counter?.replaced(counted);
|
|
17791
|
+
mode.updatePendingMessagesDisplay();
|
|
17792
|
+
mode.ui.requestRender();
|
|
17793
|
+
}
|
|
17794
|
+
/**
|
|
17795
|
+
* Show a user message from the session: when it carries an origin send id, consume or replace only that exact send's
|
|
17796
|
+
* echo (or insert before later pending echoes if none exists); otherwise fall back to text then oldest started run.
|
|
17797
|
+
*/
|
|
17323
17798
|
InteractiveModeBase.prototype.showSessionUserMessage = function(message) {
|
|
17324
17799
|
const text = this.getUserMessageText(message);
|
|
17800
|
+
const origin = userMessageOrigin(message);
|
|
17801
|
+
if (origin !== void 0) {
|
|
17802
|
+
const matched = originEchoes.get(this)?.get(origin);
|
|
17803
|
+
if (matched !== void 0) {
|
|
17804
|
+
if (hasNonEchoRowsAfter(this, matched.echo)) {
|
|
17805
|
+
echoFollowers.get(this)?.echoes.set(message, matched.text);
|
|
17806
|
+
this.discardDeferredRenderedUserInput(matched.text, matched.echo);
|
|
17807
|
+
this.addMessageToChat(message);
|
|
17808
|
+
return;
|
|
17809
|
+
}
|
|
17810
|
+
if (matched.text === text) {
|
|
17811
|
+
const kept = forgetDeferredEcho(this, matched.text, matched.echo);
|
|
17812
|
+
echoFollowers.get(this)?.echoes.set(message, matched.text);
|
|
17813
|
+
for (const component of kept ?? matched.echo) noteRowSource(component, {
|
|
17814
|
+
message,
|
|
17815
|
+
part: 0
|
|
17816
|
+
});
|
|
17817
|
+
return;
|
|
17818
|
+
}
|
|
17819
|
+
replaceDeferredEchoWithMessage(this, message, matched.text, matched.echo);
|
|
17820
|
+
return;
|
|
17821
|
+
}
|
|
17822
|
+
const awaiting = awaitingOriginSends.get(this)?.get(origin);
|
|
17823
|
+
if (awaiting !== void 0) awaiting.shown = true;
|
|
17824
|
+
echoFollowers.get(this)?.echoes.set(message, null);
|
|
17825
|
+
this.userMessagesShownBySession += 1;
|
|
17826
|
+
taggedUserMessagesShown.set(this, taggedUserMessagesShownCount(this) + 1);
|
|
17827
|
+
appendNewChildrenBeforeAttachedChild(this.chatContainer, trailingDeferredEchoAnchor(this), () => this.addMessageToChat(message));
|
|
17828
|
+
return;
|
|
17829
|
+
}
|
|
17325
17830
|
const echo = this.deferredRenderedUserInputComponents?.get(text)?.[0];
|
|
17326
17831
|
if (this.consumeDeferredRenderedUserInput(text)) {
|
|
17327
17832
|
echoFollowers.get(this)?.echoes.set(message, text);
|
|
@@ -17333,22 +17838,7 @@ InteractiveModeBase.prototype.showSessionUserMessage = function(message) {
|
|
|
17333
17838
|
}
|
|
17334
17839
|
const started = startedEchoes.get(this)?.[0];
|
|
17335
17840
|
if (started !== void 0) {
|
|
17336
|
-
|
|
17337
|
-
const renderer = this.ui;
|
|
17338
|
-
const following = renderer.isFollowingOutput !== false;
|
|
17339
|
-
const countedBefore = countChatMessages(this.chatContainer);
|
|
17340
|
-
renderer.newMessages?.observe(following, countedBefore);
|
|
17341
|
-
const echo = forgetDeferredEcho(this, started.text, started.echo);
|
|
17342
|
-
const waiting = startedEchoesOf(this);
|
|
17343
|
-
if (waiting[0] === started) waiting.shift();
|
|
17344
|
-
appendNewChildrenBeforeAttachedChild(this.chatContainer, echo?.[0], () => this.addMessageToChat(message));
|
|
17345
|
-
for (const component of echo ?? []) this.chatContainer.removeChild(component);
|
|
17346
|
-
const counted = countChatMessages(this.chatContainer);
|
|
17347
|
-
const counter = renderer.newMessages;
|
|
17348
|
-
if (!following && counter && echo && echoReadEpochs.get(echo) === counter.epoch) counter.retract(countedBefore - counted);
|
|
17349
|
-
counter?.replaced(counted);
|
|
17350
|
-
this.updatePendingMessagesDisplay();
|
|
17351
|
-
this.ui.requestRender();
|
|
17841
|
+
replaceDeferredEchoWithMessage(this, message, started.text, started.echo, started);
|
|
17352
17842
|
return;
|
|
17353
17843
|
}
|
|
17354
17844
|
echoFollowers.get(this)?.echoes.set(message, null);
|
|
@@ -17618,9 +18108,61 @@ function paintReplyNotices(mode, notes) {
|
|
|
17618
18108
|
const miss = missForOccurrence(notes);
|
|
17619
18109
|
if (miss) mode.chatContainer.addChild(new Text$1(theme.fg("warning", formatCacheMissNotice(miss)), 1, 0));
|
|
17620
18110
|
}
|
|
17621
|
-
const TAIL_STEPS =
|
|
18111
|
+
const TAIL_STEPS = 32;
|
|
18112
|
+
const PARKED_TAIL_STEPS = 128;
|
|
18113
|
+
const TAIL_PLAN_ENTRIES = 32;
|
|
18114
|
+
const HISTORY_PLAN_CHUNK_ENTRIES = 64;
|
|
18115
|
+
const MAX_TAIL_SCAN_ENTRIES = 512;
|
|
18116
|
+
const EDITOR_PROMPT_HISTORY_LIMIT = 100;
|
|
17622
18117
|
const HISTORY_SLICE_BUDGET_MS = 8;
|
|
17623
18118
|
const HISTORY_SLICE_STEPS = 24;
|
|
18119
|
+
function isCleanUserTurnEntry(entry) {
|
|
18120
|
+
if (entry.type !== "message" || entry.message.role !== "user") return false;
|
|
18121
|
+
return extractMessageText(normalizeMessageContent(entry.message).content).trim().length > 0;
|
|
18122
|
+
}
|
|
18123
|
+
/**
|
|
18124
|
+
* Find a sound split index `cut` in `(0, end)` so `entries.slice(cut, end)` can be planned independently without
|
|
18125
|
+
* affecting tool-call pairing, aborted-turn settlement, tool grouping, or notice-before-prompt ordering. Returns 0
|
|
18126
|
+
* when no clean boundary exists within `maxScan` entries (falling back to planning the whole range together).
|
|
18127
|
+
*/
|
|
18128
|
+
function findSafeHistorySplit(entries, end, targetEntries, maxScan) {
|
|
18129
|
+
if (end <= targetEntries) return 0;
|
|
18130
|
+
const minIndex = Math.max(1, end - maxScan);
|
|
18131
|
+
const unmatchedResults = /* @__PURE__ */ new Set();
|
|
18132
|
+
let fallbackCut = 0;
|
|
18133
|
+
for (let i = end - 1; i >= minIndex; i--) {
|
|
18134
|
+
const entry = entries[i];
|
|
18135
|
+
if (entry.type === "message") {
|
|
18136
|
+
const msg = entry.message;
|
|
18137
|
+
if (msg.role === "toolResult") unmatchedResults.add(msg.toolCallId);
|
|
18138
|
+
else if (msg.role === "assistant") {
|
|
18139
|
+
if (msg.stopReason === "aborted" || msg.stopReason === "error") return 0;
|
|
18140
|
+
if (Array.isArray(msg.content)) {
|
|
18141
|
+
for (const block of msg.content) if (block.type === "toolCall") unmatchedResults.delete(block.id);
|
|
18142
|
+
}
|
|
18143
|
+
} else if (msg.role === "user" && unmatchedResults.size === 0 && isCleanUserTurnEntry(entry) && chatPosition(entries[i - 1]).role !== "notice") {
|
|
18144
|
+
if (end - i >= targetEntries) return i;
|
|
18145
|
+
fallbackCut = i;
|
|
18146
|
+
}
|
|
18147
|
+
}
|
|
18148
|
+
}
|
|
18149
|
+
return unmatchedResults.size === 0 ? fallbackCut : 0;
|
|
18150
|
+
}
|
|
18151
|
+
/**
|
|
18152
|
+
* Populate editor Up-arrow history with the last `EDITOR_PROMPT_HISTORY_LIMIT` adjacent-deduplicated user prompts,
|
|
18153
|
+
* scanning from the tail instead of replaying every user turn in a huge transcript.
|
|
18154
|
+
*/
|
|
18155
|
+
function populateRecentPromptHistory(mode, sessionEntries) {
|
|
18156
|
+
const recent = [];
|
|
18157
|
+
for (let i = sessionEntries.length - 1; i >= 0 && recent.length < EDITOR_PROMPT_HISTORY_LIMIT; i--) {
|
|
18158
|
+
const entry = sessionEntries[i];
|
|
18159
|
+
if (entry.type !== "message" || entry.message.role !== "user") continue;
|
|
18160
|
+
const text = extractMessageText(normalizeMessageContent(entry.message).content).trim();
|
|
18161
|
+
if (!text || recent.at(-1) === text) continue;
|
|
18162
|
+
recent.push(text);
|
|
18163
|
+
}
|
|
18164
|
+
for (let i = recent.length - 1; i >= 0; i--) addMainPromptHistory(mode.editor, recent[i]);
|
|
18165
|
+
}
|
|
17624
18166
|
/**
|
|
17625
18167
|
* Where a saved page's replies start from, as the whole chat reaches them: the request and the dropped thinking of
|
|
17626
18168
|
* the entries read right before the page. Without a reply among them or the start of the branch, the count is unknown.
|
|
@@ -17639,13 +18181,13 @@ function earlierReplies(earlier) {
|
|
|
17639
18181
|
}
|
|
17640
18182
|
function planTranscript(mode, sessionEntries, options, layout) {
|
|
17641
18183
|
const steps = [];
|
|
17642
|
-
const grouping = options.saved ? {
|
|
18184
|
+
const grouping = options.localGrouping ?? (options.saved ? {
|
|
17643
18185
|
tracker: new ToolGroupTracker({ groupBash: false }),
|
|
17644
18186
|
starts: /* @__PURE__ */ new Map(),
|
|
17645
18187
|
lastMember: void 0,
|
|
17646
18188
|
carriedBreak: false
|
|
17647
|
-
} : mainToolGrouping(mode);
|
|
17648
|
-
if (!options.saved) resetMainToolGroup(mode);
|
|
18189
|
+
} : mainToolGrouping(mode));
|
|
18190
|
+
if (!options.saved && !options.localGrouping) resetMainToolGroup(mode);
|
|
17649
18191
|
let messageBuffer = [];
|
|
17650
18192
|
const sources = layout ? [] : void 0;
|
|
17651
18193
|
const messageMeta = /* @__PURE__ */ new Map();
|
|
@@ -17669,7 +18211,7 @@ function planTranscript(mode, sessionEntries, options, layout) {
|
|
|
17669
18211
|
}
|
|
17670
18212
|
}
|
|
17671
18213
|
firstMessage = false;
|
|
17672
|
-
if (options.saved) grouping.tracker.break();
|
|
18214
|
+
if (options.saved || options.localGrouping) grouping.tracker.break();
|
|
17673
18215
|
else breakMainToolGroup(mode);
|
|
17674
18216
|
const saved = options.saved;
|
|
17675
18217
|
let occurrence = 0;
|
|
@@ -17703,7 +18245,7 @@ function planTranscript(mode, sessionEntries, options, layout) {
|
|
|
17703
18245
|
if (sources) sources.length = 0;
|
|
17704
18246
|
messageBuffer = [];
|
|
17705
18247
|
};
|
|
17706
|
-
const headers = new ReopenedCompletionHeaders(() => ({
|
|
18248
|
+
const headers = options.headers ?? new ReopenedCompletionHeaders(() => ({
|
|
17707
18249
|
entries: mode.sessionManager.getBranch(),
|
|
17708
18250
|
recovery: mode.sessionManager.getSessionRecoveryState()
|
|
17709
18251
|
}), isProxy);
|
|
@@ -17949,25 +18491,55 @@ function markRecordRows(rows, leaves, mark) {
|
|
|
17949
18491
|
mark(row, previous);
|
|
17950
18492
|
}
|
|
17951
18493
|
}
|
|
17952
|
-
function buildHistoryInSlices(mode, history, end, layout) {
|
|
18494
|
+
function buildHistoryInSlices(mode, history, end, layout, unplanned) {
|
|
17953
18495
|
const chat = mode.chatContainer;
|
|
17954
|
-
let
|
|
18496
|
+
let pendingSteps = history;
|
|
18497
|
+
let remaining = pendingSteps.length;
|
|
17955
18498
|
let before = end;
|
|
18499
|
+
const hasMore = () => remaining > 0 || unplanned !== void 0 && unplanned.remainingEnd > 0;
|
|
18500
|
+
const planNextChunk = (planAll) => {
|
|
18501
|
+
if (!unplanned || unplanned.remainingEnd <= 0) return;
|
|
18502
|
+
const chunkEnd = unplanned.remainingEnd;
|
|
18503
|
+
const chunkStart = planAll ? 0 : findSafeHistorySplit(unplanned.entries, chunkEnd, HISTORY_PLAN_CHUNK_ENTRIES, MAX_TAIL_SCAN_ENTRIES);
|
|
18504
|
+
const localGrouping = {
|
|
18505
|
+
tracker: new ToolGroupTracker({ groupBash: false }),
|
|
18506
|
+
starts: mainToolGrouping(mode).starts,
|
|
18507
|
+
lastMember: void 0,
|
|
18508
|
+
carriedBreak: false
|
|
18509
|
+
};
|
|
18510
|
+
const activeLayout = layout?.deref();
|
|
18511
|
+
const chunkSteps = planTranscript(mode, unplanned.entries.slice(chunkStart, chunkEnd), {
|
|
18512
|
+
populateHistory: false,
|
|
18513
|
+
localGrouping,
|
|
18514
|
+
headers: unplanned.headers
|
|
18515
|
+
}, activeLayout);
|
|
18516
|
+
unplanned.remainingEnd = chunkStart;
|
|
18517
|
+
activeLayout?.advancePlannedFrom(chunkStart);
|
|
18518
|
+
pendingSteps = chunkSteps;
|
|
18519
|
+
remaining = chunkSteps.length;
|
|
18520
|
+
};
|
|
17956
18521
|
const build = (budgetMs, maxSteps) => {
|
|
17957
18522
|
const at = chat.children.indexOf(before);
|
|
17958
|
-
if (at < 0 ||
|
|
18523
|
+
if (at < 0 || !hasMore()) return false;
|
|
18524
|
+
const finishAll = !Number.isFinite(budgetMs);
|
|
17959
18525
|
const deadline = performance.now() + budgetMs;
|
|
17960
18526
|
const built = [];
|
|
17961
18527
|
const preceding = new Spacer$1(0);
|
|
17962
18528
|
const scratch = new Container$1();
|
|
17963
18529
|
mode.chatContainer = scratch;
|
|
17964
18530
|
try {
|
|
17965
|
-
|
|
18531
|
+
let steps = 0;
|
|
18532
|
+
while (steps < maxSteps && hasMore()) {
|
|
18533
|
+
if (remaining === 0) {
|
|
18534
|
+
planNextChunk(finishAll);
|
|
18535
|
+
if (remaining === 0) continue;
|
|
18536
|
+
}
|
|
17966
18537
|
scratch.children = [preceding];
|
|
17967
|
-
const step =
|
|
18538
|
+
const step = pendingSteps[--remaining];
|
|
17968
18539
|
addTranscriptStep(mode, step, false);
|
|
17969
18540
|
layout?.deref()?.paint(step.kind === "cost" ? step : step.entry, scratch, 1);
|
|
17970
18541
|
built.push(scratch.children.slice(1));
|
|
18542
|
+
steps++;
|
|
17971
18543
|
if (performance.now() >= deadline) break;
|
|
17972
18544
|
}
|
|
17973
18545
|
} finally {
|
|
@@ -17982,7 +18554,7 @@ function buildHistoryInSlices(mode, history, end, layout) {
|
|
|
17982
18554
|
if (messages > 0) mode.ui.newMessages?.historyPrepended(messages);
|
|
17983
18555
|
mode.ui.requestRender();
|
|
17984
18556
|
}
|
|
17985
|
-
if (
|
|
18557
|
+
if (hasMore()) return true;
|
|
17986
18558
|
chat.removeChild(end);
|
|
17987
18559
|
return false;
|
|
17988
18560
|
};
|
|
@@ -18013,9 +18585,30 @@ InteractiveModeBase.prototype.renderSessionEntries = function(sessionEntries, op
|
|
|
18013
18585
|
let layout = mount ? new ChatReaderLayout(sessionEntries, chat) : void 0;
|
|
18014
18586
|
if (layout) bindChatLayout(this, layout);
|
|
18015
18587
|
if (layout && parked?.shownRecords) layout.keepShown(parked.shownRecords);
|
|
18016
|
-
const
|
|
18017
|
-
|
|
18018
|
-
let
|
|
18588
|
+
const splitIndex = !regular && !parked?.keys.size && !options.suppressCompactionBoundary && !this.settingsManager.getShowCacheMissNotices() && sessionEntries.length > TAIL_PLAN_ENTRIES ? findSafeHistorySplit(sessionEntries, sessionEntries.length, TAIL_PLAN_ENTRIES, MAX_TAIL_SCAN_ENTRIES) : 0;
|
|
18589
|
+
let steps;
|
|
18590
|
+
let unplanned;
|
|
18591
|
+
if (splitIndex > 0) {
|
|
18592
|
+
if (options.populateHistory) populateRecentPromptHistory(this, sessionEntries);
|
|
18593
|
+
layout?.beginSlicedPlan(splitIndex);
|
|
18594
|
+
const headers = new ReopenedCompletionHeaders(() => ({
|
|
18595
|
+
entries: this.sessionManager.getBranch(),
|
|
18596
|
+
recovery: this.sessionManager.getSessionRecoveryState()
|
|
18597
|
+
}), isProxy);
|
|
18598
|
+
steps = planTranscript(this, sessionEntries.slice(splitIndex), {
|
|
18599
|
+
...options,
|
|
18600
|
+
populateHistory: false,
|
|
18601
|
+
headers
|
|
18602
|
+
}, layout);
|
|
18603
|
+
unplanned = {
|
|
18604
|
+
entries: sessionEntries,
|
|
18605
|
+
remainingEnd: splitIndex,
|
|
18606
|
+
headers
|
|
18607
|
+
};
|
|
18608
|
+
} else steps = planTranscript(this, sessionEntries, options, layout);
|
|
18609
|
+
if (mount && layout) retainChatRecords(mount, () => layout?.anchors() ?? []);
|
|
18610
|
+
const initialTailSteps = parked?.keys.size ? PARKED_TAIL_STEPS : TAIL_STEPS;
|
|
18611
|
+
let tailStart = this.ui.mode === "fullscreen" ? Math.max(0, steps.length - initialTailSteps) : 0;
|
|
18019
18612
|
if (parked?.keys.size) {
|
|
18020
18613
|
const adopted = steps.findIndex((step) => {
|
|
18021
18614
|
const key = stepKey(step);
|
|
@@ -18029,10 +18622,10 @@ InteractiveModeBase.prototype.renderSessionEntries = function(sessionEntries, op
|
|
|
18029
18622
|
});
|
|
18030
18623
|
}
|
|
18031
18624
|
}
|
|
18032
|
-
if (tailStart > 0) {
|
|
18625
|
+
if (tailStart > 0 || unplanned !== void 0) {
|
|
18033
18626
|
const historyEnd = new Spacer$1(0);
|
|
18034
18627
|
this.chatContainer.addChild(historyEnd);
|
|
18035
|
-
buildHistoryInSlices(this, steps.slice(0, tailStart), historyEnd, layout && new WeakRef(layout));
|
|
18628
|
+
buildHistoryInSlices(this, steps.slice(0, tailStart), historyEnd, layout && new WeakRef(layout), unplanned);
|
|
18036
18629
|
}
|
|
18037
18630
|
const adoption = adoptions.get(this);
|
|
18038
18631
|
try {
|
|
@@ -18108,7 +18701,7 @@ InteractiveModeBase.prototype.renderInitialMessages = function() {
|
|
|
18108
18701
|
if (previousSessionId !== sessionId) renderer.newMessages?.reset();
|
|
18109
18702
|
this.attachStartupNoticesContainer({ resetDetached: true });
|
|
18110
18703
|
showNativeHistoryHint(this);
|
|
18111
|
-
const entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());
|
|
18704
|
+
const entries = typeof this.sessionManager.buildContextEntries === "function" ? this.sessionManager.buildContextEntries() : buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());
|
|
18112
18705
|
this.renderSessionEntries(entries, {
|
|
18113
18706
|
updateFooter: true,
|
|
18114
18707
|
populateHistory: true
|
|
@@ -18217,7 +18810,7 @@ InteractiveModeBase.prototype.rebuildChatFromMessages = function(options = {}) {
|
|
|
18217
18810
|
this.managedToolStatusStarted = false;
|
|
18218
18811
|
this.lastStatusSpacer = void 0;
|
|
18219
18812
|
this.lastStatusText = void 0;
|
|
18220
|
-
const entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());
|
|
18813
|
+
const entries = typeof this.sessionManager.buildContextEntries === "function" ? this.sessionManager.buildContextEntries() : buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());
|
|
18221
18814
|
if (this.chatContainer.children.length > 0) renderer.newMessages?.observe(renderer.isFollowingOutput !== false, countChatMessages(this.chatContainer));
|
|
18222
18815
|
const parked = parkViewport(this, entries);
|
|
18223
18816
|
holdCompactionWidgets(this, entries, parked);
|
|
@@ -18487,6 +19080,267 @@ InteractiveModeBase.prototype.startSessionRecovery = function(reason) {
|
|
|
18487
19080
|
InteractiveModeBase.prototype.getRegisteredToolDefinition = function(toolName) {
|
|
18488
19081
|
return this.session.extensionRunner.resolveToolRenderers(toolName, () => this.session.getToolDefinition(toolName));
|
|
18489
19082
|
};
|
|
19083
|
+
/**
|
|
19084
|
+
* Hard upper bound on deferral once the first provider request has actually been
|
|
19085
|
+
* dispatched (at `before-provider-request`) or streaming has started, and deferred
|
|
19086
|
+
* startup is complete. Never armed while `deferredStartupPending` is set or any
|
|
19087
|
+
* pre-request phase (hooks, OAuth refresh, model discovery, trust dialog) is running.
|
|
19088
|
+
*/
|
|
19089
|
+
const POST_STARTUP_MAX_DEFERRAL_MS = 1200;
|
|
19090
|
+
const controllers = /* @__PURE__ */ new WeakMap();
|
|
19091
|
+
function getOrCreateController(host) {
|
|
19092
|
+
let controller = controllers.get(host);
|
|
19093
|
+
if (!controller) {
|
|
19094
|
+
controller = {
|
|
19095
|
+
state: "idle",
|
|
19096
|
+
firstPromptPreflightDepth: 0,
|
|
19097
|
+
firstRequestDispatched: false,
|
|
19098
|
+
firstPromptSettled: false,
|
|
19099
|
+
quietTimer: void 0,
|
|
19100
|
+
maxDeferralTimer: void 0,
|
|
19101
|
+
unsubscribeStreaming: void 0,
|
|
19102
|
+
unsubscribeDispatch: void 0,
|
|
19103
|
+
abortController: void 0,
|
|
19104
|
+
runner: void 0
|
|
19105
|
+
};
|
|
19106
|
+
controllers.set(host, controller);
|
|
19107
|
+
}
|
|
19108
|
+
return controller;
|
|
19109
|
+
}
|
|
19110
|
+
function clearQuietTimer(controller) {
|
|
19111
|
+
if (controller.quietTimer !== void 0) {
|
|
19112
|
+
clearTimeout(controller.quietTimer);
|
|
19113
|
+
controller.quietTimer = void 0;
|
|
19114
|
+
}
|
|
19115
|
+
}
|
|
19116
|
+
function clearMaxDeferralTimer(controller) {
|
|
19117
|
+
if (controller.maxDeferralTimer !== void 0) {
|
|
19118
|
+
clearTimeout(controller.maxDeferralTimer);
|
|
19119
|
+
controller.maxDeferralTimer = void 0;
|
|
19120
|
+
}
|
|
19121
|
+
}
|
|
19122
|
+
function clearStreamingSubscription(controller) {
|
|
19123
|
+
if (controller.unsubscribeStreaming) {
|
|
19124
|
+
try {
|
|
19125
|
+
controller.unsubscribeStreaming();
|
|
19126
|
+
} catch {}
|
|
19127
|
+
controller.unsubscribeStreaming = void 0;
|
|
19128
|
+
}
|
|
19129
|
+
}
|
|
19130
|
+
function clearDispatchSubscription(controller) {
|
|
19131
|
+
if (controller.unsubscribeDispatch) {
|
|
19132
|
+
try {
|
|
19133
|
+
controller.unsubscribeDispatch();
|
|
19134
|
+
} catch {}
|
|
19135
|
+
controller.unsubscribeDispatch = void 0;
|
|
19136
|
+
}
|
|
19137
|
+
}
|
|
19138
|
+
function isIsolatedHost(host) {
|
|
19139
|
+
return runsInteractiveEngine(host.runtimeHost);
|
|
19140
|
+
}
|
|
19141
|
+
function isDeferredStartupActive(host) {
|
|
19142
|
+
return host.deferredStartupPending === true || host.deferredStartupPromise !== void 0;
|
|
19143
|
+
}
|
|
19144
|
+
function isGateBlocked(host, controller) {
|
|
19145
|
+
if (isIsolatedHost(host)) return false;
|
|
19146
|
+
return !controller.firstPromptSettled && controller.firstPromptPreflightDepth > 0 || isDeferredStartupActive(host);
|
|
19147
|
+
}
|
|
19148
|
+
function canArmMaxDeferralCap(host, controller) {
|
|
19149
|
+
return !host.isShuttingDown && !isDeferredStartupActive(host) && (controller.firstRequestDispatched || controller.firstPromptSettled);
|
|
19150
|
+
}
|
|
19151
|
+
function isPromptStreamingEvent(event) {
|
|
19152
|
+
if (!event) return false;
|
|
19153
|
+
return event.type === "message_start" && event.message?.role === "assistant" || event.type === "message_update" || event.type === "tool_execution_start";
|
|
19154
|
+
}
|
|
19155
|
+
function startBackgroundWarmup(host, controller) {
|
|
19156
|
+
clearQuietTimer(controller);
|
|
19157
|
+
clearMaxDeferralTimer(controller);
|
|
19158
|
+
clearStreamingSubscription(controller);
|
|
19159
|
+
clearDispatchSubscription(controller);
|
|
19160
|
+
if (host.isShuttingDown) {
|
|
19161
|
+
controller.state = "stopped";
|
|
19162
|
+
return;
|
|
19163
|
+
}
|
|
19164
|
+
const runner = controller.runner;
|
|
19165
|
+
if (!runner) {
|
|
19166
|
+
controller.state = "done";
|
|
19167
|
+
return;
|
|
19168
|
+
}
|
|
19169
|
+
controller.state = "loading";
|
|
19170
|
+
const abortController = new AbortController();
|
|
19171
|
+
controller.abortController = abortController;
|
|
19172
|
+
Promise.resolve().then(() => {
|
|
19173
|
+
if (abortController.signal.aborted || host.isShuttingDown || controller.state !== "loading") return;
|
|
19174
|
+
return runner(abortController.signal);
|
|
19175
|
+
}).then(() => {
|
|
19176
|
+
if (controller.abortController === abortController) {
|
|
19177
|
+
controller.abortController = void 0;
|
|
19178
|
+
if (controller.state === "loading") controller.state = abortController.signal.aborted ? "stopped" : "done";
|
|
19179
|
+
}
|
|
19180
|
+
}, () => {
|
|
19181
|
+
if (controller.abortController === abortController) {
|
|
19182
|
+
controller.abortController = void 0;
|
|
19183
|
+
if (controller.state === "loading") controller.state = "stopped";
|
|
19184
|
+
}
|
|
19185
|
+
});
|
|
19186
|
+
}
|
|
19187
|
+
function maybeArmMaxDeferralCap(host, controller) {
|
|
19188
|
+
if (controller.maxDeferralTimer !== void 0 || !canArmMaxDeferralCap(host, controller)) return;
|
|
19189
|
+
const timer = setTimeout(() => {
|
|
19190
|
+
if (controller.maxDeferralTimer === timer) controller.maxDeferralTimer = void 0;
|
|
19191
|
+
if (host.isShuttingDown) {
|
|
19192
|
+
stopPostStartupHighlightWarmup(host);
|
|
19193
|
+
return;
|
|
19194
|
+
}
|
|
19195
|
+
if (controller.state === "waiting_for_gate" || controller.state === "quiet_rearm") startBackgroundWarmup(host, controller);
|
|
19196
|
+
}, POST_STARTUP_MAX_DEFERRAL_MS);
|
|
19197
|
+
timer.unref?.();
|
|
19198
|
+
controller.maxDeferralTimer = timer;
|
|
19199
|
+
}
|
|
19200
|
+
function scheduleQuietRearm(host, controller) {
|
|
19201
|
+
clearQuietTimer(controller);
|
|
19202
|
+
controller.state = "quiet_rearm";
|
|
19203
|
+
maybeArmMaxDeferralCap(host, controller);
|
|
19204
|
+
const timer = setTimeout(() => {
|
|
19205
|
+
if (controller.quietTimer === timer) controller.quietTimer = void 0;
|
|
19206
|
+
if (controller.state !== "quiet_rearm") return;
|
|
19207
|
+
if (host.isShuttingDown) {
|
|
19208
|
+
stopPostStartupHighlightWarmup(host);
|
|
19209
|
+
return;
|
|
19210
|
+
}
|
|
19211
|
+
if (isGateBlocked(host, controller)) {
|
|
19212
|
+
controller.state = "waiting_for_gate";
|
|
19213
|
+
maybeArmMaxDeferralCap(host, controller);
|
|
19214
|
+
return;
|
|
19215
|
+
}
|
|
19216
|
+
startBackgroundWarmup(host, controller);
|
|
19217
|
+
}, 150);
|
|
19218
|
+
timer.unref?.();
|
|
19219
|
+
controller.quietTimer = timer;
|
|
19220
|
+
}
|
|
19221
|
+
function maybeRearmFromGate(host, controller) {
|
|
19222
|
+
if (host.isShuttingDown) {
|
|
19223
|
+
stopPostStartupHighlightWarmup(host);
|
|
19224
|
+
return;
|
|
19225
|
+
}
|
|
19226
|
+
if (controller.state === "waiting_for_gate") {
|
|
19227
|
+
if (!isGateBlocked(host, controller)) scheduleQuietRearm(host, controller);
|
|
19228
|
+
else maybeArmMaxDeferralCap(host, controller);
|
|
19229
|
+
}
|
|
19230
|
+
}
|
|
19231
|
+
/**
|
|
19232
|
+
* Arms the post-startup background warmup state machine for a new `run()` lifecycle.
|
|
19233
|
+
* The initial 500 ms timer lives in `InteractiveMode.run()` (`postStartupTimer`), which
|
|
19234
|
+
* calls {@link onPostStartupTimerFired} when it elapses.
|
|
19235
|
+
*/
|
|
19236
|
+
function armPostStartupHighlightWarmup(host, runner) {
|
|
19237
|
+
const controller = getOrCreateController(host);
|
|
19238
|
+
clearQuietTimer(controller);
|
|
19239
|
+
clearMaxDeferralTimer(controller);
|
|
19240
|
+
clearStreamingSubscription(controller);
|
|
19241
|
+
clearDispatchSubscription(controller);
|
|
19242
|
+
controller.abortController?.abort();
|
|
19243
|
+
controller.abortController = void 0;
|
|
19244
|
+
controller.firstPromptPreflightDepth = 0;
|
|
19245
|
+
controller.firstRequestDispatched = false;
|
|
19246
|
+
controller.firstPromptSettled = false;
|
|
19247
|
+
controller.runner = runner;
|
|
19248
|
+
controller.state = host.isShuttingDown ? "stopped" : "timer_armed";
|
|
19249
|
+
}
|
|
19250
|
+
/** Called when `InteractiveMode.run()`'s 500 ms `postStartupTimer` fires. */
|
|
19251
|
+
function onPostStartupTimerFired(host) {
|
|
19252
|
+
const controller = controllers.get(host);
|
|
19253
|
+
if (!controller) return;
|
|
19254
|
+
if (host.isShuttingDown) {
|
|
19255
|
+
stopPostStartupHighlightWarmup(host);
|
|
19256
|
+
return;
|
|
19257
|
+
}
|
|
19258
|
+
if (controller.state !== "timer_armed") return;
|
|
19259
|
+
if (isGateBlocked(host, controller)) {
|
|
19260
|
+
controller.state = "waiting_for_gate";
|
|
19261
|
+
maybeArmMaxDeferralCap(host, controller);
|
|
19262
|
+
return;
|
|
19263
|
+
}
|
|
19264
|
+
startBackgroundWarmup(host, controller);
|
|
19265
|
+
}
|
|
19266
|
+
/**
|
|
19267
|
+
* Called when the first provider request has reached the `before-provider-request`
|
|
19268
|
+
* dispatch point (all pre-request phases — deferred startup, hooks, OAuth refresh,
|
|
19269
|
+
* model discovery — are done and the transport request is leaving). Now it is safe
|
|
19270
|
+
* to arm the hard deferral cap for slow-TTFT providers.
|
|
19271
|
+
*/
|
|
19272
|
+
function notifyPostStartupProviderRequestDispatched(host) {
|
|
19273
|
+
const controller = controllers.get(host);
|
|
19274
|
+
if (!controller || controller.firstRequestDispatched) return;
|
|
19275
|
+
controller.firstRequestDispatched = true;
|
|
19276
|
+
clearDispatchSubscription(controller);
|
|
19277
|
+
if (controller.state === "waiting_for_gate" || controller.state === "quiet_rearm") maybeArmMaxDeferralCap(host, controller);
|
|
19278
|
+
}
|
|
19279
|
+
/**
|
|
19280
|
+
* Releases the first-prompt dispatch gate as soon as the first provider request has
|
|
19281
|
+
* reached the provider and assistant streaming starts, so long multi-step turns get
|
|
19282
|
+
* live highlighting and compile-cache warmup during streaming.
|
|
19283
|
+
*/
|
|
19284
|
+
function notifyPostStartupPromptStreaming(host) {
|
|
19285
|
+
const controller = controllers.get(host);
|
|
19286
|
+
if (!controller || controller.firstPromptSettled) return;
|
|
19287
|
+
controller.firstRequestDispatched = true;
|
|
19288
|
+
controller.firstPromptSettled = true;
|
|
19289
|
+
controller.firstPromptPreflightDepth = 0;
|
|
19290
|
+
clearStreamingSubscription(controller);
|
|
19291
|
+
clearDispatchSubscription(controller);
|
|
19292
|
+
maybeRearmFromGate(host, controller);
|
|
19293
|
+
}
|
|
19294
|
+
/**
|
|
19295
|
+
* Marks the start of a prompt turn; returns an idempotent release function to call in `finally`.
|
|
19296
|
+
* On isolated hosts and on turns after the first turn settles, this is a no-op so subsequent
|
|
19297
|
+
* turns never block warmup or reset the quiet timer.
|
|
19298
|
+
*/
|
|
19299
|
+
function beginPostStartupPromptTurn(host) {
|
|
19300
|
+
if (isIsolatedHost(host)) return () => {};
|
|
19301
|
+
const controller = getOrCreateController(host);
|
|
19302
|
+
if (controller.firstPromptSettled) return () => {};
|
|
19303
|
+
controller.firstPromptPreflightDepth += 1;
|
|
19304
|
+
if (controller.state === "quiet_rearm") {
|
|
19305
|
+
clearQuietTimer(controller);
|
|
19306
|
+
controller.state = "waiting_for_gate";
|
|
19307
|
+
maybeArmMaxDeferralCap(host, controller);
|
|
19308
|
+
}
|
|
19309
|
+
if (controller.unsubscribeStreaming === void 0 && typeof host.session?.subscribe === "function") controller.unsubscribeStreaming = host.session.subscribe((event) => {
|
|
19310
|
+
if (isPromptStreamingEvent(event)) notifyPostStartupPromptStreaming(host);
|
|
19311
|
+
});
|
|
19312
|
+
if (controller.unsubscribeDispatch === void 0 && host.session !== void 0 && !controller.firstRequestDispatched) controller.unsubscribeDispatch = onSessionProviderRequestDispatched(host.session, () => {
|
|
19313
|
+
notifyPostStartupProviderRequestDispatched(host);
|
|
19314
|
+
});
|
|
19315
|
+
let released = false;
|
|
19316
|
+
return () => {
|
|
19317
|
+
if (released) return;
|
|
19318
|
+
released = true;
|
|
19319
|
+
controller.firstPromptSettled = true;
|
|
19320
|
+
controller.firstPromptPreflightDepth = 0;
|
|
19321
|
+
clearStreamingSubscription(controller);
|
|
19322
|
+
clearDispatchSubscription(controller);
|
|
19323
|
+
maybeRearmFromGate(host, controller);
|
|
19324
|
+
};
|
|
19325
|
+
}
|
|
19326
|
+
/** Called when deferred startup finishes (whether it succeeded or failed). */
|
|
19327
|
+
function notifyPostStartupDeferredComplete(host) {
|
|
19328
|
+
const controller = controllers.get(host);
|
|
19329
|
+
if (!controller) return;
|
|
19330
|
+
maybeRearmFromGate(host, controller);
|
|
19331
|
+
}
|
|
19332
|
+
/** Stops any pending timers and aborts any in-flight background warmup. */
|
|
19333
|
+
function stopPostStartupHighlightWarmup(host) {
|
|
19334
|
+
const controller = controllers.get(host);
|
|
19335
|
+
if (!controller) return;
|
|
19336
|
+
clearQuietTimer(controller);
|
|
19337
|
+
clearMaxDeferralTimer(controller);
|
|
19338
|
+
clearStreamingSubscription(controller);
|
|
19339
|
+
clearDispatchSubscription(controller);
|
|
19340
|
+
controller.abortController?.abort();
|
|
19341
|
+
controller.abortController = void 0;
|
|
19342
|
+
controller.state = "stopped";
|
|
19343
|
+
}
|
|
18490
19344
|
// dist/modes/interactive/interactive-bash-compact.js
|
|
18491
19345
|
/** Warning shown when `/compact` is submitted while a compaction is already running. */
|
|
18492
19346
|
const COMPACTION_ALREADY_IN_PROGRESS_WARNING = "Compaction is already in progress. Wait for it to finish before running /compact again.";
|
|
@@ -18582,6 +19436,7 @@ InteractiveModeBase.prototype.stop = function(fullscreenExitOutput = this.settin
|
|
|
18582
19436
|
clearTimeout(this.postStartupTimer);
|
|
18583
19437
|
this.postStartupTimer = void 0;
|
|
18584
19438
|
}
|
|
19439
|
+
stopPostStartupHighlightWarmup(this);
|
|
18585
19440
|
if (this.chatContainer instanceof StartupChatContainer) this.chatContainer.cancelChatRecordPaint();
|
|
18586
19441
|
discardChatMount(this);
|
|
18587
19442
|
cancelApprovedResourceListing(this);
|
|
@@ -18590,7 +19445,10 @@ InteractiveModeBase.prototype.stop = function(fullscreenExitOutput = this.settin
|
|
|
18590
19445
|
this.disposeAgentView?.();
|
|
18591
19446
|
this.disposeInteractiveEngineHost();
|
|
18592
19447
|
this.disposeInteractiveEngineHost = () => {};
|
|
18593
|
-
if (this.
|
|
19448
|
+
if (this.isInitialized || this.tuiStarted) {
|
|
19449
|
+
if (this.extensionTitleActive) writeDefaultTerminalTitle(this);
|
|
19450
|
+
if (this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(false);
|
|
19451
|
+
}
|
|
18594
19452
|
InteractiveModeBase.prototype.clearWorkingLoader.call(this);
|
|
18595
19453
|
this.themeController.disableAutoSync();
|
|
18596
19454
|
this.clearExtensionTerminalInputListeners();
|
|
@@ -18598,7 +19456,7 @@ InteractiveModeBase.prototype.stop = function(fullscreenExitOutput = this.settin
|
|
|
18598
19456
|
this.footer.dispose();
|
|
18599
19457
|
this.footerDataProvider.dispose();
|
|
18600
19458
|
if (this.unsubscribe) this.unsubscribe();
|
|
18601
|
-
if (this.isInitialized) {
|
|
19459
|
+
if (this.isInitialized || this.tuiStarted) {
|
|
18602
19460
|
this.stopInteractiveTui(fullscreenExitOutput);
|
|
18603
19461
|
this.isInitialized = false;
|
|
18604
19462
|
this.managedToolReadiness = "on-init";
|
|
@@ -18938,7 +19796,7 @@ InteractiveModeBase.prototype.showUserMessageSelector = async function() {
|
|
|
18938
19796
|
const fromSubagentView = this.agentView?.viewed.kind === "agent";
|
|
18939
19797
|
await this.ensureDeferredStartupComplete();
|
|
18940
19798
|
const manager = this.session.sessionManager;
|
|
18941
|
-
const stored = manager?.hasFullHistory?.() === false ? await loadOnDemand("/fork", async () => (await import("../modes/interactive/components/user-message-selector-archive.js")).ForkPromptArchive.open(manager)) : void 0;
|
|
19799
|
+
const stored = manager?.hasFullHistory?.() === false ? await loadOnDemand("/fork", async () => (await import("../modes/interactive/components/user-message-selector-archive.code.js").catch((error) => __atomicOnDemandFailed(error, "/fork"))).ForkPromptArchive.open(manager)) : void 0;
|
|
18942
19800
|
const userMessages = stored?.prompts ?? this.session.getUserMessagesForForking();
|
|
18943
19801
|
if (userMessages.length === 0) {
|
|
18944
19802
|
stored?.archive.dispose();
|
|
@@ -19610,22 +20468,32 @@ async function submitToMainChat(text, submittedDraft, prompt) {
|
|
|
19610
20468
|
const extensionCommand = this.isExtensionCommand(text);
|
|
19611
20469
|
prompt.addToHistory(text);
|
|
19612
20470
|
prompt.setText("");
|
|
20471
|
+
const originSendId = randomUUID();
|
|
20472
|
+
const trackOrigin = beginPendingOriginSend(this, originSendId);
|
|
19613
20473
|
const shownBefore = this.userMessagesShownBySession;
|
|
19614
|
-
const
|
|
20474
|
+
const taggedBefore = taggedUserMessagesShownCount(this);
|
|
20475
|
+
const startedEcho = followStartedRunEcho(this, text, {
|
|
20476
|
+
sendShowsWorkingRow: false,
|
|
20477
|
+
originSendId
|
|
20478
|
+
});
|
|
19615
20479
|
const held = extensionCommand ? holdForExtensionCommand(this) : void 0;
|
|
19616
20480
|
let submitted;
|
|
19617
20481
|
try {
|
|
19618
20482
|
submitted = await mainSteering(this).submit(text, "steer", {
|
|
19619
20483
|
route: "queue",
|
|
19620
20484
|
showAsQueued: !extensionCommand,
|
|
20485
|
+
originSendId,
|
|
19621
20486
|
onAnswered: (success, disposition) => {
|
|
19622
|
-
const
|
|
20487
|
+
const alreadyShown = trackOrigin.wasShown() || untaggedUserMessagesShownSince(this, shownBefore, taggedBefore) !== 0;
|
|
20488
|
+
const echoed = success && disposition === "started" && !text.startsWith("/") && !alreadyShown;
|
|
19623
20489
|
const echo = echoed ? this.renderDeferredUserInput(text) : void 0;
|
|
20490
|
+
if (echo !== void 0) noteDeferredEchoOrigin(this, text, echo, originSendId, taggedBefore);
|
|
19624
20491
|
if (echoed) this.expectStartedUserInput(text, shownBefore, echo);
|
|
19625
20492
|
startedEcho.answer(echoed, echo);
|
|
19626
20493
|
}
|
|
19627
20494
|
});
|
|
19628
20495
|
} finally {
|
|
20496
|
+
trackOrigin.dispose();
|
|
19629
20497
|
startedEcho.close();
|
|
19630
20498
|
held?.settle();
|
|
19631
20499
|
}
|
|
@@ -20152,7 +21020,10 @@ InteractiveModeBase.prototype.flushCompactionQueue = async function(options) {
|
|
|
20152
21020
|
};
|
|
20153
21021
|
async function sendCompactionQueue(mode, willRetry) {
|
|
20154
21022
|
if (!willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused)) {
|
|
20155
|
-
await drainCompactionQueue(mode, (message) => mode.session.prompt(message.text, {
|
|
21023
|
+
await drainCompactionQueue(mode, (message) => mode.session.prompt(message.text, {
|
|
21024
|
+
streamingBehavior: message.mode,
|
|
21025
|
+
originSendId: randomUUID()
|
|
21026
|
+
}));
|
|
20156
21027
|
return;
|
|
20157
21028
|
}
|
|
20158
21029
|
if (!willRetry && !await startCompactionQueuePrompt(mode)) return;
|
|
@@ -20226,6 +21097,7 @@ function handOffCompactionQueue(mode) {
|
|
|
20226
21097
|
let accepted = false;
|
|
20227
21098
|
mode.session.prompt(message.text, {
|
|
20228
21099
|
streamingBehavior: message.mode,
|
|
21100
|
+
originSendId: randomUUID(),
|
|
20229
21101
|
preflightResult: (success) => {
|
|
20230
21102
|
accepted = success;
|
|
20231
21103
|
if (success) confirmHandOff(mode, message);
|
|
@@ -20267,18 +21139,19 @@ async function startCompactionQueuePrompt(mode) {
|
|
|
20267
21139
|
if (!await drainCompactionQueue(mode, (message) => mode.session.prompt(message.text), firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex)) return false;
|
|
20268
21140
|
const first = takeNextCompactionMessage(mode);
|
|
20269
21141
|
if (!first) return false;
|
|
20270
|
-
const refused = await promptUntilAccepted(mode, first);
|
|
21142
|
+
const refused = await promptUntilAccepted(mode, first, void 0, randomUUID());
|
|
20271
21143
|
if (refused === void 0) return true;
|
|
20272
21144
|
returnCompactionMessage(mode, first, refused.error);
|
|
20273
21145
|
return false;
|
|
20274
21146
|
}
|
|
20275
|
-
async function promptUntilAccepted(mode, message, onAccepted) {
|
|
21147
|
+
async function promptUntilAccepted(mode, message, onAccepted, originSendId) {
|
|
20276
21148
|
let accept;
|
|
20277
21149
|
const accepted = new Promise((resolve) => {
|
|
20278
21150
|
accept = resolve;
|
|
20279
21151
|
});
|
|
20280
21152
|
const prompt = mode.session.prompt(message.text, {
|
|
20281
21153
|
streamingBehavior: message.mode,
|
|
21154
|
+
...originSendId === void 0 ? {} : { originSendId },
|
|
20282
21155
|
preflightResult: (success, disposition) => {
|
|
20283
21156
|
if (success) onAccepted?.(disposition);
|
|
20284
21157
|
accept(success);
|
|
@@ -20295,13 +21168,15 @@ async function sendHeldInput(mode) {
|
|
|
20295
21168
|
while (mode.compactionQueuedMessages.length > 0) {
|
|
20296
21169
|
const message = takeNextCompactionMessage(mode);
|
|
20297
21170
|
if (!message) return;
|
|
21171
|
+
const originSendId = randomUUID();
|
|
20298
21172
|
const echoed = !message.text.startsWith("/");
|
|
20299
21173
|
const echo = echoed ? mode.renderDeferredUserInput(message.text) : void 0;
|
|
20300
21174
|
const shownBefore = mode.userMessagesShownBySession;
|
|
21175
|
+
if (echo !== void 0) noteDeferredEchoOrigin(mode, message.text, echo, originSendId, taggedUserMessagesShownCount(mode));
|
|
20301
21176
|
const refused = await promptUntilAccepted(mode, message, echoed ? (disposition) => {
|
|
20302
21177
|
if (disposition === "queued" || disposition === "handled") mode.discardDeferredRenderedUserInput(message.text, echo);
|
|
20303
21178
|
if (disposition === "started") mode.expectStartedUserInput(message.text, shownBefore, echo);
|
|
20304
|
-
} : void 0);
|
|
21179
|
+
} : void 0, originSendId);
|
|
20305
21180
|
if (refused !== void 0) {
|
|
20306
21181
|
if (echoed) mode.discardDeferredRenderedUserInput(message.text, echo);
|
|
20307
21182
|
returnCompactionMessage(mode, message, refused.error);
|
|
@@ -20395,6 +21270,14 @@ function engineLossSubagentNotice(queue) {
|
|
|
20395
21270
|
const verb = messages.length === 1 ? "wasn't" : "weren't";
|
|
20396
21271
|
return [`Engine restarted; ${queuedMessagesPhrase(messages.length)} to ${queue.agent} ${verb} sent:`, ...messages].join("\n");
|
|
20397
21272
|
}
|
|
21273
|
+
/** The notice when a lost engine's subagent messages came back to that subagent's own editor. */
|
|
21274
|
+
function engineLossSubagentRestoredNotice(agent, count) {
|
|
21275
|
+
return `Engine restarted; ${queuedMessagesPhrase(count)} to ${agent} ${count === 1 ? "wasn't" : "weren't"} sent and ${count === 1 ? "is" : "are"} back in the editor`;
|
|
21276
|
+
}
|
|
21277
|
+
/** The notice on main when a lost engine's subagent messages wait for that subagent's chat to open. */
|
|
21278
|
+
function engineLossSubagentPendingNotice(agent, count) {
|
|
21279
|
+
return `Engine restarted; ${queuedMessagesPhrase(count)} to ${agent} ${count === 1 ? "wasn't" : "weren't"} sent; ${count === 1 ? "it's" : "they're"} back in its editor when you open it`;
|
|
21280
|
+
}
|
|
20398
21281
|
function textOfUserMessage(content) {
|
|
20399
21282
|
if (typeof content === "string") return content;
|
|
20400
21283
|
if (!Array.isArray(content)) return void 0;
|
|
@@ -20489,6 +21372,182 @@ InteractiveModeBase.prototype.attachSteeringEngineRecovery = function() {
|
|
|
20489
21372
|
stopRecovered();
|
|
20490
21373
|
};
|
|
20491
21374
|
};
|
|
21375
|
+
// dist/modes/interactive/agent-view/lost-queue-restore.js
|
|
21376
|
+
/** Canonical map key for a child's physical `(sessionId, sessionFile)` identity. */
|
|
21377
|
+
function childSessionKey(identity) {
|
|
21378
|
+
return JSON.stringify([identity.sessionId, identity.sessionFile ?? null]);
|
|
21379
|
+
}
|
|
21380
|
+
/** Physical child session identity reported by a view status, or `undefined` for an engine that does not send one. */
|
|
21381
|
+
function statusChildIdentity(status) {
|
|
21382
|
+
if (typeof status.sessionId !== "string" || status.sessionId.length === 0) return void 0;
|
|
21383
|
+
return {
|
|
21384
|
+
sessionId: status.sessionId,
|
|
21385
|
+
...typeof status.sessionFile === "string" && status.sessionFile.length > 0 ? { sessionFile: status.sessionFile } : {}
|
|
21386
|
+
};
|
|
21387
|
+
}
|
|
21388
|
+
/**
|
|
21389
|
+
* Physical child identity eligible for child-editor restore: requires the engine to report `AgentViewStatus.sessionId`
|
|
21390
|
+
* (an older engine that only sent `receipts.sessionId` falls back to notice-only) and agree with `receipts`.
|
|
21391
|
+
*/
|
|
21392
|
+
function canTrackChildRestore(status) {
|
|
21393
|
+
const identity = statusChildIdentity(status);
|
|
21394
|
+
if (identity === void 0) return void 0;
|
|
21395
|
+
const receipts = status.receipts;
|
|
21396
|
+
if (receipts !== void 0) {
|
|
21397
|
+
if (receipts.sessionId !== identity.sessionId) return void 0;
|
|
21398
|
+
if (identity.sessionFile !== void 0 && receipts.sessionFile !== void 0 && identity.sessionFile !== receipts.sessionFile) return void 0;
|
|
21399
|
+
const sessionFile = identity.sessionFile ?? receipts.sessionFile;
|
|
21400
|
+
return {
|
|
21401
|
+
sessionId: identity.sessionId,
|
|
21402
|
+
...sessionFile === void 0 ? {} : { sessionFile }
|
|
21403
|
+
};
|
|
21404
|
+
}
|
|
21405
|
+
return identity;
|
|
21406
|
+
}
|
|
21407
|
+
/** Whether `view` is a live, non-gone view of the exact physical child `identity`. */
|
|
21408
|
+
function viewMatchesIdentity(view, identity) {
|
|
21409
|
+
if (view === void 0 || view.gone) return false;
|
|
21410
|
+
const current = statusChildIdentity(view);
|
|
21411
|
+
return current !== void 0 && childSessionKey(current) === childSessionKey(identity);
|
|
21412
|
+
}
|
|
21413
|
+
/**
|
|
21414
|
+
* Typed state machine for restoring a lost subagent chat's known-unsaved queued messages into that child chat's own
|
|
21415
|
+
* composer. Guarantees:
|
|
21416
|
+
* - Immediate restore into the child's composer when that exact physical child is open and writable at settlement.
|
|
21417
|
+
* - One-shot pending restore keyed by `(sessionId, sessionFile)` when closed at settlement, consumed once on the first
|
|
21418
|
+
* writable reopen in the same host session (surviving an intervening second crash).
|
|
21419
|
+
* - Fallback to the full-text notice when read-only (at settlement or on reopen), when the engine is an older version
|
|
21420
|
+
* without `AgentViewStatus.sessionId`, or when replacement failed.
|
|
21421
|
+
* - Dropped when the child is stopped, cleared, ended non-resumably, sent to by another path, or when the host session
|
|
21422
|
+
* changes — including invalidations arriving while a receipt lookup is still in flight.
|
|
21423
|
+
* - Never writes into the main chat's editor or another child's editor.
|
|
21424
|
+
*/
|
|
21425
|
+
var SubagentQueueRestoreMachine = class {
|
|
21426
|
+
hostEpoch = 0;
|
|
21427
|
+
detached = false;
|
|
21428
|
+
pending = /* @__PURE__ */ new Map();
|
|
21429
|
+
invalidationVersions = /* @__PURE__ */ new Map();
|
|
21430
|
+
sessionInvalidationVersions = /* @__PURE__ */ new Map();
|
|
21431
|
+
beginLookup(input) {
|
|
21432
|
+
const key = input.identity === void 0 ? void 0 : childSessionKey(input.identity);
|
|
21433
|
+
return {
|
|
21434
|
+
agent: input.agent,
|
|
21435
|
+
taken: input.taken,
|
|
21436
|
+
listed: input.listed,
|
|
21437
|
+
identity: input.identity,
|
|
21438
|
+
hostEpoch: this.hostEpoch,
|
|
21439
|
+
hostSessionId: input.hostSessionId,
|
|
21440
|
+
invalidationKeyVersion: key === void 0 ? 0 : this.invalidationVersions.get(key) ?? 0,
|
|
21441
|
+
invalidationSessionVersion: input.identity === void 0 ? 0 : this.sessionInvalidationVersions.get(input.identity.sessionId) ?? 0
|
|
21442
|
+
};
|
|
21443
|
+
}
|
|
21444
|
+
settleLookup(ticket, outcome) {
|
|
21445
|
+
if (this.detached || ticket.hostEpoch !== this.hostEpoch || outcome.currentHostSessionId !== ticket.hostSessionId) return [];
|
|
21446
|
+
const classify = (message) => message.receipt === void 0 ? "unknown" : outcome.found?.saved.has(message.receipt.id) ? "saved" : outcome.found?.absent.has(message.receipt.id) ? "unsaved" : "unknown";
|
|
21447
|
+
const unconfirmed = ticket.taken.flatMap((message) => classify(message) === "unknown" ? [message.text] : []);
|
|
21448
|
+
const unsent = ticket.taken.flatMap((message) => classify(message) === "unsaved" ? [message.receipt?.typed ?? message.text] : []);
|
|
21449
|
+
const actions = [];
|
|
21450
|
+
if (unconfirmed.length > 0) actions.push({
|
|
21451
|
+
kind: "unconfirmed-notice",
|
|
21452
|
+
agent: ticket.agent,
|
|
21453
|
+
messages: unconfirmed
|
|
21454
|
+
});
|
|
21455
|
+
const restorable = [...unsent, ...ticket.listed];
|
|
21456
|
+
if (restorable.length === 0) return actions;
|
|
21457
|
+
const identity = ticket.identity;
|
|
21458
|
+
if (!(outcome.replaced && identity !== void 0 && !this.wasInvalidatedSince(identity, ticket))) {
|
|
21459
|
+
actions.push({
|
|
21460
|
+
kind: "notice-full",
|
|
21461
|
+
agent: ticket.agent,
|
|
21462
|
+
messages: restorable
|
|
21463
|
+
});
|
|
21464
|
+
return actions;
|
|
21465
|
+
}
|
|
21466
|
+
const key = childSessionKey(identity);
|
|
21467
|
+
const existing = this.pending.get(key)?.messages ?? [];
|
|
21468
|
+
if (viewMatchesIdentity(outcome.currentView, identity)) {
|
|
21469
|
+
this.pending.delete(key);
|
|
21470
|
+
const combined = [...existing, ...restorable];
|
|
21471
|
+
if (outcome.currentView?.readOnlyReason === void 0) actions.push({
|
|
21472
|
+
kind: "restore-now",
|
|
21473
|
+
agentKey: outcome.currentView.agentKey,
|
|
21474
|
+
agent: ticket.agent,
|
|
21475
|
+
messages: combined
|
|
21476
|
+
});
|
|
21477
|
+
else actions.push({
|
|
21478
|
+
kind: "notice-full",
|
|
21479
|
+
agent: ticket.agent,
|
|
21480
|
+
messages: combined
|
|
21481
|
+
});
|
|
21482
|
+
return actions;
|
|
21483
|
+
}
|
|
21484
|
+
this.pending.set(key, {
|
|
21485
|
+
key,
|
|
21486
|
+
identity,
|
|
21487
|
+
agent: ticket.agent,
|
|
21488
|
+
hostSessionId: ticket.hostSessionId,
|
|
21489
|
+
messages: [...existing, ...restorable]
|
|
21490
|
+
});
|
|
21491
|
+
actions.push({
|
|
21492
|
+
kind: "notice-pending",
|
|
21493
|
+
agent: ticket.agent,
|
|
21494
|
+
count: restorable.length
|
|
21495
|
+
});
|
|
21496
|
+
return actions;
|
|
21497
|
+
}
|
|
21498
|
+
onChildOpened(view, currentHostSessionId) {
|
|
21499
|
+
if (this.detached || view.gone) return [];
|
|
21500
|
+
const identity = statusChildIdentity(view);
|
|
21501
|
+
if (identity === void 0) return [];
|
|
21502
|
+
const key = childSessionKey(identity);
|
|
21503
|
+
const entry = this.pending.get(key);
|
|
21504
|
+
if (entry === void 0) return [];
|
|
21505
|
+
this.pending.delete(key);
|
|
21506
|
+
if (currentHostSessionId !== entry.hostSessionId) return [];
|
|
21507
|
+
if (view.readOnlyReason !== void 0) return [{
|
|
21508
|
+
kind: "notice-full",
|
|
21509
|
+
agent: entry.agent,
|
|
21510
|
+
messages: entry.messages
|
|
21511
|
+
}];
|
|
21512
|
+
return [{
|
|
21513
|
+
kind: "restore-on-open",
|
|
21514
|
+
agentKey: view.agentKey,
|
|
21515
|
+
agent: entry.agent,
|
|
21516
|
+
messages: entry.messages
|
|
21517
|
+
}];
|
|
21518
|
+
}
|
|
21519
|
+
invalidateChild(identity, _reason) {
|
|
21520
|
+
if (this.detached) return;
|
|
21521
|
+
if (identity.sessionFile !== void 0) {
|
|
21522
|
+
const key = childSessionKey(identity);
|
|
21523
|
+
this.invalidationVersions.set(key, (this.invalidationVersions.get(key) ?? 0) + 1);
|
|
21524
|
+
this.pending.delete(key);
|
|
21525
|
+
return;
|
|
21526
|
+
}
|
|
21527
|
+
this.sessionInvalidationVersions.set(identity.sessionId, (this.sessionInvalidationVersions.get(identity.sessionId) ?? 0) + 1);
|
|
21528
|
+
for (const [key, entry] of [...this.pending]) if (entry.identity.sessionId === identity.sessionId) this.pending.delete(key);
|
|
21529
|
+
}
|
|
21530
|
+
hostSessionChanged() {
|
|
21531
|
+
this.hostEpoch++;
|
|
21532
|
+
this.pending.clear();
|
|
21533
|
+
this.invalidationVersions.clear();
|
|
21534
|
+
this.sessionInvalidationVersions.clear();
|
|
21535
|
+
}
|
|
21536
|
+
hasPending(identity) {
|
|
21537
|
+
if (identity === void 0) return this.pending.size > 0;
|
|
21538
|
+
return this.pending.has(childSessionKey(identity));
|
|
21539
|
+
}
|
|
21540
|
+
dispose() {
|
|
21541
|
+
this.detached = true;
|
|
21542
|
+
this.pending.clear();
|
|
21543
|
+
this.invalidationVersions.clear();
|
|
21544
|
+
this.sessionInvalidationVersions.clear();
|
|
21545
|
+
}
|
|
21546
|
+
wasInvalidatedSince(identity, ticket) {
|
|
21547
|
+
const key = childSessionKey(identity);
|
|
21548
|
+
return (this.invalidationVersions.get(key) ?? 0) !== ticket.invalidationKeyVersion || (this.sessionInvalidationVersions.get(identity.sessionId) ?? 0) !== ticket.invalidationSessionVersion;
|
|
21549
|
+
}
|
|
21550
|
+
};
|
|
20492
21551
|
// dist/modes/interactive/agent-view/prompt-retarget.js
|
|
20493
21552
|
/**
|
|
20494
21553
|
* Retarget the main prompt to the agent the screen shows. While main is shown nothing here changes what the
|
|
@@ -20723,6 +21782,16 @@ function agentKeyOf(mode, taskId) {
|
|
|
20723
21782
|
/** Text typed for a subagent that was being opened when the request did not land, kept for when it is shown. */
|
|
20724
21783
|
const heldForTask = /* @__PURE__ */ new WeakMap();
|
|
20725
21784
|
/**
|
|
21785
|
+
* Single source of truth for keys that cancel a pending subagent open (both in `holdWhileOpening` while `openPort`
|
|
21786
|
+
* is pending and on arrival of `engine_view_agent` when a pre-view cancel is already in flight).
|
|
21787
|
+
* Never matches key releases, physical Ctrl+C, `app.clear`, or `app.exit`.
|
|
21788
|
+
*/
|
|
21789
|
+
function isCancelPendingOpenKey(keybindings, data) {
|
|
21790
|
+
if (isKeyRelease(data)) return false;
|
|
21791
|
+
if (isPhysicalCtrlC(data) || keybindings.matches(data, "app.clear") || keybindings.matches(data, "app.exit")) return false;
|
|
21792
|
+
return isPhysicalEscape(data) || keybindings.matches(data, "app.interrupt");
|
|
21793
|
+
}
|
|
21794
|
+
/**
|
|
20726
21795
|
* While a subagent is being opened, what the reader types is meant for it. The keys wait, and once it is shown they
|
|
20727
21796
|
* reach its prompt in order, Enter included. When the request does not land, their text is kept for that subagent
|
|
20728
21797
|
* (or, when it cannot be opened, shown in a notice) and the keys that send, pause or take back are dropped: nothing
|
|
@@ -20731,6 +21800,15 @@ const heldForTask = /* @__PURE__ */ new WeakMap();
|
|
|
20731
21800
|
*/
|
|
20732
21801
|
function holdWhileOpening(mode, switcher) {
|
|
20733
21802
|
let held;
|
|
21803
|
+
/** The closing navigation component (`/tasks`) mounted when a `keepScreen` open started pending, until it unmounts. */
|
|
21804
|
+
let closingComponent;
|
|
21805
|
+
const isClosingTasksMounted = () => {
|
|
21806
|
+
if (closingComponent === void 0 || mode.ui.hasOverlay()) return false;
|
|
21807
|
+
const top = mode.editorContainer.children.at(-1);
|
|
21808
|
+
if (top === closingComponent && top !== mode.editor && isNavigationView(top)) return true;
|
|
21809
|
+
closingComponent = void 0;
|
|
21810
|
+
return false;
|
|
21811
|
+
};
|
|
20734
21812
|
const keptFor = () => {
|
|
20735
21813
|
let map = heldForTask.get(mode);
|
|
20736
21814
|
if (map === void 0) {
|
|
@@ -20762,13 +21840,18 @@ function holdWhileOpening(mode, switcher) {
|
|
|
20762
21840
|
};
|
|
20763
21841
|
const hold = (data) => {
|
|
20764
21842
|
const pending = switcher.pendingTaskId;
|
|
20765
|
-
if (pending === void 0 || isKeyRelease(data)
|
|
21843
|
+
if (pending === void 0 || isKeyRelease(data)) return void 0;
|
|
21844
|
+
const promptActive = promptTakesKeys(mode);
|
|
21845
|
+
const closingTasksActive = !promptActive && isClosingTasksMounted();
|
|
21846
|
+
if (!promptActive && !closingTasksActive) return void 0;
|
|
20766
21847
|
if (isPhysicalCtrlC(data) || mode.keybindings.matches(data, "app.clear")) return void 0;
|
|
20767
21848
|
if (mode.keybindings.matches(data, "app.exit")) return void 0;
|
|
20768
|
-
if (
|
|
21849
|
+
if (isCancelPendingOpenKey(mode.keybindings, data)) {
|
|
21850
|
+
if (closingTasksActive && mode.runtimeHost instanceof IsolatedInteractiveRuntime) noteNavigationHostCancel(mode.runtimeHost);
|
|
20769
21851
|
switcher.cancelPending();
|
|
20770
21852
|
return { consume: true };
|
|
20771
21853
|
}
|
|
21854
|
+
if (!promptActive) return void 0;
|
|
20772
21855
|
if (held === void 0 || held.taskId !== pending) held = {
|
|
20773
21856
|
taskId: pending,
|
|
20774
21857
|
keys: []
|
|
@@ -20778,7 +21861,13 @@ function holdWhileOpening(mode, switcher) {
|
|
|
20778
21861
|
};
|
|
20779
21862
|
let stopListening;
|
|
20780
21863
|
const stopPending = switcher.onPending((pending, settled) => {
|
|
20781
|
-
if (pending !== void 0)
|
|
21864
|
+
if (pending !== void 0) {
|
|
21865
|
+
stopListening ??= mode.addTuiInputListener(hold);
|
|
21866
|
+
if (switcher.pendingKeepScreen && !mode.ui.hasOverlay() && !mode.editorContainer.children.includes(mode.editor)) {
|
|
21867
|
+
const top = mode.editorContainer.children.at(-1);
|
|
21868
|
+
if (top !== void 0 && top !== mode.editor && isNavigationView(top)) closingComponent = top;
|
|
21869
|
+
}
|
|
21870
|
+
} else closingComponent = void 0;
|
|
20782
21871
|
if (settled !== void 0) settle(settled.taskId, settled.outcome);
|
|
20783
21872
|
});
|
|
20784
21873
|
const stopChange = switcher.onChange(({ to }) => {
|
|
@@ -20816,23 +21905,129 @@ function reportLostAgentQueues(mode) {
|
|
|
20816
21905
|
if (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};
|
|
20817
21906
|
return attachLostAgentQueueNotices(mode, runtime);
|
|
20818
21907
|
}
|
|
21908
|
+
function currentHostSessionId(mode) {
|
|
21909
|
+
return mode.sessionManager?.getSessionId?.();
|
|
21910
|
+
}
|
|
21911
|
+
function currentChildView(mode) {
|
|
21912
|
+
const viewed = mode.agentView?.viewed;
|
|
21913
|
+
if (viewed?.kind !== "agent") return void 0;
|
|
21914
|
+
const status = viewed.port.status();
|
|
21915
|
+
return {
|
|
21916
|
+
agentKey: viewed.port.agentKey,
|
|
21917
|
+
...status.sessionId === void 0 ? {} : { sessionId: status.sessionId },
|
|
21918
|
+
...status.sessionFile === void 0 ? {} : { sessionFile: status.sessionFile },
|
|
21919
|
+
...status.readOnlyReason === void 0 ? {} : { readOnlyReason: status.readOnlyReason },
|
|
21920
|
+
gone: status.gone
|
|
21921
|
+
};
|
|
21922
|
+
}
|
|
21923
|
+
function applyRestoreActions(mode, actions) {
|
|
21924
|
+
if (actions.length === 0) return false;
|
|
21925
|
+
for (const action of actions) switch (action.kind) {
|
|
21926
|
+
case "unconfirmed-notice":
|
|
21927
|
+
mode.showWarning(engineLossUnconfirmedNotice(action.messages, action.agent));
|
|
21928
|
+
break;
|
|
21929
|
+
case "notice-full": {
|
|
21930
|
+
const notice = engineLossSubagentNotice({
|
|
21931
|
+
agent: action.agent,
|
|
21932
|
+
steering: action.messages,
|
|
21933
|
+
followUp: []
|
|
21934
|
+
});
|
|
21935
|
+
if (notice !== void 0) mode.showWarning(notice);
|
|
21936
|
+
break;
|
|
21937
|
+
}
|
|
21938
|
+
case "notice-pending":
|
|
21939
|
+
mode.showWarning(engineLossSubagentPendingNotice(action.agent, action.count));
|
|
21940
|
+
break;
|
|
21941
|
+
case "restore-now":
|
|
21942
|
+
rewritePromptOwnText(mode, {
|
|
21943
|
+
kind: "agent",
|
|
21944
|
+
agentKey: action.agentKey
|
|
21945
|
+
}, (own) => combineQueuedMessagesForEditor(action.messages, own));
|
|
21946
|
+
notifyViewed(mode, engineLossSubagentRestoredNotice(action.agent, action.messages.length), "warning");
|
|
21947
|
+
break;
|
|
21948
|
+
case "restore-on-open": rewritePromptOwnText(mode, {
|
|
21949
|
+
kind: "agent",
|
|
21950
|
+
agentKey: action.agentKey
|
|
21951
|
+
}, (own) => combineQueuedMessagesForEditor(action.messages, own));
|
|
21952
|
+
}
|
|
21953
|
+
return true;
|
|
21954
|
+
}
|
|
20819
21955
|
/**
|
|
20820
|
-
* Show
|
|
21956
|
+
* Show notices and restore known-unsaved subagent messages when `runtime`'s engine generation ends unexpectedly.
|
|
21957
|
+
* Answers the detach.
|
|
20821
21958
|
*
|
|
20822
21959
|
* A message a subagent had taken from its queue and not been seen to save may have been saved with its session. When it
|
|
20823
21960
|
* has a receipt, its engine's replacement is asked (for up to two seconds once it is up) whether its session's store
|
|
20824
|
-
* holds it: one found saved is not reported; one the store provably never saved
|
|
20825
|
-
*
|
|
20826
|
-
*
|
|
21961
|
+
* holds it: one found saved is not reported; one the store provably never saved (together with messages still listed
|
|
21962
|
+
* in that subagent's queue) is restored into that exact child chat's own composer ahead of any draft when it is open
|
|
21963
|
+
* and writable, or kept as a one-shot pending restore keyed by `(sessionId, sessionFile)` until that child opens
|
|
21964
|
+
* writable in the same host session; any other is listed in full as possibly undelivered, as is every one without a
|
|
21965
|
+
* receipt. Nothing is sent again, and nothing goes into the main prompt or another subagent's prompt.
|
|
20827
21966
|
*/
|
|
20828
21967
|
function attachLostAgentQueueNotices(mode, runtime) {
|
|
21968
|
+
const machine = new SubagentQueueRestoreMachine();
|
|
20829
21969
|
const stops = /* @__PURE__ */ new Set();
|
|
20830
|
-
let
|
|
21970
|
+
let unwatchOpenedPort;
|
|
21971
|
+
let deferredOpenPort;
|
|
21972
|
+
const consumeViewedPort = (port) => {
|
|
21973
|
+
const viewed = mode.agentView?.viewed;
|
|
21974
|
+
if (viewed?.kind !== "agent" || viewed.port !== port) return;
|
|
21975
|
+
const status = port.status();
|
|
21976
|
+
if (applyRestoreActions(mode, machine.onChildOpened({
|
|
21977
|
+
agentKey: port.agentKey,
|
|
21978
|
+
...status.sessionId === void 0 ? {} : { sessionId: status.sessionId },
|
|
21979
|
+
...status.sessionFile === void 0 ? {} : { sessionFile: status.sessionFile },
|
|
21980
|
+
...status.readOnlyReason === void 0 ? {} : { readOnlyReason: status.readOnlyReason },
|
|
21981
|
+
gone: status.gone
|
|
21982
|
+
}, currentHostSessionId(mode)))) mode.ui.requestRender();
|
|
21983
|
+
};
|
|
21984
|
+
const watchOpenedPort = (port) => {
|
|
21985
|
+
unwatchOpenedPort?.();
|
|
21986
|
+
unwatchOpenedPort = void 0;
|
|
21987
|
+
if (!machine.hasPending()) return;
|
|
21988
|
+
consumeViewedPort(port);
|
|
21989
|
+
if (!machine.hasPending()) return;
|
|
21990
|
+
unwatchOpenedPort = port.subscribe(() => {
|
|
21991
|
+
consumeViewedPort(port);
|
|
21992
|
+
if (!machine.hasPending()) {
|
|
21993
|
+
unwatchOpenedPort?.();
|
|
21994
|
+
unwatchOpenedPort = void 0;
|
|
21995
|
+
}
|
|
21996
|
+
});
|
|
21997
|
+
};
|
|
21998
|
+
const switcher = mode.agentView;
|
|
21999
|
+
const stopChange = switcher?.onChange(({ to }) => {
|
|
22000
|
+
unwatchOpenedPort?.();
|
|
22001
|
+
unwatchOpenedPort = void 0;
|
|
22002
|
+
deferredOpenPort = void 0;
|
|
22003
|
+
if (to.kind !== "agent") return;
|
|
22004
|
+
if (!machine.hasPending()) return;
|
|
22005
|
+
if (switcher.pendingTaskId !== void 0) {
|
|
22006
|
+
deferredOpenPort = to.port;
|
|
22007
|
+
return;
|
|
22008
|
+
}
|
|
22009
|
+
watchOpenedPort(to.port);
|
|
22010
|
+
}) ?? (() => {});
|
|
22011
|
+
const stopPending = switcher?.onPending((pending, settled) => {
|
|
22012
|
+
if (pending !== void 0 || settled === void 0) return;
|
|
22013
|
+
const viewed = switcher.viewed;
|
|
22014
|
+
const port = deferredOpenPort ?? (viewed.kind === "agent" ? viewed.port : void 0);
|
|
22015
|
+
deferredOpenPort = void 0;
|
|
22016
|
+
if (port !== void 0 && settled.outcome === "shown" && machine.hasPending()) watchOpenedPort(port);
|
|
22017
|
+
}) ?? (() => {});
|
|
22018
|
+
const stopEngineMessage = runtime.onEngineMessage?.((message) => {
|
|
22019
|
+
if (message.type === "engine_extension_ui_reset") machine.hostSessionChanged();
|
|
22020
|
+
else if (message.type === "engine_agent_queue_invalidated") machine.invalidateChild({
|
|
22021
|
+
sessionId: message.sessionId,
|
|
22022
|
+
...message.sessionFile === void 0 ? {} : { sessionFile: message.sessionFile }
|
|
22023
|
+
}, message.reason);
|
|
22024
|
+
}) ?? (() => {});
|
|
20831
22025
|
const stopEnded = runtime.onGenerationEnded((event) => {
|
|
20832
22026
|
if (event.expected) return;
|
|
20833
22027
|
const reported = /* @__PURE__ */ new Set();
|
|
20834
22028
|
for (const { port, controller } of liveAgentSteering(mode)) {
|
|
20835
|
-
const
|
|
22029
|
+
const status = port.status();
|
|
22030
|
+
const { delivering, unsaved, receipts, name } = status;
|
|
20836
22031
|
const texts = [...unsaved ?? [], ...delivering === void 0 ? [] : [...delivering.steering, ...delivering.followUp]];
|
|
20837
22032
|
const taken = texts.flatMap((text, index) => {
|
|
20838
22033
|
const receipt = receipts?.taken.length === texts.length ? receipts.taken[index] : void 0;
|
|
@@ -20852,22 +22047,52 @@ function attachLostAgentQueueNotices(mode, runtime) {
|
|
|
20852
22047
|
controller.loseTarget();
|
|
20853
22048
|
const listed = controller.recoverTarget() ?? [];
|
|
20854
22049
|
const find = runtime.findQueuedMessages?.bind(runtime);
|
|
20855
|
-
|
|
20856
|
-
|
|
22050
|
+
const identity = canTrackChildRestore(status);
|
|
22051
|
+
const hasReceipts = receipts !== void 0 && find !== void 0 && taken.some((message) => message.receipt !== void 0);
|
|
22052
|
+
if (runtime.onEngineRecovered === void 0 || !hasReceipts && (listed.length === 0 || identity === void 0)) {
|
|
22053
|
+
const unconfirmed = taken.map((message) => message.text);
|
|
22054
|
+
if (unconfirmed.length > 0) mode.showWarning(engineLossUnconfirmedNotice(unconfirmed, name));
|
|
22055
|
+
const notice = engineLossSubagentNotice({
|
|
22056
|
+
agent: name,
|
|
22057
|
+
steering: listed,
|
|
22058
|
+
followUp: []
|
|
22059
|
+
});
|
|
22060
|
+
if (notice !== void 0) mode.showWarning(notice);
|
|
20857
22061
|
continue;
|
|
20858
22062
|
}
|
|
22063
|
+
const ticket = machine.beginLookup({
|
|
22064
|
+
agent: name,
|
|
22065
|
+
taken,
|
|
22066
|
+
listed,
|
|
22067
|
+
identity,
|
|
22068
|
+
hostSessionId: currentHostSessionId(mode)
|
|
22069
|
+
});
|
|
20859
22070
|
const stop = runtime.onEngineRecovered((replaced) => {
|
|
20860
22071
|
stop();
|
|
20861
22072
|
stops.delete(stop);
|
|
20862
22073
|
(async () => {
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
|
|
20869
|
-
|
|
20870
|
-
|
|
22074
|
+
let found;
|
|
22075
|
+
if (replaced && hasReceipts) {
|
|
22076
|
+
const session = {
|
|
22077
|
+
sessionId: receipts.sessionId,
|
|
22078
|
+
...receipts.sessionFile === void 0 ? {} : { sessionFile: receipts.sessionFile }
|
|
22079
|
+
};
|
|
22080
|
+
found = await settledWithin(find(taken, session), RECEIPT_LOOKUP_TIMEOUT_MS);
|
|
22081
|
+
}
|
|
22082
|
+
const applied = applyRestoreActions(mode, machine.settleLookup(ticket, {
|
|
22083
|
+
replaced,
|
|
22084
|
+
found,
|
|
22085
|
+
currentHostSessionId: currentHostSessionId(mode),
|
|
22086
|
+
currentView: currentChildView(mode)
|
|
22087
|
+
}));
|
|
22088
|
+
if (machine.hasPending()) {
|
|
22089
|
+
const viewed = mode.agentView?.viewed;
|
|
22090
|
+
if (viewed?.kind === "agent") {
|
|
22091
|
+
if (mode.agentView?.pendingTaskId !== void 0) deferredOpenPort = viewed.port;
|
|
22092
|
+
else watchOpenedPort(viewed.port);
|
|
22093
|
+
}
|
|
22094
|
+
}
|
|
22095
|
+
if (applied) mode.ui.requestRender();
|
|
20871
22096
|
})();
|
|
20872
22097
|
});
|
|
20873
22098
|
stops.add(stop);
|
|
@@ -20876,28 +22101,18 @@ function attachLostAgentQueueNotices(mode, runtime) {
|
|
|
20876
22101
|
mode.ui.requestRender();
|
|
20877
22102
|
});
|
|
20878
22103
|
return () => {
|
|
20879
|
-
|
|
22104
|
+
machine.dispose();
|
|
22105
|
+
unwatchOpenedPort?.();
|
|
22106
|
+
unwatchOpenedPort = void 0;
|
|
22107
|
+
deferredOpenPort = void 0;
|
|
22108
|
+
stopChange();
|
|
22109
|
+
stopPending();
|
|
22110
|
+
stopEngineMessage();
|
|
20880
22111
|
stopEnded();
|
|
20881
22112
|
for (const stop of [...stops]) stop();
|
|
20882
22113
|
stops.clear();
|
|
20883
22114
|
};
|
|
20884
22115
|
}
|
|
20885
|
-
/**
|
|
20886
|
-
* The notices for one subagent whose engine was lost: what it had taken that `found` (its replacement's answer, if any)
|
|
20887
|
-
* does not account for, as possibly undelivered; what it never sent, `listed` and the taken messages its store never
|
|
20888
|
-
* saved, as not sent.
|
|
20889
|
-
*/
|
|
20890
|
-
function showLostAgentNotices(mode, agent, taken, listed, found) {
|
|
20891
|
-
const outcome = (message) => message.receipt === void 0 ? "unknown" : found?.saved.has(message.receipt.id) ? "saved" : found?.absent.has(message.receipt.id) ? "unsaved" : "unknown";
|
|
20892
|
-
const unconfirmed = taken.flatMap((message) => outcome(message) === "unknown" ? [message.text] : []);
|
|
20893
|
-
if (unconfirmed.length > 0) mode.showWarning(engineLossUnconfirmedNotice(unconfirmed, agent));
|
|
20894
|
-
const notice = engineLossSubagentNotice({
|
|
20895
|
-
agent,
|
|
20896
|
-
steering: [...taken.flatMap((message) => outcome(message) === "unsaved" ? [message.receipt?.typed ?? message.text] : []), ...listed],
|
|
20897
|
-
followUp: []
|
|
20898
|
-
});
|
|
20899
|
-
if (notice !== void 0) mode.showWarning(notice);
|
|
20900
|
-
}
|
|
20901
22116
|
// dist/modes/interactive/agent-view/install.js
|
|
20902
22117
|
const switchers = /* @__PURE__ */ new WeakMap();
|
|
20903
22118
|
/**
|
|
@@ -20913,43 +22128,6 @@ function agentViewSwitcher(mode, openPort = (taskId, options) => openAgentViewPo
|
|
|
20913
22128
|
}
|
|
20914
22129
|
return switcher;
|
|
20915
22130
|
}
|
|
20916
|
-
/**
|
|
20917
|
-
* Set up the single chat screen once the main screen is: the transcript area, the prompt's retargeting and the
|
|
20918
|
-
* hotkey gates follow what the switcher shows, in that order. On the isolated host the engine's panel and `/tasks`
|
|
20919
|
-
* reach the switcher through `engine_view_agent`, and learn what it shows through `set_viewed_agent`.
|
|
20920
|
-
*/
|
|
20921
|
-
/**
|
|
20922
|
-
* Tells the engine what the screen shows, with `tell`: when it changes, and when a request ends without showing what
|
|
20923
|
-
* it asked for, since the engine lists the subagent it asked to show while the screen is kept for it.
|
|
20924
|
-
*/
|
|
20925
|
-
function tellEngineViewed(switcher, tell, beforeCorrection) {
|
|
20926
|
-
const stopChange = switcher.onChange(({ to }) => tell(to.kind === "agent" ? to.port.status().taskId : void 0));
|
|
20927
|
-
const stopPending = switcher.onPending((pending, settled) => {
|
|
20928
|
-
if (pending !== void 0 || settled === void 0 || settled.outcome === "shown") return;
|
|
20929
|
-
beforeCorrection?.(settled.taskId);
|
|
20930
|
-
tell(switcher.viewedTaskId());
|
|
20931
|
-
});
|
|
20932
|
-
return () => {
|
|
20933
|
-
stopChange();
|
|
20934
|
-
stopPending();
|
|
20935
|
-
};
|
|
20936
|
-
}
|
|
20937
|
-
/**
|
|
20938
|
-
* Shows what the engine asks for (`engine_view_agent`). While the screen is kept for it, the engine's panel is told
|
|
20939
|
-
* first that the subagent is about to be shown (`tell`), so that the panel draws its row before the subagent is shown;
|
|
20940
|
-
* a request that ends without showing it tells the engine what the screen shows instead (tellEngineViewed).
|
|
20941
|
-
*/
|
|
20942
|
-
function showForEngine(switcher, message, tell) {
|
|
20943
|
-
const taskId = message.taskId === null ? void 0 : message.taskId;
|
|
20944
|
-
const keepScreen = message.keepScreen === true;
|
|
20945
|
-
const panelOnView = keepScreen && taskId !== void 0 && message.panelOnView === true;
|
|
20946
|
-
if (panelOnView) tell(taskId);
|
|
20947
|
-
switcher.requestView(taskId, {
|
|
20948
|
-
keepScreen,
|
|
20949
|
-
panel: message.panel === true || panelOnView
|
|
20950
|
-
});
|
|
20951
|
-
return panelOnView ? taskId : void 0;
|
|
20952
|
-
}
|
|
20953
22131
|
function installAgentView(mode) {
|
|
20954
22132
|
const switcher = agentViewSwitcher(mode);
|
|
20955
22133
|
const undo = [
|
|
@@ -20959,19 +22137,189 @@ function installAgentView(mode) {
|
|
|
20959
22137
|
];
|
|
20960
22138
|
const runtime = mode.runtimeHost;
|
|
20961
22139
|
if (runtime instanceof IsolatedInteractiveRuntime) {
|
|
20962
|
-
let
|
|
20963
|
-
|
|
22140
|
+
let sync = initialHostEngineViewSyncState();
|
|
22141
|
+
let resettingGeneration = false;
|
|
22142
|
+
let replacingWithPreview = false;
|
|
22143
|
+
let supersededSettledForPreview;
|
|
22144
|
+
let syncEngineRequestId;
|
|
22145
|
+
const advanceSettled = (candidate) => {
|
|
22146
|
+
if (candidate !== void 0 && candidate > sync.settledRequestId) sync = {
|
|
22147
|
+
...sync,
|
|
22148
|
+
settledRequestId: candidate
|
|
22149
|
+
};
|
|
22150
|
+
return sync.settledRequestId;
|
|
22151
|
+
};
|
|
22152
|
+
const allocateViewSeq = () => {
|
|
22153
|
+
const viewSeq = sync.viewSeq + 1;
|
|
22154
|
+
sync = {
|
|
22155
|
+
...sync,
|
|
22156
|
+
viewSeq
|
|
22157
|
+
};
|
|
22158
|
+
return viewSeq;
|
|
22159
|
+
};
|
|
22160
|
+
const sendSetViewed = (payload) => {
|
|
22161
|
+
const viewSeq = payload.viewSeq ?? allocateViewSeq();
|
|
22162
|
+
const settled = payload.settledRequestId;
|
|
22163
|
+
if (settled !== void 0 && settled > sync.lastSentSettledRequestId) sync = {
|
|
22164
|
+
...sync,
|
|
22165
|
+
lastSentSettledRequestId: settled
|
|
22166
|
+
};
|
|
22167
|
+
if (resettingGeneration) return viewSeq;
|
|
20964
22168
|
runtime.requestAgentView({
|
|
20965
22169
|
type: "set_viewed_agent",
|
|
20966
|
-
...taskId === void 0 ? {} : { taskId }
|
|
22170
|
+
...payload.taskId === void 0 ? {} : { taskId: payload.taskId },
|
|
22171
|
+
...payload.preview === true ? { preview: true } : {},
|
|
22172
|
+
viewSeq,
|
|
22173
|
+
...payload.requestId === void 0 ? {} : { requestId: payload.requestId },
|
|
22174
|
+
...settled === void 0 ? {} : { settledRequestId: settled }
|
|
20967
22175
|
}).catch(() => {});
|
|
22176
|
+
return viewSeq;
|
|
22177
|
+
};
|
|
22178
|
+
const resetGenerationSync = () => {
|
|
22179
|
+
sync = initialHostEngineViewSyncState();
|
|
22180
|
+
supersededSettledForPreview = void 0;
|
|
22181
|
+
syncEngineRequestId = void 0;
|
|
22182
|
+
resetWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY);
|
|
20968
22183
|
};
|
|
20969
22184
|
undo.push(runtime.onEngineMessage((message) => {
|
|
20970
|
-
if (message.type === "
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
22185
|
+
if (message.type === "engine_ready") {
|
|
22186
|
+
resetGenerationSync();
|
|
22187
|
+
return;
|
|
22188
|
+
}
|
|
22189
|
+
if (message.type !== "engine_view_agent") return;
|
|
22190
|
+
const taskId = message.taskId === null ? void 0 : message.taskId;
|
|
22191
|
+
const keepScreen = message.keepScreen === true;
|
|
22192
|
+
const panelOnView = keepScreen && taskId !== void 0 && message.panelOnView === true;
|
|
22193
|
+
const engineRequestId = message.requestId;
|
|
22194
|
+
const tagged = engineRequestId !== void 0;
|
|
22195
|
+
if (taskId !== void 0 && keepScreen && shouldCancelEngineViewOnArrival(true, true, true, hasUnansweredNavigationCancelInput(runtime, (data) => isCancelPendingOpenKey(mode.keybindings, data), isPhysicalEscape))) {
|
|
22196
|
+
const priorPendingActive = switcher.pendingTaskId !== void 0;
|
|
22197
|
+
const plan = planPreViewCancelAck(sync.settledRequestId, sync.lastSentSettledRequestId, engineRequestId ?? 0, priorPendingActive);
|
|
22198
|
+
advanceSettled(engineRequestId);
|
|
22199
|
+
if (priorPendingActive) switcher.cancelPending();
|
|
22200
|
+
if (plan.shouldSendAck) {
|
|
22201
|
+
const viewed = switcher.viewedTaskId();
|
|
22202
|
+
sendSetViewed({
|
|
22203
|
+
...viewed === void 0 ? {} : { taskId: viewed },
|
|
22204
|
+
...engineRequestId === void 0 && plan.nextSettledReq === 0 ? {} : { settledRequestId: plan.nextSettledReq }
|
|
22205
|
+
});
|
|
22206
|
+
}
|
|
22207
|
+
return;
|
|
22208
|
+
}
|
|
22209
|
+
replacingWithPreview = panelOnView && switcher.viewedTaskId() !== taskId;
|
|
22210
|
+
supersededSettledForPreview = void 0;
|
|
22211
|
+
syncEngineRequestId = taskId === void 0 ? engineRequestId : void 0;
|
|
22212
|
+
try {
|
|
22213
|
+
switcher.requestView(taskId, {
|
|
22214
|
+
keepScreen,
|
|
22215
|
+
panel: message.panel === true || panelOnView
|
|
22216
|
+
});
|
|
22217
|
+
} finally {
|
|
22218
|
+
replacingWithPreview = false;
|
|
22219
|
+
syncEngineRequestId = void 0;
|
|
22220
|
+
}
|
|
22221
|
+
const pendingHostId = switcher.pendingRequestId;
|
|
22222
|
+
if (pendingHostId !== void 0 && taskId !== void 0) {
|
|
22223
|
+
if (panelOnView) {
|
|
22224
|
+
const previewSeq = allocateViewSeq();
|
|
22225
|
+
sync = {
|
|
22226
|
+
...sync,
|
|
22227
|
+
pendingEngine: {
|
|
22228
|
+
hostRequestId: pendingHostId,
|
|
22229
|
+
engineRequestId,
|
|
22230
|
+
previewSeq,
|
|
22231
|
+
tagged
|
|
22232
|
+
}
|
|
22233
|
+
};
|
|
22234
|
+
stageWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY, previewSeq, tagged);
|
|
22235
|
+
sendSetViewed({
|
|
22236
|
+
taskId,
|
|
22237
|
+
preview: true,
|
|
22238
|
+
viewSeq: previewSeq,
|
|
22239
|
+
...engineRequestId === void 0 ? {} : { requestId: engineRequestId },
|
|
22240
|
+
...supersededSettledForPreview === void 0 ? {} : { settledRequestId: supersededSettledForPreview }
|
|
22241
|
+
});
|
|
22242
|
+
} else sync = {
|
|
22243
|
+
...sync,
|
|
22244
|
+
pendingEngine: {
|
|
22245
|
+
hostRequestId: pendingHostId,
|
|
22246
|
+
engineRequestId,
|
|
22247
|
+
tagged
|
|
22248
|
+
}
|
|
22249
|
+
};
|
|
22250
|
+
supersededSettledForPreview = void 0;
|
|
22251
|
+
return;
|
|
22252
|
+
}
|
|
22253
|
+
supersededSettledForPreview = void 0;
|
|
22254
|
+
const settled = advanceSettled(engineRequestId);
|
|
22255
|
+
if (engineRequestId !== void 0 && sync.lastSentSettledRequestId < engineRequestId) sendSetViewed({
|
|
22256
|
+
...switcher.viewedTaskId() === void 0 ? {} : { taskId: switcher.viewedTaskId() },
|
|
22257
|
+
settledRequestId: settled
|
|
22258
|
+
});
|
|
22259
|
+
}), runtime.onGenerationEnded(() => {
|
|
22260
|
+
resetGenerationSync();
|
|
22261
|
+
resettingGeneration = true;
|
|
22262
|
+
try {
|
|
22263
|
+
switcher.reset("generation-lost");
|
|
22264
|
+
} finally {
|
|
22265
|
+
resettingGeneration = false;
|
|
22266
|
+
}
|
|
22267
|
+
}), switcher.onChange(({ to }) => {
|
|
22268
|
+
if (resettingGeneration) return;
|
|
22269
|
+
const toTaskId = to.kind === "agent" ? to.port.status().taskId : void 0;
|
|
22270
|
+
const pending = sync.pendingEngine;
|
|
22271
|
+
if (pending !== void 0 && switcher.pendingRequestId === pending.hostRequestId && to.kind === "agent") {
|
|
22272
|
+
sync = {
|
|
22273
|
+
...sync,
|
|
22274
|
+
pendingEngine: void 0
|
|
22275
|
+
};
|
|
22276
|
+
const settled = advanceSettled(pending.engineRequestId);
|
|
22277
|
+
if (pending.previewSeq !== void 0) commitWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY, pending.previewSeq);
|
|
22278
|
+
else clearPromotedWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY);
|
|
22279
|
+
sendSetViewed({
|
|
22280
|
+
taskId: toTaskId,
|
|
22281
|
+
settledRequestId: settled
|
|
22282
|
+
});
|
|
22283
|
+
return;
|
|
22284
|
+
}
|
|
22285
|
+
clearPromotedWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY);
|
|
22286
|
+
const settled = advanceSettled(syncEngineRequestId);
|
|
22287
|
+
sendSetViewed({
|
|
22288
|
+
...toTaskId === void 0 ? {} : { taskId: toTaskId },
|
|
22289
|
+
settledRequestId: settled
|
|
22290
|
+
});
|
|
22291
|
+
}), switcher.onPending((pendingTask, settled) => {
|
|
22292
|
+
if (resettingGeneration || settled === void 0) return;
|
|
22293
|
+
const active = sync.pendingEngine;
|
|
22294
|
+
if (active !== void 0 && settled.requestId === active.hostRequestId) {
|
|
22295
|
+
sync = {
|
|
22296
|
+
...sync,
|
|
22297
|
+
pendingEngine: void 0
|
|
22298
|
+
};
|
|
22299
|
+
const settledReq = advanceSettled(active.engineRequestId);
|
|
22300
|
+
if (settled.outcome === "shown") {
|
|
22301
|
+
if (active.previewSeq !== void 0) commitWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY, active.previewSeq);
|
|
22302
|
+
if (active.engineRequestId !== void 0 && sync.lastSentSettledRequestId < active.engineRequestId) sendSetViewed({
|
|
22303
|
+
...switcher.viewedTaskId() === void 0 ? {} : { taskId: switcher.viewedTaskId() },
|
|
22304
|
+
settledRequestId: settledReq
|
|
22305
|
+
});
|
|
22306
|
+
return;
|
|
22307
|
+
}
|
|
22308
|
+
if (replacingWithPreview) {
|
|
22309
|
+
if (active.engineRequestId !== void 0) supersededSettledForPreview = settledReq;
|
|
22310
|
+
return;
|
|
22311
|
+
}
|
|
22312
|
+
if (active.previewSeq !== void 0) cancelWidgetPreview(runtime, AGENT_PANEL_WIDGET_KEY, active.tagged ? void 0 : 250);
|
|
22313
|
+
sendSetViewed({
|
|
22314
|
+
...switcher.viewedTaskId() === void 0 ? {} : { taskId: switcher.viewedTaskId() },
|
|
22315
|
+
settledRequestId: settledReq
|
|
22316
|
+
});
|
|
22317
|
+
return;
|
|
22318
|
+
}
|
|
22319
|
+
if (pendingTask === void 0 && settled.outcome !== "shown") sendSetViewed({
|
|
22320
|
+
...switcher.viewedTaskId() === void 0 ? {} : { taskId: switcher.viewedTaskId() },
|
|
22321
|
+
settledRequestId: sync.settledRequestId
|
|
22322
|
+
});
|
|
20975
22323
|
}));
|
|
20976
22324
|
}
|
|
20977
22325
|
mode.disposeAgentView = () => {
|
|
@@ -21407,7 +22755,10 @@ InteractiveModeBase.prototype.init = async function() {
|
|
|
21407
22755
|
});
|
|
21408
22756
|
markLifecycleTiming("tui-start");
|
|
21409
22757
|
if (this.options.terminal === void 0 && startupShellTerminal() !== void 0) await whenStartupShellCanHandOver();
|
|
22758
|
+
if (this.isShuttingDown) return;
|
|
21410
22759
|
const earlyEditor = this.options.terminal === void 0 ? handOverStartupShell() : void 0;
|
|
22760
|
+
this.tuiStarted = true;
|
|
22761
|
+
this.terminalStopped = false;
|
|
21411
22762
|
this.ui.start();
|
|
21412
22763
|
if (earlyEditor) {
|
|
21413
22764
|
this.defaultEditor.restoreDraft(earlyEditor.draft);
|
|
@@ -21472,24 +22823,35 @@ InteractiveModeBase.prototype.init = async function() {
|
|
|
21472
22823
|
else if (needsChangelogPreload((this.session?.state?.messages?.length ?? 0) > 0, this.settingsManager?.getLastChangelogVersion?.(), VERSION)) await preloadChangelog(getChangelogPath());
|
|
21473
22824
|
const startup = this.sessionStartup;
|
|
21474
22825
|
await bindInitialEagerSession(this);
|
|
21475
|
-
if (startup?.cancelled) return;
|
|
22826
|
+
if (startup?.cancelled || this.isShuttingDown) return;
|
|
21476
22827
|
reportUnavailableTools(this);
|
|
22828
|
+
if ((this.sessionManager?.getEntryCount?.() ?? 0) > 64) {
|
|
22829
|
+
await yieldToTimerTurn();
|
|
22830
|
+
if (startup?.cancelled || this.isShuttingDown) return;
|
|
22831
|
+
}
|
|
21477
22832
|
}
|
|
21478
22833
|
this.attachStartupNoticesContainer();
|
|
21479
22834
|
this.renderInitialMessages();
|
|
21480
22835
|
if (!this.deferredStartupPending) this.startSessionRecovery("startup");
|
|
21481
22836
|
onThemeChange(() => {
|
|
22837
|
+
if (this.isShuttingDown || !this.isInitialized) return;
|
|
21482
22838
|
this.ui.invalidate();
|
|
21483
22839
|
this.updateEditorBorderColor();
|
|
21484
22840
|
this.ui.requestRender();
|
|
21485
22841
|
});
|
|
21486
22842
|
updateProviderCountFromSnapshot(this);
|
|
21487
22843
|
};
|
|
21488
|
-
InteractiveModeBase.
|
|
21489
|
-
|
|
21490
|
-
const
|
|
22844
|
+
/** Writes Atomic's default terminal window title and clears {@link InteractiveModeBase.extensionTitleActive}. */
|
|
22845
|
+
function writeDefaultTerminalTitle(mode) {
|
|
22846
|
+
const cwdBasename = path$1.basename(mode.sessionManager.getCwd());
|
|
22847
|
+
const sessionName = mode.sessionManager.getSessionName();
|
|
21491
22848
|
const title = sessionName ? `${APP_TITLE} - ${sessionName} - ${cwdBasename}` : `${APP_TITLE} - ${cwdBasename}`;
|
|
21492
|
-
|
|
22849
|
+
mode.ui.terminal.setTitle(replaceControlCharacters(title));
|
|
22850
|
+
mode.extensionTitleActive = false;
|
|
22851
|
+
}
|
|
22852
|
+
InteractiveModeBase.prototype.updateTerminalTitle = function() {
|
|
22853
|
+
if (this.isShuttingDown || this.terminalStopped || this.isInitialized === false && !this.tuiStarted) return;
|
|
22854
|
+
writeDefaultTerminalTitle(this);
|
|
21493
22855
|
};
|
|
21494
22856
|
/**
|
|
21495
22857
|
* Shows how a resumed session's checkout was prepared with the startup notices, which survive the chat rebuild that
|
|
@@ -21517,6 +22879,14 @@ InteractiveModeBase.prototype.run = async function() {
|
|
|
21517
22879
|
if (this.isShuttingDown || startup?.cancelled || this.sessionStartup?.cancelled) return;
|
|
21518
22880
|
if (shouldRefreshCatalogsOnStartup()) refreshCatalogsAfterTuiStartup(this);
|
|
21519
22881
|
if (this.postStartupTimer !== void 0) clearTimeout(this.postStartupTimer);
|
|
22882
|
+
armPostStartupHighlightWarmup(this, (signal) => {
|
|
22883
|
+
if (processCompileCacheDeferral() && !this.isShuttingDown) import("./p0-cli-BB45ZQY6.js").catch((error) => __atomicOnDemandFailed(error, "this feature")).then((n) => n.compile_cache_warmup_host_exports).then(({ warmCompileCache }) => warmCompileCache(engineHeapRuntimeArgsForHost(true))).catch(() => {});
|
|
22884
|
+
return loadAllHighlightLanguages({ signal }).then(() => {
|
|
22885
|
+
if (this.isShuttingDown || signal.aborted) return;
|
|
22886
|
+
this.ui.invalidate();
|
|
22887
|
+
this.ui.requestRender();
|
|
22888
|
+
});
|
|
22889
|
+
});
|
|
21520
22890
|
this.postStartupTimer = setTimeout(() => {
|
|
21521
22891
|
this.postStartupTimer = void 0;
|
|
21522
22892
|
if (this.isShuttingDown) return;
|
|
@@ -21535,12 +22905,7 @@ InteractiveModeBase.prototype.run = async function() {
|
|
|
21535
22905
|
if (warning) this.showWarning(warning, startupNoticesContainer);
|
|
21536
22906
|
});
|
|
21537
22907
|
if (!this.deferredStartupPending && !this.deferredStartupPromise) this.maybeWarnAboutAnthropicSubscriptionAuth(void 0, startupNoticesContainer);
|
|
21538
|
-
|
|
21539
|
-
loadAllHighlightLanguages().then(() => {
|
|
21540
|
-
if (this.isShuttingDown) return;
|
|
21541
|
-
this.ui.invalidate();
|
|
21542
|
-
this.ui.requestRender();
|
|
21543
|
-
});
|
|
22908
|
+
onPostStartupTimerFired(this);
|
|
21544
22909
|
}, 500);
|
|
21545
22910
|
this.postStartupTimer.unref?.();
|
|
21546
22911
|
const { migratedProviders, startupDiagnostics, resumeNotices, initialMessage, initialImages, initialMessages } = this.options;
|
|
@@ -21554,17 +22919,27 @@ InteractiveModeBase.prototype.run = async function() {
|
|
|
21554
22919
|
const startupPrompt = Boolean(initialMessage || initialMessages && initialMessages.length > 0);
|
|
21555
22920
|
if (startupPrompt) this.startManagedToolReadiness();
|
|
21556
22921
|
if (this.deferredStartupPending && startupPrompt) await this.ensureDeferredStartupComplete();
|
|
21557
|
-
if (initialMessage)
|
|
21558
|
-
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
|
|
22922
|
+
if (initialMessage) {
|
|
22923
|
+
const endInitialTurn = beginPostStartupPromptTurn(this);
|
|
22924
|
+
try {
|
|
22925
|
+
await this.session.prompt(initialMessage, { images: initialImages });
|
|
22926
|
+
} catch (error) {
|
|
22927
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
22928
|
+
this.showError(errorMessage);
|
|
22929
|
+
} finally {
|
|
22930
|
+
endInitialTurn();
|
|
22931
|
+
}
|
|
21562
22932
|
}
|
|
21563
|
-
if (initialMessages) for (const message of initialMessages)
|
|
21564
|
-
|
|
21565
|
-
|
|
21566
|
-
|
|
21567
|
-
|
|
22933
|
+
if (initialMessages) for (const message of initialMessages) {
|
|
22934
|
+
const endInitialTurn = beginPostStartupPromptTurn(this);
|
|
22935
|
+
try {
|
|
22936
|
+
await this.session.prompt(message);
|
|
22937
|
+
} catch (error) {
|
|
22938
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
22939
|
+
this.showError(errorMessage);
|
|
22940
|
+
} finally {
|
|
22941
|
+
endInitialTurn();
|
|
22942
|
+
}
|
|
21568
22943
|
}
|
|
21569
22944
|
while (true) {
|
|
21570
22945
|
const nextInput = this.getUserInput();
|
|
@@ -21731,6 +23106,7 @@ async function ensureDeferredStartupComplete(mode) {
|
|
|
21731
23106
|
reportDebugAsync("storage", "deferred-startup-incomplete", failureDebugFields(error));
|
|
21732
23107
|
} finally {
|
|
21733
23108
|
if (mode.deferredStartupPromise === startupPromise && !mode.deferredStartupPending) mode.deferredStartupPromise = void 0;
|
|
23109
|
+
notifyPostStartupDeferredComplete(mode);
|
|
21734
23110
|
}
|
|
21735
23111
|
}
|
|
21736
23112
|
InteractiveModeBase.prototype.ensureDeferredStartupComplete = async function() {
|
|
@@ -21771,9 +23147,12 @@ InteractiveModeBase.prototype.completeDeferredStartup = async function() {
|
|
|
21771
23147
|
if (completedStartupTrust) showSessionNotices(this, this.runtimeHost?.services.diagnostics);
|
|
21772
23148
|
else await applyDeferredModelScope(this);
|
|
21773
23149
|
await this.retryDeferredModelRestore(this.startupNoticesContainer);
|
|
21774
|
-
if (!runsInteractiveEngine(this.runtimeHost) && !this.
|
|
21775
|
-
if (
|
|
21776
|
-
|
|
23150
|
+
if (!runsInteractiveEngine(this.runtimeHost) && !this.isShuttingDown) {
|
|
23151
|
+
if (this.promptTurnWorkingLoaderActive) prewarmModelApi(this.session.model, this.session.modelRuntime);
|
|
23152
|
+
else setImmediate(() => {
|
|
23153
|
+
if (!this.isShuttingDown) prewarmModelApi(this.session.model, this.session.modelRuntime);
|
|
23154
|
+
});
|
|
23155
|
+
}
|
|
21777
23156
|
} finally {
|
|
21778
23157
|
checkFallbackModels();
|
|
21779
23158
|
}
|
|
@@ -21807,6 +23186,7 @@ InteractiveModeBase.prototype.completeDeferredStartup = async function() {
|
|
|
21807
23186
|
}
|
|
21808
23187
|
await reportUnavailableTools(this);
|
|
21809
23188
|
this.startSessionRecovery("startup");
|
|
23189
|
+
notifyPostStartupDeferredComplete(this);
|
|
21810
23190
|
};
|
|
21811
23191
|
async function applyDeferredModelScope(mode) {
|
|
21812
23192
|
const patterns = mode.options.deferredModelScopePatterns;
|
|
@@ -22790,7 +24170,11 @@ InteractiveModeBase.prototype.createExtensionUIContext = function() {
|
|
|
22790
24170
|
setFooter: (factory) => shown(this.setExtensionFooter(factory)),
|
|
22791
24171
|
onWidgetRelease: (key, listener) => this.onExtensionWidgetRelease(key, listener),
|
|
22792
24172
|
setHeader: (factory) => shown(this.setExtensionHeader(factory)),
|
|
22793
|
-
setTitle: (title) =>
|
|
24173
|
+
setTitle: (title) => {
|
|
24174
|
+
if (this.isShuttingDown || this.terminalStopped || this.isInitialized === false && !this.tuiStarted) return;
|
|
24175
|
+
this.extensionTitleActive = true;
|
|
24176
|
+
this.ui.terminal.setTitle(replaceControlCharacters(title));
|
|
24177
|
+
},
|
|
22794
24178
|
custom: (factory, options) => this.showExtensionCustom(factory, options),
|
|
22795
24179
|
hostSessionPicker: (request) => openLocalHostSessionPicker({
|
|
22796
24180
|
custom: (factory, options) => this.showExtensionCustom(factory, options),
|
|
@@ -23501,7 +24885,10 @@ function toInteractiveSubmission(value) {
|
|
|
23501
24885
|
}
|
|
23502
24886
|
// dist/modes/interactive/interactive-prompt-turn.js
|
|
23503
24887
|
InteractiveModeBase.prototype.runUserPromptTurn = async function(input) {
|
|
24888
|
+
const endPostStartupPromptTurn = beginPostStartupPromptTurn(this);
|
|
23504
24889
|
const { text: userInput, draft, echo: submittedEcho } = toInteractiveSubmission(input);
|
|
24890
|
+
const originSendId = randomUUID();
|
|
24891
|
+
if (submittedEcho !== void 0) noteDeferredEchoOrigin(this, userInput, submittedEcho, originSendId);
|
|
23505
24892
|
const extensionCommandHold = typeof input === "string" ? void 0 : takeSubmittedExtensionCommandHold(input);
|
|
23506
24893
|
const turn = this.promptTurn ?? { dispatched: false };
|
|
23507
24894
|
this.promptTurn = turn;
|
|
@@ -23527,14 +24914,17 @@ InteractiveModeBase.prototype.runUserPromptTurn = async function(input) {
|
|
|
23527
24914
|
if (!(!(this.runtimeHost instanceof IsolatedInteractiveRuntime) && await tryExecuteSessionSlashCommand(this.session, userInput))) {
|
|
23528
24915
|
if (!(this.runtimeHost instanceof IsolatedInteractiveRuntime) || !this.isExtensionCommand(userInput)) await this.session.resumeQueuedMessages();
|
|
23529
24916
|
const shownBefore = this.userMessagesShownBySession;
|
|
24917
|
+
if (submittedEcho !== void 0) noteDeferredEchoShownBaseline(this, submittedEcho, taggedUserMessagesShownCount(this));
|
|
23530
24918
|
const startedEcho = followStartedRunEcho(this, userInput, {
|
|
23531
24919
|
sendShowsWorkingRow: true,
|
|
23532
|
-
echo: submittedEcho
|
|
24920
|
+
echo: submittedEcho,
|
|
24921
|
+
originSendId
|
|
23533
24922
|
});
|
|
23534
24923
|
echo = startedEcho;
|
|
23535
24924
|
let started = false;
|
|
23536
24925
|
await this.session.prompt(userInput, {
|
|
23537
24926
|
streamingBehavior: "steer",
|
|
24927
|
+
originSendId,
|
|
23538
24928
|
preflightResult: (success, disposition) => {
|
|
23539
24929
|
refused = !success;
|
|
23540
24930
|
if (success && (disposition === "queued" || disposition === "handled")) this.discardDeferredRenderedUserInput(userInput, submittedEcho);
|
|
@@ -23567,6 +24957,7 @@ InteractiveModeBase.prototype.runUserPromptTurn = async function(input) {
|
|
|
23567
24957
|
this.workingRunMeter.stop();
|
|
23568
24958
|
this.stopWorkingLoader();
|
|
23569
24959
|
}
|
|
24960
|
+
endPostStartupPromptTurn();
|
|
23570
24961
|
}
|
|
23571
24962
|
};
|
|
23572
24963
|
// dist/modes/interactive/interactive-summarization-retry-events.js
|
|
@@ -23835,7 +25226,7 @@ async function handleAgentEvent(event, call) {
|
|
|
23835
25226
|
this.pendingTools.clear();
|
|
23836
25227
|
mainTurnToolBatches.delete(this);
|
|
23837
25228
|
endMainToolTurn(this);
|
|
23838
|
-
if (this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(true);
|
|
25229
|
+
if (!this.isShuttingDown && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(true);
|
|
23839
25230
|
if (this.retryEscapeHandler) {
|
|
23840
25231
|
this.defaultEditor.onEscape = this.retryEscapeHandler;
|
|
23841
25232
|
this.retryEscapeHandler = void 0;
|
|
@@ -23928,6 +25319,7 @@ async function handleAgentEvent(event, call) {
|
|
|
23928
25319
|
this.updatePendingMessagesDisplay();
|
|
23929
25320
|
this.ui.requestRender();
|
|
23930
25321
|
} else if (event.message.role === "assistant") {
|
|
25322
|
+
notifyPostStartupPromptStreaming(this);
|
|
23931
25323
|
this.streamingComponent = new AssistantMessageComponent(void 0, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad, this.getMarkdownTransformers(), true, this.settingsManager.getLatexRenderingEnabled());
|
|
23932
25324
|
this.streamingMessage = beginStreamingAssistantMessage(event.message);
|
|
23933
25325
|
this.chatContainer.addChild(this.streamingComponent);
|
|
@@ -23936,6 +25328,7 @@ async function handleAgentEvent(event, call) {
|
|
|
23936
25328
|
}
|
|
23937
25329
|
break;
|
|
23938
25330
|
case "message_update":
|
|
25331
|
+
notifyPostStartupPromptStreaming(this);
|
|
23939
25332
|
if (this.streamingMessage) {
|
|
23940
25333
|
applyAssistantMessageDelta(this.streamingMessage, event.assistantMessageEvent);
|
|
23941
25334
|
this.workingRunMeter.streaming(this.streamingMessage);
|
|
@@ -24059,7 +25452,7 @@ async function handleAgentEvent(event, call) {
|
|
|
24059
25452
|
this.workingRunMeter.stop();
|
|
24060
25453
|
this.workingMessage = void 0;
|
|
24061
25454
|
const compactionInProgress = this.compactionActive;
|
|
24062
|
-
if (!compactionInProgress && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(false);
|
|
25455
|
+
if (!this.isShuttingDown && !compactionInProgress && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(false);
|
|
24063
25456
|
if (this.loadingAnimation) this.stopWorkingLoader();
|
|
24064
25457
|
if (workedSnapshot !== void 0 && this.workingVisible && !compactionInProgress && !this.loadingAnimation && !this.autoCompactionLoader && !this.retryLoader && !this.fallbackLoader) {
|
|
24065
25458
|
this.statusContainer.clear();
|
|
@@ -24084,7 +25477,7 @@ async function handleAgentEvent(event, call) {
|
|
|
24084
25477
|
break;
|
|
24085
25478
|
}
|
|
24086
25479
|
case "compaction_start": {
|
|
24087
|
-
if (this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(true);
|
|
25480
|
+
if (!this.isShuttingDown && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(true);
|
|
24088
25481
|
if (this.autoCompactionLoader) {
|
|
24089
25482
|
this.autoCompactionLoader.stop();
|
|
24090
25483
|
this.autoCompactionLoader = void 0;
|
|
@@ -24112,7 +25505,7 @@ async function handleAgentEvent(event, call) {
|
|
|
24112
25505
|
if (manualTakeoverPending) this.manualCompactionTakeoverPending = true;
|
|
24113
25506
|
else if (event.reason === "manual") this.manualCompactionTakeoverPending = false;
|
|
24114
25507
|
const resumesActiveRun = event.midTurn && !event.aborted && !event.errorMessage && !manualTakeoverPending;
|
|
24115
|
-
if (!manualTakeoverPending && !resumesActiveRun && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(false);
|
|
25508
|
+
if (!this.isShuttingDown && !manualTakeoverPending && !resumesActiveRun && this.settingsManager.getShowTerminalProgress()) this.ui.terminal.setProgress(false);
|
|
24116
25509
|
if (!manualTakeoverPending && this.autoCompactionEscapeHandlerSaved) {
|
|
24117
25510
|
this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
|
|
24118
25511
|
this.autoCompactionEscapeHandler = void 0;
|
|
@@ -24386,6 +25779,8 @@ function hostEnding(mode) {
|
|
|
24386
25779
|
ending = {
|
|
24387
25780
|
sigterms: 0,
|
|
24388
25781
|
terminalLost: false,
|
|
25782
|
+
stdoutLost: false,
|
|
25783
|
+
quitDisposed: false,
|
|
24389
25784
|
consoleClosed: false,
|
|
24390
25785
|
lostExitDeciding: false,
|
|
24391
25786
|
terminalLoss: loss.promise,
|
|
@@ -24421,6 +25816,7 @@ function terminalEnded(mode, notice) {
|
|
|
24421
25816
|
if (ending.terminalLost) return;
|
|
24422
25817
|
ending.terminalLost = true;
|
|
24423
25818
|
ending.settleTerminalLoss();
|
|
25819
|
+
if (ending.quitDisposed) return;
|
|
24424
25820
|
spareEngineFromKill(mode);
|
|
24425
25821
|
killSupervisedProcessTrees();
|
|
24426
25822
|
setTimeout(() => lostTerminalBoundEnded(mode), TERMINAL_LOST_SHUTDOWN_MS);
|
|
@@ -24581,9 +25977,14 @@ InteractiveModeBase.prototype.shutdown = async function(options) {
|
|
|
24581
25977
|
await Promise.race([this.exitOutputWritten, ending.terminalLoss]);
|
|
24582
25978
|
await disposeRuntime(this, false);
|
|
24583
25979
|
if (ending.terminalLost) return exitAsTerminalLost(ending);
|
|
25980
|
+
ending.quitDisposed = true;
|
|
24584
25981
|
const resumeCommand = await formatResumeCommand(this.sessionManager);
|
|
24585
|
-
if (ending.
|
|
24586
|
-
if (resumeCommand
|
|
25982
|
+
if (ending.consoleClosed) return exitAsTerminalLost(ending);
|
|
25983
|
+
if (resumeCommand && !ending.stdoutLost) try {
|
|
25984
|
+
process.stdout.write(`${chalk.dim("To resume this session:")} ${resumeCommand}\n`);
|
|
25985
|
+
} catch (error) {
|
|
25986
|
+
if (!isDeadTerminalError(error)) throw error;
|
|
25987
|
+
}
|
|
24587
25988
|
process.exit(0);
|
|
24588
25989
|
};
|
|
24589
25990
|
/**
|
|
@@ -24682,18 +26083,19 @@ function registerEndingHandlers(mode, cleanups) {
|
|
|
24682
26083
|
process.prependListener(signal, handler);
|
|
24683
26084
|
cleanups.push(() => process.off(signal, handler));
|
|
24684
26085
|
}
|
|
24685
|
-
const terminalErrorHandler = (error) => {
|
|
24686
|
-
if (!isDeadTerminalError(error)) {
|
|
24687
|
-
if (hostEnding(mode).lostExitDeciding) return;
|
|
24688
|
-
throw error;
|
|
24689
|
-
}
|
|
24690
|
-
mode.handleTerminalLost();
|
|
24691
|
-
};
|
|
24692
26086
|
for (const stream of [
|
|
24693
26087
|
process.stdin,
|
|
24694
26088
|
process.stdout,
|
|
24695
26089
|
process.stderr
|
|
24696
26090
|
]) {
|
|
26091
|
+
const terminalErrorHandler = (error) => {
|
|
26092
|
+
if (!isDeadTerminalError(error)) {
|
|
26093
|
+
if (hostEnding(mode).lostExitDeciding) return;
|
|
26094
|
+
throw error;
|
|
26095
|
+
}
|
|
26096
|
+
if (stream === process.stdout) hostEnding(mode).stdoutLost = true;
|
|
26097
|
+
mode.handleTerminalLost();
|
|
26098
|
+
};
|
|
24697
26099
|
stream.on("error", terminalErrorHandler);
|
|
24698
26100
|
cleanups.push(() => stream.off("error", terminalErrorHandler));
|
|
24699
26101
|
}
|
|
@@ -24775,7 +26177,8 @@ InteractiveModeBase.prototype.handleFollowUp = async function() {
|
|
|
24775
26177
|
prompt.setText("");
|
|
24776
26178
|
const submitted = await mainSteering(this).submit(text, "followUp", {
|
|
24777
26179
|
route: "queue",
|
|
24778
|
-
showAsQueued: !this.isExtensionCommand(text)
|
|
26180
|
+
showAsQueued: !this.isExtensionCommand(text),
|
|
26181
|
+
originSendId: randomUUID()
|
|
24779
26182
|
});
|
|
24780
26183
|
if (submitted.kind === "failed") throw submitted.error;
|
|
24781
26184
|
if (submitted.kind === "lost") {
|
|
@@ -25407,7 +26810,7 @@ InteractiveModeBase.prototype.showTrustSelector = async function() {
|
|
|
25407
26810
|
InteractiveModeBase.prototype.showTreeSelector = async function(initialSelectedId) {
|
|
25408
26811
|
await this.ensureDeferredStartupComplete();
|
|
25409
26812
|
const mainPrompt = promptHandle(this, "main");
|
|
25410
|
-
const archived = this.sessionManager.hasFullHistory?.() === false ? await loadOnDemand("/tree", async () => (await import("../modes/interactive/components/stored-tree-view.js")).StoredTreeView.open(this.sessionManager)) : void 0;
|
|
26813
|
+
const archived = this.sessionManager.hasFullHistory?.() === false ? await loadOnDemand("/tree", async () => (await import("../modes/interactive/components/stored-tree-view.code.js").catch((error) => __atomicOnDemandFailed(error, "/tree"))).StoredTreeView.open(this.sessionManager)) : void 0;
|
|
25411
26814
|
const tree = archived?.tree ?? this.sessionManager.getTree();
|
|
25412
26815
|
const realLeafId = archived ? archived.leaf : this.sessionManager.getLeafId();
|
|
25413
26816
|
if (archived) {
|
|
@@ -26746,4 +28149,49 @@ var InteractiveMode = class extends InteractiveModeBase {
|
|
|
26746
28149
|
};
|
|
26747
28150
|
export { CustomEntryComponent, InteractiveMode, serviceTierWarnings };
|
|
26748
28151
|
|
|
26749
|
-
//# sourceMappingURL=mode-interactive-sdk-7KXUFI2F.js.map
|
|
28152
|
+
//# sourceMappingURL=mode-interactive-sdk-7KXUFI2F.js.map
|
|
28153
|
+
// __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
|
|
28154
|
+
// demand that fails in a process an in-place update left running says to restart.
|
|
28155
|
+
function __atomicOnDemandFailed(error, feature) {
|
|
28156
|
+
return (async () => {
|
|
28157
|
+
const root = new URL("../", import.meta.url);
|
|
28158
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
28159
|
+
const key = `${root.href}#0.10.5-alpha.1`;
|
|
28160
|
+
let release = releases.get(key);
|
|
28161
|
+
if (release === undefined) {
|
|
28162
|
+
const current = (async () => {
|
|
28163
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
28164
|
+
try {
|
|
28165
|
+
const held = await import(new URL(path, root).href);
|
|
28166
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
28167
|
+
} catch {
|
|
28168
|
+
// Not a file this process can load: the next.
|
|
28169
|
+
}
|
|
28170
|
+
}
|
|
28171
|
+
return undefined;
|
|
28172
|
+
})().then((found) => {
|
|
28173
|
+
if (found === undefined && releases.get(key) === current) releases.delete(key);
|
|
28174
|
+
return found;
|
|
28175
|
+
});
|
|
28176
|
+
releases.set(key, current);
|
|
28177
|
+
release = current;
|
|
28178
|
+
}
|
|
28179
|
+
const running = await release;
|
|
28180
|
+
let installed;
|
|
28181
|
+
try {
|
|
28182
|
+
const { readFile } = process.getBuiltinModule("node:fs/promises");
|
|
28183
|
+
installed = JSON.parse(await readFile(new URL("../package.json", root), "utf8")).version;
|
|
28184
|
+
} catch {
|
|
28185
|
+
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
28186
|
+
}
|
|
28187
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.5-alpha.1" ? installed : running !== undefined && running.version !== "0.10.5-alpha.1" ? "0.10.5-alpha.1" : undefined;
|
|
28188
|
+
if (updatedTo === undefined) throw error;
|
|
28189
|
+
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
28190
|
+
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|
|
28191
|
+
cause: error,
|
|
28192
|
+
});
|
|
28193
|
+
restart.name = "UpdatedInstallError";
|
|
28194
|
+
restart[Symbol.for("atomic.on-demand-restart.v1")] = { application, updatedTo, feature };
|
|
28195
|
+
throw restart;
|
|
28196
|
+
})();
|
|
28197
|
+
}
|