@bastani/atomic 0.10.11-alpha.2 → 0.10.11-alpha.3
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 +99 -0
- package/README.md +5 -8
- 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 +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +340 -163
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-EZUKEP4Q.js} +48 -40
- package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-RTOHJFDJ.js} +195 -42
- package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +33 -43
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +39 -23
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +90 -1176
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +186 -35
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +23 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +913 -289
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
- package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
- package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +170 -74
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +298 -47
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
- package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +136 -19
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +2 -3
- 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/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- 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 +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- 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 +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- 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.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 +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- 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/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/process-start-token.d.ts +8 -0
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- 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/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +19 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +11 -0
- package/dist/core/storage/fenced-paths.js +11 -0
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +8 -13
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +51 -3
- 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 +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +7 -8
- package/dist/core/storage/schema-catalog.js +8 -8
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- 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.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 +2 -2
- 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 +4 -7
- 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.d.ts +5 -1
- 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 +3 -3
- 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 +43 -4
- 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-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +48 -11
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- 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.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +6 -1
- package/dist/core/storage/sqlite-facade.js +1 -0
- package/dist/core/storage/sqlite-facade.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.d.ts +26 -115
- 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.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/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +40 -3
- package/dist/core/worktree-snapshot/blob-store.js +414 -21
- 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/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +79 -38
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- 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 +1 -1
- 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.d.ts +3 -1
- 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/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/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- 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/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- 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/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1421 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -2,7 +2,7 @@ import type { SqliteDatabase } from "./database.js";
|
|
|
2
2
|
import { TeamProfileConfigError } from "./errors.js";
|
|
3
3
|
import type { StorageSteps } from "./file-identity.js";
|
|
4
4
|
import type { AdapterOptions, SecretRef, StorageSelection } from "./provider.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { TeamProfile, TeamProfileOptions } from "./team.js";
|
|
6
6
|
/** A secret held only in this process's memory: it is never written to settings, environments or files. */
|
|
7
7
|
export interface InMemorySecretRef {
|
|
8
8
|
readonly value: string;
|
|
@@ -29,51 +29,13 @@ export type StorageInputSelection = StorageSettingsSelection | {
|
|
|
29
29
|
export declare function selectStorage(value: StorageInputSelection, source: "sdk" | "settings" | "env" | "cli", field: string, defaultPath: string | (() => string)): StorageSelection;
|
|
30
30
|
export declare function selectStorageAsync(value: StorageInputSelection, source: "sdk" | "settings" | "env" | "cli", field: string, defaultPath: () => Promise<string>): Promise<StorageSelection>;
|
|
31
31
|
export declare function selectStorageSteps(value: StorageInputSelection, source: "sdk" | "settings" | "env" | "cli", field: string, defaultPath: string | (() => StorageSteps<string>)): StorageSteps<StorageSelection>;
|
|
32
|
-
/**
|
|
33
|
-
export declare const LIBSQL_ADAPTER_PACKAGE = "@bastani/atomic-storage-libsql";
|
|
34
|
-
/** Filename prefix for private token files created by `atomic storage join` and `atomic team join` in the agent directory. */
|
|
32
|
+
/** A token file `atomic storage join` created in the agent directory has this filename prefix. */
|
|
35
33
|
export declare const STORAGE_TOKEN_FILE = "storage-token";
|
|
36
|
-
/** The `sessions.storage` value
|
|
34
|
+
/** The `sessions.storage` value that pins sessions to the local default store, named explicitly. */
|
|
37
35
|
export declare const LOCAL_SESSIONS_STORAGE: {
|
|
38
36
|
readonly path: "workflows/journal.sqlite";
|
|
39
37
|
};
|
|
40
|
-
export declare const TEAM_PROFILE_ENV = "ATOMIC_PROFILE";
|
|
41
|
-
export declare const TEAM_URL_ENV = "ATOMIC_TEAM_URL";
|
|
42
|
-
export declare const TEAM_TOKEN_ENV = "ATOMIC_TEAM_TOKEN";
|
|
43
|
-
export declare const TEAM_TOKEN_FILE_ENV = "ATOMIC_TEAM_TOKEN_FILE";
|
|
44
|
-
export declare const TEAM_PREFIX_ENV = "ATOMIC_TEAM_PREFIX";
|
|
45
|
-
/** The variables `ATOMIC_PROFILE=ci` reads; setting any of them without the profile is an error. */
|
|
46
|
-
export declare const TEAM_VARIABLES: readonly string[];
|
|
47
|
-
/** A team database selection in the settings form: usable as `createAgentSession({ storage })`. */
|
|
48
|
-
export interface TeamStorageSelection {
|
|
49
|
-
readonly adapter: string;
|
|
50
|
-
readonly options: Readonly<Record<string, string>>;
|
|
51
|
-
readonly secrets?: Readonly<Record<string, SecretRef>>;
|
|
52
|
-
readonly prefix?: string;
|
|
53
|
-
}
|
|
54
|
-
export interface TeamProfileSelectionOptions {
|
|
55
|
-
readonly profile: "ci";
|
|
56
|
-
/** `libsql://`, `https://`, `wss://` or absolute `file:` URL, without a credential. */
|
|
57
|
-
readonly url: string;
|
|
58
|
-
/** The database token, held as an in-memory `{ value }` secret that is never serialized or written. */
|
|
59
|
-
readonly token?: string;
|
|
60
|
-
/** A file holding the database token; relative paths resolve against the working directory. */
|
|
61
|
-
readonly tokenFile?: string;
|
|
62
|
-
/** An environment variable holding the database token, read when the store opens. */
|
|
63
|
-
readonly tokenEnv?: string;
|
|
64
|
-
readonly prefix?: string;
|
|
65
|
-
}
|
|
66
38
|
export type TeamInputSource = "sdk" | "cli" | "env";
|
|
67
|
-
/** Whether a team database URL needs no token: a local `file:` database. */
|
|
68
|
-
export declare function isFileUrl(url: string): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Check a team database URL: a supported scheme, an absolute `file:` URL, and no credential in it. `postgres` only
|
|
71
|
-
* changes the unsupported-URL hint, for the commands that also take a `postgres://` URL through
|
|
72
|
-
* {@link checkSharedDatabaseArguments}.
|
|
73
|
-
*/
|
|
74
|
-
export declare function checkTeamUrl(url: string | undefined, source: TeamInputSource, options?: {
|
|
75
|
-
readonly postgres?: boolean;
|
|
76
|
-
}): string;
|
|
77
39
|
/** The first-party PostgreSQL adapter package that `atomic storage join postgres://…` and `--db postgres://…` select. */
|
|
78
40
|
export declare const POSTGRES_ADAPTER_PACKAGE = "@bastani/atomic-storage-postgres";
|
|
79
41
|
/** The platform credential a Postgres selection's `auth` option names, instead of a password. */
|
|
@@ -85,7 +47,7 @@ export declare function isPostgresUrl(url: string): boolean;
|
|
|
85
47
|
/** The shared database a command line names: its URL and where its credential comes from. */
|
|
86
48
|
export interface SharedDatabaseArguments {
|
|
87
49
|
readonly url: string;
|
|
88
|
-
/**
|
|
50
|
+
/** A password or token file another process keeps fresh, referenced in place. */
|
|
89
51
|
readonly tokenFile?: string;
|
|
90
52
|
/** Postgres only: a password file. */
|
|
91
53
|
readonly passwordFile?: string;
|
|
@@ -100,9 +62,9 @@ export interface CheckedSharedDatabase {
|
|
|
100
62
|
readonly auth?: PostgresAuth;
|
|
101
63
|
}
|
|
102
64
|
/**
|
|
103
|
-
* Check the database URL and credential flags of `atomic storage join` and `--db
|
|
104
|
-
* `postgresql://` URL takes exactly one of `--password-file`, `--token-file` and `--auth
|
|
105
|
-
*
|
|
65
|
+
* Check the database URL and credential flags of `atomic storage join` and `--db`: a `postgres://` or
|
|
66
|
+
* `postgresql://` URL that takes exactly one of `--password-file`, `--token-file` and `--auth`. A URL of the removed
|
|
67
|
+
* libSQL adapter is refused with how to move off it.
|
|
106
68
|
*/
|
|
107
69
|
export declare function checkSharedDatabaseArguments(input: SharedDatabaseArguments): CheckedSharedDatabase;
|
|
108
70
|
/** Check a table prefix with the same rules as every storage prefix. */
|
|
@@ -112,45 +74,8 @@ export declare function checkTeamPrefix(prefix: string | undefined, source: Team
|
|
|
112
74
|
* a file a selection references is read for every connection; an unreadable or empty file is an invalid input.
|
|
113
75
|
*/
|
|
114
76
|
export declare function readTeamTokenFile(path: string, source: TeamInputSource, field?: string, read?: "trimmed" | "as-connections-read"): string;
|
|
115
|
-
export declare function readTeamTokenFileAsync(path: string, source: TeamInputSource, field?: string, read?: "trimmed" | "as-connections-read"): Promise<string>;
|
|
116
|
-
/** A missing token for a URL that needs one. */
|
|
117
|
-
export declare function missingTeamToken(url: string, source: Exclude<TeamInputSource, "env">): TeamProfileConfigError;
|
|
118
77
|
/** More than one token source. */
|
|
119
78
|
export declare function conflictingTeamToken(source: TeamInputSource, fields: readonly string[]): TeamProfileConfigError;
|
|
120
|
-
/** A whitespace-only literal token, or an empty variable name. */
|
|
121
|
-
export declare function emptyTeamToken(source: TeamInputSource, field?: string): TeamProfileConfigError;
|
|
122
|
-
/**
|
|
123
|
-
* The CI profile as a team database selection, without reading or writing settings: sessions and Intercom can both
|
|
124
|
-
* use it. A literal `token` becomes an in-memory `{ value }` secret that serializes as
|
|
125
|
-
* `[redacted]` and that only SDK callers can pass; `tokenFile` (absolute path) and `tokenEnv` are references read
|
|
126
|
-
* when the store opens. Inputs are checked first; nothing else happens.
|
|
127
|
-
*/
|
|
128
|
-
export declare function teamProfileSelection(options: TeamProfileSelectionOptions): TeamStorageSelection;
|
|
129
|
-
/**
|
|
130
|
-
* The selection `ATOMIC_PROFILE=ci` makes from `ATOMIC_TEAM_URL` and `ATOMIC_TEAM_TOKEN` or `ATOMIC_TEAM_TOKEN_FILE`
|
|
131
|
-
* (plus an optional `ATOMIC_TEAM_PREFIX`), or `undefined` without a profile. The token is referenced, never copied:
|
|
132
|
-
* `{ env: "ATOMIC_TEAM_TOKEN" }` or the token file's absolute path, so the selection can be handed to child processes.
|
|
133
|
-
* Invalid input throws {@link TeamProfileConfigError} with `source: "env"`: a team variable without the profile, or
|
|
134
|
-
* the profile without its URL or token, is `incomplete-profile` naming every missing variable at once.
|
|
135
|
-
*/
|
|
136
|
-
export declare function environmentTeamProfile(env?: NodeJS.ProcessEnv): TeamStorageSelection | undefined;
|
|
137
|
-
export declare function environmentTeamProfileSelection(env?: NodeJS.ProcessEnv): TeamStorageSelection | undefined;
|
|
138
|
-
export declare function environmentTeamProfileAsync(env?: NodeJS.ProcessEnv): Promise<TeamStorageSelection | undefined>;
|
|
139
|
-
/**
|
|
140
|
-
* Use a team database for Intercom while sessions stay private: checks every input and the
|
|
141
|
-
* connection first, then sets the global `storage` setting to the team database and `sessions.storage` to the local
|
|
142
|
-
* default store in one settings write, and restarts the Intercom broker so it routes through the team database.
|
|
143
|
-
* Rejects with `TeamProfileConfigError` for an invalid input and `TeamProfileError` otherwise; on any rejection
|
|
144
|
-
* nothing was changed. A failed broker restart is reported in `broker`, not thrown.
|
|
145
|
-
*/
|
|
146
|
-
export declare function joinTeam(options: JoinTeamOptions): Promise<TeamJoinResult>;
|
|
147
|
-
/**
|
|
148
|
-
* Restore the individual layout: remove the global `storage` setting and the `sessions.storage` pin when they hold
|
|
149
|
-
* exactly what `joinTeam` writes, leave every other value in place, delete the removed selection's token file unless
|
|
150
|
-
* another setting references it, and restart the Intercom broker when `storage` was removed. Running it again
|
|
151
|
-
* changes nothing.
|
|
152
|
-
*/
|
|
153
|
-
export declare function leaveTeam(options?: LeaveTeamOptions): Promise<TeamLeaveResult>;
|
|
154
79
|
/**
|
|
155
80
|
* The layout in effect for this process and working directory (`individual`, `team`, `ci` or `custom`), from the
|
|
156
81
|
* storage each domain selects. Reads only; an invalid selection rejects with its `StorageConfigError`.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SHARED_STORAGE_JOIN_HINT, StorageConfigError, StoragePrefixError, TeamProfileConfigError, } from "./errors.js";
|
|
2
|
+
import { StorageConfigError, StoragePrefixError, TeamProfileConfigError, } from "./errors.js";
|
|
3
|
+
import { isLibsqlUrl, LIBSQL_REMOVED_HINT, REMOVED_LIBSQL_ADAPTER } from "./libsql-removed.js";
|
|
5
4
|
import { validateStoragePrefix } from "./prefix.js";
|
|
6
5
|
/** What every serialization of an in-memory secret shows instead of the secret. */
|
|
7
6
|
export const REDACTED_SECRET = "[redacted]";
|
|
@@ -81,6 +80,8 @@ function selectStorageAt(value, source, field, defaultPath) {
|
|
|
81
80
|
if (value.adapter !== undefined) {
|
|
82
81
|
if (typeof value.adapter !== "string" || value.adapter.length === 0)
|
|
83
82
|
return invalid("invalid-adapter");
|
|
83
|
+
if (value.adapter === REMOVED_LIBSQL_ADAPTER)
|
|
84
|
+
throw new StorageConfigError(source, field, "libsql-removed", LIBSQL_REMOVED_HINT);
|
|
84
85
|
if ("path" in value || "memory" in value)
|
|
85
86
|
return invalid("multiple-selection-forms");
|
|
86
87
|
if (value.options !== undefined) {
|
|
@@ -142,67 +143,18 @@ export function* selectStorageSteps(value, source, field, defaultPath) {
|
|
|
142
143
|
const selection = selectStorageAt(value, source, field, PENDING_DEFAULT_PATH);
|
|
143
144
|
return takesDefaultPath(value, selection) ? { ...selection, path: yield* defaultPath() } : selection;
|
|
144
145
|
}
|
|
145
|
-
/**
|
|
146
|
-
export const LIBSQL_ADAPTER_PACKAGE = "@bastani/atomic-storage-libsql";
|
|
147
|
-
/** Filename prefix for private token files created by `atomic storage join` and `atomic team join` in the agent directory. */
|
|
146
|
+
/** A token file `atomic storage join` created in the agent directory has this filename prefix. */
|
|
148
147
|
export const STORAGE_TOKEN_FILE = "storage-token";
|
|
149
|
-
/** The `sessions.storage` value
|
|
148
|
+
/** The `sessions.storage` value that pins sessions to the local default store, named explicitly. */
|
|
150
149
|
export const LOCAL_SESSIONS_STORAGE = { path: "workflows/journal.sqlite" };
|
|
151
|
-
export const TEAM_PROFILE_ENV = "ATOMIC_PROFILE";
|
|
152
|
-
export const TEAM_URL_ENV = "ATOMIC_TEAM_URL";
|
|
153
|
-
export const TEAM_TOKEN_ENV = "ATOMIC_TEAM_TOKEN";
|
|
154
|
-
export const TEAM_TOKEN_FILE_ENV = "ATOMIC_TEAM_TOKEN_FILE";
|
|
155
|
-
export const TEAM_PREFIX_ENV = "ATOMIC_TEAM_PREFIX";
|
|
156
|
-
/** The variables `ATOMIC_PROFILE=ci` reads; setting any of them without the profile is an error. */
|
|
157
|
-
export const TEAM_VARIABLES = [TEAM_URL_ENV, TEAM_TOKEN_ENV, TEAM_TOKEN_FILE_ENV, TEAM_PREFIX_ENV];
|
|
158
150
|
const FIELDS = {
|
|
159
|
-
sdk: {
|
|
160
|
-
cli: {
|
|
161
|
-
env: {
|
|
162
|
-
profile: TEAM_PROFILE_ENV,
|
|
163
|
-
url: TEAM_URL_ENV,
|
|
164
|
-
token: TEAM_TOKEN_ENV,
|
|
165
|
-
tokenFile: TEAM_TOKEN_FILE_ENV,
|
|
166
|
-
prefix: TEAM_PREFIX_ENV,
|
|
167
|
-
},
|
|
151
|
+
sdk: { url: "url", token: "token", tokenFile: "tokenFile", prefix: "prefix" },
|
|
152
|
+
cli: { url: "<url>", token: "--token-file", tokenFile: "--token-file", prefix: "--prefix" },
|
|
153
|
+
env: { url: "url", token: "token", tokenFile: "tokenFile", prefix: "prefix" },
|
|
168
154
|
};
|
|
169
155
|
function invalid(code, source, field, hint, extra = {}) {
|
|
170
156
|
return new TeamProfileConfigError(code, { source, field, hint, ...extra });
|
|
171
157
|
}
|
|
172
|
-
/** Whether a database URL holds the token itself: userinfo, or the `authToken` query parameter libSQL URLs accept. */
|
|
173
|
-
function carriesCredential(url) {
|
|
174
|
-
if (!URL.canParse(url))
|
|
175
|
-
return false;
|
|
176
|
-
const { username, password, searchParams } = new URL(url);
|
|
177
|
-
return username !== "" || password !== "" || searchParams.has("authToken");
|
|
178
|
-
}
|
|
179
|
-
/** Whether a team database URL needs no token: a local `file:` database. */
|
|
180
|
-
export function isFileUrl(url) {
|
|
181
|
-
return url.startsWith("file:");
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Check a team database URL: a supported scheme, an absolute `file:` URL, and no credential in it. `postgres` only
|
|
185
|
-
* changes the unsupported-URL hint, for the commands that also take a `postgres://` URL through
|
|
186
|
-
* {@link checkSharedDatabaseArguments}.
|
|
187
|
-
*/
|
|
188
|
-
export function checkTeamUrl(url, source, options = {}) {
|
|
189
|
-
const field = FIELDS[source].url;
|
|
190
|
-
if (url === undefined || url.length === 0) {
|
|
191
|
-
throw invalid("missing-url", source, field, "Pass the team database URL, for example libsql://<db>.turso.io.");
|
|
192
|
-
}
|
|
193
|
-
if (!/^(libsql|https?|wss?):\/\/[^/]/.test(url) && !isFileUrl(url)) {
|
|
194
|
-
throw invalid("unsupported-url", source, field, options.postgres === true
|
|
195
|
-
? "Use a postgres://, postgresql://, libsql://, https://, wss://, or absolute file: URL."
|
|
196
|
-
: "Use a libsql://, https://, wss://, or absolute file: URL.");
|
|
197
|
-
}
|
|
198
|
-
if (isFileUrl(url) && !url.startsWith("file:/")) {
|
|
199
|
-
throw invalid("relative-file-url", source, field, "Use an absolute file: URL (for example file:///path/to/shared.sqlite), so every working directory uses the same database.");
|
|
200
|
-
}
|
|
201
|
-
if (carriesCredential(url)) {
|
|
202
|
-
throw invalid("credential-in-url", source, field, `The URL carries a credential (user name, password, or authToken). Remove it and pass the token with ${FIELDS[source].token === FIELDS[source].tokenFile ? FIELDS[source].tokenFile : `${FIELDS[source].token} or ${FIELDS[source].tokenFile}`} instead, so it never reaches settings or output.`);
|
|
203
|
-
}
|
|
204
|
-
return url;
|
|
205
|
-
}
|
|
206
158
|
/** The first-party PostgreSQL adapter package that `atomic storage join postgres://…` and `--db postgres://…` select. */
|
|
207
159
|
export const POSTGRES_ADAPTER_PACKAGE = "@bastani/atomic-storage-postgres";
|
|
208
160
|
/** What `--auth` takes, and the `auth` option each value selects; the option values themselves are accepted too. */
|
|
@@ -233,9 +185,9 @@ function checkPostgresUrl(url, source) {
|
|
|
233
185
|
return url;
|
|
234
186
|
}
|
|
235
187
|
/**
|
|
236
|
-
* Check the database URL and credential flags of `atomic storage join` and `--db
|
|
237
|
-
* `postgresql://` URL takes exactly one of `--password-file`, `--token-file` and `--auth
|
|
238
|
-
*
|
|
188
|
+
* Check the database URL and credential flags of `atomic storage join` and `--db`: a `postgres://` or
|
|
189
|
+
* `postgresql://` URL that takes exactly one of `--password-file`, `--token-file` and `--auth`. A URL of the removed
|
|
190
|
+
* libSQL adapter is refused with how to move off it.
|
|
239
191
|
*/
|
|
240
192
|
export function checkSharedDatabaseArguments(input) {
|
|
241
193
|
const { url, tokenFile, passwordFile, auth } = input;
|
|
@@ -257,14 +209,9 @@ export function checkSharedDatabaseArguments(input) {
|
|
|
257
209
|
throw invalid("unsupported-auth", "cli", "--auth", "Use --auth azure, --auth aws or --auth gcp.");
|
|
258
210
|
return { url, auth: mode };
|
|
259
211
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
])
|
|
264
|
-
if (value !== undefined)
|
|
265
|
-
throw invalid("unsupported-option", "cli", flag, `Only postgres:// and postgresql:// URLs take ${flag}; pass a libSQL database token with --token-file.`);
|
|
266
|
-
checkTeamUrl(url, "cli", { postgres: true });
|
|
267
|
-
return tokenFile === undefined ? { url } : { url, tokenFile };
|
|
212
|
+
throw invalid(isLibsqlUrl(url) ? "libsql-removed" : "unsupported-url", "cli", FIELDS.cli.url, isLibsqlUrl(url)
|
|
213
|
+
? `Atomic opens shared databases on PostgreSQL only: use a postgres:// or postgresql:// URL. ${LIBSQL_REMOVED_HINT}`
|
|
214
|
+
: "Use a postgres:// or postgresql:// URL, for example postgres://atomic@db.example.com:5432/atomic.");
|
|
268
215
|
}
|
|
269
216
|
/** Check a table prefix with the same rules as every storage prefix. */
|
|
270
217
|
export function checkTeamPrefix(prefix, source) {
|
|
@@ -296,16 +243,6 @@ export function readTeamTokenFile(path, source, field = FIELDS[source].tokenFile
|
|
|
296
243
|
}
|
|
297
244
|
return teamTokenOf(text, path, source, field, read);
|
|
298
245
|
}
|
|
299
|
-
export async function readTeamTokenFileAsync(path, source, field = FIELDS[source].tokenFile, read = "trimmed") {
|
|
300
|
-
let text;
|
|
301
|
-
try {
|
|
302
|
-
text = await readFile(path, "utf8");
|
|
303
|
-
}
|
|
304
|
-
catch (error) {
|
|
305
|
-
throw unreadableTokenFile(path, source, field, error);
|
|
306
|
-
}
|
|
307
|
-
return teamTokenOf(text, path, source, field, read);
|
|
308
|
-
}
|
|
309
246
|
function unreadableTokenFile(path, source, field, cause) {
|
|
310
247
|
return invalid("unreadable-token-file", source, field, `Check that ${path} exists and is readable.`, {
|
|
311
248
|
path,
|
|
@@ -324,168 +261,16 @@ function teamTokenOf(text, path, source, field, read) {
|
|
|
324
261
|
if (token.length === 0) {
|
|
325
262
|
throw invalid("empty-token", source, field, field === "--password-file"
|
|
326
263
|
? `The password file ${path} is empty: write the database password into it.`
|
|
327
|
-
: `The token file ${path} is empty: write the token into it
|
|
264
|
+
: `The token file ${path} is empty: write the database password or token into it.`, { path });
|
|
328
265
|
}
|
|
329
266
|
return token;
|
|
330
267
|
}
|
|
331
|
-
/** A missing token for a URL that needs one. */
|
|
332
|
-
export function missingTeamToken(url, source) {
|
|
333
|
-
const scheme = url.split(":")[0];
|
|
334
|
-
return invalid("missing-token", source, FIELDS[source].token, source === "cli"
|
|
335
|
-
? `--token-file is required for ${scheme}: URLs; only absolute file: URLs need no token.`
|
|
336
|
-
: `Pass the database token for ${scheme}: URLs; only absolute file: URLs need no token.`);
|
|
337
|
-
}
|
|
338
268
|
/** More than one token source. */
|
|
339
269
|
export function conflictingTeamToken(source, fields) {
|
|
340
270
|
return invalid("conflicting-token", source, fields.join(", "), `Pass only one of ${fields.join(", ")}.`);
|
|
341
271
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return invalid("empty-token", source, field, `${field} is empty: pass the database token.`);
|
|
345
|
-
}
|
|
346
|
-
function checkProfile(profile, source) {
|
|
347
|
-
if (profile === "ci")
|
|
348
|
-
return profile;
|
|
349
|
-
throw invalid("unknown-profile", source, FIELDS[source].profile, source === "env" ? `Set ${TEAM_PROFILE_ENV} to ci, or unset it.` : 'Pass profile: "ci".');
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* The CI profile as a team database selection, without reading or writing settings: sessions and Intercom can both
|
|
353
|
-
* use it. A literal `token` becomes an in-memory `{ value }` secret that serializes as
|
|
354
|
-
* `[redacted]` and that only SDK callers can pass; `tokenFile` (absolute path) and `tokenEnv` are references read
|
|
355
|
-
* when the store opens. Inputs are checked first; nothing else happens.
|
|
356
|
-
*/
|
|
357
|
-
export function teamProfileSelection(options) {
|
|
358
|
-
checkProfile(options.profile, "sdk");
|
|
359
|
-
const url = checkTeamUrl(options.url, "sdk");
|
|
360
|
-
const sources = ["token", "tokenFile", "tokenEnv"].filter((name) => options[name] !== undefined);
|
|
361
|
-
if (sources.length > 1)
|
|
362
|
-
throw conflictingTeamToken("sdk", ["token", "tokenFile", "tokenEnv"]);
|
|
363
|
-
const prefix = checkTeamPrefix(options.prefix, "sdk");
|
|
364
|
-
let authToken;
|
|
365
|
-
if (options.token !== undefined) {
|
|
366
|
-
if (options.token.trim().length === 0)
|
|
367
|
-
throw emptyTeamToken("sdk");
|
|
368
|
-
authToken = inMemorySecret(options.token);
|
|
369
|
-
}
|
|
370
|
-
else if (options.tokenFile !== undefined) {
|
|
371
|
-
const path = resolve(options.tokenFile);
|
|
372
|
-
readTeamTokenFile(path, "sdk");
|
|
373
|
-
authToken = { file: path };
|
|
374
|
-
}
|
|
375
|
-
else if (options.tokenEnv !== undefined) {
|
|
376
|
-
if (options.tokenEnv.length === 0)
|
|
377
|
-
throw emptyTeamToken("sdk", "tokenEnv");
|
|
378
|
-
if (!process.env[options.tokenEnv]) {
|
|
379
|
-
throw invalid("missing-token", "sdk", "tokenEnv", `Set ${options.tokenEnv} to the database token: the selection reads the token from it when the store opens.`);
|
|
380
|
-
}
|
|
381
|
-
authToken = { env: options.tokenEnv };
|
|
382
|
-
}
|
|
383
|
-
else if (!isFileUrl(url)) {
|
|
384
|
-
throw missingTeamToken(url, "sdk");
|
|
385
|
-
}
|
|
386
|
-
return {
|
|
387
|
-
adapter: LIBSQL_ADAPTER_PACKAGE,
|
|
388
|
-
options: { url },
|
|
389
|
-
...(authToken === undefined ? {} : { secrets: { authToken } }),
|
|
390
|
-
...(prefix === undefined ? {} : { prefix }),
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function environmentValue(env, name) {
|
|
394
|
-
const value = env[name];
|
|
395
|
-
return value === undefined || value.length === 0 ? undefined : value;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* The selection `ATOMIC_PROFILE=ci` makes from `ATOMIC_TEAM_URL` and `ATOMIC_TEAM_TOKEN` or `ATOMIC_TEAM_TOKEN_FILE`
|
|
399
|
-
* (plus an optional `ATOMIC_TEAM_PREFIX`), or `undefined` without a profile. The token is referenced, never copied:
|
|
400
|
-
* `{ env: "ATOMIC_TEAM_TOKEN" }` or the token file's absolute path, so the selection can be handed to child processes.
|
|
401
|
-
* Invalid input throws {@link TeamProfileConfigError} with `source: "env"`: a team variable without the profile, or
|
|
402
|
-
* the profile without its URL or token, is `incomplete-profile` naming every missing variable at once.
|
|
403
|
-
*/
|
|
404
|
-
export function environmentTeamProfile(env = process.env) {
|
|
405
|
-
const parsed = parseEnvironmentTeamProfile(env);
|
|
406
|
-
if (parsed?.tokenFile !== undefined)
|
|
407
|
-
readTeamTokenFile(parsed.tokenFile, "env");
|
|
408
|
-
return parsed?.selection;
|
|
409
|
-
}
|
|
410
|
-
export function environmentTeamProfileSelection(env = process.env) {
|
|
411
|
-
return parseEnvironmentTeamProfile(env)?.selection;
|
|
412
|
-
}
|
|
413
|
-
export async function environmentTeamProfileAsync(env = process.env) {
|
|
414
|
-
const parsed = parseEnvironmentTeamProfile(env);
|
|
415
|
-
if (parsed?.tokenFile !== undefined)
|
|
416
|
-
await readTeamTokenFileAsync(parsed.tokenFile, "env");
|
|
417
|
-
return parsed?.selection;
|
|
418
|
-
}
|
|
419
|
-
function parseEnvironmentTeamProfile(env) {
|
|
420
|
-
const profile = environmentValue(env, TEAM_PROFILE_ENV);
|
|
421
|
-
const url = environmentValue(env, TEAM_URL_ENV);
|
|
422
|
-
const token = environmentValue(env, TEAM_TOKEN_ENV);
|
|
423
|
-
const tokenFile = environmentValue(env, TEAM_TOKEN_FILE_ENV);
|
|
424
|
-
const prefix = environmentValue(env, TEAM_PREFIX_ENV);
|
|
425
|
-
if (profile === undefined) {
|
|
426
|
-
const set = TEAM_VARIABLES.filter((name) => environmentValue(env, name) !== undefined);
|
|
427
|
-
if (set.length === 0)
|
|
428
|
-
return undefined;
|
|
429
|
-
throw invalid("incomplete-profile", "env", TEAM_PROFILE_ENV, `${set.join(", ")} ${set.length === 1 ? "is" : "are"} set but ${TEAM_PROFILE_ENV} is not: set ${TEAM_PROFILE_ENV}=ci to use the team database in this process, or unset ${set.length === 1 ? "it" : "them"} (to join this machine to the team database instead, run ${SHARED_STORAGE_JOIN_HINT}).`, { missing: [TEAM_PROFILE_ENV] });
|
|
430
|
-
}
|
|
431
|
-
checkProfile(profile, "env");
|
|
432
|
-
const missing = [
|
|
433
|
-
...(url === undefined ? [TEAM_URL_ENV] : []),
|
|
434
|
-
...(token === undefined && tokenFile === undefined && (url === undefined || !isFileUrl(url))
|
|
435
|
-
? [`${TEAM_TOKEN_ENV} or ${TEAM_TOKEN_FILE_ENV}`]
|
|
436
|
-
: []),
|
|
437
|
-
];
|
|
438
|
-
if (missing.length > 0) {
|
|
439
|
-
throw invalid("incomplete-profile", "env", missing.join(", "), `${TEAM_PROFILE_ENV}=ci needs the team database URL and its token: set ${missing.join(" and ")} (only an absolute file: URL needs no token).`, { missing });
|
|
440
|
-
}
|
|
441
|
-
const checkedUrl = checkTeamUrl(url, "env");
|
|
442
|
-
if (token !== undefined && tokenFile !== undefined) {
|
|
443
|
-
throw conflictingTeamToken("env", [TEAM_TOKEN_ENV, TEAM_TOKEN_FILE_ENV]);
|
|
444
|
-
}
|
|
445
|
-
const checkedPrefix = checkTeamPrefix(prefix, "env");
|
|
446
|
-
let secrets;
|
|
447
|
-
let checkedTokenFile;
|
|
448
|
-
if (token !== undefined) {
|
|
449
|
-
if (token.trim().length === 0)
|
|
450
|
-
throw emptyTeamToken("env");
|
|
451
|
-
secrets = { authToken: { env: TEAM_TOKEN_ENV } };
|
|
452
|
-
}
|
|
453
|
-
else if (tokenFile !== undefined) {
|
|
454
|
-
if (!isAbsolute(tokenFile)) {
|
|
455
|
-
throw invalid("relative-token-file", "env", TEAM_TOKEN_FILE_ENV, `Set ${TEAM_TOKEN_FILE_ENV} to an absolute path, for example under $RUNNER_TEMP: the processes Atomic starts would resolve a relative path against their own working directory.`);
|
|
456
|
-
}
|
|
457
|
-
checkedTokenFile = resolve(tokenFile);
|
|
458
|
-
secrets = { authToken: { file: checkedTokenFile } };
|
|
459
|
-
}
|
|
460
|
-
const selection = {
|
|
461
|
-
adapter: LIBSQL_ADAPTER_PACKAGE,
|
|
462
|
-
options: { url: checkedUrl },
|
|
463
|
-
...(secrets === undefined ? {} : { secrets }),
|
|
464
|
-
...(checkedPrefix === undefined ? {} : { prefix: checkedPrefix }),
|
|
465
|
-
};
|
|
466
|
-
return checkedTokenFile === undefined ? { selection } : { selection, tokenFile: checkedTokenFile };
|
|
467
|
-
}
|
|
468
|
-
// The team setup SDK loads the settings and storage machinery on first use, so importing the storage module stays
|
|
469
|
-
// cheap for storage adapters and hosts that never set up a team.
|
|
470
|
-
/**
|
|
471
|
-
* Use a team database for Intercom while sessions stay private: checks every input and the
|
|
472
|
-
* connection first, then sets the global `storage` setting to the team database and `sessions.storage` to the local
|
|
473
|
-
* default store in one settings write, and restarts the Intercom broker so it routes through the team database.
|
|
474
|
-
* Rejects with `TeamProfileConfigError` for an invalid input and `TeamProfileError` otherwise; on any rejection
|
|
475
|
-
* nothing was changed. A failed broker restart is reported in `broker`, not thrown.
|
|
476
|
-
*/
|
|
477
|
-
export async function joinTeam(options) {
|
|
478
|
-
return (await import("./team.code.js").catch((error) => __atomicOnDemandFailed(error, "session storage"))).joinTeam(options);
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Restore the individual layout: remove the global `storage` setting and the `sessions.storage` pin when they hold
|
|
482
|
-
* exactly what `joinTeam` writes, leave every other value in place, delete the removed selection's token file unless
|
|
483
|
-
* another setting references it, and restart the Intercom broker when `storage` was removed. Running it again
|
|
484
|
-
* changes nothing.
|
|
485
|
-
*/
|
|
486
|
-
export async function leaveTeam(options = {}) {
|
|
487
|
-
return (await import("./team.code.js").catch((error) => __atomicOnDemandFailed(error, "session storage"))).leaveTeam(options);
|
|
488
|
-
}
|
|
272
|
+
// `getTeamProfile` loads the settings and storage machinery on first use, so importing the storage module stays
|
|
273
|
+
// cheap for storage adapters and hosts that never read the layout.
|
|
489
274
|
/**
|
|
490
275
|
* The layout in effect for this process and working directory (`individual`, `team`, `ci` or `custom`), from the
|
|
491
276
|
* storage each domain selects. Reads only; an invalid selection rejects with its `StorageConfigError`.
|
|
@@ -500,7 +285,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
500
285
|
return (async () => {
|
|
501
286
|
const root = new URL("../../", import.meta.url);
|
|
502
287
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
503
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
288
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
504
289
|
let release = releases.get(key);
|
|
505
290
|
if (release === undefined) {
|
|
506
291
|
const current = (async () => {
|
|
@@ -528,7 +313,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
528
313
|
} catch {
|
|
529
314
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
530
315
|
}
|
|
531
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.
|
|
316
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.3" ? installed : running !== undefined && running.version !== "0.10.11-alpha.3" ? "0.10.11-alpha.3" : undefined;
|
|
532
317
|
if (updatedTo === undefined) throw error;
|
|
533
318
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
534
319
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|