@bastani/atomic 0.10.10-alpha.2 → 0.10.11-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 +142 -0
- package/README.md +1 -1
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +8 -10
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +6 -6
- package/dist/_shared/mode-shared-2QJSCUM6.js +52 -15
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-RRLVN7ER.js → sdk-AVFII7NK.js} +757 -233
- package/dist/_shared/sdk-AVFII7NK.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +3 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-57KF6LZH.js} +94 -42
- package/dist/_shared/startup-0-0-57KF6LZH.js.map +1 -0
- package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-GIY75K46.js} +75 -13
- package/dist/_shared/startup-0-1-GIY75K46.js.map +1 -0
- package/dist/_shared/startup-0-2-27OWFHV6.js +72 -7
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -1
- package/dist/_shared/startup-0-3-T4DVFYWX.js +4 -4
- package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
- package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +27 -69
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +31 -7
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +7 -6
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +4 -4
- package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1219 -714
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +14 -8
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +24 -0
- package/dist/builtin/intercom/broker/broker.bundle.mjs +993 -362
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
- package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
- package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
- package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
- package/dist/builtin/intercom/broker/paths.ts +8 -4
- package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
- package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
- package/dist/builtin/intercom/broker/sql-lease-store.ts +375 -65
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +270 -101
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
- package/dist/builtin/intercom/broker/sql-schema.ts +139 -1
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
- package/dist/builtin/intercom/index.bundle.mjs +11 -8
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +2 -2
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/compaction/compactor.d.ts +2 -0
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +1 -1
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +2 -2
- package/dist/core/extensions/runner-context.js +3 -3
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-resolver-defaults.d.ts +3 -2
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/sdk.code.js +3 -4
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.d.ts +5 -2
- package/dist/core/session-manager-core.js +17 -13
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/added-exports.d.ts +6 -0
- package/dist/core/storage/added-exports.js +16 -0
- package/dist/core/storage/added-exports.js.map +1 -0
- package/dist/core/storage/database.d.ts +16 -0
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +47 -0
- package/dist/core/storage/fenced-paths.js +53 -0
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.js +31 -2
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -0
- package/dist/core/storage/index.js +5 -2
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/migrations.d.ts +22 -0
- package/dist/core/storage/migrations.js +55 -0
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +19 -6
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +53 -4
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +3 -2
- package/dist/core/storage/prefix.js +18 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +42 -0
- package/dist/core/storage/schema-catalog.js +141 -0
- package/dist/core/storage/schema-catalog.js.map +1 -0
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +41 -20
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +3 -3
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +176 -36
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +2 -2
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +5 -0
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-chat-records.d.ts +15 -0
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +102 -5
- package/dist/core/storage/session/sql-session-store.impl.js +4 -4
- package/dist/core/storage/session/sql-session-store.js +4 -4
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.code.js +1 -1
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/session/types.d.ts +14 -0
- package/dist/core/storage/sqlite-facade.d.ts +37 -5
- package/dist/core/storage/sqlite-facade.js +351 -18
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +83 -0
- package/dist/core/storage/statement-sequence.js +21 -0
- package/dist/core/storage/statement-sequence.js.map +1 -1
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.code.js +1 -1
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/bash.d.ts +8 -4
- package/dist/core/tools/history-session.d.ts +5 -0
- package/dist/core/tools/history-tasks.d.ts +123 -0
- package/dist/core/tools/kill.d.ts +5 -2
- package/dist/core/tools/powershell.d.ts +2 -2
- package/dist/core/tools/read-url.code.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/tools/read.d.ts +12 -2
- package/dist/core/tools/resource-selectors.d.ts +2 -0
- package/dist/core/tools/search.d.ts +12 -2
- package/dist/core/worktree-snapshot/blob-store.d.ts +14 -2
- package/dist/core/worktree-snapshot/blob-store.js +69 -16
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +2 -2
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +1 -0
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/task-inspector.d.ts +2 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +2 -2
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/0.js +1 -1
- package/dist/startup-stages/1.js +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +8 -1
- package/dist/startup-stages/3.js +1 -6
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/7.js +1 -5
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks.md +123 -23
- package/docs/compaction.md +18 -0
- package/docs/docs.json +2 -0
- package/docs/environment-variables.md +1 -1
- package/docs/getting-started/installation.md +9 -2
- package/docs/guides/postgres-pgbouncer.md +339 -0
- package/docs/guides/postgres-tuning.md +311 -0
- package/docs/guides/resume-on-any-machine.md +2 -2
- package/docs/guides.md +2 -0
- package/docs/index.md +1 -1
- package/docs/libraries/agent-core.md +1 -1
- package/docs/libraries/ai.md +2 -2
- package/docs/libraries/codemode.md +1 -1
- package/docs/libraries/storage-libsql.md +6 -1
- package/docs/libraries/storage-postgres.md +11 -6
- package/docs/libraries/tui.md +1 -1
- package/docs/libraries.md +2 -2
- package/docs/programmatic.md +1 -1
- package/docs/quickstart.md +1 -1
- package/docs/sdk/storage.md +1 -1
- package/docs/sdk/web-server.md +1 -3
- package/docs/sdk.md +1 -7
- package/docs/sessions.md +58 -2
- package/docs/settings.md +20 -1
- package/docs/skills/authoring.md +1 -1
- package/docs/skills.md +79 -6
- package/docs/storage.md +262 -12
- package/docs/subagents/reference.md +2 -2
- package/docs/subagents.md +4 -3
- package/docs/tools.md +44 -10
- package/docs/windows.md +1 -1
- package/package.json +9 -9
- package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
- package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
|
@@ -92,14 +92,22 @@ function refusalFor(ask: ReleasedAskRecord, messageId: string): ReleasedReplyDec
|
|
|
92
92
|
return { kind: "refused", error: refusalOf(ask, messageId) };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/** The first live presence
|
|
95
|
+
/** The first live presence of the session `sessionId`, with the broker hosting it. */
|
|
96
96
|
async function liveSession(
|
|
97
97
|
state: Pick<ReleasedReplyState, "leases">,
|
|
98
|
-
|
|
98
|
+
sessionId: string,
|
|
99
99
|
): Promise<ReleasedReplyOwner | undefined> {
|
|
100
|
-
|
|
100
|
+
const { leases } = state;
|
|
101
|
+
// Only the presences that may be the session's, by index, where the store can (#6560).
|
|
102
|
+
const live =
|
|
103
|
+
leases.listLiveFor === undefined
|
|
104
|
+
? await leases.listLive("presence", BROKER_LEASE_STALE_AFTER_MS)
|
|
105
|
+
: await leases.listLiveFor(sessionId, BROKER_LEASE_STALE_AFTER_MS);
|
|
106
|
+
// Presences are stored with every string well formed (#6560).
|
|
107
|
+
const id = sessionId.toWellFormed();
|
|
108
|
+
for (const lease of live) {
|
|
101
109
|
const subject = lease.subject as RecipientPresenceSubject;
|
|
102
|
-
if (
|
|
110
|
+
if (subject.session.id === id) {
|
|
103
111
|
return { identity: subject.targetIdentity, sessionId: subject.session.id, hostBrokerId: lease.holderId };
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -108,7 +116,7 @@ async function liveSession(
|
|
|
108
116
|
|
|
109
117
|
/** The owner where it is connected now, or where it last was, so the reply waits there for it. */
|
|
110
118
|
async function ownerOfSession(state: ReleasedReplyState, ownerSessionId: string): Promise<ReleasedReplyOwner | undefined> {
|
|
111
|
-
const live = await liveSession(state,
|
|
119
|
+
const live = await liveSession(state, ownerSessionId);
|
|
112
120
|
// A presence or record under the owner's id bound to another return address is not the owner (multi-node binding).
|
|
113
121
|
if (live !== undefined && (await holdsSessionId(state.knownSessions, ownerSessionId, returnAddressOf(live.identity))))
|
|
114
122
|
return live;
|
|
@@ -145,7 +153,11 @@ export async function ownerOfReleasedReplyRow(
|
|
|
145
153
|
row: Pick<OutboxRow, "targetIdentity">,
|
|
146
154
|
): Promise<ReleasedReplyOwner> {
|
|
147
155
|
const identity = row.targetIdentity;
|
|
148
|
-
|
|
156
|
+
// The live presence of the row's identity: the one lease under that key (#6560).
|
|
157
|
+
const read = await state.leases.read({ kind: "presence", targetIdentity: identity });
|
|
158
|
+
if (read.status !== "found" || read.lease.ageMs > BROKER_LEASE_STALE_AFTER_MS) return { identity, sessionId: "" };
|
|
159
|
+
const subject = read.lease.subject as RecipientPresenceSubject;
|
|
160
|
+
return { identity, sessionId: subject.session.id, hostBrokerId: read.lease.holderId };
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
async function ownerOfRow(state: ReleasedReplyState, messageId: string): Promise<ReleasedReplyOwner | undefined> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dialectOf, type SqliteDatabase } from "@bastani/atomic/storage";
|
|
2
|
+
import { catalogHasColumns } from "./sql-schema.js";
|
|
2
3
|
|
|
3
4
|
function isLineTerminatorCode(code: number): boolean {
|
|
4
5
|
return code === 0x0a || code === 0x0d || code === 0x2028 || code === 0x2029;
|
|
@@ -80,7 +81,7 @@ function isDuplicateColumn(error: unknown): boolean {
|
|
|
80
81
|
* A statement the database refused for a privilege the role lacks: the PostgreSQL adapter's `missing-privilege`, which
|
|
81
82
|
* the database facade reports as the cause of its `StorageUnavailableError`.
|
|
82
83
|
*/
|
|
83
|
-
function isMissingPrivilege(error: unknown): boolean {
|
|
84
|
+
export function isMissingPrivilege(error: unknown): boolean {
|
|
84
85
|
let at = error;
|
|
85
86
|
for (let depth = 0; depth < 4 && typeof at === "object" && at !== null; depth++) {
|
|
86
87
|
if ((at as { reason?: unknown }).reason === "missing-privilege") return true;
|
|
@@ -123,6 +124,8 @@ export async function addMissingColumns(
|
|
|
123
124
|
withColumn?: string,
|
|
124
125
|
): Promise<void> {
|
|
125
126
|
const dialect = dialectOf(database);
|
|
127
|
+
// An open that read the catalog and found every column there runs no transaction (#6560).
|
|
128
|
+
if (await catalogHasColumns(database, table, Object.keys(columns))) return;
|
|
126
129
|
for (const [column, definition] of Object.entries(columns)) {
|
|
127
130
|
const probe = dialect.columnExists(table, column);
|
|
128
131
|
try {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@bastani/atomic/storage";
|
|
11
11
|
import { ENDED_CHILD_QUEUE_BYTES_TOTAL_MAX, EndedChildQueueFullError } from "./ended-child-wakes.js";
|
|
12
12
|
import type { IntercomBrokerStateOptions } from "./multinode-state-store.js";
|
|
13
|
-
import { ensureBrokerSchema } from "./sql-schema.js";
|
|
13
|
+
import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* #5999 durable wake queue: the messages queued for subagents that ended (to be resumed, or kept while paused), kept
|
|
@@ -287,8 +287,13 @@ class OrderedWrites {
|
|
|
287
287
|
private brokenUntil = Number.NEGATIVE_INFINITY;
|
|
288
288
|
private brokenBy: unknown;
|
|
289
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @param domain The queue's table: its writes touch the queue's own tables alone, so they exclude one another, not
|
|
292
|
+
* every writer of a shared database (#6560).
|
|
293
|
+
*/
|
|
290
294
|
constructor(
|
|
291
295
|
private readonly database: SqliteDatabase,
|
|
296
|
+
private readonly domain: string,
|
|
292
297
|
private readonly lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
|
|
293
298
|
) {}
|
|
294
299
|
|
|
@@ -340,7 +345,7 @@ class OrderedWrites {
|
|
|
340
345
|
}
|
|
341
346
|
}
|
|
342
347
|
return outcomes;
|
|
343
|
-
}, { lockWaitMs: this.lockWaitMs });
|
|
348
|
+
}, { lockWaitMs: this.lockWaitMs, concurrency: { kind: "serial", domain: this.domain } });
|
|
344
349
|
batch.forEach((item, index) => {
|
|
345
350
|
const outcome = results[index]!;
|
|
346
351
|
if (outcome.ok) item.resolve(outcome.value);
|
|
@@ -548,53 +553,17 @@ function failureForm(senderJson: string, requestJson: string | null): { readonly
|
|
|
548
553
|
}
|
|
549
554
|
|
|
550
555
|
/**
|
|
551
|
-
*
|
|
552
|
-
*
|
|
556
|
+
* Creates the ended-child queue's tables unless the store's ledger says they are there, as its first open on a database
|
|
557
|
+
* does, and as `atomic storage migrate` does, so a runtime role that may not create tables finds them (#6560).
|
|
553
558
|
*/
|
|
554
|
-
export async function
|
|
555
|
-
{ database, prefix }: IntercomBrokerStateOptions,
|
|
556
|
-
{
|
|
557
|
-
home,
|
|
558
|
-
holder,
|
|
559
|
-
ownsDatabase = false,
|
|
560
|
-
retire: retiring = false,
|
|
561
|
-
lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
|
|
562
|
-
servedSinceLastHolder,
|
|
563
|
-
pid,
|
|
564
|
-
compact = false,
|
|
565
|
-
}: {
|
|
566
|
-
readonly home: string;
|
|
567
|
-
readonly holder: string;
|
|
568
|
-
readonly ownsDatabase?: boolean;
|
|
569
|
-
/** How long a write waits for another process's write lock (default {@link ENDED_QUEUE_LOCK_WAIT_MS}). */
|
|
570
|
-
readonly lockWaitMs?: number;
|
|
571
|
-
/**
|
|
572
|
-
* Whether another broker can have served this home since the store's last holder, which kept nothing and told
|
|
573
|
-
* senders their messages were lost: given the store's identity, says if this broker could not prove it did not.
|
|
574
|
-
* Unproven, a store with messages is retired. Absent: never retired so.
|
|
575
|
-
*/
|
|
576
|
-
readonly servedSinceLastHolder?: (storeId: string) => boolean;
|
|
577
|
-
/** This broker's process id, recorded as the store's holder. */
|
|
578
|
-
readonly pid?: string;
|
|
579
|
-
/** A broker that kept the queue in memory told its sessions what this store kept was lost: drop it. */
|
|
580
|
-
readonly retire?: boolean;
|
|
581
|
-
/**
|
|
582
|
-
* The database is this store's own file: once its queue drains, the file gives the space its messages took back,
|
|
583
|
-
* a bounded step at a time (incremental auto-vacuum). A shared database keeps its own maintenance.
|
|
584
|
-
*/
|
|
585
|
-
readonly compact?: boolean;
|
|
586
|
-
},
|
|
587
|
-
): Promise<EndedChildQueueStore> {
|
|
588
|
-
let retire = retiring;
|
|
559
|
+
export async function ensureEndedChildQueueSchema({ database, prefix }: IntercomBrokerStateOptions): Promise<void> {
|
|
589
560
|
const valid = validateStoragePrefix(prefix, dialectOf(database).name);
|
|
590
561
|
const queue = `${valid}intercom_ended_child_queue`;
|
|
591
|
-
// The messages themselves, apart from the rows a broker updates (holder, wake, away, handed over): an update never
|
|
592
|
-
// rewrites a message.
|
|
593
562
|
const bodies = `${valid}intercom_ended_child_bodies`;
|
|
594
563
|
const wakes = `${valid}intercom_ended_child_wakes`;
|
|
595
564
|
const meta = `${valid}intercom_ended_child_meta`;
|
|
596
565
|
const { types } = dialectOf(database);
|
|
597
|
-
|
|
566
|
+
await ensureBrokerSchema(database, prefix, "ended-child-queue", (tx) =>
|
|
598
567
|
tx.exec(`
|
|
599
568
|
CREATE TABLE IF NOT EXISTS ${queue}(
|
|
600
569
|
seq ${types.serialKey},
|
|
@@ -636,6 +605,58 @@ export async function openSqlEndedChildQueueStore(
|
|
|
636
605
|
);
|
|
637
606
|
`),
|
|
638
607
|
);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* #5999: the queue on `database`, tables `<prefix>intercom_ended_child_queue`, `<prefix>intercom_ended_child_wakes` and
|
|
612
|
+
* `<prefix>intercom_ended_child_meta`. `home` partitions the rows by broker home; `holder` is this broker instance.
|
|
613
|
+
*/
|
|
614
|
+
export async function openSqlEndedChildQueueStore(
|
|
615
|
+
{ database, prefix }: IntercomBrokerStateOptions,
|
|
616
|
+
{
|
|
617
|
+
home,
|
|
618
|
+
holder,
|
|
619
|
+
ownsDatabase = false,
|
|
620
|
+
retire: retiring = false,
|
|
621
|
+
lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
|
|
622
|
+
servedSinceLastHolder,
|
|
623
|
+
pid,
|
|
624
|
+
compact = false,
|
|
625
|
+
}: {
|
|
626
|
+
readonly home: string;
|
|
627
|
+
readonly holder: string;
|
|
628
|
+
readonly ownsDatabase?: boolean;
|
|
629
|
+
/** How long a write waits for another process's write lock (default {@link ENDED_QUEUE_LOCK_WAIT_MS}). */
|
|
630
|
+
readonly lockWaitMs?: number;
|
|
631
|
+
/**
|
|
632
|
+
* Whether another broker can have served this home since the store's last holder, which kept nothing and told
|
|
633
|
+
* senders their messages were lost: given the store's identity, says if this broker could not prove it did not.
|
|
634
|
+
* Unproven, a store with messages is retired. Absent: never retired so.
|
|
635
|
+
*/
|
|
636
|
+
readonly servedSinceLastHolder?: (storeId: string) => boolean;
|
|
637
|
+
/** This broker's process id, recorded as the store's holder. */
|
|
638
|
+
readonly pid?: string;
|
|
639
|
+
/** A broker that kept the queue in memory told its sessions what this store kept was lost: drop it. */
|
|
640
|
+
readonly retire?: boolean;
|
|
641
|
+
/**
|
|
642
|
+
* The database is this store's own file: once its queue drains, the file gives the space its messages took back,
|
|
643
|
+
* a bounded step at a time (incremental auto-vacuum). A shared database keeps its own maintenance.
|
|
644
|
+
*/
|
|
645
|
+
readonly compact?: boolean;
|
|
646
|
+
},
|
|
647
|
+
): Promise<EndedChildQueueStore> {
|
|
648
|
+
let retire = retiring;
|
|
649
|
+
const valid = validateStoragePrefix(prefix, dialectOf(database).name);
|
|
650
|
+
const queue = `${valid}intercom_ended_child_queue`;
|
|
651
|
+
// The messages themselves, apart from the rows a broker updates (holder, wake, away, handed over): an update never
|
|
652
|
+
// rewrites a message.
|
|
653
|
+
const bodies = `${valid}intercom_ended_child_bodies`;
|
|
654
|
+
const wakes = `${valid}intercom_ended_child_wakes`;
|
|
655
|
+
const meta = `${valid}intercom_ended_child_meta`;
|
|
656
|
+
// Set up when a home first opens the queue, long after the broker's other stores: checked against a read of the
|
|
657
|
+
// schema catalog of its own, so a database where another home set the queue up costs no transaction or lock (#6560).
|
|
658
|
+
const createSchema = () =>
|
|
659
|
+
withBrokerSchemaCatalog(database, prefix, () => ensureEndedChildQueueSchema({ database, prefix }));
|
|
639
660
|
// The identity of a store already set up is read without a write, so a broker's start never waits for another
|
|
640
661
|
// process's write lock on it (a reader of a write-ahead log is not blocked by a writer). A new one is set up first.
|
|
641
662
|
const readMeta = async (): Promise<{ readonly id: string; readonly holderPid?: string } | undefined> => {
|
|
@@ -667,10 +688,10 @@ export async function openSqlEndedChildQueueStore(
|
|
|
667
688
|
await tx.run(`INSERT INTO ${meta}(home, store_id) VALUES (?, ?) ON CONFLICT DO NOTHING`, home, randomUUID());
|
|
668
689
|
const row = await tx.get<SqliteRow & { store_id: string }>(`SELECT store_id FROM ${meta} WHERE home = ?`, home);
|
|
669
690
|
return row?.store_id as string;
|
|
670
|
-
});
|
|
691
|
+
}, { concurrency: { kind: "serial", domain: queue } });
|
|
671
692
|
}
|
|
672
693
|
const keeper = id;
|
|
673
|
-
const writes = new OrderedWrites(database, lockWaitMs);
|
|
694
|
+
const writes = new OrderedWrites(database, queue, lockWaitMs);
|
|
674
695
|
let compacting: Promise<void> | undefined;
|
|
675
696
|
let closing = false;
|
|
676
697
|
const pragmaOf = async (executor: SqliteExecutor, name: string): Promise<number> => {
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
InvalidStateInput,
|
|
12
12
|
StateStoreInvalidReason,
|
|
13
13
|
} from "./multinode-state-store.js";
|
|
14
|
-
import { ensureBrokerSchema } from "./sql-schema.js";
|
|
14
|
+
import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
|
|
15
15
|
|
|
16
16
|
type HeldRow = SqliteRow & {
|
|
17
17
|
reservation_key: string;
|
|
@@ -35,9 +35,17 @@ function heldSendOf(row: HeldRow): HeldSend {
|
|
|
35
35
|
* S3: `HeldSendStore` on the shared storage adapter's database, table `<prefix>intercom_held_sends`. Sends are keyed
|
|
36
36
|
* by `reservationKeyFor(capability)`; the capability itself is never stored.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export function openSqlHeldSendStore(options: IntercomBrokerStateOptions): Promise<HeldSendStore> {
|
|
39
|
+
// Its schema checks answer from one read of the catalog, shared with an open around it: a current schema costs
|
|
40
|
+
// no transaction and no lock, also when the store is opened on its own (#6560).
|
|
41
|
+
return withBrokerSchemaCatalog(options.database, options.prefix, () => openHeldSendStoreInCatalog(options));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function openHeldSendStoreInCatalog({ database, prefix }: IntercomBrokerStateOptions): Promise<HeldSendStore> {
|
|
39
45
|
const table = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_held_sends`;
|
|
40
46
|
const { types, nowMs } = dialectOf(database);
|
|
47
|
+
/** `take` reads and writes this table alone, so it excludes other takes, not every writer (#6560). */
|
|
48
|
+
const serial = { concurrency: { kind: "serial", domain: table } } as const;
|
|
41
49
|
await ensureBrokerSchema(database, prefix, "held-sends", (tx) =>
|
|
42
50
|
tx.exec(`
|
|
43
51
|
CREATE TABLE IF NOT EXISTS ${table}(
|
|
@@ -84,7 +92,7 @@ export async function openSqlHeldSendStore({ database, prefix }: IntercomBrokerS
|
|
|
84
92
|
const taken = await tx.all<HeldRow>(selectForReservation, reservationKey);
|
|
85
93
|
await tx.run(`DELETE FROM ${table} WHERE reservation_key = ?`, reservationKey);
|
|
86
94
|
return taken;
|
|
87
|
-
});
|
|
95
|
+
}, serial);
|
|
88
96
|
return { status: "taken", sends: rows.map(heldSendOf) };
|
|
89
97
|
},
|
|
90
98
|
async drop(messageId): Promise<HeldSendDropResult> {
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
SessionIdReclaim,
|
|
14
14
|
SessionIdReclaimResult,
|
|
15
15
|
} from "./multinode-state-store.js";
|
|
16
|
-
import { ensureBrokerSchema } from "./sql-schema.js";
|
|
16
|
+
import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
|
|
17
17
|
|
|
18
18
|
type BindingRow = SqliteRow & { return_address: string; owner_token?: string | null; owner_broker?: string | null };
|
|
19
19
|
|
|
@@ -66,9 +66,16 @@ function stateFromRow(row: KnownRow): KnownSessionState {
|
|
|
66
66
|
* `toLowerCase` form the lookup compares. Table `<prefix>intercom_session_bindings` binds each Intercom id to the return
|
|
67
67
|
* address of the session that registered it (`""` for none).
|
|
68
68
|
*/
|
|
69
|
-
export
|
|
69
|
+
export function openSqlKnownSessionStore(options: IntercomBrokerStateOptions): Promise<KnownSessionStore> {
|
|
70
|
+
// Its schema checks answer from one read of the catalog, shared with an open around it: a current schema costs
|
|
71
|
+
// no transaction and no lock, also when the store is opened on its own (#6560).
|
|
72
|
+
return withBrokerSchemaCatalog(options.database, options.prefix, () => openKnownSessionStoreInCatalog(options));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function openKnownSessionStoreInCatalog({
|
|
70
76
|
database,
|
|
71
77
|
prefix,
|
|
78
|
+
reader = database,
|
|
72
79
|
}: IntercomBrokerStateOptions): Promise<KnownSessionStore> {
|
|
73
80
|
const table = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_known_sessions`;
|
|
74
81
|
const bindings = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_session_bindings`;
|
|
@@ -349,7 +356,8 @@ export async function openSqlKnownSessionStore({
|
|
|
349
356
|
},
|
|
350
357
|
async lookup(target, retentionMs): Promise<KnownSessionLookupResult> {
|
|
351
358
|
if (target.length === 0) return { status: "invalid", reason: "empty-target" };
|
|
352
|
-
|
|
359
|
+
// Through the reader, which never waits behind this database's writes (#6560).
|
|
360
|
+
const rows = await reader.all<KnownRow>(
|
|
353
361
|
// One reading of the clock, so a session found within the retention reports an age within it too.
|
|
354
362
|
`WITH clock AS (SELECT ${nowMs} AS now)
|
|
355
363
|
SELECT target_identity, intercom_session_id${aliasColumn}, name_json, atomic_session_id, group_name, groups_json,
|
|
@@ -375,7 +383,7 @@ export async function openSqlKnownSessionStore({
|
|
|
375
383
|
...(owned ? { owners } : {}),
|
|
376
384
|
async binding(intercomSessionId, retentionMs): Promise<KnownSessionBindingResult> {
|
|
377
385
|
if (intercomSessionId.length === 0) return { status: "invalid", reason: "empty-session-id" };
|
|
378
|
-
const bound = await
|
|
386
|
+
const bound = await reader.get<BindingRow>(
|
|
379
387
|
`SELECT return_address FROM ${bindings} WHERE intercom_session_id = ? AND ${nowMs} - recorded_at <= ?`,
|
|
380
388
|
intercomSessionId,
|
|
381
389
|
retentionMs,
|
|
@@ -392,14 +400,18 @@ export async function openSqlKnownSessionStore({
|
|
|
392
400
|
},
|
|
393
401
|
async markLost(targetIdentities): Promise<void> {
|
|
394
402
|
if (targetIdentities.length === 0) return;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
+
// Each row's write is guarded on its own: only other `markLost`s, locking the same rows, are excluded (#6560).
|
|
404
|
+
await database.transaction(
|
|
405
|
+
async (tx) => {
|
|
406
|
+
for (const identity of targetIdentities) {
|
|
407
|
+
await tx.run(
|
|
408
|
+
`UPDATE ${table} SET lost_at = ${nowMs} WHERE target_identity = ? AND lost_at IS NULL`,
|
|
409
|
+
identity,
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
{ concurrency: { kind: "serial", domain: table } },
|
|
414
|
+
);
|
|
403
415
|
},
|
|
404
416
|
async listLost(olderThanMs): Promise<KnownSessionState[]> {
|
|
405
417
|
const rows = await database.all<KnownRow>(
|