@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
|
@@ -35,14 +35,15 @@ import { retractBrokerStartAnnouncement } from "./start-announcement.js";
|
|
|
35
35
|
import { type HeldDirectory, holdDirectory, socketPathIdentity } from "./directory-hold.js";
|
|
36
36
|
import { createBrokerHostIdentityReader, systemSources } from "./broker-instance.js";
|
|
37
37
|
import {
|
|
38
|
+
chooseBrokerSocketPath,
|
|
39
|
+
consumeBrokerSocketPathOverride,
|
|
38
40
|
getBrokerAwayAsksPath,
|
|
39
41
|
getBrokerDeliveredMessagesPath,
|
|
40
42
|
getBrokerEndedChildQueuePath,
|
|
41
43
|
getBrokerPidPath,
|
|
42
|
-
getBrokerWatchdogLogPath,
|
|
43
|
-
chooseBrokerSocketPath,
|
|
44
44
|
getBrokerSocketPath,
|
|
45
45
|
getBrokerSocketReplacementLockPath,
|
|
46
|
+
getBrokerWatchdogLogPath,
|
|
46
47
|
getIntercomDirPath,
|
|
47
48
|
recordBrokerSocketPath,
|
|
48
49
|
} from "./paths.js";
|
|
@@ -75,9 +76,11 @@ type ReleasedAskerReplyRouter,
|
|
|
75
76
|
type SendClientMessage,
|
|
76
77
|
detachSend,
|
|
77
78
|
messageFrameFor,
|
|
79
|
+
retargetSendToSessionId,
|
|
78
80
|
resolveSessionAliasesWith,
|
|
79
81
|
senderAtReceipt,
|
|
80
82
|
} from "./send-handler.js";
|
|
83
|
+
import { isVerticalBypass } from "./group-isolation.js";
|
|
81
84
|
import { buildMessageSendSignature } from "./send-signature.js";
|
|
82
85
|
import {
|
|
83
86
|
DurableEndedQueue,
|
|
@@ -93,13 +96,15 @@ import {
|
|
|
93
96
|
type BrokerStateOpener,
|
|
94
97
|
LOCAL_RETRY_LOOKUP_BOUND_MS,
|
|
95
98
|
MultiNodeRouter,
|
|
96
|
-
presenceBoundAfterClaim,
|
|
97
99
|
readSharedStorageSetting,
|
|
100
|
+
registrationBoundAfterClaim,
|
|
98
101
|
resolveMultiNodeStartup,
|
|
99
102
|
SHARED_STORAGE_UNAVAILABLE_REASON,
|
|
103
|
+
type SessionIdClaimProgress,
|
|
100
104
|
type SessionIdGrant,
|
|
101
105
|
type UnansweredSessionIdClaim,
|
|
102
106
|
} from "./multinode-router.js";
|
|
107
|
+
import { BROKER_CONNECT_TIMEOUT_MS } from "./registration-bounds.js";
|
|
103
108
|
import { OUTBOX_BACKUP_POLL_INTERVAL_MS } from "./multinode-state-store.js";
|
|
104
109
|
import { SupervisorChannelCache } from "./supervisor-channel.js";
|
|
105
110
|
import { SessionIdReclaim } from "./session-id-reclaim.js";
|
|
@@ -195,8 +200,10 @@ import {
|
|
|
195
200
|
import { SUPERVISOR_AUTHORIZATION_REFUSED_CODE, SUPERVISOR_AUTHORIZATION_REFUSED_REASON } from "../supervisor-refusal.js";
|
|
196
201
|
|
|
197
202
|
const INTERCOM_DIR = getIntercomDirPath();
|
|
203
|
+
/** Consumed once at startup and removed from `process.env` so broker-spawned host commands never inherit it. */
|
|
204
|
+
const BROKER_SOCKET_PATH_OVERRIDE = consumeBrokerSocketPathOverride();
|
|
198
205
|
/** The socket clients reach the running broker on, until this broker chooses its own under the startup lock (#5040). */
|
|
199
|
-
let SOCKET_PATH = getBrokerSocketPath();
|
|
206
|
+
let SOCKET_PATH = BROKER_SOCKET_PATH_OVERRIDE ?? getBrokerSocketPath();
|
|
200
207
|
const BROKER_IDLE_TIMEOUT_MS = 5_000;
|
|
201
208
|
const UNCLASSIFIED_CONNECTION_RECHECK_MS = 100;
|
|
202
209
|
const PID_PATH = getBrokerPidPath();
|
|
@@ -502,6 +509,16 @@ class IntercomBroker {
|
|
|
502
509
|
/** Why multi-node routing is off or unavailable, for `broker_status` and the log. */
|
|
503
510
|
private multiNodeReason: string | undefined = NO_SHARED_STORAGE_REASON;
|
|
504
511
|
private multiNodeFirstAttempt: Promise<void> = Promise.resolve();
|
|
512
|
+
/** Sends held while `multiNodeStatus === "starting"`, drained synchronously in FIFO order when startup settles. */
|
|
513
|
+
private readonly pendingMultiNodeSends: Array<{
|
|
514
|
+
request: RemoteSendRequest;
|
|
515
|
+
settled: boolean;
|
|
516
|
+
bound?: NodeJS.Timeout;
|
|
517
|
+
}> = [];
|
|
518
|
+
/** In-place replacement target when a timed-out local send during `starting` synchronously re-enters as remote. */
|
|
519
|
+
private activeStartingFallback:
|
|
520
|
+
| { readonly entry: { request: RemoteSendRequest; settled: boolean; bound?: NodeJS.Timeout }; replaced: boolean }
|
|
521
|
+
| undefined;
|
|
505
522
|
private shuttingDown = false;
|
|
506
523
|
/** Held from before this broker writes its pid file until it listens or gives up starting. */
|
|
507
524
|
private releaseStartupLock: () => void = () => {};
|
|
@@ -564,12 +581,12 @@ class IntercomBroker {
|
|
|
564
581
|
this.releaseStartupLock = startupLock;
|
|
565
582
|
this.holdsStartupLock = startupLock.held;
|
|
566
583
|
// Read again under the lock: a broker that started meanwhile may have recorded a socket of its own.
|
|
567
|
-
SOCKET_PATH = getBrokerSocketPath();
|
|
584
|
+
SOCKET_PATH = BROKER_SOCKET_PATH_OVERRIDE ?? getBrokerSocketPath();
|
|
568
585
|
if (await isSocketAnswering(SOCKET_PATH)) {
|
|
569
586
|
this.releaseStartupLock();
|
|
570
587
|
exitBecauseLiveBrokerOwnsSocket();
|
|
571
588
|
}
|
|
572
|
-
SOCKET_PATH = chooseBrokerSocketPath();
|
|
589
|
+
SOCKET_PATH = BROKER_SOCKET_PATH_OVERRIDE ?? chooseBrokerSocketPath();
|
|
573
590
|
// #5999 durable wake queue: which broker served before this one, as every version leaves it: the pid it recorded
|
|
574
591
|
// (kept when it crashed), and the socket lock generation before the one this broker took.
|
|
575
592
|
const taken = latestSocketReplacementGeneration(SOCKET_REPLACEMENT_LOCK_PATH);
|
|
@@ -1062,7 +1079,7 @@ class IntercomBroker {
|
|
|
1062
1079
|
? { childName: registered, groups: sessionGroups(info), ...(supervisorId ? { authorizedBy: supervisorId } : {}) }
|
|
1063
1080
|
: undefined,
|
|
1064
1081
|
);
|
|
1065
|
-
for (const send of departedSends.filter(isQueuedForWake)) this.dispatchQueuedForWake(send, registered);
|
|
1082
|
+
for (const send of departedSends.filter(isQueuedForWake)) this.dispatchQueuedForWake(send, registered, id);
|
|
1066
1083
|
for (const send of restoredSends) this.dispatchSend(send.socket, send.clientMessage, send.senderId);
|
|
1067
1084
|
this.dispatchHeldSends(departedSends.filter((send) => !isQueuedForWake(send)));
|
|
1068
1085
|
};
|
|
@@ -1219,6 +1236,14 @@ class IntercomBroker {
|
|
|
1219
1236
|
if (clientMessage.protocol !== undefined && !isBrokerProtocolRange(clientMessage.protocol)) {
|
|
1220
1237
|
throw new Error("Invalid protocol range");
|
|
1221
1238
|
}
|
|
1239
|
+
if (
|
|
1240
|
+
clientMessage.connectTimeoutMs !== undefined &&
|
|
1241
|
+
(typeof clientMessage.connectTimeoutMs !== "number" ||
|
|
1242
|
+
!Number.isFinite(clientMessage.connectTimeoutMs) ||
|
|
1243
|
+
clientMessage.connectTimeoutMs <= 0)
|
|
1244
|
+
) {
|
|
1245
|
+
throw new Error("Invalid connect timeout");
|
|
1246
|
+
}
|
|
1222
1247
|
const registrationReach = readRegistrationReach(
|
|
1223
1248
|
clientMessage.reach,
|
|
1224
1249
|
clientMessage.session,
|
|
@@ -1265,6 +1290,11 @@ class IntercomBroker {
|
|
|
1265
1290
|
}
|
|
1266
1291
|
|
|
1267
1292
|
this.openDeliveredMessages();
|
|
1293
|
+
const clientTimeoutMs =
|
|
1294
|
+
typeof clientMessage.connectTimeoutMs === "number" ? clientMessage.connectTimeoutMs : BROKER_CONNECT_TIMEOUT_MS;
|
|
1295
|
+
const readMono = performance.now();
|
|
1296
|
+
const clientRemainingMs = (): number =>
|
|
1297
|
+
Math.max(0, clientTimeoutMs - Math.max(0, performance.now() - readMono));
|
|
1268
1298
|
// #3760: a restored or reconnected session keeps the id peers know when it is free; never a live one.
|
|
1269
1299
|
const preferred = this.sessionIdReclaim.grant(
|
|
1270
1300
|
clientMessage.preferredSessionId,
|
|
@@ -1292,7 +1322,7 @@ class IntercomBroker {
|
|
|
1292
1322
|
// #5607: a client that takes ids back is told which id it awaits; a hand-over it presents takes one.
|
|
1293
1323
|
const takesIdHandoff = clientMessage.takesIdHandoff === true;
|
|
1294
1324
|
const idHandoff = typeof clientMessage.idHandoff === "string" ? clientMessage.idHandoff : undefined;
|
|
1295
|
-
const claimProgress = { extendedMs: 0 };
|
|
1325
|
+
const claimProgress: SessionIdClaimProgress = { extendedMs: 0 };
|
|
1296
1326
|
void multiNode
|
|
1297
1327
|
.claimSessionId(
|
|
1298
1328
|
preferred,
|
|
@@ -1314,10 +1344,10 @@ class IntercomBroker {
|
|
|
1314
1344
|
if (claimed.status === "granted")
|
|
1315
1345
|
void multiNode.releaseOwner({ intercomSessionId: claimed.grant.sessionId, token: claimed.grant.token });
|
|
1316
1346
|
else if (claimed.status === "unanswered")
|
|
1317
|
-
void multiNode.releaseOwner(
|
|
1318
|
-
intercomSessionId: claimed.unanswered.sessionId,
|
|
1319
|
-
|
|
1320
|
-
|
|
1347
|
+
void multiNode.releaseOwner(
|
|
1348
|
+
{ intercomSessionId: claimed.unanswered.sessionId, token: claimed.unanswered.token },
|
|
1349
|
+
claimed.unanswered.claim,
|
|
1350
|
+
);
|
|
1321
1351
|
};
|
|
1322
1352
|
if (socket.destroyed || socket.writableEnded) {
|
|
1323
1353
|
giveBack();
|
|
@@ -1335,13 +1365,15 @@ class IntercomBroker {
|
|
|
1335
1365
|
const awaited =
|
|
1336
1366
|
takesIdHandoff &&
|
|
1337
1367
|
(claimed.status === "held" || (claimed.status === "unanswered" && claimed.unanswered.recovery !== undefined));
|
|
1368
|
+
const unanswered = claimed.status === "unanswered" ? claimed.unanswered : undefined;
|
|
1369
|
+
const presenceBoundMs = registrationBoundAfterClaim(claimProgress, clientRemainingMs());
|
|
1338
1370
|
this.completeSessionRegistration(
|
|
1339
1371
|
socket,
|
|
1340
1372
|
registration,
|
|
1341
1373
|
granted !== undefined ? granted.sessionId : randomUUID(),
|
|
1342
1374
|
supervisorId,
|
|
1343
1375
|
setId,
|
|
1344
|
-
|
|
1376
|
+
unanswered,
|
|
1345
1377
|
granted,
|
|
1346
1378
|
// #5607: held by another registration of this session (or for this one, by a hand-over that did not take
|
|
1347
1379
|
// it this time): a client that takes ids back awaits it, and keeps asking for it rather than saving the
|
|
@@ -1349,13 +1381,24 @@ class IntercomBroker {
|
|
|
1349
1381
|
awaited ? preferred : undefined,
|
|
1350
1382
|
!awaited ? undefined : claimed.status === "held" ? claimed.recovery : claimed.unanswered.recovery,
|
|
1351
1383
|
// The claim and the presence wait together stay within the client's registration wait.
|
|
1352
|
-
|
|
1384
|
+
presenceBoundMs,
|
|
1353
1385
|
);
|
|
1354
1386
|
})
|
|
1355
1387
|
.catch((error: unknown) => socket.destroy(error instanceof Error ? error : new Error(String(error))));
|
|
1356
1388
|
break;
|
|
1357
1389
|
}
|
|
1358
|
-
this.completeSessionRegistration(
|
|
1390
|
+
this.completeSessionRegistration(
|
|
1391
|
+
socket,
|
|
1392
|
+
registration,
|
|
1393
|
+
preferred ?? randomUUID(),
|
|
1394
|
+
supervisorId,
|
|
1395
|
+
setId,
|
|
1396
|
+
undefined,
|
|
1397
|
+
undefined,
|
|
1398
|
+
undefined,
|
|
1399
|
+
undefined,
|
|
1400
|
+
registrationBoundAfterClaim({ extendedMs: 0 }, clientRemainingMs()),
|
|
1401
|
+
);
|
|
1359
1402
|
break;
|
|
1360
1403
|
}
|
|
1361
1404
|
|
|
@@ -1899,30 +1942,54 @@ class IntercomBroker {
|
|
|
1899
1942
|
// a sender's later message never overtakes its earlier ones. Sends to other sessions never wait.
|
|
1900
1943
|
if (typeof clientMessage.to === "string" && this.endedQueue.restorePhase !== "idle" && this.endedQueue.restorePhase !== "ready") {
|
|
1901
1944
|
const sender = senderId === null ? undefined : this.sessions.get(senderId);
|
|
1902
|
-
const
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
const
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1945
|
+
const supervisorSend = clientMessage.type === "supervisor_send";
|
|
1946
|
+
const message = isMessage(clientMessage.message) ? clientMessage.message : undefined;
|
|
1947
|
+
if (!supervisorSend || (sender?.supervisorId !== undefined && clientMessage.to.trim() === sender.supervisorId)) {
|
|
1948
|
+
const extraReachable: ConnectedSession[] = [];
|
|
1949
|
+
const returnPathReachable: ConnectedSession[] = [];
|
|
1950
|
+
if (sender !== undefined) {
|
|
1951
|
+
if (supervisorSend && sender.supervisorId !== undefined) {
|
|
1952
|
+
const supervisor = this.sessions.get(sender.supervisorId);
|
|
1953
|
+
if (supervisor !== undefined) extraReachable.push(supervisor);
|
|
1954
|
+
}
|
|
1955
|
+
const replyTo = message?.replyTo;
|
|
1956
|
+
if (replyTo !== undefined) {
|
|
1957
|
+
for (const session of this.sessions.values()) {
|
|
1958
|
+
if (
|
|
1959
|
+
this.pendingQuestions.matchesReply(sender.info.id, session.info.id, replyTo) ||
|
|
1960
|
+
isVerticalBypass({
|
|
1961
|
+
replyTo,
|
|
1962
|
+
sender: sender.info,
|
|
1963
|
+
target: session.info,
|
|
1964
|
+
supervisorCache: this.supervisorChannel,
|
|
1965
|
+
})
|
|
1966
|
+
) {
|
|
1967
|
+
extraReachable.push(session);
|
|
1968
|
+
}
|
|
1910
1969
|
}
|
|
1911
1970
|
}
|
|
1971
|
+
if (message !== undefined && mayUseReturnPath(message, supervisorSend, sender)) {
|
|
1972
|
+
for (const session of this.returnPathAuthority.answerable(sender)) returnPathReachable.push(session);
|
|
1973
|
+
}
|
|
1912
1974
|
}
|
|
1913
|
-
|
|
1914
|
-
|
|
1975
|
+
const plainSend =
|
|
1976
|
+
!supervisorSend &&
|
|
1977
|
+
message?.replyTo === undefined &&
|
|
1978
|
+
clientMessage.requirePendingReply !== true &&
|
|
1979
|
+
clientMessage.expectedRecipientId === undefined;
|
|
1980
|
+
if (
|
|
1981
|
+
shouldHoldSendForEndedQueueRestore(this.endedQueue, clientMessage.to, sender, this.sessions, {
|
|
1982
|
+
...(this.multiNode === undefined || !plainSend
|
|
1983
|
+
? {}
|
|
1984
|
+
: { localAliasTarget: (target) => this.multiNode?.localAliasTarget(target) }),
|
|
1985
|
+
...(extraReachable.length === 0 ? {} : { extraReachable }),
|
|
1986
|
+
...(returnPathReachable.length === 0 ? {} : { returnPathReachable }),
|
|
1987
|
+
})
|
|
1988
|
+
) {
|
|
1989
|
+
this.endedQueue.whenRestored(() => this.dispatchSend(socket, clientMessage, senderId));
|
|
1990
|
+
return;
|
|
1915
1991
|
}
|
|
1916
1992
|
}
|
|
1917
|
-
if (
|
|
1918
|
-
shouldHoldSendForEndedQueueRestore(this.endedQueue, clientMessage.to, sender, this.sessions, {
|
|
1919
|
-
...(this.multiNode === undefined ? {} : { localAliasTarget: (target) => this.multiNode?.localAliasTarget(target) }),
|
|
1920
|
-
...(extraReachable.length === 0 ? {} : { extraReachable }),
|
|
1921
|
-
})
|
|
1922
|
-
) {
|
|
1923
|
-
this.endedQueue.whenRestored(() => this.dispatchSend(socket, clientMessage, senderId));
|
|
1924
|
-
return;
|
|
1925
|
-
}
|
|
1926
1993
|
}
|
|
1927
1994
|
handleBrokerSend(
|
|
1928
1995
|
socket,
|
|
@@ -2088,22 +2155,40 @@ class IntercomBroker {
|
|
|
2088
2155
|
}
|
|
2089
2156
|
if (this.multiNodeStatus === "starting") {
|
|
2090
2157
|
if (request.localTarget === undefined) {
|
|
2091
|
-
|
|
2158
|
+
if (this.activeStartingFallback !== undefined) {
|
|
2159
|
+
this.activeStartingFallback.entry.request = request;
|
|
2160
|
+
this.activeStartingFallback.entry.settled = false;
|
|
2161
|
+
this.activeStartingFallback.entry.bound = undefined;
|
|
2162
|
+
this.activeStartingFallback.replaced = true;
|
|
2163
|
+
return;
|
|
2164
|
+
}
|
|
2165
|
+
this.pendingMultiNodeSends.push({ request, settled: false });
|
|
2092
2166
|
return;
|
|
2093
2167
|
}
|
|
2094
2168
|
// A send to a session on this broker waits for the first opening at most as long as the router's own retry
|
|
2095
2169
|
// lookup would, then is delivered locally; whichever comes second does nothing, so it is answered once.
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2170
|
+
const pending: { request: RemoteSendRequest; settled: boolean; bound?: NodeJS.Timeout } = {
|
|
2171
|
+
request,
|
|
2172
|
+
settled: false,
|
|
2173
|
+
};
|
|
2174
|
+
pending.bound = setTimeout(() => {
|
|
2175
|
+
if (pending.settled) return;
|
|
2176
|
+
pending.settled = true;
|
|
2177
|
+
const fallback = { entry: pending, replaced: false };
|
|
2178
|
+
const previous = this.activeStartingFallback;
|
|
2179
|
+
this.activeStartingFallback = fallback;
|
|
2180
|
+
try {
|
|
2181
|
+
request.notFound();
|
|
2182
|
+
} finally {
|
|
2183
|
+
this.activeStartingFallback = previous;
|
|
2184
|
+
}
|
|
2185
|
+
if (!fallback.replaced) {
|
|
2186
|
+
const index = this.pendingMultiNodeSends.indexOf(pending);
|
|
2187
|
+
if (index !== -1) this.pendingMultiNodeSends.splice(index, 1);
|
|
2188
|
+
}
|
|
2100
2189
|
}, LOCAL_RETRY_LOOKUP_BOUND_MS);
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
answered = true;
|
|
2104
|
-
clearTimeout(bound);
|
|
2105
|
-
this.routeRemoteSend(request);
|
|
2106
|
-
});
|
|
2190
|
+
pending.bound.unref?.();
|
|
2191
|
+
this.pendingMultiNodeSends.push(pending);
|
|
2107
2192
|
return;
|
|
2108
2193
|
}
|
|
2109
2194
|
writeMessageIfOpen(request.socket, {
|
|
@@ -2152,6 +2237,13 @@ class IntercomBroker {
|
|
|
2152
2237
|
});
|
|
2153
2238
|
const settle = (status: "on" | "off" | "unavailable"): void => {
|
|
2154
2239
|
this.multiNodeStatus = status;
|
|
2240
|
+
const queued = this.pendingMultiNodeSends.splice(0);
|
|
2241
|
+
for (const pending of queued) {
|
|
2242
|
+
if (pending.settled) continue;
|
|
2243
|
+
pending.settled = true;
|
|
2244
|
+
if (pending.bound !== undefined) clearTimeout(pending.bound);
|
|
2245
|
+
this.routeRemoteSend(pending.request);
|
|
2246
|
+
}
|
|
2155
2247
|
settleFirstAttempt();
|
|
2156
2248
|
};
|
|
2157
2249
|
const report = (error: unknown): void => {
|
|
@@ -2182,8 +2274,9 @@ class IntercomBroker {
|
|
|
2182
2274
|
try {
|
|
2183
2275
|
const opened = await opener.openIntercomBrokerState(source);
|
|
2184
2276
|
this.openSharedEndedQueue = opened.state.openEndedChildQueue;
|
|
2277
|
+
let router: MultiNodeRouter;
|
|
2185
2278
|
try {
|
|
2186
|
-
|
|
2279
|
+
router = await MultiNodeRouter.start({
|
|
2187
2280
|
...opened,
|
|
2188
2281
|
// #4997: the same across this broker's restarts on this host, as its away-ask store is.
|
|
2189
2282
|
home: createHash("sha256").update(`${hostname()}\0${INTERCOM_DIR}`).digest("hex").slice(0, 32),
|
|
@@ -2236,7 +2329,7 @@ class IntercomBroker {
|
|
|
2236
2329
|
// here; mirror the ones still in force so other brokers hold sends for them too. Releases and owner
|
|
2237
2330
|
// departures from now on reach the router behind these reserves.
|
|
2238
2331
|
for (const reservation of this.restoringRecipients.active()) {
|
|
2239
|
-
|
|
2332
|
+
router.restoringReserved(
|
|
2240
2333
|
reservation.capability,
|
|
2241
2334
|
reservation.ownerSessionId,
|
|
2242
2335
|
reservation.childName,
|
|
@@ -2246,15 +2339,16 @@ class IntercomBroker {
|
|
|
2246
2339
|
{ wake: reservation.wake },
|
|
2247
2340
|
);
|
|
2248
2341
|
if (reservation.gone !== undefined) {
|
|
2249
|
-
|
|
2342
|
+
router.restoringReleased(reservation.capability, reservation.ownerSessionId, reservation.gone);
|
|
2250
2343
|
}
|
|
2251
2344
|
}
|
|
2252
2345
|
// #4997: the asks a crashed or stopped broker left here between two top-level sessions move to the shared
|
|
2253
2346
|
// state, as an away session's do, since either session may come back on another broker.
|
|
2254
2347
|
// The away store opens with the delivered-message authority, at the first registration otherwise.
|
|
2255
2348
|
this.openDeliveredMessages();
|
|
2256
|
-
void
|
|
2257
|
-
if (this.shuttingDown) await
|
|
2349
|
+
void router.publishAwayRoutes(this.pendingQuestions.movableDormant());
|
|
2350
|
+
if (this.shuttingDown) await router.close().catch(() => {});
|
|
2351
|
+
this.multiNode = router;
|
|
2258
2352
|
this.multiNodeReason = undefined;
|
|
2259
2353
|
const { adapter, prefix } = describeSharedStorage(setting);
|
|
2260
2354
|
console.error(`Intercom multi-node routing is on (adapter ${adapter}, prefix ${prefix ?? "none"})`);
|
|
@@ -2587,7 +2681,8 @@ class IntercomBroker {
|
|
|
2587
2681
|
// A subagent registered already takes what was kept for it.
|
|
2588
2682
|
if (session.supervisorId === undefined || session.registrationName === undefined) continue;
|
|
2589
2683
|
const sends = this.departedChildren.registered(session.registrationName, sessionGroups(session.info), session.supervisorId);
|
|
2590
|
-
for (const send of sends.filter(isQueuedForWake))
|
|
2684
|
+
for (const send of sends.filter(isQueuedForWake))
|
|
2685
|
+
this.dispatchQueuedForWake(send, session.registrationName, session.info.id);
|
|
2591
2686
|
this.dispatchHeldSends(sends.filter((send) => !isQueuedForWake(send)));
|
|
2592
2687
|
}
|
|
2593
2688
|
}
|
|
@@ -2784,9 +2879,22 @@ class IntercomBroker {
|
|
|
2784
2879
|
* would tell the sender stays here, except a refusal, which the sender gets as that message's delivery failure. One
|
|
2785
2880
|
* kept while the subagent was paused is marked so, so the subagent takes it after what it is continued with.
|
|
2786
2881
|
*/
|
|
2787
|
-
private dispatchQueuedForWake(
|
|
2882
|
+
private dispatchQueuedForWake(
|
|
2883
|
+
send: HeldSend,
|
|
2884
|
+
childName: string = send.clientMessage.to.trim(),
|
|
2885
|
+
targetSessionId?: string,
|
|
2886
|
+
): void {
|
|
2788
2887
|
const clientMessage = send.clientMessage as HeldSend["clientMessage"] & { message: Message };
|
|
2789
|
-
|
|
2888
|
+
const message: Message = isHeldWhilePaused(send)
|
|
2889
|
+
? { ...clientMessage.message, heldWhilePaused: true }
|
|
2890
|
+
: clientMessage.message;
|
|
2891
|
+
const dispatchedMessage =
|
|
2892
|
+
targetSessionId !== undefined
|
|
2893
|
+
? retargetSendToSessionId(clientMessage, targetSessionId, message)
|
|
2894
|
+
: (() => {
|
|
2895
|
+
if (isHeldWhilePaused(send)) clientMessage.message = message;
|
|
2896
|
+
return clientMessage;
|
|
2897
|
+
})();
|
|
2790
2898
|
const write = (socket: net.Socket, frame: BrokerMessage): boolean => {
|
|
2791
2899
|
if (socket !== send.socket) return writeMessageIfOpen(socket, frame);
|
|
2792
2900
|
const about = (frame as { readonly messageId?: unknown }).messageId;
|
|
@@ -2801,7 +2909,7 @@ class IntercomBroker {
|
|
|
2801
2909
|
writeMessageIfOpen(sender.socket, { type: "delivered", messageId: send.messageId });
|
|
2802
2910
|
// An ask that reached its subagent while its asker is away: the reply is held for the asker, as for any ask
|
|
2803
2911
|
// whose asker is away.
|
|
2804
|
-
if (sender === undefined &&
|
|
2912
|
+
if (sender === undefined && message.expectsReply === true && send.senderReturnAddress !== undefined)
|
|
2805
2913
|
this.pendingQuestions.keepForAwayAsker(send.messageId, send.senderId, send.senderReturnAddress);
|
|
2806
2914
|
this.endedQueue.settled([send.messageId]);
|
|
2807
2915
|
}
|
|
@@ -2811,7 +2919,7 @@ class IntercomBroker {
|
|
|
2811
2919
|
};
|
|
2812
2920
|
handleBrokerSend(
|
|
2813
2921
|
send.socket,
|
|
2814
|
-
|
|
2922
|
+
dispatchedMessage,
|
|
2815
2923
|
send.senderId,
|
|
2816
2924
|
this.sessions,
|
|
2817
2925
|
this.deliveredMessages,
|
|
@@ -3348,6 +3456,7 @@ class IntercomBroker {
|
|
|
3348
3456
|
for (const pending of this.releasedReplyAcks.values()) clearTimeout(pending.timer);
|
|
3349
3457
|
this.releasedReplyAcks.clear();
|
|
3350
3458
|
this.receipts.clear();
|
|
3459
|
+
this.returnPaths.clearPending();
|
|
3351
3460
|
this.deliveredMessageCache?.close();
|
|
3352
3461
|
// The watchdog thread ends while this broker's pipe still answers its probes. On Windows, process.exit waits for
|
|
3353
3462
|
// that thread, and the thread for its probe's connection: one made after the pipe server closed, while a session's
|
|
@@ -58,7 +58,11 @@ import {
|
|
|
58
58
|
IntercomClientDisconnectedError,
|
|
59
59
|
} from "../recoverable-disconnect.js";
|
|
60
60
|
import { type IntercomHostedSessionTimeoutFields, IntercomHostedSessionTimeoutError } from "../hosted-session-timeout-error.js";
|
|
61
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
type BrokerPidStat,
|
|
63
|
+
isUnansweredCloseFromRetiringBroker,
|
|
64
|
+
snapshotBrokerPidBeforeRequest,
|
|
65
|
+
} from "./retiring-broker-check.js";
|
|
62
66
|
import { IntercomBrokerProtocolError, IntercomRoutingChangedError, IntercomRoutingUnavailableError } from "@bastani/atomic";
|
|
63
67
|
import {
|
|
64
68
|
BROKER_PROTOCOL,
|
|
@@ -70,7 +74,7 @@ import {
|
|
|
70
74
|
VERIFIED_REGISTRATION_PROTOCOL,
|
|
71
75
|
} from "./protocol-version.js";
|
|
72
76
|
import { IntercomSupervisorAuthorizationRefusedError, SUPERVISOR_AUTHORIZATION_REFUSED_CODE } from "../supervisor-refusal.js";
|
|
73
|
-
import { SEND_RESPONSE_TIMEOUT_MS } from "../retry-policy.js";
|
|
77
|
+
import { BROKER_DISCONNECT_TIMEOUT_MS, HELD_SEND_GRACE_MS, SEND_RESPONSE_TIMEOUT_MS } from "../retry-policy.js";
|
|
74
78
|
import {
|
|
75
79
|
ENDED_CHILD_OWNER_AWAY_MAX_MS,
|
|
76
80
|
ENDED_CHILD_WAKE_ANSWER_MS,
|
|
@@ -100,8 +104,8 @@ function expiredHere(
|
|
|
100
104
|
/** #5999: the most messages kept here as queued for subagents that ended; the oldest is forgotten first. */
|
|
101
105
|
const ENDED_QUEUED_MAX = 1_024;
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
export
|
|
107
|
+
import { BROKER_CONNECT_TIMEOUT_MS } from "./registration-bounds.js";
|
|
108
|
+
export { BROKER_CONNECT_TIMEOUT_MS };
|
|
105
109
|
const GROUP_REQUEST_TIMEOUT_MS = 5000;
|
|
106
110
|
const PRESENCE_ACK_TIMEOUT_MS = 5000;
|
|
107
111
|
const RESTORING_RECIPIENT_REQUEST_TIMEOUT_MS = 5000;
|
|
@@ -154,19 +158,25 @@ function isLostBrokerSignature(error: Error): boolean {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
/**
|
|
157
|
-
* A failure before registration, classified: when it has the signature of a
|
|
158
|
-
* broker
|
|
159
|
-
*
|
|
160
|
-
* stays what it
|
|
161
|
+
* A failure before registration, classified through the shared retiring-broker check: when it has the signature of a
|
|
162
|
+
* lost broker and the broker went away, changed `broker.pid`, crashed, or is being replaced under a live spawn lock,
|
|
163
|
+
* the failure is recoverable by spawning or connecting to its replacement. A broker that stays up and unchanged closed
|
|
164
|
+
* the connection for its own reasons (a refused, unsupported, or malformed registration), so the failure stays what it
|
|
165
|
+
* was.
|
|
161
166
|
*/
|
|
162
|
-
async function classifyRegistrationFailure(
|
|
163
|
-
|
|
167
|
+
async function classifyRegistrationFailure(
|
|
168
|
+
error: Error,
|
|
169
|
+
socketPath: string,
|
|
170
|
+
agentDir: string | undefined,
|
|
171
|
+
pidBefore: BrokerPidStat | undefined,
|
|
172
|
+
): Promise<Error> {
|
|
173
|
+
if (!isLostBrokerSignature(error) || !(await isUnansweredCloseFromRetiringBroker(socketPath, agentDir, pidBefore))) {
|
|
174
|
+
return error;
|
|
175
|
+
}
|
|
164
176
|
return new IntercomBrokerRetiringError(`Intercom broker went away before it registered this session: ${error.message}`, {
|
|
165
177
|
cause: error,
|
|
166
178
|
});
|
|
167
179
|
}
|
|
168
|
-
/** Extra wait past a broker hold, so the broker's own outcome for a held send always arrives first (#3760). */
|
|
169
|
-
const HELD_SEND_GRACE_MS = 5000;
|
|
170
180
|
/** #5145: how many outcomes a client remembers hearing, so a second copy of one is not heard again. */
|
|
171
181
|
const HEARD_OUTCOMES_MAX = 1_000;
|
|
172
182
|
|
|
@@ -697,6 +707,10 @@ export class IntercomClient extends EventEmitter {
|
|
|
697
707
|
const resolvedSocketPath = this.resolveBrokerSocketPath();
|
|
698
708
|
const socketPath = typeof resolvedSocketPath === "string" ? resolvedSocketPath : await resolvedSocketPath;
|
|
699
709
|
if (attempt.signal.aborted) throw connectAborted();
|
|
710
|
+
const agentDir = this.explicitBrokerSocketPath === undefined ? this.brokerAgentDir : undefined;
|
|
711
|
+
const pidBefore = await snapshotBrokerPidBeforeRequest(agentDir);
|
|
712
|
+
if (attempt.signal.aborted) throw connectAborted();
|
|
713
|
+
const attemptState = { registerWritten: false };
|
|
700
714
|
try {
|
|
701
715
|
await this.connectOnce(
|
|
702
716
|
socketPath,
|
|
@@ -707,13 +721,14 @@ export class IntercomClient extends EventEmitter {
|
|
|
707
721
|
messageSource,
|
|
708
722
|
registrationGroup,
|
|
709
723
|
expectedRouting,
|
|
724
|
+
attemptState,
|
|
710
725
|
);
|
|
711
726
|
return;
|
|
712
727
|
} catch (error) {
|
|
713
728
|
if (attempt.signal.aborted) throw connectAborted();
|
|
714
729
|
if (!(error instanceof Error)) throw error;
|
|
715
|
-
if (!isBacklogRefusal(error) || retry >= BROKER_BACKLOG_RETRIES) {
|
|
716
|
-
const classified = await classifyRegistrationFailure(error, socketPath);
|
|
730
|
+
if (attemptState.registerWritten || !isBacklogRefusal(error) || retry >= BROKER_BACKLOG_RETRIES) {
|
|
731
|
+
const classified = await classifyRegistrationFailure(error, socketPath, agentDir, pidBefore);
|
|
717
732
|
if (attempt.signal.aborted) throw connectAborted();
|
|
718
733
|
if (expectedRouting?.verify === true && classified instanceof ConnectionClosedBeforeRegistrationError) {
|
|
719
734
|
throw new IntercomRoutingUnavailableError("unsupported", "register");
|
|
@@ -738,6 +753,7 @@ export class IntercomClient extends EventEmitter {
|
|
|
738
753
|
messageSource?: Message["source"],
|
|
739
754
|
registrationGroup?: string,
|
|
740
755
|
expectedRouting?: ExpectedRouting,
|
|
756
|
+
attemptState?: { registerWritten: boolean },
|
|
741
757
|
): Promise<void> {
|
|
742
758
|
if (this.socket) {
|
|
743
759
|
return Promise.reject(new Error("Already connected"));
|
|
@@ -751,6 +767,8 @@ export class IntercomClient extends EventEmitter {
|
|
|
751
767
|
this.verifyRelease = undefined;
|
|
752
768
|
|
|
753
769
|
return new Promise((resolve, reject) => {
|
|
770
|
+
const connectTimeoutMs = this.connectTimeoutMs;
|
|
771
|
+
const connectStartedAt = performance.now();
|
|
754
772
|
const socket = net.connect(socketPath);
|
|
755
773
|
this.socket = socket;
|
|
756
774
|
this.disconnectError = null;
|
|
@@ -765,7 +783,7 @@ export class IntercomClient extends EventEmitter {
|
|
|
765
783
|
socket.destroy();
|
|
766
784
|
reject(new IntercomBrokerTimeoutError("Connection timeout"));
|
|
767
785
|
}
|
|
768
|
-
},
|
|
786
|
+
}, connectTimeoutMs);
|
|
769
787
|
|
|
770
788
|
let connectionEstablished = false;
|
|
771
789
|
|
|
@@ -873,6 +891,7 @@ export class IntercomClient extends EventEmitter {
|
|
|
873
891
|
};
|
|
874
892
|
this._groups = normalizeGroups(registration.groups, registration.group);
|
|
875
893
|
this.sentReach = reach;
|
|
894
|
+
if (attemptState !== undefined) attemptState.registerWritten = true;
|
|
876
895
|
writeMessage(socket, {
|
|
877
896
|
...(expectedRouting?.verify === true
|
|
878
897
|
? { type: "register_verified", expectedRouting: { acrossMachines: expectedRouting.acrossMachines } }
|
|
@@ -880,6 +899,7 @@ export class IntercomClient extends EventEmitter {
|
|
|
880
899
|
session: registration,
|
|
881
900
|
...(reach === undefined ? {} : { reach: { home: reach.home, reachable: [...reach.reachable] } }),
|
|
882
901
|
protocol: { ...BROKER_PROTOCOL },
|
|
902
|
+
connectTimeoutMs: Math.max(1, Math.round(connectTimeoutMs - Math.max(0, performance.now() - connectStartedAt))),
|
|
883
903
|
...(registrationGroup !== undefined ? { registrationGroup } : {}),
|
|
884
904
|
returnAddress: this.returnAddress,
|
|
885
905
|
...(this.preferredSessionId === undefined ? {} : { preferredSessionId: this.preferredSessionId }),
|
|
@@ -1497,7 +1517,7 @@ export class IntercomClient extends EventEmitter {
|
|
|
1497
1517
|
};
|
|
1498
1518
|
const timeout = setTimeout(() => {
|
|
1499
1519
|
socket.destroy();
|
|
1500
|
-
},
|
|
1520
|
+
}, BROKER_DISCONNECT_TIMEOUT_MS);
|
|
1501
1521
|
socket.once("close", onClose);
|
|
1502
1522
|
socket.once("error", onError);
|
|
1503
1523
|
try {
|