@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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __name } from "./rolldown-runtime-BGM3D5V3.js";
|
|
2
|
-
import { APP_NAME, BUILTIN_PACKAGE_DIR_NAMES, CONFIG_DIR_NAME, ENV_CLEAR_ON_SHRINK, ENV_HARDWARE_CURSOR,
|
|
3
|
-
import { BLUEPRINT_CONTEXT_TYPE, BlueprintBuildFailedError, BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError, BlueprintUsesUnsupportedError, CACHE_WARMING_MODES, COMMAND_FOREGROUND_BUDGET_MS, CompactionConfigError, DEFAULT_BUILTIN_SELECTION_EXTRA_TOOLS, DEFAULT_MAX_BYTES, EditInputError, EditMatchError, EditTargetError, FileToolAbortedError, HostListenerFailures, LONG_LIVED_COMMANDS, Minimatch, RESTART_CANCELLED_MESSAGE, STALE_EXTENSION_CONTEXT_MESSAGE, ShellTimeoutError, SqliteSelectorConnection, SubscriptionChildUnavailableError, SubscriptionClosedError, SubscriptionConfigError, TASK_MARKS, TaskMessageError, TaskMessageTimeoutError, WriteSelectorError, activeToolExecutionStarts, allToolNames, announceBlueprintBuildWaiting, applyBashSessionEnvironment, asyncScope, attachJsonlLineReader, attachLineReader, bindSavedTaskOrigins, blueprintBuildShared, blueprintDigest, canonicalEventBusFor, chatPosition, clearAssignmentIfClosed, clearLockHolder, clearLockHolderAsync, convertBufferWithMarkit, convertFileWithMarkit, createGitEnvironment, defaultToolNamesFor, defineTool, detectSupportedImageMimeTypeFromFile, displayTodoId, entryLines, expandSearchUrl, experimentalToolSamplingProperty, filterSearchOutputByLineRange, formatReadLineRange as formatReadLineRange$1, formatSelectedLines, formatSize, formatTimeoutSeconds as formatTimeoutSeconds$1, formatTodoId, frozenClocks, getManifestFromPackageJson, getTextOutput, getTodoPath, getTodoStatus, getTodoTitle, getTodosDir, getTodosDirLabel, getToolListError, handOverBuildTimings, holdDeprecationWarnings, holdToolsUntilBuilt, hostInputError, invalidArgText, invalidateNativeSearchCache, isBlueprintError, isGitProvisionError, isGitUnavailableError, isPathInside, isReadResourceSelector, isReadableUrlPath, isTodoClosed, isToolModifier, keptTaskHint, linkPath, literalPathLike, loadNativeSearchBinding, mergeReadRanges, nativeModuleProblem, normalizePathLikeInput, normalizeTodoId, noteSavedSeq,
|
|
4
|
-
import { EMPTY_OUTPUT_TEXT, HistorySearchPositions, MAX_INDEXED_ENTRY_CHARS, ResumeTimingsRecorder, SEARCH_PART_CHARS, SessionStorageSelectionSchema, TaskElapsedClocks, TaskToolError, WorkspaceDriftError, WorkspaceRestoreError, WorkspaceSnapshotError, bindTaskClock, bindTaskClockSource, buildDirectoryTree, buildDirectoryTreeFromOperations, cancelReceiptSentence, captureRegistrationInvocation, compareCreated, compareFrozen, conflictEntries, convertToLlm, createBranchSummaryMessage, createCustomMessage, diffLines, ensureTool, execCommand, findWorkspaceError, formatResumeTimings, invocationExtension, invocationRuntime, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspaceSnapshotError, lifecycleScopeForOwner, normalizeAzureSettings, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseInteractiveEngineMessage, parseSkillUri, presentTaskError, prewarmModelApi, readConflictUrl, readLocalFileChunks, recordBlueprintStep, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, renderTodoCall, renderTodoResult, resolveInstalledGit, resolveInvocationRuntime, selectReadLinesFromChunks, selectReadLinesFromList, serializeInteractiveEngineFrame, serializeTodoForAgent, serializeTodoListForAgent, sessionPosition, settingsWriteOwner, splitSearchTextParts, startupSourceId, taskClockOf, taskClockRunning, timeCheckoutRestore, unpackIds, unreadablePathError, validateEventSource, validateSubscriptionAdmission, waitResultTail, waitStatus, withoutSearchPosition, writeRenderers } from "./startup-0-1-
|
|
2
|
+
import { APP_NAME, BUILTIN_PACKAGE_DIR_NAMES, CONFIG_DIR_NAME, ENV_CLEAR_ON_SHRINK, ENV_HARDWARE_CURSOR, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, addHostStorageAdapter, canonicalizePath as canonicalizePath$1, createChildProcessEnvironment, flushPersistentCompileCache, formatPathRelativeToCwdOrAbsolute, getAgentConfigPaths, getAgentDir, getAgentDirs, getBinDir, getBlueprintActionsDir, getCwdRelativePath, getEnvValue, getGlobalBlueprintPath, getHomeDir, getProjectBlueprintPath, getProjectConfigPaths, getReadmePath, hostStorageAdapter, isBunBinary, isBunRuntime, isChildProcessExitStatusUnknownError, isLocalPath, markLifecycleTiming, normalizePath, removeOwnedInteractiveEngineBootstrapAsync, resolvePath, shortenHomePath, splitBom, stripBom, waitForChildProcess, writeInteractiveEngineBootstrapAsync } from "./p0-cli-BB45ZQY6.js";
|
|
3
|
+
import { BLUEPRINT_CONTEXT_TYPE, BlueprintBuildFailedError, BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError, BlueprintUsesUnsupportedError, CACHE_WARMING_MODES, COMMAND_FOREGROUND_BUDGET_MS, CompactionConfigError, DEFAULT_BUILTIN_SELECTION_EXTRA_TOOLS, DEFAULT_MAX_BYTES, EditInputError, EditMatchError, EditTargetError, FileToolAbortedError, HostListenerFailures, LONG_LIVED_COMMANDS, Minimatch, RESTART_CANCELLED_MESSAGE, STALE_EXTENSION_CONTEXT_MESSAGE, ShellTimeoutError, SqliteSelectorConnection, SubscriptionChildUnavailableError, SubscriptionClosedError, SubscriptionConfigError, TASK_MARKS, TaskMessageError, TaskMessageTimeoutError, WriteSelectorError, activeToolExecutionStarts, allToolNames, announceBlueprintBuildWaiting, applyBashSessionEnvironment, asyncScope, attachJsonlLineReader, attachLineReader, bindSavedTaskOrigins, blueprintBuildShared, blueprintDigest, canonicalEventBusFor, chatPosition, clearAssignmentIfClosed, clearLockHolder, clearLockHolderAsync, convertBufferWithMarkit, convertFileWithMarkit, createGitEnvironment, defaultToolNamesFor, defineTool, detectSupportedImageMimeTypeFromFile, displayTodoId, entryLines, expandSearchUrl, experimentalToolSamplingProperty, filterSearchOutputByLineRange, formatReadLineRange as formatReadLineRange$1, formatSelectedLines, formatSize, formatTimeoutSeconds as formatTimeoutSeconds$1, formatTodoId, frozenClocks, getManifestFromPackageJson, getTextOutput, getTodoPath, getTodoStatus, getTodoTitle, getTodosDir, getTodosDirLabel, getToolListError, handOverBuildTimings, holdDeprecationWarnings, holdToolsUntilBuilt, hostInputError, invalidArgText, invalidateNativeSearchCache, isBlueprintError, isGitProvisionError, isGitUnavailableError, isPathInside, isReadResourceSelector, isReadableUrlPath, isTodoClosed, isToolModifier, keptTaskHint, linkPath, literalPathLike, loadNativeSearchBinding, mergeReadRanges, nativeModuleProblem, normalizePathLikeInput, normalizeTodoId, noteSavedSeq, originalHistoryNote, prepareLockTakeover, projectTrustHandlerRegistered, projectTrustedBeforeExtensions, readLedger, readTaskOutputTail, receiveChatReceipt, recordLockHolder, recordLockHolderAsync, registerCanonicalEventBus, releaseDeprecationWarnings, renderBlueprintContext, renderToolPath, replaceTabs, reportContained, repositoryKey, resolvePhysicalPathAsync, rootKey, savedReadLines, scopedBackgroundTasks, searchPosition, selectExactReadRanges, selectReadRanges, serializeJsonLine, settingsFileNoticeKey, settingsInternals, shortenPath, sleep, sliceHead, snapshotBashSessionEnvironment, sortTodos, spawnHostProcess, splitLineRangeSelector, splitPathLikeGlob, splitReadLineSelector, splitTodosByAssignment, startShellDeadline, startToolTimer, str, stringEntries, takeOverDeadHolder, takeOverDeadHolderAsync, takeQueuedDeliveryChange, taskResumer, timestamp, toolTimerText, transcriptHeaderLines, truncateHead, truncateLine, updateLedger, validateTodoId, warnDeprecation, withFileMutationQueue, withResolvingFileMutationQueue, workspaceKey } from "./startup-0-0-EZUKEP4Q.js";
|
|
4
|
+
import { EMPTY_OUTPUT_TEXT, HistorySearchPositions, MAX_INDEXED_ENTRY_CHARS, ResumeTimingsRecorder, SEARCH_PART_CHARS, SessionStorageSelectionSchema, TaskElapsedClocks, TaskToolError, WorkspaceDriftError, WorkspaceRestoreError, WorkspaceSnapshotError, bindTaskClock, bindTaskClockSource, buildDirectoryTree, buildDirectoryTreeFromOperations, cancelReceiptSentence, captureRegistrationInvocation, compareCreated, compareFrozen, conflictEntries, convertToLlm, createBranchSummaryMessage, createCustomMessage, diffLines, ensureTool, execCommand, findWorkspaceError, formatResumeTimings, invocationExtension, invocationRuntime, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspaceSnapshotError, lifecycleScopeForOwner, normalizeAzureSettings, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseInteractiveEngineMessage, parseSkillUri, presentTaskError, prewarmModelApi, readConflictUrl, readLocalFileChunks, recordBlueprintStep, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, renderTodoCall, renderTodoResult, resolveInstalledGit, resolveInvocationRuntime, selectReadLinesFromChunks, selectReadLinesFromList, serializeInteractiveEngineFrame, serializeTodoForAgent, serializeTodoListForAgent, sessionPosition, settingsWriteOwner, splitSearchTextParts, startupSourceId, taskClockOf, taskClockRunning, timeCheckoutRestore, unpackIds, unreadablePathError, validateEventSource, validateSubscriptionAdmission, waitResultTail, waitStatus, withoutSearchPosition, writeRenderers } from "./startup-0-1-RTOHJFDJ.js";
|
|
5
5
|
import { CodeHighlighter, FS_WATCH_RETRY_DELAY_MS, applyEarlyInputChunk, closeWatcher, getLanguageFromPath, graphemeAt, highlightCode, isSafeFsWatchPathError, keepStartupDialogDraft, migrateKeybindingsConfig, parenthesizedKeyHint, recordTimingLines, sanitizeTerminalText, singleLineDisplayText, slashCommandHint, terminalDisplayText, theme, watchWithErrorHandlerAsync, withEarlyInputHeldForStartupDialog } from "./p2-shell-main-B2WIALFD.js";
|
|
6
6
|
import { parseJsonFileContent } from "./p1-shared-RG5I5LJ6.js";
|
|
7
|
-
import { ProjectTrustStore, failureDebugFields,
|
|
8
|
-
import { FILE_HEADERS_ONLY, InteractiveEngineMonitor, ModelConfig, RpcTerminalDrain,
|
|
7
|
+
import { ProjectTrustStore, failureDebugFields, hasProjectTrustInputsAsync, inLockTurn, matchesOnSameLineCI, redactUrlCredentials, releaseLock, releaseLockSync, renameReplacing, renameReplacingAsync, renameWithRetry, reportDebugAsync, waitForLock, waitForLockSync } from "./p1b-elig-TVB5CBLL.js";
|
|
8
|
+
import { FILE_HEADERS_ONLY, InteractiveEngineMonitor, ModelConfig, RpcTerminalDrain, TodoParams, addShellOutputPreview, assertSessionOpen, bindTaskChatPage, captureTaskChatFile, chatPageRequest, createTwoFilesPatch, drainSessionWork, dropWrongTypedSettings, estimateTokens, formatKillCall, formatPatch, formatTruncationNotice, formatWorkingElapsed, getNativeMcpToolIdentity, getPowerShellConfigAsync, getShellConfigAsync, getShellEnvAsync, hasCallingSessionWork, invalidSettingMessage, isPowerShellAvailable, isResumePreconditionError, isTodoOperationError, killChildProcessTree, loadTaskOwnTranscriptEntries, markNativeMcpToolDefinition, rebuildKillResult, rebuildShellWaitResult, selectProcessStorageSteps, sessionGenerationClosing, sessionLifetime, spawnShellProcess, structuredPatch, taskChatPage, taskExtensionStatuses, taskOwnTranscriptEntries, taskTranscriptSource, trackDetachedChildPid, trackDetachedChildProcess, trackSessionWork, untrackDetachedChildPid, watchTaskExtensionStatuses, wrapToolDefinition } from "./startup-0-2-5QHPCEON.js";
|
|
9
9
|
import { appendToLog, applyContextEdit, assertExtensionAction, buildProcessStarting, extensionWorkOpen, findSessionOpenHolder, getBaseDirsForScope, getOwnerTaskSession, getOwnerTaskStore, inExtensionCleanup, isResumeFailure, isRetiredExtensionCleanup, isTaskTurnInterrupted, loadArchiveSnapshot, logTail, migrateAzureProvider, migrateAzureProviderAsync, onExtensionSessionQuit, openStepLog, processImage, resolvePathFromBase, resolveWorktreeSnapshotSettings, runLoggedProcess, sessionEntryToContextMessages, sha256Hex, startElapsedMs, stripLeadingCdCommandAsync, taskResumedTurns, trackExtensionWork, watchOwnerTaskStoreBinding, withTodoLock } from "./startup-0-3-4ZYBYQNM.js";
|
|
10
10
|
import { DecisionConfigError, SessionHistoryNotLoadedError, asAcceptedRequestFailure, isDecisionConfigError, markRpcTransportFailure, rpcTransportError } from "./settings-startup-HXQLSUWM.js";
|
|
11
11
|
import { JsonlSessionStore, LegacySessionStore, checkedCustomMessage, checkedCustomType, checkedLabel, getLastConversationMessageId, getLatestSessionSummary, historyPageGeneration, storeSnapshotIndex, transcriptCursorWithin } from "./startup-8-0-34CBHPZH.js";
|
|
@@ -19,19 +19,18 @@ import { chmodSync, constants, existsSync, lstatSync, mkdirSync, promises, readF
|
|
|
19
19
|
import nodePath, { dirname, isAbsolute, join, resolve, sep } from "path";
|
|
20
20
|
import { constants as constants$1, tmpdir } from "node:os";
|
|
21
21
|
import path, { basename as basename$1, delimiter as delimiter$1, dirname as dirname$1, extname, isAbsolute as isAbsolute$1, join as join$1, parse as parse$2, relative as relative$1, resolve as resolve$1, sep as sep$1, win32 as win32$1 } from "node:path";
|
|
22
|
-
import { fileURLToPath } from "node:url";
|
|
23
22
|
import { spawn } from "node:child_process";
|
|
24
23
|
import { execFile as execFile$1 } from "child_process";
|
|
25
24
|
import { createSessionCwdMatcherAsync } from "../utils/canonical-path.js";
|
|
26
25
|
import { pathExists, pathExists as pathExists$1 } from "../utils/path-exists.js";
|
|
27
|
-
import { accessSync as accessSync$1,
|
|
26
|
+
import { accessSync as accessSync$1, constants as constants$2, createReadStream, existsSync as existsSync$1, readFileSync as readFileSync$1, realpath as realpath$2, realpathSync as realpathSync$1, statSync as statSync$1, writeSync } from "node:fs";
|
|
28
27
|
import { Worker } from "node:worker_threads";
|
|
29
28
|
import { EVAL_WORKER_BUILTIN, evalWorkerExecArgv } from "../utils/worker-threads.js";
|
|
30
29
|
import { startupNodeOptions } from "@bastani/atomic-codemode/node-options";
|
|
31
30
|
import { isModelType, normalizeContext, normalizeProviderId, retryAssistantCall, uuidv7 } from "@bastani/atomic-ai";
|
|
32
31
|
import { Box, Container, Spacer, Text, getImageDimensions, truncateToWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
|
|
33
32
|
import chalk from "chalk";
|
|
34
|
-
import {
|
|
33
|
+
import { StorageConfigError, isStorageError } from "../core/storage/errors.js";
|
|
35
34
|
import { access as access$1, lstat as lstat$1, mkdir as mkdir$1, readFile as readFile$1, readdir as readdir$1, readlink as readlink$1, rename as rename$1, rm as rm$1, stat as stat$2, writeFile as writeFile$1 } from "fs/promises";
|
|
36
35
|
import crypto$1, { createHash, randomUUID } from "node:crypto";
|
|
37
36
|
import { inspect, isDeepStrictEqual, promisify, types } from "node:util";
|
|
@@ -40,15 +39,15 @@ import { completeSimple } from "@bastani/atomic-ai/compat";
|
|
|
40
39
|
import { randomUUID as randomUUID$1 } from "crypto";
|
|
41
40
|
import { createInterface } from "node:readline";
|
|
42
41
|
import { DEGRADED_RESTORE_RETENTION_DAYS, snapshotBlobHashes } from "../core/worktree-snapshot/blob-store.js";
|
|
43
|
-
import { StorageProvider
|
|
42
|
+
import { StorageProvider } from "../core/storage/provider.js";
|
|
44
43
|
import { setImmediate as setImmediate$1 } from "node:timers";
|
|
45
44
|
import { isProxy } from "node:util/types";
|
|
46
|
-
import {
|
|
45
|
+
import { defaultSessionDatabasePathAsync, defaultSessionDatabasePathSteps, defaultSharedStoragePathSteps, runStorageSteps, runStorageStepsSync, storagePathBaseDirSteps, storageSettingsSteps } from "../core/storage/file-identity.js";
|
|
47
46
|
import { Type as Type$1 } from "@bastani/atomic-ai/utils/typebox/index";
|
|
48
47
|
import { deflateRaw as deflateRaw$1, gunzip as gunzip$1, gzip as gzip$1, inflateRaw as inflateRaw$1 } from "node:zlib";
|
|
49
48
|
import { getAllBuiltinModels } from "@bastani/atomic-ai/providers/all";
|
|
50
49
|
import { Value } from "@bastani/atomic-ai/utils/typebox/value";
|
|
51
|
-
import {
|
|
50
|
+
import { selectStorageSteps } from "../core/storage/selection.js";
|
|
52
51
|
// dist/core/session-worktree-snapshots.js
|
|
53
52
|
/** Built-in tools that can change files: a turn that called one records a snapshot. */
|
|
54
53
|
const FILE_WRITING_TOOLS = /* @__PURE__ */ new Set([
|
|
@@ -7655,11 +7654,10 @@ function promptAnswerOptionsOf(item) {
|
|
|
7655
7654
|
...item.choices === void 0 ? {} : { choices: [...item.choices] }
|
|
7656
7655
|
};
|
|
7657
7656
|
}
|
|
7658
|
-
function sourceOf
|
|
7657
|
+
function sourceOf(session, id) {
|
|
7659
7658
|
if (typeof id !== "string" || id.length === 0 || id === "main" || id.startsWith(taskPrefix)) return void 0;
|
|
7660
7659
|
for (const source of hubOf(session)?.all() ?? []) for (const item of sourceItems(source)) if (item.id === id) return source;
|
|
7661
7660
|
}
|
|
7662
|
-
__name(sourceOf$1, "sourceOf");
|
|
7663
7661
|
function normalizeActionResult(result) {
|
|
7664
7662
|
if (typeof result !== "object" || result === null) return {
|
|
7665
7663
|
ok: false,
|
|
@@ -7679,7 +7677,7 @@ function normalizeActionResult(result) {
|
|
|
7679
7677
|
function openAgentPanelItem(session, id, options) {
|
|
7680
7678
|
try {
|
|
7681
7679
|
if (typeof id !== "string" || id.length === 0) return false;
|
|
7682
|
-
const source = sourceOf
|
|
7680
|
+
const source = sourceOf(session, id);
|
|
7683
7681
|
const open = source === void 0 ? void 0 : readPanelField(source, "open");
|
|
7684
7682
|
if (source === void 0 || typeof open !== "function") return false;
|
|
7685
7683
|
const onReturn = options?.onReturn;
|
|
@@ -7717,7 +7715,7 @@ async function stopAgentPanelItem(session, id) {
|
|
|
7717
7715
|
ok: false,
|
|
7718
7716
|
reason: "This item cannot be stopped from here."
|
|
7719
7717
|
};
|
|
7720
|
-
const source = sourceOf
|
|
7718
|
+
const source = sourceOf(session, id);
|
|
7721
7719
|
const taskId = agentPanelTaskId(id);
|
|
7722
7720
|
if (taskId !== void 0 && source === void 0) {
|
|
7723
7721
|
const store = getOwnerTaskStore(session);
|
|
@@ -7754,7 +7752,7 @@ async function answerAgentPanelItem(session, id, text, options) {
|
|
|
7754
7752
|
ok: false,
|
|
7755
7753
|
reason: "This item cannot be answered from here."
|
|
7756
7754
|
};
|
|
7757
|
-
const source = sourceOf
|
|
7755
|
+
const source = sourceOf(session, id);
|
|
7758
7756
|
const answer = source === void 0 ? void 0 : readPanelField(source, "answer");
|
|
7759
7757
|
if (source === void 0 || typeof answer !== "function") return {
|
|
7760
7758
|
ok: false,
|
|
@@ -13277,35 +13275,51 @@ parentPort.on("message", (msg) => {
|
|
|
13277
13275
|
}
|
|
13278
13276
|
});
|
|
13279
13277
|
`;
|
|
13278
|
+
/**
|
|
13279
|
+
* How long a task with no time limit (a background history task's) runs on the shared worker before it gets that
|
|
13280
|
+
* worker to itself and the tasks after it get a new one. Its pattern may backtrack for minutes, and nothing but its
|
|
13281
|
+
* own stop would end it, so every other history call would otherwise wait behind it.
|
|
13282
|
+
*/
|
|
13283
|
+
const OWN_WORKER_AFTER_MS = 200;
|
|
13280
13284
|
let activeWorker;
|
|
13281
13285
|
let activeTask;
|
|
13282
13286
|
const waitingQueue = [];
|
|
13287
|
+
/** Workers handed to one long task with no time limit; each runs only that task and ends with it. */
|
|
13288
|
+
const ownWorkers = /* @__PURE__ */ new Map();
|
|
13283
13289
|
let nextRequestId = 1;
|
|
13284
|
-
function
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
worker.
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13290
|
+
function spawnWorker() {
|
|
13291
|
+
const worker = new Worker(WORKER_SCRIPT, {
|
|
13292
|
+
eval: true,
|
|
13293
|
+
execArgv: evalWorkerExecArgv()
|
|
13294
|
+
});
|
|
13295
|
+
worker.on("message", (message) => {
|
|
13296
|
+
const task = worker === activeWorker ? activeTask : ownWorkers.get(worker);
|
|
13297
|
+
if (!task || !message || message.id !== task.id) return;
|
|
13298
|
+
if (worker === activeWorker) activeTask = void 0;
|
|
13299
|
+
else endOwnWorker(worker);
|
|
13300
|
+
if (message.error !== void 0) task.settle({ error: new Error(message.error) });
|
|
13301
|
+
else task.settle({ reply: message });
|
|
13302
|
+
pumpQueue();
|
|
13303
|
+
});
|
|
13304
|
+
worker.on("error", (error) => {
|
|
13305
|
+
let task;
|
|
13306
|
+
if (worker === activeWorker) {
|
|
13300
13307
|
killActiveWorker();
|
|
13301
|
-
|
|
13308
|
+
task = activeTask;
|
|
13302
13309
|
activeTask = void 0;
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13310
|
+
} else {
|
|
13311
|
+
task = ownWorkers.get(worker);
|
|
13312
|
+
if (!task) return;
|
|
13313
|
+
endOwnWorker(worker);
|
|
13314
|
+
}
|
|
13315
|
+
task?.settle({ error });
|
|
13316
|
+
pumpQueue();
|
|
13317
|
+
});
|
|
13318
|
+
worker.unref();
|
|
13319
|
+
return worker;
|
|
13320
|
+
}
|
|
13321
|
+
function getWorker() {
|
|
13322
|
+
activeWorker ??= spawnWorker();
|
|
13309
13323
|
return activeWorker;
|
|
13310
13324
|
}
|
|
13311
13325
|
function killActiveWorker() {
|
|
@@ -13313,6 +13327,17 @@ function killActiveWorker() {
|
|
|
13313
13327
|
activeWorker = void 0;
|
|
13314
13328
|
if (current) current.terminate();
|
|
13315
13329
|
}
|
|
13330
|
+
function endOwnWorker(worker) {
|
|
13331
|
+
ownWorkers.delete(worker);
|
|
13332
|
+
worker.terminate();
|
|
13333
|
+
}
|
|
13334
|
+
function handOffActiveWorker(task) {
|
|
13335
|
+
if (activeTask !== task || !activeWorker) return;
|
|
13336
|
+
ownWorkers.set(activeWorker, task);
|
|
13337
|
+
activeWorker = void 0;
|
|
13338
|
+
activeTask = void 0;
|
|
13339
|
+
pumpQueue();
|
|
13340
|
+
}
|
|
13316
13341
|
function pumpQueue() {
|
|
13317
13342
|
while (activeTask === void 0 && waitingQueue.length > 0) {
|
|
13318
13343
|
const next = waitingQueue.shift();
|
|
@@ -13327,6 +13352,10 @@ function pumpQueue() {
|
|
|
13327
13352
|
}, next.transfer ? [...next.transfer] : []);
|
|
13328
13353
|
next.dispatched = true;
|
|
13329
13354
|
activeTask = next;
|
|
13355
|
+
if (!Number.isFinite(next.deadline)) {
|
|
13356
|
+
next.handOff = setTimeout(() => handOffActiveWorker(next), OWN_WORKER_AFTER_MS);
|
|
13357
|
+
next.handOff.unref?.();
|
|
13358
|
+
}
|
|
13330
13359
|
} catch (error) {
|
|
13331
13360
|
activeTask = void 0;
|
|
13332
13361
|
next.dispatched = false;
|
|
@@ -13351,6 +13380,7 @@ function runWorkerTask(payload, timeoutMs, signal, transfer) {
|
|
|
13351
13380
|
if (settled) return;
|
|
13352
13381
|
settled = true;
|
|
13353
13382
|
clearTimeout(timer);
|
|
13383
|
+
clearTimeout(task.handOff);
|
|
13354
13384
|
signal?.removeEventListener("abort", onAbort);
|
|
13355
13385
|
if ("error" in outcome) reject(outcome.error);
|
|
13356
13386
|
else if ("timedOut" in outcome) resolve(outcome);
|
|
@@ -13370,6 +13400,13 @@ function runWorkerTask(payload, timeoutMs, signal, transfer) {
|
|
|
13370
13400
|
killActiveWorker();
|
|
13371
13401
|
task.settle(outcome);
|
|
13372
13402
|
pumpQueue();
|
|
13403
|
+
return;
|
|
13404
|
+
}
|
|
13405
|
+
for (const [worker, owner] of ownWorkers) {
|
|
13406
|
+
if (owner !== task) continue;
|
|
13407
|
+
endOwnWorker(worker);
|
|
13408
|
+
task.settle(outcome);
|
|
13409
|
+
return;
|
|
13373
13410
|
}
|
|
13374
13411
|
};
|
|
13375
13412
|
const onAbort = () => {
|
|
@@ -25238,1137 +25275,6 @@ async function resolveSessionStore(cwd, options = {}) {
|
|
|
25238
25275
|
throw error;
|
|
25239
25276
|
}
|
|
25240
25277
|
}
|
|
25241
|
-
// dist/core/storage/storage-status.js
|
|
25242
|
-
/** How long one database connectivity check may take, from opening the database to the answer of its `SELECT 1`. */
|
|
25243
|
-
const STORAGE_PROBE_TIMEOUT_MS = 15e3;
|
|
25244
|
-
/**
|
|
25245
|
-
* How long `storage status` waits for an adapter module to load before giving up on a hung evaluation; separate from
|
|
25246
|
-
* {@link STORAGE_PROBE_TIMEOUT_MS} so the server-probe timer starts only once the connection attempt starts.
|
|
25247
|
-
*/
|
|
25248
|
-
const STORAGE_ADAPTER_LOAD_TIMEOUT_MS = 15e3;
|
|
25249
|
-
const errorText = describeStorageError;
|
|
25250
|
-
function envSet(name) {
|
|
25251
|
-
const value = process.env[name];
|
|
25252
|
-
return value !== void 0 && value.length > 0;
|
|
25253
|
-
}
|
|
25254
|
-
function prefixSuffix(prefix) {
|
|
25255
|
-
return prefix ? ` (prefix ${prefix})` : "";
|
|
25256
|
-
}
|
|
25257
|
-
function describeStorageSelection(selection) {
|
|
25258
|
-
switch (selection.kind) {
|
|
25259
|
-
case "memory": return "memory";
|
|
25260
|
-
case "jsonl": return `JSONL directory ${selection.dir}`;
|
|
25261
|
-
case "sqlite": return `SQLite ${selection.path}${prefixSuffix(selection.prefix)}`;
|
|
25262
|
-
case "database": return `database ${selection.database.descriptor.adapter}${prefixSuffix(selection.prefix)}`;
|
|
25263
|
-
case "adapter": {
|
|
25264
|
-
const server = postgresServer(selection);
|
|
25265
|
-
if (server !== void 0) return `PostgreSQL ${server} via ${selection.module}${prefixSuffix(selection.prefix)}`;
|
|
25266
|
-
return `adapter ${selection.module}${prefixSuffix(selection.prefix)}`;
|
|
25267
|
-
}
|
|
25268
|
-
}
|
|
25269
|
-
}
|
|
25270
|
-
/** A Postgres selection's server, without the user name, the query and the fragment; undefined for other selections. */
|
|
25271
|
-
function postgresServer(selection) {
|
|
25272
|
-
const url = selection.options?.url;
|
|
25273
|
-
if (selection.module !== POSTGRES_ADAPTER_PACKAGE || typeof url !== "string" || !URL.canParse(url)) return void 0;
|
|
25274
|
-
const server = new URL(url);
|
|
25275
|
-
server.username = "";
|
|
25276
|
-
server.password = "";
|
|
25277
|
-
server.search = "";
|
|
25278
|
-
server.hash = "";
|
|
25279
|
-
return server.href;
|
|
25280
|
-
}
|
|
25281
|
-
function withTimeout(operation, label, timeoutMs) {
|
|
25282
|
-
let timer;
|
|
25283
|
-
return Promise.race([operation, new Promise((_, reject) => {
|
|
25284
|
-
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`${label} did not answer within ${timeoutMs / 1e3} s`)), timeoutMs);
|
|
25285
|
-
})]).finally(() => clearTimeout(timer));
|
|
25286
|
-
}
|
|
25287
|
-
/**
|
|
25288
|
-
* Load the selection's adapter and run `SELECT 1` on its database; `inspect` reads it before it closes. Nothing is
|
|
25289
|
-
* created: a SQLite file that does not exist yet is not opened, and no Atomic table is touched.
|
|
25290
|
-
*/
|
|
25291
|
-
async function probeSelection(selection, context, inspect, timeoutMs) {
|
|
25292
|
-
if (selection.kind === "memory") return { connection: {
|
|
25293
|
-
status: "skipped",
|
|
25294
|
-
detail: "in memory; nothing to open"
|
|
25295
|
-
} };
|
|
25296
|
-
if (selection.kind === "jsonl") return { connection: {
|
|
25297
|
-
status: "skipped",
|
|
25298
|
-
detail: existsSync$1(selection.dir) ? "directory exists" : "directory not created yet"
|
|
25299
|
-
} };
|
|
25300
|
-
if (selection.kind === "database") return { connection: {
|
|
25301
|
-
status: "skipped",
|
|
25302
|
-
detail: "caller-owned database"
|
|
25303
|
-
} };
|
|
25304
|
-
if (selection.kind === "sqlite") {
|
|
25305
|
-
if (selection.path === "" || selection.path === ":memory:") return { connection: {
|
|
25306
|
-
status: "skipped",
|
|
25307
|
-
detail: "in memory; nothing to open"
|
|
25308
|
-
} };
|
|
25309
|
-
if (!existsSync$1(selection.path)) return { connection: {
|
|
25310
|
-
status: "skipped",
|
|
25311
|
-
detail: "file not created yet; Atomic creates it on first use"
|
|
25312
|
-
} };
|
|
25313
|
-
const { openNodeSqliteDatabase } = await import("../core/storage/node-sqlite.js").catch((error) => __atomicOnDemandFailed(error, "session storage"));
|
|
25314
|
-
return { connection: await roundTrip(() => openNodeSqliteDatabase(selection.path, { readOnly: true }), "SQLite file", inspect, timeoutMs) };
|
|
25315
|
-
}
|
|
25316
|
-
const module = selection.module;
|
|
25317
|
-
let adapter;
|
|
25318
|
-
try {
|
|
25319
|
-
adapter = await withTimeout(loadStorageAdapter(module, context), "Loading the adapter", Math.max(timeoutMs, STORAGE_ADAPTER_LOAD_TIMEOUT_MS));
|
|
25320
|
-
} catch (error) {
|
|
25321
|
-
return {
|
|
25322
|
-
adapter: {
|
|
25323
|
-
module,
|
|
25324
|
-
loaded: false,
|
|
25325
|
-
detail: errorText(error)
|
|
25326
|
-
},
|
|
25327
|
-
connection: {
|
|
25328
|
-
status: "skipped",
|
|
25329
|
-
detail: "adapter not loaded"
|
|
25330
|
-
}
|
|
25331
|
-
};
|
|
25332
|
-
}
|
|
25333
|
-
const { resolvePackageStorageAdapter } = await import("../core/package-manager-storage-adapters.code.js").catch((error) => __atomicOnDemandFailed(error, "this feature"));
|
|
25334
|
-
const resolved = await resolvePackageStorageAdapter(module, context.agentDir);
|
|
25335
|
-
const loaded = {
|
|
25336
|
-
module,
|
|
25337
|
-
loaded: true,
|
|
25338
|
-
...resolved === void 0 ? {} : { detail: `from ${resolved}` }
|
|
25339
|
-
};
|
|
25340
|
-
if (adapter.openDatabase === void 0) return {
|
|
25341
|
-
adapter: loaded,
|
|
25342
|
-
noDatabaseHook: true,
|
|
25343
|
-
connection: {
|
|
25344
|
-
status: "skipped",
|
|
25345
|
-
detail: "the adapter has no openDatabase hook; its stores were not opened"
|
|
25346
|
-
}
|
|
25347
|
-
};
|
|
25348
|
-
let options;
|
|
25349
|
-
try {
|
|
25350
|
-
options = await resolveAdapterOptions(selection, context, adapter.liveSecrets);
|
|
25351
|
-
} catch (error) {
|
|
25352
|
-
return {
|
|
25353
|
-
adapter: loaded,
|
|
25354
|
-
connection: {
|
|
25355
|
-
status: "failed",
|
|
25356
|
-
detail: errorText(error)
|
|
25357
|
-
}
|
|
25358
|
-
};
|
|
25359
|
-
}
|
|
25360
|
-
if (typeof options.url === "string" && options.url.startsWith("file:")) {
|
|
25361
|
-
if (!options.url.startsWith("file:/")) return {
|
|
25362
|
-
adapter: loaded,
|
|
25363
|
-
connection: {
|
|
25364
|
-
status: "skipped",
|
|
25365
|
-
detail: "relative file: URL cannot be safely probed"
|
|
25366
|
-
}
|
|
25367
|
-
};
|
|
25368
|
-
try {
|
|
25369
|
-
const path = fileURLToPath(options.url);
|
|
25370
|
-
if (!existsSync$1(path)) return {
|
|
25371
|
-
adapter: loaded,
|
|
25372
|
-
connection: {
|
|
25373
|
-
status: "skipped",
|
|
25374
|
-
detail: "file not found; Atomic creates it on first use"
|
|
25375
|
-
}
|
|
25376
|
-
};
|
|
25377
|
-
return {
|
|
25378
|
-
adapter: loaded,
|
|
25379
|
-
connection: (await probeSelection({
|
|
25380
|
-
kind: "sqlite",
|
|
25381
|
-
path
|
|
25382
|
-
}, context, inspect, timeoutMs)).connection
|
|
25383
|
-
};
|
|
25384
|
-
} catch (error) {
|
|
25385
|
-
return {
|
|
25386
|
-
adapter: loaded,
|
|
25387
|
-
connection: {
|
|
25388
|
-
status: "failed",
|
|
25389
|
-
detail: errorText(error)
|
|
25390
|
-
}
|
|
25391
|
-
};
|
|
25392
|
-
}
|
|
25393
|
-
}
|
|
25394
|
-
return {
|
|
25395
|
-
adapter: loaded,
|
|
25396
|
-
connection: await roundTrip(() => openAdapterSelectionDatabase(selection, context, adapter), "The database", inspect, timeoutMs, postgresServer(selection))
|
|
25397
|
-
};
|
|
25398
|
-
}
|
|
25399
|
-
/** The server version a Postgres database reports, as status shows it after the `SELECT 1` answer. */
|
|
25400
|
-
async function postgresServerVersion(database) {
|
|
25401
|
-
return `PostgreSQL ${(await database.get("SELECT current_setting('server_version') AS version")).version}`;
|
|
25402
|
-
}
|
|
25403
|
-
/**
|
|
25404
|
-
* How a Postgres database's wake-ups reach this process (#5103): through `LISTEN`, or by polling alone, and why. Undefined
|
|
25405
|
-
* for a database without notifications.
|
|
25406
|
-
*/
|
|
25407
|
-
async function postgresWakeUps(database) {
|
|
25408
|
-
const state = await database.notifications?.state();
|
|
25409
|
-
if (state === void 0) return void 0;
|
|
25410
|
-
if (state.status === "listening") return "wake-ups: LISTEN/NOTIFY";
|
|
25411
|
-
if (state.status === "connecting") return "wake-ups: connecting";
|
|
25412
|
-
return state.reason === "pooler" ? "wake-ups: polling only, notifications do not pass the URL's transaction pooler (set listenUrl to a direct endpoint)" : "wake-ups: polling only, the listen connection failed";
|
|
25413
|
-
}
|
|
25414
|
-
async function roundTrip(open, label, inspect, timeoutMs, postgres) {
|
|
25415
|
-
const started = Date.now();
|
|
25416
|
-
let database;
|
|
25417
|
-
try {
|
|
25418
|
-
database = await withTimeout(open(), label, timeoutMs);
|
|
25419
|
-
const opened = database;
|
|
25420
|
-
await withTimeout(opened.get("SELECT 1 AS ok"), label, timeoutMs);
|
|
25421
|
-
const elapsed = Date.now() - started;
|
|
25422
|
-
if (inspect) await withTimeout(inspect(opened), "Inspecting the database", timeoutMs).catch(() => {});
|
|
25423
|
-
if (postgres !== void 0) {
|
|
25424
|
-
const version = await withTimeout(postgresServerVersion(opened), "Reading the server version", timeoutMs).catch(() => void 0);
|
|
25425
|
-
const wakeUps = await withTimeout(postgresWakeUps(opened), "Probing wake-ups", timeoutMs).catch(() => void 0);
|
|
25426
|
-
return {
|
|
25427
|
-
status: "ok",
|
|
25428
|
-
detail: `postgres ${postgres} answered in ${elapsed} ms${version === void 0 ? "" : `, ${version}`}${wakeUps === void 0 ? "" : `; ${wakeUps}`}`
|
|
25429
|
-
};
|
|
25430
|
-
}
|
|
25431
|
-
return {
|
|
25432
|
-
status: "ok",
|
|
25433
|
-
detail: `${opened.descriptor.adapter} ${opened.descriptor.location} answered in ${elapsed} ms`
|
|
25434
|
-
};
|
|
25435
|
-
} catch (error) {
|
|
25436
|
-
return {
|
|
25437
|
-
status: "failed",
|
|
25438
|
-
detail: errorText(error)
|
|
25439
|
-
};
|
|
25440
|
-
} finally {
|
|
25441
|
-
if (database) await withTimeout(database.close(), "Closing the database", timeoutMs).catch(() => {});
|
|
25442
|
-
}
|
|
25443
|
-
}
|
|
25444
|
-
function settingLayers(global, project, projectTrusted, read, field) {
|
|
25445
|
-
return [{
|
|
25446
|
-
label: `project settings: ${field}`,
|
|
25447
|
-
present: projectTrusted && read(project) !== void 0
|
|
25448
|
-
}, {
|
|
25449
|
-
label: `global settings: ${field}`,
|
|
25450
|
-
present: read(global) !== void 0
|
|
25451
|
-
}];
|
|
25452
|
-
}
|
|
25453
|
-
function sourceOf(layers) {
|
|
25454
|
-
const present = layers.filter((layer) => layer.present).map((layer) => layer.label);
|
|
25455
|
-
return {
|
|
25456
|
-
source: present[0] ?? "default",
|
|
25457
|
-
overridden: present.slice(1)
|
|
25458
|
-
};
|
|
25459
|
-
}
|
|
25460
|
-
/** The source label of the `ATOMIC_PROFILE=ci` team database. */
|
|
25461
|
-
const TEAM_PROFILE_SOURCE = `${TEAM_PROFILE_ENV}=ci`;
|
|
25462
|
-
/**
|
|
25463
|
-
* The shared selection this process and these settings make: `--storage`, `ATOMIC_STORAGE` or the
|
|
25464
|
-
* `ATOMIC_PROFILE=ci` team database, else the `storage` setting; `undefined` when none of them is set.
|
|
25465
|
-
*/
|
|
25466
|
-
function selectSharedStorage(agentDir, settings) {
|
|
25467
|
-
const processChoice = selectProcessStorage("shared", agentDir, void 0, settings);
|
|
25468
|
-
if (processChoice !== void 0) return processChoice.selection;
|
|
25469
|
-
const value = settings.storage;
|
|
25470
|
-
if (value === void 0) return void 0;
|
|
25471
|
-
const selection = selectStorage(value, "settings", "storage", () => defaultSharedStoragePath(agentDir, settings));
|
|
25472
|
-
return selection.kind === "sqlite" && !isAbsolute$1(selection.path) ? {
|
|
25473
|
-
...selection,
|
|
25474
|
-
path: join$1(storagePathBaseDir(selection.path, agentDir, settings), selection.path)
|
|
25475
|
-
} : selection;
|
|
25476
|
-
}
|
|
25477
|
-
/**
|
|
25478
|
-
* The raw shared selection a broker started from this process would read: `--storage`, `ATOMIC_STORAGE` or the
|
|
25479
|
-
* `ATOMIC_PROFILE=ci` team database, else global `storage`.
|
|
25480
|
-
*/
|
|
25481
|
-
function sharedSelection(globalStorage, processSelection = processSharedStorageSelection()) {
|
|
25482
|
-
if (processSelection === void 0) return globalStorage;
|
|
25483
|
-
const parsed = JSON.parse(processSelection);
|
|
25484
|
-
return parsed === null || typeof parsed !== "object" || Array.isArray(parsed) ? void 0 : parsed;
|
|
25485
|
-
}
|
|
25486
|
-
/**
|
|
25487
|
-
* The shared selection Intercom's multi-node routing would use, resolved like the broker resolves it; `undefined`
|
|
25488
|
-
* when there is none or it is in memory, which leaves multi-node routing off.
|
|
25489
|
-
*/
|
|
25490
|
-
function selectIntercomStorage(agentDir, globalStorage) {
|
|
25491
|
-
const processSelection = processSharedStorageSelection();
|
|
25492
|
-
const value = sharedSelection(globalStorage, processSelection);
|
|
25493
|
-
if (value === void 0) return void 0;
|
|
25494
|
-
const settings = globalStorage === void 0 ? void 0 : { storage: globalStorage };
|
|
25495
|
-
const selection = selectStorage(value, processSelection === void 0 ? "settings" : "env", "storage", () => defaultSharedStoragePath(agentDir, settings));
|
|
25496
|
-
if (selection.kind === "memory" || selection.kind === "sqlite" && selection.path === ":memory:") return void 0;
|
|
25497
|
-
return selection.kind === "sqlite" && !isAbsolute$1(selection.path) ? {
|
|
25498
|
-
...selection,
|
|
25499
|
-
path: resolvePath(selection.path, storagePathBaseDir(selection.path, agentDir, settings))
|
|
25500
|
-
} : selection;
|
|
25501
|
-
}
|
|
25502
|
-
function projectTrust(cwd, agentDir) {
|
|
25503
|
-
if (!hasProjectTrustInputs(cwd)) return true;
|
|
25504
|
-
return new ProjectTrustStore(agentDir).get(cwd) ?? SettingsManager.create(cwd, agentDir, { projectTrusted: false }).getDefaultProjectTrust() === "always";
|
|
25505
|
-
}
|
|
25506
|
-
/** The shared selection {@link selectSharedStorage} makes in this directory, with its trusted project settings. */
|
|
25507
|
-
function effectiveSharedSelection(cwd, agentDir) {
|
|
25508
|
-
return selectSharedStorage(agentDir, SettingsManager.create(cwd, agentDir, { projectTrusted: projectTrust(cwd, agentDir) }).getSettings());
|
|
25509
|
-
}
|
|
25510
|
-
/**
|
|
25511
|
-
* Which storage each domain selects and where that selection comes from, following the same precedence as
|
|
25512
|
-
* sessions and the Intercom broker; with `probe`, whether each adapter loads and each database answers, and what the
|
|
25513
|
-
* running broker uses.
|
|
25514
|
-
*/
|
|
25515
|
-
async function collectStorageStatus(options) {
|
|
25516
|
-
const { cwd, agentDir } = options;
|
|
25517
|
-
const projectTrusted = projectTrust(cwd, agentDir);
|
|
25518
|
-
const manager = SettingsManager.create(cwd, agentDir, { projectTrusted });
|
|
25519
|
-
const settingsErrors = manager.drainErrors().filter(({ invalidKey }) => invalidKey === void 0);
|
|
25520
|
-
if (settingsErrors.length > 0) throw new Error(`Cannot load settings: ${settingsErrors.map(({ scope, error }) => `${scope} settings: ${error.message}`).join("; ")}`);
|
|
25521
|
-
const global = manager.getGlobalSettings();
|
|
25522
|
-
const project = manager.getProjectSettings();
|
|
25523
|
-
const merged = manager.getSettings();
|
|
25524
|
-
const notes = [];
|
|
25525
|
-
let usesLocalStorage = false;
|
|
25526
|
-
const unappliedProject = projectTrusted ? {} : SettingsManager.create(cwd, agentDir, { projectTrusted: true }).getProjectSettings();
|
|
25527
|
-
if (unappliedProject.storage !== void 0 || unappliedProject.sessions?.storage !== void 0) notes.push("Project settings select storage, but the project is not trusted, so they are not applied.");
|
|
25528
|
-
if (projectTrusted && project.storage !== void 0) notes.push("Project settings set `storage`, which Intercom ignores: multi-node routing reads only global settings or ATOMIC_STORAGE.");
|
|
25529
|
-
const env = (name) => ({
|
|
25530
|
-
label: name,
|
|
25531
|
-
present: envSet(name)
|
|
25532
|
-
});
|
|
25533
|
-
const teamProfile = {
|
|
25534
|
-
label: TEAM_PROFILE_SOURCE,
|
|
25535
|
-
present: envSet(TEAM_PROFILE_ENV)
|
|
25536
|
-
};
|
|
25537
|
-
const sessionsSetting = (settings) => settings.sessions?.storage;
|
|
25538
|
-
const storageSetting = (settings) => settings.storage;
|
|
25539
|
-
const layers = {
|
|
25540
|
-
sessions: [
|
|
25541
|
-
env(SESSIONS_STORAGE_ENV),
|
|
25542
|
-
env(ENV_SESSION_DIR),
|
|
25543
|
-
env(STORAGE_ENV),
|
|
25544
|
-
teamProfile,
|
|
25545
|
-
...settingLayers(global, project, projectTrusted, sessionsSetting, "sessions.storage"),
|
|
25546
|
-
...settingLayers(global, project, projectTrusted, storageSetting, "storage")
|
|
25547
|
-
],
|
|
25548
|
-
intercom: [
|
|
25549
|
-
env(STORAGE_ENV),
|
|
25550
|
-
teamProfile,
|
|
25551
|
-
{
|
|
25552
|
-
label: "global settings: storage",
|
|
25553
|
-
present: global.storage !== void 0
|
|
25554
|
-
}
|
|
25555
|
-
]
|
|
25556
|
-
};
|
|
25557
|
-
const checked = /* @__PURE__ */ new Map();
|
|
25558
|
-
const probeOnce = async (domain, selection, inspect) => {
|
|
25559
|
-
if (!options.probe) return void 0;
|
|
25560
|
-
const key = storageSelectionKey(selection, agentDir);
|
|
25561
|
-
const earlier = checked.get(key);
|
|
25562
|
-
if (earlier !== void 0 && inspect === void 0) return {
|
|
25563
|
-
...earlier.probe,
|
|
25564
|
-
sameAs: earlier.domain
|
|
25565
|
-
};
|
|
25566
|
-
const probe = await probeSelection(selection, {
|
|
25567
|
-
agentDir,
|
|
25568
|
-
domain
|
|
25569
|
-
}, inspect, options.probeTimeoutMs ?? 15e3);
|
|
25570
|
-
if (earlier === void 0) checked.set(key, {
|
|
25571
|
-
domain,
|
|
25572
|
-
probe
|
|
25573
|
-
});
|
|
25574
|
-
return probe;
|
|
25575
|
-
};
|
|
25576
|
-
const domains = [];
|
|
25577
|
-
const sessions = sourceOf(layers.sessions);
|
|
25578
|
-
try {
|
|
25579
|
-
const selection = selectSessionStorageWithSettings(cwd, {
|
|
25580
|
-
agentDir,
|
|
25581
|
-
settings: merged
|
|
25582
|
-
});
|
|
25583
|
-
if (selection.kind === "sqlite" || selection.kind === "jsonl") usesLocalStorage = true;
|
|
25584
|
-
const probe = await probeOnce("sessions", selection);
|
|
25585
|
-
domains.push({
|
|
25586
|
-
domain: "sessions",
|
|
25587
|
-
selection: describeStorageSelection(selection),
|
|
25588
|
-
source: sessions.source,
|
|
25589
|
-
overridden: sessions.overridden,
|
|
25590
|
-
...probe === void 0 ? {} : { probe }
|
|
25591
|
-
});
|
|
25592
|
-
} catch (error) {
|
|
25593
|
-
domains.push({
|
|
25594
|
-
domain: "sessions",
|
|
25595
|
-
selection: "invalid",
|
|
25596
|
-
source: sessions.source,
|
|
25597
|
-
overridden: sessions.overridden,
|
|
25598
|
-
error: errorText(error)
|
|
25599
|
-
});
|
|
25600
|
-
}
|
|
25601
|
-
const intercom = sourceOf(layers.intercom);
|
|
25602
|
-
try {
|
|
25603
|
-
const resolved = selectIntercomStorage(agentDir, global.storage);
|
|
25604
|
-
if (resolved === void 0) domains.push({
|
|
25605
|
-
domain: "intercom",
|
|
25606
|
-
selection: "off",
|
|
25607
|
-
source: intercom.source,
|
|
25608
|
-
overridden: intercom.overridden,
|
|
25609
|
-
multiNode: sharedSelection(global.storage) === void 0 ? "off: no shared storage selection (top-level `storage` in global settings, ATOMIC_STORAGE, or ATOMIC_PROFILE=ci)" : "off: the shared storage selection is in memory"
|
|
25610
|
-
});
|
|
25611
|
-
else {
|
|
25612
|
-
if (resolved.kind === "sqlite") usesLocalStorage = true;
|
|
25613
|
-
let liveBrokers;
|
|
25614
|
-
const control = options.control;
|
|
25615
|
-
const probe = await probeOnce("intercom", resolved, control === void 0 ? void 0 : async (database) => {
|
|
25616
|
-
liveBrokers = await control.readLiveBrokers(database, resolved.kind === "adapter" || resolved.kind === "sqlite" ? resolved.prefix : void 0) ?? [];
|
|
25617
|
-
});
|
|
25618
|
-
const multiNode = probe === void 0 ? void 0 : probe.adapter?.loaded === false ? "off: the adapter cannot be loaded" : probe.noDatabaseHook ? "off: the adapter has no openDatabase hook" : probe.connection.status === "failed" ? "unavailable: the database did not answer" : resolved.kind === "sqlite" ? "on (a local SQLite file: only brokers on this machine share it)" : "on";
|
|
25619
|
-
domains.push({
|
|
25620
|
-
domain: "intercom",
|
|
25621
|
-
selection: describeStorageSelection(resolved),
|
|
25622
|
-
source: intercom.source,
|
|
25623
|
-
overridden: intercom.overridden,
|
|
25624
|
-
...probe === void 0 ? {} : { probe },
|
|
25625
|
-
...multiNode === void 0 ? {} : { multiNode },
|
|
25626
|
-
...liveBrokers === void 0 ? {} : { liveBrokers }
|
|
25627
|
-
});
|
|
25628
|
-
}
|
|
25629
|
-
} catch (error) {
|
|
25630
|
-
domains.push({
|
|
25631
|
-
domain: "intercom",
|
|
25632
|
-
selection: "invalid",
|
|
25633
|
-
source: intercom.source,
|
|
25634
|
-
overridden: intercom.overridden,
|
|
25635
|
-
error: errorText(error)
|
|
25636
|
-
});
|
|
25637
|
-
}
|
|
25638
|
-
if (usesLocalStorage) {
|
|
25639
|
-
const adoptionNotice = takeStorageAdoptionNotice(agentDir, merged);
|
|
25640
|
-
if (adoptionNotice !== void 0) notes.unshift(adoptionNotice);
|
|
25641
|
-
}
|
|
25642
|
-
return {
|
|
25643
|
-
agentDir,
|
|
25644
|
-
cwd,
|
|
25645
|
-
projectTrusted,
|
|
25646
|
-
domains,
|
|
25647
|
-
notes,
|
|
25648
|
-
...options.control === void 0 ? {} : { broker: await brokerSection(options.control, agentDir) }
|
|
25649
|
-
};
|
|
25650
|
-
}
|
|
25651
|
-
async function brokerSection(control, agentDir) {
|
|
25652
|
-
try {
|
|
25653
|
-
const query = await control.queryIntercomBroker(agentDir);
|
|
25654
|
-
if (query.state === "stopped") return { state: "stopped" };
|
|
25655
|
-
if (query.state === "legacy") return query.pid === void 0 ? { state: "legacy" } : {
|
|
25656
|
-
state: "legacy",
|
|
25657
|
-
pid: query.pid
|
|
25658
|
-
};
|
|
25659
|
-
const { report } = query;
|
|
25660
|
-
const expected = control.expectedBrokerStorage(agentDir, processStorageEnvironment());
|
|
25661
|
-
return {
|
|
25662
|
-
state: "running",
|
|
25663
|
-
pid: report.pid,
|
|
25664
|
-
sessions: report.sessions,
|
|
25665
|
-
matchesCurrent: report.storage?.digest === expected?.digest,
|
|
25666
|
-
...report.storage === void 0 ? {} : { source: report.storage.source },
|
|
25667
|
-
multiNode: report.multiNode,
|
|
25668
|
-
multiNodeLine: control.describeMultiNodeStatus(report.multiNode)
|
|
25669
|
-
};
|
|
25670
|
-
} catch (error) {
|
|
25671
|
-
return {
|
|
25672
|
-
state: "unknown",
|
|
25673
|
-
error: errorText(error)
|
|
25674
|
-
};
|
|
25675
|
-
}
|
|
25676
|
-
}
|
|
25677
|
-
/**
|
|
25678
|
-
* The launch warning for a shared storage adapter this executable cannot load: the Intercom broker would leave
|
|
25679
|
-
* multi-node routing off with only a `broker.log` line. Load-only: no database is opened. `undefined` when the
|
|
25680
|
-
* shared selection names no adapter or it loads.
|
|
25681
|
-
*/
|
|
25682
|
-
async function checkSharedStorageAdapter(agentDir, globalStorage) {
|
|
25683
|
-
let value;
|
|
25684
|
-
try {
|
|
25685
|
-
value = sharedSelection(globalStorage);
|
|
25686
|
-
} catch {
|
|
25687
|
-
return;
|
|
25688
|
-
}
|
|
25689
|
-
const module = value?.adapter;
|
|
25690
|
-
if (typeof module !== "string" || module.length === 0) return void 0;
|
|
25691
|
-
try {
|
|
25692
|
-
await loadStorageAdapter(module, {
|
|
25693
|
-
agentDir,
|
|
25694
|
-
domain: "intercom"
|
|
25695
|
-
});
|
|
25696
|
-
return;
|
|
25697
|
-
} catch (error) {
|
|
25698
|
-
const executable = isBunBinary ? process.execPath : process.argv[1] ?? process.execPath;
|
|
25699
|
-
const cause = error instanceof StorageAdapterLoadError && error.cause instanceof Error ? error.cause : error;
|
|
25700
|
-
return `Storage adapter "${module}" cannot be loaded by this Atomic (${executable}): ${errorText(cause)}. Intercom multi-node routing stays off, and sessions that select this adapter fail to open. Run "atomic storage status" for details.`;
|
|
25701
|
-
}
|
|
25702
|
-
}
|
|
25703
|
-
// dist/core/storage/team.js
|
|
25704
|
-
/**
|
|
25705
|
-
* Team setup: one settings write that shares Intercom routing through a team database while
|
|
25706
|
-
* sessions stay in the local store (`joinTeam`), its exact undo (`leaveTeam`), the layout in effect
|
|
25707
|
-
* (`getTeamProfile`), and the shared-database join that `atomic storage join` and `atomic team join` both run.
|
|
25708
|
-
*/
|
|
25709
|
-
function settingsPathOf(agentDir) {
|
|
25710
|
-
return join$1(agentDir, "settings.json");
|
|
25711
|
-
}
|
|
25712
|
-
/**
|
|
25713
|
-
* Why a settings file cannot be read, without any of its content: the file-system error code, or where its JSON
|
|
25714
|
-
* breaks. A parser message can quote part of the file, such as a key, so it is never shown.
|
|
25715
|
-
*/
|
|
25716
|
-
function unreadableSettingsDetail(error) {
|
|
25717
|
-
const code = error.code;
|
|
25718
|
-
if (typeof code === "string") return code;
|
|
25719
|
-
if (!(error instanceof SyntaxError)) return error.name;
|
|
25720
|
-
const position = /\(line (\d+) column (\d+)\)/.exec(error.message);
|
|
25721
|
-
return position === null ? "not valid JSON" : `not valid JSON at line ${position[1]}, column ${position[2]}`;
|
|
25722
|
-
}
|
|
25723
|
-
function unreadableSettingsError(subject, cause) {
|
|
25724
|
-
return new TeamProfileError("settings-unreadable", {
|
|
25725
|
-
subject,
|
|
25726
|
-
detail: unreadableSettingsDetail(cause),
|
|
25727
|
-
hint: `Fix ${subject} first, then run the command again.`,
|
|
25728
|
-
cause
|
|
25729
|
-
});
|
|
25730
|
-
}
|
|
25731
|
-
function openGlobalSettings(cwd, agentDir) {
|
|
25732
|
-
const manager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });
|
|
25733
|
-
const failure = manager.drainErrors().find(({ invalidKey }) => invalidKey === void 0);
|
|
25734
|
-
if (failure !== void 0) {
|
|
25735
|
-
const settingsPath = failure.path ?? settingsPathOf(agentDir);
|
|
25736
|
-
if (isLocked(failure.error)) throw lockedError(settingsPath, failure.error, "Nothing was changed.");
|
|
25737
|
-
throw unreadableSettingsError(settingsPath, failure.error);
|
|
25738
|
-
}
|
|
25739
|
-
return manager;
|
|
25740
|
-
}
|
|
25741
|
-
function writePrivateFile(path, token) {
|
|
25742
|
-
mkdirSync$1(dirname$1(path), { recursive: true });
|
|
25743
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
25744
|
-
try {
|
|
25745
|
-
writeFileSync$1(temporary, token, { mode: 384 });
|
|
25746
|
-
chmodSync$1(temporary, 384);
|
|
25747
|
-
renameSync$1(temporary, path);
|
|
25748
|
-
} catch (error) {
|
|
25749
|
-
rmSync$1(temporary, { force: true });
|
|
25750
|
-
throw error;
|
|
25751
|
-
}
|
|
25752
|
-
}
|
|
25753
|
-
async function checkConnection(target, agentDir, adapter) {
|
|
25754
|
-
const database = await openAdapterSelectionDatabase({
|
|
25755
|
-
kind: "adapter",
|
|
25756
|
-
module: target.adapter,
|
|
25757
|
-
options: target.options,
|
|
25758
|
-
...target.secret === void 0 ? {} : { secrets: { [target.secretName]: inMemorySecret(target.secret) } }
|
|
25759
|
-
}, {
|
|
25760
|
-
agentDir,
|
|
25761
|
-
domain: "sessions"
|
|
25762
|
-
}, adapter);
|
|
25763
|
-
try {
|
|
25764
|
-
await database.get("SELECT 1 AS ok");
|
|
25765
|
-
} finally {
|
|
25766
|
-
await database.close();
|
|
25767
|
-
}
|
|
25768
|
-
}
|
|
25769
|
-
/** The `StorageConfigError` `error` is, or was caused by, if any. */
|
|
25770
|
-
function storageConfigCause(error) {
|
|
25771
|
-
let current = error;
|
|
25772
|
-
for (let depth = 0; depth < 8 && current instanceof Error; depth++) {
|
|
25773
|
-
if (current instanceof StorageConfigError) return current;
|
|
25774
|
-
current = current.cause;
|
|
25775
|
-
}
|
|
25776
|
-
}
|
|
25777
|
-
/** How long a join waits for the team database to connect and answer `SELECT 1`, after the adapter has loaded. */
|
|
25778
|
-
const TEAM_CONNECTION_TIMEOUT_MS = 15e3;
|
|
25779
|
-
/**
|
|
25780
|
-
* `checkConnection`, bounded by `timeoutMs` once the adapter module has loaded: a database that does not answer fails
|
|
25781
|
-
* with a retryable {@link TeamProfileTimeoutError} instead of waiting for the operating system's connection timeout. A
|
|
25782
|
-
* check that fails after the deadline is recorded as the timeout error's `cleanupCause`. `elapsedMs` is never below
|
|
25783
|
-
* `timeoutMs`: Node can fire a timer a millisecond before the wall clock shows its delay has passed.
|
|
25784
|
-
*/
|
|
25785
|
-
async function checkConnectionWithin(target, agentDir, timeoutMs) {
|
|
25786
|
-
const url = target.options.url;
|
|
25787
|
-
let timer;
|
|
25788
|
-
let started = 0;
|
|
25789
|
-
let check;
|
|
25790
|
-
let outcome;
|
|
25791
|
-
try {
|
|
25792
|
-
const adapter = await loadStorageAdapter(target.adapter, {
|
|
25793
|
-
agentDir,
|
|
25794
|
-
domain: "sessions"
|
|
25795
|
-
});
|
|
25796
|
-
started = Date.now();
|
|
25797
|
-
check = checkConnection(target, agentDir, adapter).then(() => "answered");
|
|
25798
|
-
const deadline = new Promise((resolveDeadline) => {
|
|
25799
|
-
timer = setTimeout(() => resolveDeadline("timed-out"), timeoutMs);
|
|
25800
|
-
});
|
|
25801
|
-
outcome = await Promise.race([check, deadline]);
|
|
25802
|
-
} catch (error) {
|
|
25803
|
-
const config = storageConfigCause(error);
|
|
25804
|
-
if (config?.reason === "auth-unavailable") throw new TeamProfileError("auth-unavailable", {
|
|
25805
|
-
subject: url,
|
|
25806
|
-
detail: "auth-unavailable",
|
|
25807
|
-
hint: `Nothing was changed. ${config.hint ?? "Check the cloud identity's sign-in"}`,
|
|
25808
|
-
cause: error
|
|
25809
|
-
});
|
|
25810
|
-
if (config !== void 0) throw config;
|
|
25811
|
-
throw new TeamProfileError("connection-failed", {
|
|
25812
|
-
subject: url,
|
|
25813
|
-
detail: describeStorageError$1(error),
|
|
25814
|
-
hint: "Nothing was changed. Check the URL, the token and the network, then run the command again.",
|
|
25815
|
-
cause: error
|
|
25816
|
-
});
|
|
25817
|
-
} finally {
|
|
25818
|
-
clearTimeout(timer);
|
|
25819
|
-
}
|
|
25820
|
-
if (outcome === "answered") return;
|
|
25821
|
-
const timeout = new TeamProfileTimeoutError({
|
|
25822
|
-
subject: url,
|
|
25823
|
-
timeoutMs,
|
|
25824
|
-
elapsedMs: Math.max(Date.now() - started, timeoutMs),
|
|
25825
|
-
phase: "connect",
|
|
25826
|
-
hint: "Nothing was changed. Check that the database is reachable from this machine, then run the command again."
|
|
25827
|
-
});
|
|
25828
|
-
check.catch((late) => {
|
|
25829
|
-
Object.defineProperty(timeout, "cleanupCause", {
|
|
25830
|
-
value: late,
|
|
25831
|
-
configurable: true
|
|
25832
|
-
});
|
|
25833
|
-
});
|
|
25834
|
-
throw timeout;
|
|
25835
|
-
}
|
|
25836
|
-
/** The token file a `{ file }` reference names, resolved like the storage provider resolves it. */
|
|
25837
|
-
function secretFilePath(ref, agentDir) {
|
|
25838
|
-
if (ref === void 0 || !("file" in ref)) return void 0;
|
|
25839
|
-
return resolve$1(secretFilePath$1(ref.file, agentDir));
|
|
25840
|
-
}
|
|
25841
|
-
/** Whether a path is a token file that a join created in this agent directory. */
|
|
25842
|
-
function isJoinTokenFile(path, agentDir) {
|
|
25843
|
-
return dirname$1(path) === resolve$1(agentDir) && basename$1(path).startsWith(`${STORAGE_TOKEN_FILE}.`);
|
|
25844
|
-
}
|
|
25845
|
-
/** The join-created token file `storage` references as `secretName`, when it already holds `token`. */
|
|
25846
|
-
function reusableTokenFile(storage, secretName, token, agentDir) {
|
|
25847
|
-
const path = secretFilePath(storage?.secrets?.[secretName], agentDir);
|
|
25848
|
-
if (path === void 0 || !isJoinTokenFile(path, agentDir)) return void 0;
|
|
25849
|
-
let stored;
|
|
25850
|
-
try {
|
|
25851
|
-
stored = readFileSync$1(path, "utf8");
|
|
25852
|
-
} catch (error) {
|
|
25853
|
-
if (error instanceof Error) return void 0;
|
|
25854
|
-
throw error;
|
|
25855
|
-
}
|
|
25856
|
-
return stored === token ? path : void 0;
|
|
25857
|
-
}
|
|
25858
|
-
function isLocked(error) {
|
|
25859
|
-
return error.code === "ELOCKED";
|
|
25860
|
-
}
|
|
25861
|
-
/** Another process holds the settings lock: retryable, since a lock left by a killed process expires. */
|
|
25862
|
-
function lockedError(settingsPath, cause, outcome) {
|
|
25863
|
-
return new TeamProfileError("settings-locked", {
|
|
25864
|
-
subject: settingsPath,
|
|
25865
|
-
hint: `${outcome} Run the command again in a few seconds; a lock left by a killed process expires after 10 seconds.`,
|
|
25866
|
-
cause
|
|
25867
|
-
});
|
|
25868
|
-
}
|
|
25869
|
-
/** A failed settings write: `settings-locked` while another process holds the lock, else the I/O error. */
|
|
25870
|
-
function settingsWriteError(settingsPath, cause, outcome) {
|
|
25871
|
-
if (isLocked(cause)) return lockedError(settingsPath, cause, outcome);
|
|
25872
|
-
return new TeamProfileError("settings-write-failed", {
|
|
25873
|
-
subject: settingsPath,
|
|
25874
|
-
detail: describeStorageError$1(cause),
|
|
25875
|
-
hint: `${outcome} Check that the file and its directory are writable and the disk has space, then run the command again.`,
|
|
25876
|
-
cause
|
|
25877
|
-
});
|
|
25878
|
-
}
|
|
25879
|
-
function withGlobalSettings(agentDir, outcome, run) {
|
|
25880
|
-
const settingsPath = settingsPathOf(agentDir);
|
|
25881
|
-
let result;
|
|
25882
|
-
try {
|
|
25883
|
-
new FileSettingsStorage(dirname$1(agentDir), agentDir).withPrimaryWriteLock("global", (current) => {
|
|
25884
|
-
let settings = {};
|
|
25885
|
-
if (current !== void 0) try {
|
|
25886
|
-
const parsed = parseJsonFileContent(current);
|
|
25887
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new TypeError("not a JSON object");
|
|
25888
|
-
settings = parsed;
|
|
25889
|
-
} catch (error) {
|
|
25890
|
-
throw unreadableSettingsError(settingsPath, error);
|
|
25891
|
-
}
|
|
25892
|
-
result = run(settings);
|
|
25893
|
-
});
|
|
25894
|
-
} catch (error) {
|
|
25895
|
-
if (error instanceof TeamProfileError) throw error;
|
|
25896
|
-
throw settingsWriteError(settingsPath, error, outcome);
|
|
25897
|
-
}
|
|
25898
|
-
return result;
|
|
25899
|
-
}
|
|
25900
|
-
function cleanupAfter(primary, cleanup) {
|
|
25901
|
-
try {
|
|
25902
|
-
cleanup();
|
|
25903
|
-
} catch (cleanupCause) {
|
|
25904
|
-
Object.defineProperty(primary, "cleanupCause", {
|
|
25905
|
-
value: cleanupCause,
|
|
25906
|
-
configurable: true
|
|
25907
|
-
});
|
|
25908
|
-
}
|
|
25909
|
-
}
|
|
25910
|
-
function joinPlan(options, source, cwd) {
|
|
25911
|
-
if (!options.pinLocalSessions && isPostgresUrl(options.url)) {
|
|
25912
|
-
const checked = checkSharedDatabaseArguments(options);
|
|
25913
|
-
const target = {
|
|
25914
|
-
adapter: POSTGRES_ADAPTER_PACKAGE,
|
|
25915
|
-
secretName: "password"
|
|
25916
|
-
};
|
|
25917
|
-
if (checked.auth !== void 0) return { target: {
|
|
25918
|
-
...target,
|
|
25919
|
-
options: {
|
|
25920
|
-
url: checked.url,
|
|
25921
|
-
auth: checked.auth
|
|
25922
|
-
}
|
|
25923
|
-
} };
|
|
25924
|
-
if (checked.passwordFile !== void 0) {
|
|
25925
|
-
const password = readTeamTokenFile(resolve$1(cwd, checked.passwordFile), source, "--password-file");
|
|
25926
|
-
return {
|
|
25927
|
-
target: {
|
|
25928
|
-
...target,
|
|
25929
|
-
options: { url: checked.url },
|
|
25930
|
-
secret: password
|
|
25931
|
-
},
|
|
25932
|
-
copy: password
|
|
25933
|
-
};
|
|
25934
|
-
}
|
|
25935
|
-
const reference = resolve$1(cwd, checked.tokenFile);
|
|
25936
|
-
const password = readTeamTokenFile(reference, source, void 0, "as-connections-read");
|
|
25937
|
-
return {
|
|
25938
|
-
target: {
|
|
25939
|
-
...target,
|
|
25940
|
-
options: { url: checked.url },
|
|
25941
|
-
secret: password
|
|
25942
|
-
},
|
|
25943
|
-
reference
|
|
25944
|
-
};
|
|
25945
|
-
}
|
|
25946
|
-
const url = checkTeamUrl(options.url, source);
|
|
25947
|
-
if (options.token !== void 0 && options.tokenFile !== void 0) throw conflictingTeamToken(source, source === "cli" ? ["--token-file"] : ["token", "tokenFile"]);
|
|
25948
|
-
let token;
|
|
25949
|
-
if (options.tokenFile !== void 0) token = readTeamTokenFile(resolve$1(cwd, options.tokenFile), source);
|
|
25950
|
-
else if (options.token !== void 0) {
|
|
25951
|
-
token = options.token.trim();
|
|
25952
|
-
if (token.length === 0) throw emptyTeamToken(source);
|
|
25953
|
-
} else if (!isFileUrl(url)) throw missingTeamToken(url, source);
|
|
25954
|
-
return {
|
|
25955
|
-
target: {
|
|
25956
|
-
adapter: LIBSQL_ADAPTER_PACKAGE,
|
|
25957
|
-
options: { url },
|
|
25958
|
-
secretName: "authToken",
|
|
25959
|
-
secret: token
|
|
25960
|
-
},
|
|
25961
|
-
copy: token
|
|
25962
|
-
};
|
|
25963
|
-
}
|
|
25964
|
-
/**
|
|
25965
|
-
* Point the global `storage` setting at a shared libSQL / Turso or PostgreSQL database, as `atomic storage join` and
|
|
25966
|
-
* `atomic team join` do. Every input and precondition is checked before the first write: the URL, the token, the
|
|
25967
|
-
* prefix, readable global settings, the installed adapter and a `SELECT 1` on the database. The token is stored in a
|
|
25968
|
-
* private file in the agent directory (mode 600), reusing the file the current selection references when it already
|
|
25969
|
-
* holds the same token, and settings are written in one update; with `pinLocalSessions`, that update also sets
|
|
25970
|
-
* `sessions.storage` to the local default store. On failure nothing is changed.
|
|
25971
|
-
*/
|
|
25972
|
-
async function joinSharedDatabase(options, source, connectionTimeoutMs = TEAM_CONNECTION_TIMEOUT_MS) {
|
|
25973
|
-
const agentDir = resolve$1(options.agentDir ?? getAgentDir());
|
|
25974
|
-
const cwd = resolve$1(options.cwd ?? process.cwd());
|
|
25975
|
-
const plan = joinPlan(options, source, cwd);
|
|
25976
|
-
const { target } = plan;
|
|
25977
|
-
const token = plan.copy;
|
|
25978
|
-
const prefix = checkTeamPrefix(options.prefix, source);
|
|
25979
|
-
openGlobalSettings(cwd, agentDir);
|
|
25980
|
-
const settingsPath = settingsPathOf(agentDir);
|
|
25981
|
-
if (await resolvePackageStorageAdapter(target.adapter, agentDir) === void 0) throw new TeamProfileError("adapter-not-installed", {
|
|
25982
|
-
subject: `${target.adapter} for ${agentDir}`,
|
|
25983
|
-
hint: `Install it, then run this command again: atomic install npm:${target.adapter}`
|
|
25984
|
-
});
|
|
25985
|
-
await checkConnectionWithin(target, agentDir, connectionTimeoutMs);
|
|
25986
|
-
const unchanged = "Nothing was changed: the previous selection and its token are kept.";
|
|
25987
|
-
await prepareLockTakeover(`${settingsPath}.lock`);
|
|
25988
|
-
const { storage, previous, previousPin, tokenPath, reused } = withGlobalSettings(agentDir, unchanged, (settings) => {
|
|
25989
|
-
const previous = settings.storage;
|
|
25990
|
-
const reused = token === void 0 ? void 0 : reusableTokenFile(previous, target.secretName, token, agentDir);
|
|
25991
|
-
const tokenPath = token === void 0 ? void 0 : reused ?? join$1(agentDir, `${STORAGE_TOKEN_FILE}.${randomUUID()}`);
|
|
25992
|
-
const created = token !== void 0 && tokenPath !== void 0 && reused === void 0 ? tokenPath : void 0;
|
|
25993
|
-
if (token !== void 0 && created !== void 0) try {
|
|
25994
|
-
writePrivateFile(created, token);
|
|
25995
|
-
} catch (error) {
|
|
25996
|
-
throw new TeamProfileError("token-write-failed", {
|
|
25997
|
-
subject: created,
|
|
25998
|
-
detail: describeStorageError$1(error),
|
|
25999
|
-
hint: "Nothing was changed. Check that the agent directory is writable, then run the command again.",
|
|
26000
|
-
cause: error
|
|
26001
|
-
});
|
|
26002
|
-
}
|
|
26003
|
-
const file = tokenPath === void 0 ? plan.reference : relative$1(storageHomeDir(agentDir), tokenPath).split(sep$1).join("/");
|
|
26004
|
-
const storage = {
|
|
26005
|
-
adapter: target.adapter,
|
|
26006
|
-
options: target.options,
|
|
26007
|
-
...file === void 0 ? {} : { secrets: { [target.secretName]: { file } } },
|
|
26008
|
-
...prefix === void 0 ? {} : { prefix }
|
|
26009
|
-
};
|
|
26010
|
-
const next = {
|
|
26011
|
-
...settings,
|
|
26012
|
-
storage
|
|
26013
|
-
};
|
|
26014
|
-
if (options.pinLocalSessions) {
|
|
26015
|
-
next.sessions = {
|
|
26016
|
-
...settings.sessions,
|
|
26017
|
-
storage: LOCAL_SESSIONS_STORAGE
|
|
26018
|
-
};
|
|
26019
|
-
next.teamJoin = { storage: storageFingerprint(storage) };
|
|
26020
|
-
}
|
|
26021
|
-
try {
|
|
26022
|
-
writeSettingsFile(settingsPath, JSON.stringify(next, null, 2));
|
|
26023
|
-
} catch (error) {
|
|
26024
|
-
const failure = settingsWriteError(settingsPath, error, unchanged);
|
|
26025
|
-
if (created !== void 0) cleanupAfter(failure, () => rmSync$1(created, { force: true }));
|
|
26026
|
-
throw failure;
|
|
26027
|
-
}
|
|
26028
|
-
return {
|
|
26029
|
-
storage,
|
|
26030
|
-
previous,
|
|
26031
|
-
previousPin: settings.sessions?.storage,
|
|
26032
|
-
tokenPath,
|
|
26033
|
-
reused
|
|
26034
|
-
};
|
|
26035
|
-
});
|
|
26036
|
-
return {
|
|
26037
|
-
settingsPath,
|
|
26038
|
-
storage,
|
|
26039
|
-
...options.pinLocalSessions ? { sessionsStorage: LOCAL_SESSIONS_STORAGE } : {},
|
|
26040
|
-
...tokenPath === void 0 ? {} : { tokenPath },
|
|
26041
|
-
token: tokenPath === void 0 ? "none" : reused === void 0 ? "new" : "reused",
|
|
26042
|
-
...plan.reference === void 0 ? {} : { referencedFile: plan.reference },
|
|
26043
|
-
...previous === void 0 || JSON.stringify(previous) === JSON.stringify(storage) ? {} : { replaced: describePrevious(() => selectStorage(previous, "settings", "storage", "")) },
|
|
26044
|
-
...options.pinLocalSessions && previousPin !== void 0 && !isLocalSessionsPin(previousPin) ? { replacedSessionsStorage: describePrevious(() => selectSessionSetting(previousPin, "sessions.storage", agentDir)) } : {}
|
|
26045
|
-
};
|
|
26046
|
-
}
|
|
26047
|
-
function describePrevious(select) {
|
|
26048
|
-
try {
|
|
26049
|
-
return describeStorageSelection(select());
|
|
26050
|
-
} catch (error) {
|
|
26051
|
-
if (error instanceof StorageError) return "an invalid selection";
|
|
26052
|
-
throw error;
|
|
26053
|
-
}
|
|
26054
|
-
}
|
|
26055
|
-
async function restartBroker(agentDir, context, onProgress) {
|
|
26056
|
-
try {
|
|
26057
|
-
return await (context.loadControl ? await context.loadControl() : await (await import("../core/intercom-broker-control.code.js").catch((error) => __atomicOnDemandFailed(error, "intercom"))).loadIntercomBrokerControl()).restartIntercomBroker(agentDir, onProgress === void 0 ? {} : { onProgress });
|
|
26058
|
-
} catch (error) {
|
|
26059
|
-
return {
|
|
26060
|
-
status: "failed",
|
|
26061
|
-
error: new TeamProfileError("broker-restart-failed", {
|
|
26062
|
-
subject: agentDir,
|
|
26063
|
-
detail: describeStorageError$1(error),
|
|
26064
|
-
hint: "The settings are saved. Run `atomic intercom restart` so the broker uses them.",
|
|
26065
|
-
cause: error
|
|
26066
|
-
})
|
|
26067
|
-
};
|
|
26068
|
-
}
|
|
26069
|
-
}
|
|
26070
|
-
const installedAdapters = /* @__PURE__ */ new Map();
|
|
26071
|
-
async function loadTeamAdapter(agentDir, reason) {
|
|
26072
|
-
try {
|
|
26073
|
-
await loadStorageAdapter(LIBSQL_ADAPTER_PACKAGE, {
|
|
26074
|
-
agentDir,
|
|
26075
|
-
domain: "sessions"
|
|
26076
|
-
});
|
|
26077
|
-
} catch (error) {
|
|
26078
|
-
if (!(error instanceof StorageAdapterLoadError)) throw error;
|
|
26079
|
-
throw new TeamProfileError("adapter-not-installed", {
|
|
26080
|
-
subject: `${LIBSQL_ADAPTER_PACKAGE} for ${agentDir}`,
|
|
26081
|
-
detail: describeStorageError$1(error.cause instanceof Error ? error.cause : error),
|
|
26082
|
-
hint: `${reason} opens the team database through it. Install it, then run again: atomic install npm:${LIBSQL_ADAPTER_PACKAGE}`,
|
|
26083
|
-
cause: error
|
|
26084
|
-
});
|
|
26085
|
-
}
|
|
26086
|
-
}
|
|
26087
|
-
/**
|
|
26088
|
-
* Whether `ATOMIC_PROFILE=ci` still selects the team database in this process. `--storage` and `ATOMIC_STORAGE`
|
|
26089
|
-
* outrank it for sessions and the Intercom broker alike, while a domain variable outranks it only for
|
|
26090
|
-
* its own store. So the profile selects some store exactly when it is the shared selection the broker receives.
|
|
26091
|
-
*/
|
|
26092
|
-
async function teamProfileInEffect() {
|
|
26093
|
-
const team = await environmentTeamProfileAsync();
|
|
26094
|
-
return team !== void 0 && await processSharedStorageSelectionAsync() === JSON.stringify(team);
|
|
26095
|
-
}
|
|
26096
|
-
/**
|
|
26097
|
-
* Fail fast, before any store opens, when this process selects the team database but cannot load the libSQL
|
|
26098
|
-
* adapter: `ATOMIC_PROFILE=ci` while it selects a store, or an SDK `storage` selection naming the adapter. The
|
|
26099
|
-
* adapter is loaded, not opened, once per agent directory and process. The CLI checks at startup and
|
|
26100
|
-
* `createAgentSession` before it creates a session.
|
|
26101
|
-
*/
|
|
26102
|
-
async function assertTeamAdapterInstalled(agentDir, selection) {
|
|
26103
|
-
const reason = await teamProfileInEffect() ? "ATOMIC_PROFILE=ci" : selection !== void 0 && "adapter" in selection && selection.adapter === LIBSQL_ADAPTER_PACKAGE ? "The storage selection" : void 0;
|
|
26104
|
-
if (reason === void 0) return;
|
|
26105
|
-
const key = resolve$1(agentDir);
|
|
26106
|
-
let check = installedAdapters.get(key);
|
|
26107
|
-
if (check === void 0) {
|
|
26108
|
-
const current = loadTeamAdapter(key, reason).catch((error) => {
|
|
26109
|
-
if (installedAdapters.get(key) === current) installedAdapters.delete(key);
|
|
26110
|
-
throw error;
|
|
26111
|
-
});
|
|
26112
|
-
installedAdapters.set(key, current);
|
|
26113
|
-
check = current;
|
|
26114
|
-
}
|
|
26115
|
-
return check;
|
|
26116
|
-
}
|
|
26117
|
-
/** `joinTeam` with the input source its errors name and the CLI's broker control. */
|
|
26118
|
-
async function joinTeamWith(options, source, context = {}) {
|
|
26119
|
-
const joined = await joinSharedDatabase({
|
|
26120
|
-
...options,
|
|
26121
|
-
pinLocalSessions: true
|
|
26122
|
-
}, source, context.connectionTimeoutMs ?? 15e3);
|
|
26123
|
-
context.onJoined?.(joined);
|
|
26124
|
-
const broker = await restartBroker(dirname$1(joined.settingsPath), context, options.onProgress);
|
|
26125
|
-
return {
|
|
26126
|
-
...joined,
|
|
26127
|
-
sessionsStorage: LOCAL_SESSIONS_STORAGE,
|
|
26128
|
-
broker
|
|
26129
|
-
};
|
|
26130
|
-
}
|
|
26131
|
-
/**
|
|
26132
|
-
* Use a team database for Intercom while sessions stay private: checks every input and the
|
|
26133
|
-
* connection first, then sets the global `storage` setting to the team database and `sessions.storage` to the local
|
|
26134
|
-
* default store in one settings write, and restarts the Intercom broker so it routes through the team database.
|
|
26135
|
-
* Throws {@link TeamProfileConfigError} for an invalid input and {@link TeamProfileError} otherwise; on any thrown
|
|
26136
|
-
* failure nothing was changed. A failed broker restart is reported in `broker`, not thrown.
|
|
26137
|
-
*/
|
|
26138
|
-
function joinTeam(options) {
|
|
26139
|
-
return joinTeamWith(options, "sdk");
|
|
26140
|
-
}
|
|
26141
|
-
function canonicalJson(value) {
|
|
26142
|
-
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
26143
|
-
if (value !== null && typeof value === "object") return `{${Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(",")}}`;
|
|
26144
|
-
return JSON.stringify(value);
|
|
26145
|
-
}
|
|
26146
|
-
function storageFingerprint(storage) {
|
|
26147
|
-
return `sha256:${createHash("sha256").update(canonicalJson(storage)).digest("hex")}`;
|
|
26148
|
-
}
|
|
26149
|
-
/** Whether `storage` is exactly the selection the last team join recorded, for this agent directory. */
|
|
26150
|
-
function isJoinedStorage(storage, record, agentDir) {
|
|
26151
|
-
if (storage === void 0 || record?.storage !== storageFingerprint(storage)) return false;
|
|
26152
|
-
if (storage.adapter !== LIBSQL_ADAPTER_PACKAGE) return false;
|
|
26153
|
-
const keys = Object.keys(storage).filter((key) => key !== "prefix" && key !== "secrets");
|
|
26154
|
-
if (keys.length !== 2 || !keys.includes("adapter") || !keys.includes("options")) return false;
|
|
26155
|
-
const options = storage.options ?? {};
|
|
26156
|
-
if (Object.keys(options).length !== 1 || typeof options.url !== "string") return false;
|
|
26157
|
-
if (storage.secrets === void 0) return isFileUrl(options.url);
|
|
26158
|
-
const names = Object.keys(storage.secrets);
|
|
26159
|
-
const path = secretFilePath(storage.secrets.authToken, agentDir);
|
|
26160
|
-
return names.length === 1 && path !== void 0 && isJoinTokenFile(path, agentDir);
|
|
26161
|
-
}
|
|
26162
|
-
function isLocalSessionsPin(value) {
|
|
26163
|
-
return value !== void 0 && JSON.stringify(Object.keys(value)) === JSON.stringify(["path"]) && "path" in value && value.path === LOCAL_SESSIONS_STORAGE.path;
|
|
26164
|
-
}
|
|
26165
|
-
/** Every token file the given settings reference. */
|
|
26166
|
-
function referencedTokenFiles(settings, agentDir) {
|
|
26167
|
-
const workflows = settings.workflows;
|
|
26168
|
-
const journal = workflows !== null && typeof workflows === "object" && !Array.isArray(workflows) ? workflows.journal : void 0;
|
|
26169
|
-
const sessions = settings.sessions?.storage;
|
|
26170
|
-
return [
|
|
26171
|
-
settings.storage,
|
|
26172
|
-
journal,
|
|
26173
|
-
sessions && !("dir" in sessions) ? sessions : void 0
|
|
26174
|
-
].flatMap((selection) => Object.values(selection?.secrets ?? {}).flatMap((ref) => secretFilePath(ref, agentDir) ?? []));
|
|
26175
|
-
}
|
|
26176
|
-
function projectSettingsPathOf(cwd) {
|
|
26177
|
-
return getProjectConfigPaths(cwd, "settings.json")[0];
|
|
26178
|
-
}
|
|
26179
|
-
function isSameFile(first, second) {
|
|
26180
|
-
return existsSync$1(first) && existsSync$1(second) && realpathSync$1(first) === realpathSync$1(second);
|
|
26181
|
-
}
|
|
26182
|
-
function readIndependentProjectSettings(cwd, settingsPath) {
|
|
26183
|
-
let merged = {};
|
|
26184
|
-
for (const path of getProjectConfigPaths(cwd, "settings.json").reverse()) {
|
|
26185
|
-
if (!existsSync$1(path) || isSameFile(settingsPath, path)) continue;
|
|
26186
|
-
try {
|
|
26187
|
-
merged = deepMergeSettings(merged, parseJsonFileContent(readFileSync$1(path, "utf-8")));
|
|
26188
|
-
} catch (error) {
|
|
26189
|
-
throw unreadableSettingsError(path, error);
|
|
26190
|
-
}
|
|
26191
|
-
}
|
|
26192
|
-
return merged;
|
|
26193
|
-
}
|
|
26194
|
-
function readIndependentGlobalSettings(agentDir, settingsPath) {
|
|
26195
|
-
const paths = agentDir === getAgentDir() ? getAgentConfigPaths("settings.json") : [settingsPath];
|
|
26196
|
-
let merged = {};
|
|
26197
|
-
for (const path of paths.reverse()) {
|
|
26198
|
-
if (!existsSync$1(path) || isSameFile(settingsPath, path)) continue;
|
|
26199
|
-
try {
|
|
26200
|
-
merged = deepMergeSettings(merged, parseJsonFileContent(readFileSync$1(path, "utf-8")));
|
|
26201
|
-
} catch (error) {
|
|
26202
|
-
throw unreadableSettingsError(path, error);
|
|
26203
|
-
}
|
|
26204
|
-
}
|
|
26205
|
-
return merged;
|
|
26206
|
-
}
|
|
26207
|
-
function readProjectSettings(cwd, agentDir) {
|
|
26208
|
-
const projectPath = projectSettingsPathOf(cwd);
|
|
26209
|
-
const storage = new FileSettingsStorage(cwd, agentDir, { projectReadPaths: getProjectConfigPaths(cwd, "settings.json") });
|
|
26210
|
-
try {
|
|
26211
|
-
let merged;
|
|
26212
|
-
storage.withLock("project", (current) => {
|
|
26213
|
-
merged = current;
|
|
26214
|
-
});
|
|
26215
|
-
return merged === void 0 ? {} : parseJsonFileContent(merged);
|
|
26216
|
-
} catch (error) {
|
|
26217
|
-
if (isLocked(error)) throw lockedError(projectPath, error, "Nothing was changed.");
|
|
26218
|
-
throw unreadableSettingsError(projectPath, error);
|
|
26219
|
-
}
|
|
26220
|
-
}
|
|
26221
|
-
/** `leaveTeam` with the CLI's broker control. */
|
|
26222
|
-
async function leaveTeamWith(options = {}, context = {}) {
|
|
26223
|
-
const agentDir = resolve$1(options.agentDir ?? getAgentDir());
|
|
26224
|
-
const cwd = resolve$1(options.cwd ?? process.cwd());
|
|
26225
|
-
const settingsPath = settingsPathOf(agentDir);
|
|
26226
|
-
openGlobalSettings(cwd, agentDir);
|
|
26227
|
-
const unchanged = "Nothing was changed.";
|
|
26228
|
-
const empty = {
|
|
26229
|
-
settingsPath,
|
|
26230
|
-
removed: [],
|
|
26231
|
-
kept: [],
|
|
26232
|
-
deletedTokenFiles: [],
|
|
26233
|
-
keptTokenFiles: []
|
|
26234
|
-
};
|
|
26235
|
-
if (!existsSync$1(settingsPath)) return empty;
|
|
26236
|
-
const trusted = projectTrust(cwd, agentDir);
|
|
26237
|
-
await Promise.all([prepareLockTakeover(`${settingsPath}.lock`), prepareLockTakeover(`${projectSettingsPathOf(cwd)}.lock`)]);
|
|
26238
|
-
const outcome = withGlobalSettings(agentDir, unchanged, (global) => {
|
|
26239
|
-
const project = isSameFile(settingsPath, projectSettingsPathOf(cwd)) ? readIndependentProjectSettings(cwd, settingsPath) : readProjectSettings(cwd, agentDir);
|
|
26240
|
-
const inherited = readIndependentGlobalSettings(agentDir, settingsPath);
|
|
26241
|
-
const storage = global.storage;
|
|
26242
|
-
const removed = [];
|
|
26243
|
-
const kept = [];
|
|
26244
|
-
if (isJoinedStorage(storage, global.teamJoin, agentDir)) removed.push("storage");
|
|
26245
|
-
else if (storage !== void 0) kept.push({
|
|
26246
|
-
key: "storage",
|
|
26247
|
-
reason: "changed"
|
|
26248
|
-
});
|
|
26249
|
-
const pin = global.sessions?.storage;
|
|
26250
|
-
const storageRemains = storage !== void 0 && !removed.includes("storage") || inherited.storage !== void 0 || trusted && project.storage !== void 0;
|
|
26251
|
-
if (isLocalSessionsPin(pin)) {
|
|
26252
|
-
if (storageRemains) kept.push({
|
|
26253
|
-
key: "sessions.storage",
|
|
26254
|
-
reason: "storage-remains"
|
|
26255
|
-
});
|
|
26256
|
-
else removed.push("sessions.storage");
|
|
26257
|
-
} else if (pin !== void 0) kept.push({
|
|
26258
|
-
key: "sessions.storage",
|
|
26259
|
-
reason: "changed"
|
|
26260
|
-
});
|
|
26261
|
-
if (removed.length === 0) return {
|
|
26262
|
-
...empty,
|
|
26263
|
-
kept
|
|
26264
|
-
};
|
|
26265
|
-
const tokenPath = removed.includes("storage") ? secretFilePath(storage?.secrets?.authToken, agentDir) : void 0;
|
|
26266
|
-
const next = { ...global };
|
|
26267
|
-
if (removed.includes("storage")) delete next.storage;
|
|
26268
|
-
if (next.storage === void 0) delete next.teamJoin;
|
|
26269
|
-
if (removed.includes("sessions.storage")) {
|
|
26270
|
-
const { storage: _pin, ...sessions } = { ...global.sessions };
|
|
26271
|
-
if (Object.keys(sessions).length === 0) delete next.sessions;
|
|
26272
|
-
else next.sessions = sessions;
|
|
26273
|
-
}
|
|
26274
|
-
try {
|
|
26275
|
-
writeSettingsFile(settingsPath, JSON.stringify(next, null, 2));
|
|
26276
|
-
} catch (error) {
|
|
26277
|
-
throw settingsWriteError(settingsPath, error, unchanged);
|
|
26278
|
-
}
|
|
26279
|
-
const deletedTokenFiles = [];
|
|
26280
|
-
const keptTokenFiles = [];
|
|
26281
|
-
let tokenFailure;
|
|
26282
|
-
if (tokenPath !== void 0) {
|
|
26283
|
-
if ([
|
|
26284
|
-
next,
|
|
26285
|
-
inherited,
|
|
26286
|
-
project
|
|
26287
|
-
].flatMap((settings) => referencedTokenFiles(settings, agentDir)).includes(tokenPath)) keptTokenFiles.push(tokenPath);
|
|
26288
|
-
else try {
|
|
26289
|
-
rmSync$1(tokenPath, { force: true });
|
|
26290
|
-
deletedTokenFiles.push(tokenPath);
|
|
26291
|
-
} catch (error) {
|
|
26292
|
-
tokenFailure = new TeamProfileError("token-delete-failed", {
|
|
26293
|
-
subject: tokenPath,
|
|
26294
|
-
detail: describeStorageError$1(error),
|
|
26295
|
-
hint: "The team settings were removed. Delete the token file yourself.",
|
|
26296
|
-
cause: error
|
|
26297
|
-
});
|
|
26298
|
-
}
|
|
26299
|
-
}
|
|
26300
|
-
return {
|
|
26301
|
-
settingsPath,
|
|
26302
|
-
removed,
|
|
26303
|
-
kept,
|
|
26304
|
-
deletedTokenFiles,
|
|
26305
|
-
keptTokenFiles,
|
|
26306
|
-
tokenFailure
|
|
26307
|
-
};
|
|
26308
|
-
});
|
|
26309
|
-
if (outcome.removed.length === 0) return outcome;
|
|
26310
|
-
context.onLeft?.({
|
|
26311
|
-
settingsPath,
|
|
26312
|
-
removed: outcome.removed,
|
|
26313
|
-
kept: outcome.kept
|
|
26314
|
-
});
|
|
26315
|
-
const broker = outcome.removed.includes("storage") ? await restartBroker(agentDir, context, options.onProgress) : void 0;
|
|
26316
|
-
if ("tokenFailure" in outcome && outcome.tokenFailure !== void 0) throw outcome.tokenFailure;
|
|
26317
|
-
return {
|
|
26318
|
-
settingsPath,
|
|
26319
|
-
removed: outcome.removed,
|
|
26320
|
-
kept: outcome.kept,
|
|
26321
|
-
deletedTokenFiles: outcome.deletedTokenFiles,
|
|
26322
|
-
keptTokenFiles: outcome.keptTokenFiles,
|
|
26323
|
-
...broker === void 0 ? {} : { broker }
|
|
26324
|
-
};
|
|
26325
|
-
}
|
|
26326
|
-
/**
|
|
26327
|
-
* Restore the individual layout: remove the global `storage` setting and the `sessions.storage` pin when they hold
|
|
26328
|
-
* exactly what `joinTeam` writes, leave every other value in place, delete the removed selection's token file unless
|
|
26329
|
-
* another setting references it, and restart the Intercom broker when `storage` was removed. The pin is kept while
|
|
26330
|
-
* another `storage` remains, because sessions would otherwise move to it. Running it again changes nothing.
|
|
26331
|
-
*/
|
|
26332
|
-
function leaveTeam(options = {}) {
|
|
26333
|
-
return leaveTeamWith(options);
|
|
26334
|
-
}
|
|
26335
|
-
function isLocalDefault(selection, agentDir, settings) {
|
|
26336
|
-
return selection.kind === "sqlite" && !selection.prefix && resolve$1(selection.path) === resolve$1(defaultSessionDatabasePath(agentDir, settings));
|
|
26337
|
-
}
|
|
26338
|
-
/**
|
|
26339
|
-
* The layout in effect for this process and working directory, from the storage each domain selects (process-level
|
|
26340
|
-
* selections, `ATOMIC_PROFILE=ci`, trusted project settings and global settings, as sessions and the Intercom broker
|
|
26341
|
-
* resolve them). Reads only; an invalid selection throws its `StorageConfigError`.
|
|
26342
|
-
*/
|
|
26343
|
-
function selectTeamProfile(options = {}) {
|
|
26344
|
-
const agentDir = resolve$1(options.agentDir ?? getAgentDir());
|
|
26345
|
-
const cwd = resolve$1(options.cwd ?? process.cwd());
|
|
26346
|
-
const manager = SettingsManager.create(cwd, agentDir, { projectTrusted: projectTrust(cwd, agentDir) });
|
|
26347
|
-
const failure = manager.drainErrors().find(({ invalidKey }) => invalidKey === void 0);
|
|
26348
|
-
if (failure !== void 0) {
|
|
26349
|
-
if (isLocked(failure.error)) throw lockedError(`${failure.scope} settings`, failure.error, "Nothing was read.");
|
|
26350
|
-
throw new TeamProfileError("settings-unreadable", {
|
|
26351
|
-
subject: `${failure.scope} settings`,
|
|
26352
|
-
detail: unreadableSettingsDetail(failure.error),
|
|
26353
|
-
hint: "Fix the settings file, then run the command again.",
|
|
26354
|
-
cause: failure.error
|
|
26355
|
-
});
|
|
26356
|
-
}
|
|
26357
|
-
const merged = manager.getSettings();
|
|
26358
|
-
const sessions = selectSessionStorageWithSettings(cwd, {
|
|
26359
|
-
agentDir,
|
|
26360
|
-
settings: merged
|
|
26361
|
-
});
|
|
26362
|
-
const selected = selectSharedStorage(agentDir, merged);
|
|
26363
|
-
const intercom = selectIntercomStorage(agentDir, manager.getGlobalSettings().storage);
|
|
26364
|
-
const shared = intercom?.kind === "adapter" ? storageSelectionKey(intercom, agentDir) : void 0;
|
|
26365
|
-
const sharesStorage = shared !== void 0 && selected !== void 0 && storageSelectionKey(selected, agentDir) === shared;
|
|
26366
|
-
return {
|
|
26367
|
-
profile: isLocalDefault(sessions, agentDir, merged) && (selected === void 0 || isLocalDefault(selected, agentDir, merged)) && intercom === void 0 ? "individual" : sharesStorage && isLocalDefault(sessions, agentDir, merged) ? "team" : sharesStorage && storageSelectionKey(sessions, agentDir) === shared ? "ci" : "custom",
|
|
26368
|
-
sessions: describeStorageSelection(sessions),
|
|
26369
|
-
intercom: intercom === void 0 ? "off" : describeStorageSelection(intercom)
|
|
26370
|
-
};
|
|
26371
|
-
}
|
|
26372
25278
|
// dist/cli/file-processor.js
|
|
26373
25279
|
/**
|
|
26374
25280
|
* Process @file CLI arguments into text content and image attachments
|
|
@@ -27686,6 +26592,14 @@ function appendBoundedStderr(existing, chunk) {
|
|
|
27686
26592
|
while (start < bytes.length && (bytes[start] & 192) === 128) start++;
|
|
27687
26593
|
return `${bytes.subarray(start).toString("utf8")}${marker}`;
|
|
27688
26594
|
}
|
|
26595
|
+
/**
|
|
26596
|
+
* `<name>(<pid>) MallocStackLogging: …`, a macOS notice. Once a memory-pressure or memory-limit event has made libmalloc
|
|
26597
|
+
* load its stack-logging support, every fork() of that process prints "can't turn off malloc stack logging because it
|
|
26598
|
+
* was not enabled" from inside fork(), to the parent's stderr, before the child sets up its own stdio. The native task
|
|
26599
|
+
* supervisor forks to start each command in a session of its own, so the engine's stderr got one per command. It is
|
|
26600
|
+
* the OS's, never the child's, and nothing a user can act on.
|
|
26601
|
+
*/
|
|
26602
|
+
const MACOS_STACK_LOGGING_NOTICE = /^\S+\(\d+\) MallocStackLogging: .*(?:\n|$)/gm;
|
|
27689
26603
|
/** Batch noisy child output outside the pipe callback without filesystem work. */
|
|
27690
26604
|
function createStderrReporter(report) {
|
|
27691
26605
|
let pending = "";
|
|
@@ -27695,10 +26609,10 @@ function createStderrReporter(report) {
|
|
|
27695
26609
|
if (scheduled) return;
|
|
27696
26610
|
scheduled = true;
|
|
27697
26611
|
setImmediate(() => {
|
|
27698
|
-
const message = pending;
|
|
26612
|
+
const message = pending.replace(MACOS_STACK_LOGGING_NOTICE, "");
|
|
27699
26613
|
pending = "";
|
|
27700
26614
|
scheduled = false;
|
|
27701
|
-
report(message);
|
|
26615
|
+
if (message) report(message);
|
|
27702
26616
|
});
|
|
27703
26617
|
};
|
|
27704
26618
|
}
|
|
@@ -28776,16 +27690,16 @@ function getArtifactManager(artifactsDir) {
|
|
|
28776
27690
|
}
|
|
28777
27691
|
return manager;
|
|
28778
27692
|
}
|
|
28779
|
-
export { ACTIONS_GITHUB_BASE_URL_ENV, BASH_SHELL_PRESENTATION, BLUEPRINT_FULL_BUILD_MAX_AGE_MS, BLUEPRINT_STEP_TIMEOUT_MS, DEGRADED_RESTORE_RETENTION_DAYS, ENGINE_SESSION_STORAGE_FLAG, ENGINE_SHUTDOWN_GRACE_MS, EVENT_REPORT_MESSAGE_TYPE, EVENT_SUBSCRIPTION_CHILD_ENTRY_TYPE, EVENT_SUBSCRIPTION_ENTRY_TYPE, EVENT_SUBSCRIPTION_PROCESSED_ENTRY_TYPE, FooterDataProvider, HistoryTaskRegistry, RpcClient, SETUP_COMMAND_ALIAS,
|
|
27693
|
+
export { ACTIONS_GITHUB_BASE_URL_ENV, BASH_SHELL_PRESENTATION, BLUEPRINT_FULL_BUILD_MAX_AGE_MS, BLUEPRINT_STEP_TIMEOUT_MS, DEGRADED_RESTORE_RETENTION_DAYS, ENGINE_SESSION_STORAGE_FLAG, ENGINE_SHUTDOWN_GRACE_MS, EVENT_REPORT_MESSAGE_TYPE, EVENT_SUBSCRIPTION_CHILD_ENTRY_TYPE, EVENT_SUBSCRIPTION_ENTRY_TYPE, EVENT_SUBSCRIPTION_PROCESSED_ENTRY_TYPE, FileSettingsStorage, FooterDataProvider, HistoryTaskRegistry, RpcClient, SETUP_COMMAND_ALIAS, SUBSCRIPTION_REPORT_TOOL_NAME, SessionWorktreeSnapshotRecorder, SettingsFileChangedError, SettingsManager, adoptInlineSnapshotBlobs, agentPanelExtensionItems, agentPanelItems, agentPanelSourceHubOf, agentPanelSourcesGeneration, agentPanelTaskId, agentSessionSummaryMethods, agentSessionTreeMethods, answerAgentPanelItem, appendBoundedStderr, applyReadLineSelection, applyToolModifiers, bashToolSystemPromptContribution, bindTaskTranscriptFragments, blueprintNotices, blueprintRepository, boundExtensionRuntimes, buildInteractiveEngineArgs, builtinToolBlockPresentation, canIsolateSessionStore, cancelSessionSubscriptions, checkoutsNeedingRebuild, collectEntriesForBranchSummary, compareWorktreeSnapshot, composeInternalRouters, continueSessionWhereItWorked, copyPanelItemStableKey, createBashTool, createBashToolDefinition, createCodingTools, createEditTool, createEditToolDefinition, createExtensionAPI, createExtensionRuntime, createFindTool, createFindToolDefinition, createHistoryRouter, createKillTool, createKillToolDefinition, createLoadedToolDefinition, createLocalBashOperations, createLocalPowerShellOperations, createLsTool, createLsToolDefinition, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createSearchTool, createSearchToolDefinition, createSubscriberReportTool, createToolDefinitionsFor, createWriteTool, createWriteToolDefinition, currentWorktreeRestoreNotices, currentWorktreeRootMappings, currentWorktreeSnapshots, decodeReadableUrl, defaultToolSelectionFor, degradedRestorePin, deleteSessionWithSnapshotRefs, describeBlueprints, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeWorktreeRestoreStatus, describeWorktreeSnapshot, discardDegradedRestore, dismissedAgentPanelItems, drainExtensionAPIWork, editToolSystemPromptContribution, extractDocumentMarkdown, findToolSystemPromptContribution, findUnansweredToolCall, formatDegradedRestoreNotice, formatEventReport, formatToolBlockElapsed, formatUnrestoredNotice, formatWorktreeRestoreNotice, formatWorktreeRestoreWarning, generateBranchSummary, generateDiffString, generateUnifiedPatch, getArtifactManager, getEngineSessionStorage, hasSubagentCaptures, hostStoragePackagesRegistered, inheritChildSessionOptionsWithDefaults, inheritedRemotes, inlineSnapshotBlobs, isBuiltinToolCallRenderer, isBuiltinToolResultRenderer, isDocumentPath, isInside$1 as isInside, isInterruptedPanelTask, isPlainRuntimeMetadataCommand, latestSessionSnapshot, latestSessionSnapshotAsync, launchedTaskViewSource, lazyTaskPanelItem, liveTaskRowOrigin, loadProjectContextFiles, loadProjectContextFilesAsync, lsToolSystemPromptContribution, mapPathForCwd, mapPathForCwdAsync, mapRestoredPath, mapRestoredPathAsync, markInterruptedPanelTask, materializePanelItem, modelHasReasoning, needsRebuild, notifyAgentPanelChanged, notifyAgentPanelSourceHubRebound, onOwnerTaskAction, openAgentPanelItem, openSessionInWorktree, ownerTaskViewSource, panelItemStableKey, parentHistoryNotices, parseActionReference, pathExists, plainNoticeBlock, prepareBranchEntries, prepareInitialMessage, prepareSessionResume, prewarmHostDefaultModelApi, prewarmInteractiveEngineRpcMode, projectSettingsChooseSessionStorage, promptAnswerOptionsOf, readTaskDetailForView, readTaskPageForChat, readTaskPageForView, readToolSystemPromptContribution, recordBlueprintContext, recordRestoredWorktreeContext, registerHostStoragePackages, registerHostStoragePackagesAsync, releaseSessionWorktrees, removeSavedModelRoutingSettings, removeSavedModelRoutingSettingsAsync, resolveAppMode, resolveCliPaths, resolveExcludedToolsForAppMode, resolveExistingPromptSourcePath, resolveExistingPromptSourcePaths, resolvePackageStorageAdapter, resolvePromptInput, resolveSessionStore, resumeSessionWorktree, resumeStoreDir, retainTaskWindowReader, retireExtensionAPI, runAction, runBlueprintBuild, runExtensionAPICleanup, runMigrations, runMigrationsAsync, runResourceRegistrationBatch, sampleAgentPanelSources, savedBoundaryCursor, savedProjectTrust, savedProjectTrustAsync, sealExtensionAPI, searchToolSystemPromptContribution, seedEventPrompt, selectSessionSetting, selectSessionStorage, selectSessionStorageWithSettings, selectSessionStorageWithSettingsAsync, serializeConversation, sessionManagerContinuesIn, sessionManagerRunsInRecordedCheckout, sessionResumeOptions, sessionSnapshotBlobs, sessionStorageSettingsDiffer, setUpResumedBlueprints, settingsFileTarget, settingsFileTargetAsync, shellCommandPrefixFor, shortTaskTitle, shouldStartRpcCatalogRefresh, showDeprecationWarnings, snapshotBlobInliner, sourceError, stopAgentPanelItem, subscribeAgentPanel, subscribeAgentPanelExtensions, subscribeSession, takeEngineSessionStorageArg, taskCursorsAround, taskPanelItem, taskPanelItems, taskPanelModel, taskPanelRole, taskPanelState, taskRunGeneration, taskTranscriptFile, taskTranscriptFragments, taskTranscriptUnsavedAnswer, toPrintOutputMode, toolsWithReport, withTaskTranscriptArchive, withWorktreeRestoreNotices, withWorktreeRootMappings, worktreeNeedsRestore, worktreeRestoreNotices, writeSettingsFile, writeSettingsFileAsync, writeToolSystemPromptContribution };
|
|
28780
27694
|
|
|
28781
|
-
//# sourceMappingURL=startup-8-1-
|
|
27695
|
+
//# sourceMappingURL=startup-8-1-LZFXSD3Z.js.map
|
|
28782
27696
|
// __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
|
|
28783
27697
|
// demand that fails in a process an in-place update left running says to restart.
|
|
28784
27698
|
function __atomicOnDemandFailed(error, feature) {
|
|
28785
27699
|
return (async () => {
|
|
28786
27700
|
const root = new URL("../", import.meta.url);
|
|
28787
27701
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
28788
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
27702
|
+
const key = `${root.href}#0.10.11-alpha.3`;
|
|
28789
27703
|
let release = releases.get(key);
|
|
28790
27704
|
if (release === undefined) {
|
|
28791
27705
|
const current = (async () => {
|
|
@@ -28813,7 +27727,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
28813
27727
|
} catch {
|
|
28814
27728
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
28815
27729
|
}
|
|
28816
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.
|
|
27730
|
+
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;
|
|
28817
27731
|
if (updatedTo === undefined) throw error;
|
|
28818
27732
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
28819
27733
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|