@bastani/atomic 0.10.4 → 0.10.5
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 +122 -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} +519 -316
- 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 +42 -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 +12 -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/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 +30 -1096
- package/dist/cli/auth-cli.impl.js.map +1 -1
- package/dist/cli/auth-cli.js +11 -7
- 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 +30 -900
- package/dist/cli/blueprint-command.impl.js.map +1 -1
- package/dist/cli/blueprint-command.js +11 -7
- 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 +33 -105
- package/dist/cli/intercom-command.impl.js.map +1 -1
- package/dist/cli/intercom-command.js +11 -7
- 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 +33 -57
- package/dist/cli/list-models.impl.js.map +1 -1
- package/dist/cli/list-models.js +11 -7
- 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 +33 -52
- package/dist/cli/session-picker.impl.js.map +1 -1
- package/dist/cli/session-picker.js +11 -7
- 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 +35 -4
- package/dist/cli/startup-ui.js +11 -7
- 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 +35 -2
- package/dist/cli/storage-command.js +11 -7
- 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 +33 -186
- package/dist/cli/storage-search-session.impl.js.map +1 -1
- package/dist/cli/storage-search-session.js +11 -7
- 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 +32 -213
- package/dist/cli/team-command.impl.js.map +1 -1
- package/dist/cli/team-command.js +11 -7
- 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 +35 -2
- package/dist/core/debug.js +11 -7
- 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 +34 -255
- package/dist/core/export-html/card-projection.impl.js.map +1 -1
- package/dist/core/export-html/card-projection.js +11 -7
- 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 +30 -604
- package/dist/core/export-html/index.impl.js.map +1 -1
- package/dist/core/export-html/index.js +11 -7
- 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 +35 -2
- package/dist/core/export-html/json-spans.js +11 -7
- 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 +31 -120
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -1
- package/dist/core/export-html/oversized-render-inputs.js +11 -7
- 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 +33 -347
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -1
- package/dist/core/export-html/tool-renderer.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/jiti-loader.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/jiti-static-loader.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/loader-host-modules.js +11 -7
- 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 +35 -4
- package/dist/core/intercom-broker-control-host.js +11 -7
- 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 +35 -17
- package/dist/core/intercom-broker-control.impl.js.map +1 -1
- package/dist/core/intercom-broker-control.js +11 -7
- 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 +35 -2
- package/dist/core/package-manager-storage-adapters.js +11 -7
- 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 +35 -8
- package/dist/core/sdk.js +11 -7
- 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 +35 -2
- package/dist/core/session-manager-list.js +11 -7
- 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 +35 -7
- package/dist/core/session-manager.js +11 -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 +35 -2
- package/dist/core/session-storage.js +11 -7
- 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 +33 -34
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.js +11 -7
- 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 +32 -97
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.js +11 -7
- 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 +34 -58
- package/dist/core/storage/session/card-view.impl.js.map +1 -1
- package/dist/core/storage/session/card-view.js +11 -7
- 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 +33 -91
- package/dist/core/storage/session/child-reader.impl.js.map +1 -1
- package/dist/core/storage/session/child-reader.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/chunked-resume-projection.js +11 -7
- 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 +31 -634
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -1
- package/dist/core/storage/session/expanded-child-details.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/fork-row-bytes.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/fork-row-index.js +11 -7
- 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 +30 -574
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -1
- package/dist/core/storage/session/fork-staging.js +11 -7
- 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 +30 -471
- package/dist/core/storage/session/fork-window.impl.js.map +1 -1
- package/dist/core/storage/session/fork-window.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/history-pages.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/jsonl-entry-projection.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/jsonl-session-store.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/memory-session-store.js +11 -7
- 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 +33 -69
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -1
- package/dist/core/storage/session/pinned-branch-resume.js +11 -7
- 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 +32 -461
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -1
- package/dist/core/storage/session/released-history-files.js +11 -7
- 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 +32 -53
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/session-resume.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/snapshot-cut.js +11 -7
- 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 +34 -60
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -1
- package/dist/core/storage/session/snapshot-history.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/sql-session-store.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/tree-outline.js +11 -7
- 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 +31 -337
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -1
- package/dist/core/storage/session/tree-presentation.js +11 -7
- 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 +35 -2
- package/dist/core/storage/storage-status.js +11 -7
- 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 +35 -2
- package/dist/core/storage/team.js +11 -7
- 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 +35 -2
- package/dist/core/structured-output/index.js +11 -7
- 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 +33 -251
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -1
- package/dist/core/tasks/task-completion-entry.js +11 -7
- 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 +32 -375
- package/dist/core/tasks/task-file-history.impl.js.map +1 -1
- package/dist/core/tasks/task-file-history.js +11 -7
- package/dist/core/tasks/{task-reference-archive.impl.js → task-reference-archive.code.js} +51 -6
- package/dist/core/tasks/{task-reference-archive.impl.js.map → task-reference-archive.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-archive.js +11 -7
- package/dist/core/tasks/{task-reference-identity.impl.js → task-reference-identity.code.js} +1 -1
- package/dist/core/tasks/{task-reference-identity.impl.js.map → task-reference-identity.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-identity.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-reference-stream.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-unsaved-answer.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-view-source.js +12 -8
- 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 +30 -1524
- package/dist/core/tools/read-url.impl.js.map +1 -1
- package/dist/core/tools/read-url.js +11 -7
- 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 +35 -5
- package/dist/core/worktree-snapshot/errors.js +11 -7
- 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 +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.js +11 -7
- 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 +30 -612
- package/dist/extensions/codemode/execute.impl.js.map +1 -1
- package/dist/extensions/codemode/execute.js +11 -7
- 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 +33 -107
- package/dist/extensions/codemode/renderer.impl.js.map +1 -1
- package/dist/extensions/codemode/renderer.js +11 -7
- 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 +32 -561
- package/dist/extensions/mcp/cli.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.js +11 -7
- 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 -7
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.js +11 -7
- 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 +35 -4
- package/dist/extensions/mcp/runtime.js +11 -7
- 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 +35 -11
- package/dist/main-first-time-setup.impl.js.map +1 -1
- package/dist/main-first-time-setup.js +11 -7
- 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 +33 -290
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.js +11 -7
- 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 +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.js +11 -7
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -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 -1067
- package/dist/package-manager-cli.impl.js.map +1 -1
- package/dist/package-manager-cli.js +11 -7
- 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 +33 -105
- package/dist/utils/startup-database-spare.impl.js.map +1 -1
- package/dist/utils/startup-database-spare.js +11 -7
- 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 +35 -2
- package/dist/utils/tools-manager.js +11 -7
- 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 +1 -1
- 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
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipelined per-(sender, target) send-order gate for multi-node routing.
|
|
3
|
+
*
|
|
4
|
+
* Read-only shared-store lookups and local lookup timers start immediately in parallel when sends arrive,
|
|
5
|
+
* while observable commits (local socket handoff, shared outbox enqueue, or remote-reservation hold) wait
|
|
6
|
+
* for strictly earlier in-flight sends from the same canonical sender to the same canonical target.
|
|
7
|
+
*
|
|
8
|
+
* State machine per ticket:
|
|
9
|
+
* - `resolving`: remote send whose canonical target identity is not yet resolved.
|
|
10
|
+
* - `resolved`: canonical target identity is known (immediate for local sends, after resolution for remote sends).
|
|
11
|
+
* - `done`: observable commit or failure completed; removed immediately so idle senders retain no memory.
|
|
12
|
+
*
|
|
13
|
+
* Every wait edge points strictly backward in arrival sequence number (`earlier.seq < current.seq`), so the
|
|
14
|
+
* wait-for graph is acyclic and deadlock-free even when local sends fall back re-entrantly to remote routing.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface DeferredWait {
|
|
18
|
+
readonly promise: Promise<void>;
|
|
19
|
+
readonly resolve: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createDeferredWait(): DeferredWait {
|
|
23
|
+
let resolve: () => void = () => {};
|
|
24
|
+
const promise = new Promise<void>((res) => {
|
|
25
|
+
resolve = res;
|
|
26
|
+
});
|
|
27
|
+
return { promise, resolve };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type SendOrderPhase = "resolving" | "resolved" | "done";
|
|
31
|
+
|
|
32
|
+
export interface SendOrderTicket {
|
|
33
|
+
readonly senderKey: string;
|
|
34
|
+
readonly seq: number;
|
|
35
|
+
readonly rawTarget: string;
|
|
36
|
+
readonly arrivedRegSeq: number;
|
|
37
|
+
isLocal: boolean;
|
|
38
|
+
/** True when this ticket may exceed `LOCAL_RETRY_LOOKUP_BOUND_MS` (remote send, reply serial lane, or shared-DB wait). */
|
|
39
|
+
unbounded: boolean;
|
|
40
|
+
phase: SendOrderPhase;
|
|
41
|
+
targetIdentity: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface InternalTicket extends SendOrderTicket {
|
|
45
|
+
previousTargetIdentity?: string;
|
|
46
|
+
readonly pendingLocalTargetIdentities?: ReadonlySet<string>;
|
|
47
|
+
waitingOn?: InternalTicket;
|
|
48
|
+
lastBlocker?: InternalTicket;
|
|
49
|
+
targetKnownWait?: DeferredWait;
|
|
50
|
+
unboundedWait?: DeferredWait;
|
|
51
|
+
finishedWait?: DeferredWait;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type BeginSendTicketOptions =
|
|
55
|
+
| {
|
|
56
|
+
readonly senderKey: string;
|
|
57
|
+
readonly rawTarget: string;
|
|
58
|
+
readonly arrivedRegSeq: number;
|
|
59
|
+
readonly isLocal: true;
|
|
60
|
+
readonly targetIdentity: string;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
readonly senderKey: string;
|
|
64
|
+
readonly rawTarget: string;
|
|
65
|
+
readonly arrivedRegSeq: number;
|
|
66
|
+
readonly isLocal: false;
|
|
67
|
+
/** Local target identities whose return path to this sender is pending and matches `rawTarget`. */
|
|
68
|
+
readonly pendingLocalTargetIdentities?: ReadonlySet<string>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Known identifiers of a resolved target, used to skip unrelated still-resolving remote sends. */
|
|
72
|
+
export interface TargetMatchInfo {
|
|
73
|
+
readonly sessionId?: string;
|
|
74
|
+
readonly names?: readonly string[];
|
|
75
|
+
readonly atomicSessionId?: string;
|
|
76
|
+
readonly aliases?: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface WaitForEarlierOptions {
|
|
80
|
+
readonly targetIdentity: string;
|
|
81
|
+
/** Local target's registration epoch on this broker (enables O(1) skip of earlier remote sends). */
|
|
82
|
+
readonly targetRegSeq?: number;
|
|
83
|
+
/** Local target's awaited session ID, if any (checked when skipping earlier remote sends). */
|
|
84
|
+
readonly awaitedId?: string;
|
|
85
|
+
/** Local target's held alias session ID, if any (checked when skipping earlier remote sends). */
|
|
86
|
+
readonly aliasId?: string;
|
|
87
|
+
/** Known identifiers for this target; earlier still-resolving sends that cannot match are skipped. */
|
|
88
|
+
readonly targetMatch?: TargetMatchInfo;
|
|
89
|
+
/** Local lookup deadline promise: bounds a local send's wait behind earlier remote or unbounded tickets. */
|
|
90
|
+
readonly localBound?: Promise<"expired">;
|
|
91
|
+
/** True when `localBound` has already expired synchronously before entering `waitForEarlier`. */
|
|
92
|
+
readonly localBoundExpired?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Monotonic timestamp (`performance.now()`) of the latest shared-store progress made by `earlier` or its
|
|
95
|
+
* upstream blocker chain, or `undefined` when no store progress has occurred. When `localBound` expires while
|
|
96
|
+
* the blocker is actively progressing, the wait extends by `progressSilenceMs` from that progress (up to
|
|
97
|
+
* `maxLocalWaitUntil`) so healthy multi-step DB work never breaks FIFO, while a hung DB still releases at
|
|
98
|
+
* `localBound`.
|
|
99
|
+
*/
|
|
100
|
+
readonly blockerProgressAt?: (earlier: SendOrderTicket) => number | undefined;
|
|
101
|
+
/** Silence window (ms) to wait past a progressing blocker's latest store answer; 0 disables extension. */
|
|
102
|
+
readonly progressSilenceMs?: number;
|
|
103
|
+
/** Hard monotonic deadline (`performance.now()`) past which progress extensions stop. */
|
|
104
|
+
readonly maxLocalWaitUntil?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function rawTargetCouldMatch(rawTarget: string, target: TargetMatchInfo): boolean {
|
|
108
|
+
if (target.sessionId !== undefined) {
|
|
109
|
+
if (rawTarget === target.sessionId) return true;
|
|
110
|
+
if (rawTarget.length === 8 && target.sessionId.toLowerCase().startsWith(rawTarget.toLowerCase())) return true;
|
|
111
|
+
}
|
|
112
|
+
if (target.atomicSessionId !== undefined && rawTarget === target.atomicSessionId) return true;
|
|
113
|
+
if (target.names !== undefined) {
|
|
114
|
+
const lower = rawTarget.toLowerCase();
|
|
115
|
+
for (const name of target.names) {
|
|
116
|
+
if (lower === name.toLowerCase()) return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (target.aliases !== undefined && target.aliases.includes(rawTarget)) return true;
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Coordinates commit order per canonical `(senderKey, targetIdentity)` without serializing independent
|
|
125
|
+
* read-only store lookups or introducing cross-target or cross-sender head-of-line blocking.
|
|
126
|
+
*/
|
|
127
|
+
export class SendOrderGate {
|
|
128
|
+
private nextSeq = 0;
|
|
129
|
+
private closed = false;
|
|
130
|
+
private readonly bySender = new Map<string, InternalTicket[]>();
|
|
131
|
+
|
|
132
|
+
/** Number of senders with at least one in-flight send ticket (0 when idle). */
|
|
133
|
+
get activeSenders(): number {
|
|
134
|
+
return this.bySender.size;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Reserve a FIFO arrival ticket synchronously when a send enters multi-node routing. */
|
|
138
|
+
begin(options: BeginSendTicketOptions): SendOrderTicket {
|
|
139
|
+
const ticket: InternalTicket = {
|
|
140
|
+
senderKey: options.senderKey,
|
|
141
|
+
seq: ++this.nextSeq,
|
|
142
|
+
rawTarget: options.rawTarget,
|
|
143
|
+
arrivedRegSeq: options.arrivedRegSeq,
|
|
144
|
+
isLocal: options.isLocal,
|
|
145
|
+
unbounded: !options.isLocal,
|
|
146
|
+
phase: options.isLocal ? "resolved" : "resolving",
|
|
147
|
+
targetIdentity: options.isLocal ? options.targetIdentity : undefined,
|
|
148
|
+
...(!options.isLocal && options.pendingLocalTargetIdentities !== undefined
|
|
149
|
+
? { pendingLocalTargetIdentities: options.pendingLocalTargetIdentities }
|
|
150
|
+
: {}),
|
|
151
|
+
};
|
|
152
|
+
if (this.closed) {
|
|
153
|
+
ticket.phase = "done";
|
|
154
|
+
return ticket;
|
|
155
|
+
}
|
|
156
|
+
let list = this.bySender.get(options.senderKey);
|
|
157
|
+
if (list === undefined) {
|
|
158
|
+
list = [];
|
|
159
|
+
this.bySender.set(options.senderKey, list);
|
|
160
|
+
}
|
|
161
|
+
list.push(ticket);
|
|
162
|
+
return ticket;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Record the resolved canonical target identity for a send, unblocking unrelated targets immediately. */
|
|
166
|
+
resolveTarget(ticket: SendOrderTicket, targetIdentity: string): void {
|
|
167
|
+
const internal = ticket as InternalTicket;
|
|
168
|
+
if (internal.phase === "done") return;
|
|
169
|
+
internal.targetIdentity = targetIdentity;
|
|
170
|
+
if (internal.phase === "resolving") {
|
|
171
|
+
internal.phase = "resolved";
|
|
172
|
+
const wait = internal.targetKnownWait;
|
|
173
|
+
internal.targetKnownWait = undefined;
|
|
174
|
+
wait?.resolve();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Mark an in-flight ticket as able to exceed `LOCAL_RETRY_LOOKUP_BOUND_MS` (for example because it is queued in
|
|
180
|
+
* a reply lane behind remote replies, adopting a shared route, or writing to the shared store). Wakes any local
|
|
181
|
+
* send already waiting on it so it enforces its own local deadline.
|
|
182
|
+
*/
|
|
183
|
+
markUnbounded(ticket: SendOrderTicket): void {
|
|
184
|
+
const internal = ticket as InternalTicket;
|
|
185
|
+
if (internal.phase === "done" || internal.unbounded) return;
|
|
186
|
+
internal.unbounded = true;
|
|
187
|
+
const wait = internal.unboundedWait;
|
|
188
|
+
internal.unboundedWait = undefined;
|
|
189
|
+
wait?.resolve();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Transition a local send ticket in place to remote resolution when local handoff falls back re-entrantly
|
|
194
|
+
* because the local target disconnected, was fenced, or lost an alias. Keeps the original arrival `seq`.
|
|
195
|
+
*/
|
|
196
|
+
reenterRemote(ticket: SendOrderTicket): void {
|
|
197
|
+
const internal = ticket as InternalTicket;
|
|
198
|
+
if (internal.phase === "done") return;
|
|
199
|
+
if (internal.targetIdentity !== undefined) internal.previousTargetIdentity = internal.targetIdentity;
|
|
200
|
+
internal.isLocal = false;
|
|
201
|
+
internal.unbounded = true;
|
|
202
|
+
internal.targetIdentity = undefined;
|
|
203
|
+
internal.phase = "resolving";
|
|
204
|
+
internal.targetKnownWait = undefined;
|
|
205
|
+
const unbounded = internal.unboundedWait;
|
|
206
|
+
internal.unboundedWait = undefined;
|
|
207
|
+
unbounded?.resolve();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Wait for all strictly earlier in-flight sends from the same sender that target (or may target)
|
|
212
|
+
* `options.targetIdentity`. Returns `undefined` synchronously on the uncontended fast path so callers
|
|
213
|
+
* incur zero extra Promise allocations or microtasks.
|
|
214
|
+
*/
|
|
215
|
+
waitForEarlier(ticket: SendOrderTicket, options: WaitForEarlierOptions): Promise<void> | undefined {
|
|
216
|
+
const internal = ticket as InternalTicket;
|
|
217
|
+
if (this.closed || internal.phase === "done") return undefined;
|
|
218
|
+
this.resolveTarget(internal, options.targetIdentity);
|
|
219
|
+
const list = this.bySender.get(internal.senderKey);
|
|
220
|
+
if (list === undefined || list.length <= 1) return undefined;
|
|
221
|
+
if (!this.hasBlockingEarlier(list, internal, options)) return undefined;
|
|
222
|
+
return this.waitLoop(internal, options);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Return the in-flight earlier ticket currently blocking `ticket` (following any wait chain), or `undefined`. */
|
|
226
|
+
blockingTicket(ticket: SendOrderTicket): SendOrderTicket | undefined {
|
|
227
|
+
let cursor = (ticket as InternalTicket).waitingOn;
|
|
228
|
+
let head: InternalTicket | undefined;
|
|
229
|
+
while (cursor !== undefined && cursor.phase !== "done") {
|
|
230
|
+
head = cursor;
|
|
231
|
+
cursor = cursor.waitingOn;
|
|
232
|
+
}
|
|
233
|
+
return head;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Return the most recent earlier ticket that `ticket` waited on (even if it just finished). */
|
|
237
|
+
lastBlockingTicket(ticket: SendOrderTicket): SendOrderTicket | undefined {
|
|
238
|
+
return (ticket as InternalTicket).lastBlocker;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Mark a ticket done, wake any waiting later sends, and prune empty sender entries. */
|
|
242
|
+
finish(ticket: SendOrderTicket): void {
|
|
243
|
+
const internal = ticket as InternalTicket;
|
|
244
|
+
if (internal.phase === "done") return;
|
|
245
|
+
internal.phase = "done";
|
|
246
|
+
internal.waitingOn = undefined;
|
|
247
|
+
const targetWait = internal.targetKnownWait;
|
|
248
|
+
internal.targetKnownWait = undefined;
|
|
249
|
+
targetWait?.resolve();
|
|
250
|
+
const unboundedWait = internal.unboundedWait;
|
|
251
|
+
internal.unboundedWait = undefined;
|
|
252
|
+
unboundedWait?.resolve();
|
|
253
|
+
const finishedWait = internal.finishedWait;
|
|
254
|
+
internal.finishedWait = undefined;
|
|
255
|
+
finishedWait?.resolve();
|
|
256
|
+
const list = this.bySender.get(internal.senderKey);
|
|
257
|
+
if (list !== undefined) {
|
|
258
|
+
const index = list.indexOf(internal);
|
|
259
|
+
if (index !== -1) list.splice(index, 1);
|
|
260
|
+
if (list.length === 0) this.bySender.delete(internal.senderKey);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Unblock all waiting sends and clear all state when the router closes. */
|
|
265
|
+
close(): void {
|
|
266
|
+
if (this.closed) return;
|
|
267
|
+
this.closed = true;
|
|
268
|
+
for (const list of this.bySender.values()) {
|
|
269
|
+
for (const ticket of list) {
|
|
270
|
+
ticket.phase = "done";
|
|
271
|
+
ticket.waitingOn = undefined;
|
|
272
|
+
ticket.targetKnownWait?.resolve();
|
|
273
|
+
ticket.targetKnownWait = undefined;
|
|
274
|
+
ticket.unboundedWait?.resolve();
|
|
275
|
+
ticket.unboundedWait = undefined;
|
|
276
|
+
ticket.finishedWait?.resolve();
|
|
277
|
+
ticket.finishedWait = undefined;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
this.bySender.clear();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private waitKind(
|
|
284
|
+
earlier: InternalTicket,
|
|
285
|
+
current: InternalTicket,
|
|
286
|
+
options: WaitForEarlierOptions,
|
|
287
|
+
): "skip" | "target" | "finish" {
|
|
288
|
+
if (earlier.phase === "done") return "skip";
|
|
289
|
+
if (earlier.phase === "resolved") {
|
|
290
|
+
return earlier.targetIdentity === options.targetIdentity ? "finish" : "skip";
|
|
291
|
+
}
|
|
292
|
+
// Earlier remote send is still resolving its target identity.
|
|
293
|
+
if (earlier.previousTargetIdentity === options.targetIdentity) return "target";
|
|
294
|
+
if (earlier.pendingLocalTargetIdentities?.has(options.targetIdentity)) return "finish";
|
|
295
|
+
if (current.isLocal && options.targetRegSeq !== undefined && options.targetRegSeq <= earlier.arrivedRegSeq) {
|
|
296
|
+
const matchesAlias = earlier.rawTarget === options.awaitedId || earlier.rawTarget === options.aliasId;
|
|
297
|
+
if (!matchesAlias) return "skip";
|
|
298
|
+
}
|
|
299
|
+
if (options.targetMatch !== undefined && !rawTargetCouldMatch(earlier.rawTarget, options.targetMatch)) {
|
|
300
|
+
return "skip";
|
|
301
|
+
}
|
|
302
|
+
return "target";
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private isBounded(current: InternalTicket, earlier: InternalTicket, hasBound: boolean): boolean {
|
|
306
|
+
return current.isLocal && (!earlier.isLocal || earlier.unbounded) && hasBound;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private extensionRemainingMs(earlier: InternalTicket, options: WaitForEarlierOptions): number {
|
|
310
|
+
const silenceMs = options.progressSilenceMs ?? 0;
|
|
311
|
+
if (silenceMs <= 0 || options.blockerProgressAt === undefined) return 0;
|
|
312
|
+
const progressAt = options.blockerProgressAt(earlier);
|
|
313
|
+
if (progressAt === undefined) return 0;
|
|
314
|
+
const now = performance.now();
|
|
315
|
+
const capUntil = options.maxLocalWaitUntil ?? Number.POSITIVE_INFINITY;
|
|
316
|
+
return Math.max(0, Math.min(capUntil, progressAt + silenceMs) - now);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private hasBlockingEarlier(
|
|
320
|
+
list: readonly InternalTicket[],
|
|
321
|
+
current: InternalTicket,
|
|
322
|
+
options: WaitForEarlierOptions,
|
|
323
|
+
): boolean {
|
|
324
|
+
const hasBound = options.localBound !== undefined || options.localBoundExpired === true;
|
|
325
|
+
for (const earlier of list) {
|
|
326
|
+
if (earlier.seq >= current.seq) break;
|
|
327
|
+
if (this.waitKind(earlier, current, options) === "skip") continue;
|
|
328
|
+
if (
|
|
329
|
+
options.localBoundExpired === true &&
|
|
330
|
+
this.isBounded(current, earlier, hasBound) &&
|
|
331
|
+
this.extensionRemainingMs(earlier, options) <= 0
|
|
332
|
+
)
|
|
333
|
+
continue;
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private awaitTargetKnown(ticket: InternalTicket): Promise<void> {
|
|
340
|
+
if (ticket.phase !== "resolving" || this.closed) return Promise.resolve();
|
|
341
|
+
ticket.targetKnownWait ??= createDeferredWait();
|
|
342
|
+
return ticket.targetKnownWait.promise;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private awaitUnbounded(ticket: InternalTicket): Promise<void> {
|
|
346
|
+
if (!ticket.isLocal || ticket.unbounded || ticket.phase === "done" || this.closed) return Promise.resolve();
|
|
347
|
+
ticket.unboundedWait ??= createDeferredWait();
|
|
348
|
+
return ticket.unboundedWait.promise;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private awaitFinished(ticket: InternalTicket): Promise<void> {
|
|
352
|
+
if (ticket.phase === "done" || this.closed) return Promise.resolve();
|
|
353
|
+
ticket.finishedWait ??= createDeferredWait();
|
|
354
|
+
return ticket.finishedWait.promise;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private async waitLoop(current: InternalTicket, options: WaitForEarlierOptions): Promise<void> {
|
|
358
|
+
let localBoundExpired = options.localBoundExpired === true;
|
|
359
|
+
const boundPromise = localBoundExpired
|
|
360
|
+
? undefined
|
|
361
|
+
: options.localBound?.then(() => {
|
|
362
|
+
localBoundExpired = true;
|
|
363
|
+
});
|
|
364
|
+
const hasBound = localBoundExpired || boundPromise !== undefined;
|
|
365
|
+
try {
|
|
366
|
+
while (!this.closed && current.phase !== "done") {
|
|
367
|
+
const list = this.bySender.get(current.senderKey);
|
|
368
|
+
if (list === undefined) return;
|
|
369
|
+
let waited = false;
|
|
370
|
+
for (const earlier of list) {
|
|
371
|
+
if (earlier.seq >= current.seq) break;
|
|
372
|
+
const kind = this.waitKind(earlier, current, options);
|
|
373
|
+
if (kind === "skip") continue;
|
|
374
|
+
const bounded = this.isBounded(current, earlier, hasBound);
|
|
375
|
+
const wait = kind === "target" ? this.awaitTargetKnown(earlier) : this.awaitFinished(earlier);
|
|
376
|
+
if (bounded && localBoundExpired) {
|
|
377
|
+
const remainingMs = this.extensionRemainingMs(earlier, options);
|
|
378
|
+
if (remainingMs <= 0) continue;
|
|
379
|
+
let extTimer: ReturnType<typeof setTimeout> | undefined;
|
|
380
|
+
const extExpired = new Promise<"expired">((resolve) => {
|
|
381
|
+
extTimer = setTimeout(() => resolve("expired"), Math.ceil(remainingMs));
|
|
382
|
+
extTimer.unref?.();
|
|
383
|
+
});
|
|
384
|
+
current.waitingOn = earlier;
|
|
385
|
+
current.lastBlocker = earlier;
|
|
386
|
+
try {
|
|
387
|
+
await Promise.race([wait, extExpired]);
|
|
388
|
+
} finally {
|
|
389
|
+
clearTimeout(extTimer);
|
|
390
|
+
current.waitingOn = undefined;
|
|
391
|
+
}
|
|
392
|
+
waited = true;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
current.waitingOn = earlier;
|
|
396
|
+
current.lastBlocker = earlier;
|
|
397
|
+
if (bounded && boundPromise !== undefined) await Promise.race([wait, boundPromise]);
|
|
398
|
+
else if (current.isLocal && hasBound) await Promise.race([wait, this.awaitUnbounded(earlier)]);
|
|
399
|
+
else await wait;
|
|
400
|
+
current.waitingOn = undefined;
|
|
401
|
+
waited = true;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
if (!waited) return;
|
|
405
|
+
}
|
|
406
|
+
} finally {
|
|
407
|
+
current.waitingOn = undefined;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|