@bastani/atomic 0.10.9 → 0.10.10-alpha.2
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 +83 -0
- package/README.md +226 -163
- 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 +27 -12
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
- package/dist/_shared/sdk-RRLVN7ER.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/settings-startup-8-DNZ2RIHM.js +4 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
- package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
- package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
- package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +150 -62
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
- package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
- package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
- package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
- package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
- package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +87 -116
- package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
- package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
- package/dist/builtin/intercom/group.ts +7 -3
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/README.md +61 -27
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/README.md +74 -141
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/README.md +61 -88
- package/dist/builtin/web-access/index.bundle.mjs +387 -351
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +2 -2
- 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.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- 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 +2 -2
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/compaction/compactor.d.ts +20 -14
- package/dist/core/compaction/errors.d.ts +120 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/model-resolver.d.ts +2 -2
- 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.code.js +1 -1
- 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/api-types.d.ts +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- 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/provider-types.d.ts +18 -6
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.js +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-config.d.ts +40 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-resolver-scope.d.ts +4 -4
- package/dist/core/model-runtime.d.ts +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/provider-composer-internal.d.ts +11 -2
- 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.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- 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/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- 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 +2 -2
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +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/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.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/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- 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.code.js +1 -1
- 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.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +2 -2
- 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.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +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 +2 -2
- 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-extensions.d.ts +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -7
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +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/theme/color-utils.d.ts +5 -5
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
- package/dist/modes/rpc/rpc-types.d.ts +29 -2
- package/dist/package-manager-cli.code.js +5 -5
- 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/5.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -2
- package/dist/startup-stages/9.js +2 -1
- package/dist/utils/native-module.d.ts +44 -0
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks.md +238 -243
- package/docs/build.md +21 -15
- package/docs/changelog.mdx +1 -1
- package/docs/codemode.md +68 -51
- package/docs/compaction/reference.md +65 -26
- package/docs/compaction.md +118 -66
- package/docs/computer-use.md +179 -146
- package/docs/containerization.md +87 -33
- package/docs/custom-provider/api-reference.md +152 -13
- package/docs/custom-provider/oauth.md +45 -28
- package/docs/custom-provider/override.md +14 -7
- package/docs/custom-provider/registration.md +77 -67
- package/docs/custom-provider/streaming.md +42 -19
- package/docs/custom-provider.md +26 -62
- package/docs/development.md +81 -42
- package/docs/docs.json +54 -38
- package/docs/environment-variables.md +92 -64
- package/docs/extensions/api-reference.md +326 -735
- package/docs/extensions/authoring.md +186 -269
- package/docs/extensions/events.md +308 -375
- package/docs/extensions/examples.md +122 -74
- package/docs/extensions/ui.md +217 -197
- package/docs/extensions.md +189 -259
- package/docs/getting-started/authentication.md +27 -14
- package/docs/getting-started/first-session.md +25 -26
- package/docs/getting-started/installation.md +62 -84
- package/docs/getting-started/project-instructions.md +39 -14
- package/docs/guides/configuration.md +62 -20
- package/docs/guides/intercom.md +20 -12
- package/docs/guides/non-interactive.md +31 -16
- package/docs/guides/orchestration.md +17 -9
- package/docs/guides/resume-on-any-machine.md +63 -52
- package/docs/guides/subagents.md +26 -14
- package/docs/guides/team-setup.md +49 -27
- package/docs/guides.md +30 -23
- package/docs/herdr.md +22 -17
- package/docs/index.md +24 -17
- package/docs/intercom/operations.md +90 -66
- package/docs/intercom/reference.md +219 -192
- package/docs/intercom.md +111 -92
- package/docs/json.md +73 -71
- package/docs/keybindings.md +74 -48
- package/docs/libraries/agent-core.md +52 -9
- package/docs/libraries/ai.md +90 -63
- package/docs/libraries/codemode.md +31 -8
- package/docs/libraries/schema.md +12 -9
- package/docs/libraries/storage-libsql.md +92 -0
- package/docs/libraries/storage-postgres.md +119 -0
- package/docs/libraries/telemetry.md +42 -9
- package/docs/libraries/tui.md +74 -94
- package/docs/libraries.md +25 -8
- package/docs/llama-cpp.md +38 -33
- package/docs/mcp-servers.md +140 -88
- package/docs/models/reference.md +53 -36
- package/docs/models-configuration.md +19 -13
- package/docs/models.md +102 -87
- package/docs/orchestration/migrating-workflows.md +22 -20
- package/docs/orchestration/patterns.md +36 -21
- package/docs/orchestration.md +24 -21
- package/docs/packages/authoring.md +29 -18
- package/docs/packages/reference.md +77 -16
- package/docs/packages.md +34 -34
- package/docs/programmatic.md +28 -21
- package/docs/prompt-templates.md +65 -41
- package/docs/providers/reference.md +36 -20
- package/docs/providers.md +78 -76
- package/docs/quickstart.md +42 -54
- package/docs/reference/cli.md +256 -254
- package/docs/reference.md +30 -23
- package/docs/rpc/examples.md +121 -17
- package/docs/rpc/extension-ui.md +86 -63
- package/docs/rpc/protocol.md +817 -358
- package/docs/rpc.md +78 -152
- package/docs/sdk/reference.md +309 -73
- package/docs/sdk/storage.md +614 -0
- package/docs/sdk/structured-decisions.md +168 -65
- package/docs/sdk/web-server.md +80 -46
- package/docs/sdk.md +168 -215
- package/docs/security.md +117 -44
- package/docs/session-format.md +127 -76
- package/docs/sessions.md +155 -113
- package/docs/settings.md +293 -205
- package/docs/shell-aliases.md +15 -6
- package/docs/skills/authoring.md +17 -9
- package/docs/skills/reference.md +23 -21
- package/docs/skills.md +148 -97
- package/docs/storage.md +172 -260
- package/docs/subagents/authoring.md +148 -15
- package/docs/subagents/reference.md +105 -29
- package/docs/subagents.md +247 -250
- package/docs/terminal-setup.md +97 -69
- package/docs/termux.md +51 -85
- package/docs/themes/reference.md +51 -37
- package/docs/themes.md +52 -55
- package/docs/tmux.md +38 -21
- package/docs/tools.md +209 -147
- package/docs/tui/reference.md +64 -32
- package/docs/tui.md +38 -66
- package/docs/usage.md +94 -86
- package/docs/verification.md +25 -25
- package/docs/web-access.md +106 -54
- package/docs/windows.md +55 -57
- package/docs/worktree-snapshots.md +82 -74
- package/examples/sdk/11-sessions.ts +4 -4
- package/package.json +8 -8
- package/schemas/models.schema.json +58 -7
- package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
- package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
- package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
package/docs/storage.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Storage"
|
|
3
|
-
|
|
2
|
+
title: "Storage backends"
|
|
3
|
+
sidebarTitle: "Storage"
|
|
4
|
+
description: "Configure local SQLite, PostgreSQL, or Turso/libSQL storage, export and import sessions, and build custom storage adapters."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
#
|
|
7
|
+
Atomic saves sessions in a local SQLite database (`~/.atomic/workflows/journal.sqlite`) by default. You can switch to another SQLite file, a JSONL directory, an in-memory store, PostgreSQL, Turso/libSQL, or a custom database adapter through [storage settings](/settings#sessions) or [per-process overrides](#selecting-storage-per-process).
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
| Track | Start with |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| **CLI and operator setup** | [Which store to choose](#which-store-to-choose), [PostgreSQL](#postgresql), [Turso and libSQL](#turso-and-libsql), [Sharing storage across hosts](#sharing-storage-across-hosts) |
|
|
12
|
+
| **Node.js and TypeScript SDK** | [SDK session storage](/sdk/storage), [SDK and local SQLite API](#sdk-and-local-sqlite-api), [SessionManager API](/session-format#sessionmanager-api) |
|
|
13
|
+
| **Custom adapters and SQL drivers** | [Selecting an adapter](#selecting-an-adapter), [Bring your own driver](#bring-your-own-driver), [Adapter conformance](#adapter-conformance) |
|
|
9
14
|
|
|
10
15
|
- A configured persistent store never silently falls back to memory when it fails to open.
|
|
11
16
|
- A subagent keeps its session in its launching parent's store unless the launch specifies a `sessionDir` for a fresh subagent. Fresh subagent sessions are marked internal and hidden from normal session lists. See [Subagents](/subagents).
|
|
@@ -26,33 +31,38 @@ To move existing sessions between stores, see [Exporting and importing sessions]
|
|
|
26
31
|
|
|
27
32
|
Local SQLite works out of the box with no external server. Atomic enables WAL mode, `FULL` synchronous writes, foreign keys, and cross-process writer queuing automatically.
|
|
28
33
|
|
|
34
|
+
- Passing an empty object `{}` in top-level `storage` selects `<storageHome>/storage.sqlite`. Passing `{}` in `sessions.storage` selects `<storageHome>/workflows/journal.sqlite` (overriding any shared `storage`).
|
|
35
|
+
- JSONL directory stores (`{ "dir": "..." }`) are allowed **only** in `sessions.storage` and `ATOMIC_SESSIONS_STORAGE`. Passing `"dir"` in top-level `storage`, `--storage`, `--storage-file`, or `ATOMIC_STORAGE` fails with `StorageConfigError`.
|
|
36
|
+
|
|
29
37
|
### Storage home
|
|
30
38
|
|
|
31
|
-
Relative `path` and `dir` settings, relative `--storage` and `ATOMIC_STORAGE` paths, relative `secrets.file` paths, and shared `repos/` and `worktrees/` directories resolve against the agent directory's **storage home
|
|
39
|
+
Relative `path` and `dir` settings, relative `--storage` and `ATOMIC_STORAGE` paths, relative `secrets.file` paths, and shared `repos/` and `worktrees/` directories resolve against the agent directory's **storage home**.
|
|
32
40
|
|
|
33
41
|
- **Default agent directory (`~/.atomic/agent`).** Storage home is `~/.atomic` under the current `HOME`. Moving or remounting the home directory keeps relative paths portable.
|
|
34
42
|
- **Custom agent directory (`ATOMIC_CODING_AGENT_DIR`, `PI_CODING_AGENT_DIR`, or SDK `agentDir`).** Storage home is `<agentDir>` itself so sibling profiles stay isolated.
|
|
35
|
-
- **
|
|
43
|
+
- **Upgrading from an older custom agent directory layout.** When a custom agent directory upgrades from an older layout that kept a recognized session database or configured relative path in `<parent>` (other than `~/.atomic`), the first eligible profile keeps using `<parent>` and prints a one-time notice. Profiles that already have their own store stay isolated. Use absolute paths to share a local store intentionally across profiles.
|
|
36
44
|
- **Relative secret files.** A relative `secrets.file` reference can still read an existing file in `<parent>`.
|
|
37
45
|
|
|
38
46
|
`atomic storage status` never creates missing agent directories. A read-only agent directory works with a writable storage home, though recording a new storage-home decision requires a writable agent directory.
|
|
39
47
|
|
|
40
48
|
### Locks in the agent directory
|
|
41
49
|
|
|
42
|
-
Processes that share an agent directory coordinate writes to `settings.json`, `auth.json`, project trust decisions, and session claims using
|
|
50
|
+
Processes that share an agent directory coordinate writes to `settings.json`, `auth.json`, project trust decisions, and session claims using lock files beside those files. If a process exits unexpectedly while holding a lock, the next process takes over automatically.
|
|
43
51
|
|
|
44
52
|
These locks protect only processes on the same machine viewing the agent directory through the same local filesystem. Do not share one agent directory:
|
|
45
53
|
|
|
46
|
-
- across multiple machines on a network filesystem (NFS, SMB, or cloud-synced folders), where
|
|
54
|
+
- across multiple machines on a network filesystem (NFS, SMB, or cloud-synced folders), where OS file locks may not work across hosts;
|
|
47
55
|
- on one machine through both a local path and a container volume, bind mount, or network mount of the same directory.
|
|
48
56
|
|
|
49
57
|
Give each machine or container its own agent directory with `ATOMIC_CODING_AGENT_DIR`, and share sessions through a [shared database](#sharing-storage-across-hosts).
|
|
50
58
|
|
|
51
|
-
If Atomic warns that a
|
|
59
|
+
If Atomic warns that a lock takeover file (such as `settings.json.lock.takeover.lock`) or leftover dead lock directory cannot be opened or removed, another user (such as a previous `sudo` run) owns it. Fix ownership or remove the stale lock, for example `sudo chown $USER ~/.atomic/agent/settings.json.lock.takeover.lock`. Until fixed, stale locks expire after 10 seconds before another process takes over.
|
|
52
60
|
|
|
53
61
|
## PostgreSQL
|
|
54
62
|
|
|
55
|
-
`@bastani/atomic-storage-postgres` stores Atomic's shared state in PostgreSQL 16 or later
|
|
63
|
+
`@bastani/atomic-storage-postgres` stores Atomic's shared state in PostgreSQL. **Atomic sessions require PostgreSQL 16 or later** (for session JSON query functions). The adapter itself accepts PostgreSQL 14 or later on connect for non-session tables, and rejects servers older than PostgreSQL 14.
|
|
64
|
+
|
|
65
|
+
It works with self-hosted PostgreSQL and managed services, including Azure Database for PostgreSQL Flexible Server, Azure HorizonDB, Amazon RDS and Aurora PostgreSQL, Google Cloud SQL, AlloyDB, Neon, and Supabase.
|
|
56
66
|
|
|
57
67
|
### What works on PostgreSQL
|
|
58
68
|
|
|
@@ -88,6 +98,8 @@ Next, run `atomic storage migrate` from a machine with the owner role credential
|
|
|
88
98
|
atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password
|
|
89
99
|
```
|
|
90
100
|
|
|
101
|
+
Passing `--token-file`, `--password-file`, `--auth`, or `--prefix` to `atomic storage migrate` requires passing `--db <url>` too. `atomic storage migrate` has no `--schema` flag; to migrate a custom schema, set `options.schema` in `settings.json`, `--storage`, or `ATOMIC_STORAGE` and run `atomic storage migrate` without `--db`.
|
|
102
|
+
|
|
91
103
|
Then connect to the `atomic` database as `atomic_owner` and grant the runtime role its privileges:
|
|
92
104
|
|
|
93
105
|
```sql
|
|
@@ -104,13 +116,13 @@ These statements grant every privilege the runtime role needs. `LISTEN`, `NOTIFY
|
|
|
104
116
|
|
|
105
117
|
Provider notes:
|
|
106
118
|
|
|
107
|
-
- **Self-hosted PostgreSQL (
|
|
119
|
+
- **Self-hosted PostgreSQL (16+) and Amazon RDS / Aurora.** Use the statements above. On RDS, run `GRANT atomic_owner TO <master user>;` before `CREATE DATABASE ... OWNER atomic_owner`.
|
|
108
120
|
- **Azure Database for PostgreSQL Flexible Server.** Run the statements above as the server administrator (a member of `azure_pg_admin`). If you explicitly select `schema: "public"`, also run `GRANT CREATE ON SCHEMA public TO atomic_owner;` as the administrator.
|
|
109
121
|
- **Google Cloud SQL.** Run the statements above as `postgres` or another member of `cloudsqlsuperuser`.
|
|
110
122
|
|
|
111
123
|
When the runtime role lacks a required privilege or the schema is behind the current Atomic release, opening the store fails with `StorageConfigError` (`reason: "missing-privilege"`). The error names the exact `GRANT` or `atomic storage migrate` command to run.
|
|
112
124
|
|
|
113
|
-
|
|
125
|
+
If you have not run `atomic storage migrate` after an upgrade and a low-privilege runtime role clones a session across connections, Atomic falls back to copying in memory and prints a one-time warning asking you to run `atomic storage migrate` as the owner role.
|
|
114
126
|
|
|
115
127
|
Every Atomic process opens a connection pool of up to 8 connections (`maxConnections`). If your fleet exceeds the server's `max_connections`, lower `maxConnections` or connect through a [connection pooler](#connection-poolers).
|
|
116
128
|
|
|
@@ -139,8 +151,8 @@ atomic storage status
|
|
|
139
151
|
`atomic storage join` accepts `postgres://` and `postgresql://` URLs with a username and no embedded password. Pass exactly one credential option:
|
|
140
152
|
|
|
141
153
|
- `--password-file <path>` copies the password into a private mode-`600` `~/.atomic/agent/storage-token.<id>` file. You can delete the input file afterward.
|
|
142
|
-
- `--token-file <path>` saves the path as-is and rereads the file on every new connection. Use this with a Vault agent or secrets sidecar that rotates credentials automatically.
|
|
143
|
-
- `--auth azure`, `--auth aws`, or `--auth gcp` authenticates using the machine's cloud identity. See [Cloud identities](#cloud-identities).
|
|
154
|
+
- `--token-file <path>` saves the path as-is and rereads the file on every new connection. Use this with a Vault agent or secrets sidecar that rotates credentials automatically. Atomic strips only one trailing `\n` or `\r\n` when reading PostgreSQL token files, so avoid extra trailing spaces or blank lines.
|
|
155
|
+
- `--auth azure`, `--auth aws`, or `--auth gcp` (the long forms `azure-entra`, `aws-iam`, and `gcp-iam` are also accepted) authenticates using the machine's cloud identity. See [Cloud identities](#cloud-identities).
|
|
144
156
|
|
|
145
157
|
`atomic storage join` tests the connection with `SELECT 1` before writing anything, then updates only the top-level `storage` key in `~/.atomic/agent/settings.json`:
|
|
146
158
|
|
|
@@ -154,25 +166,25 @@ atomic storage status
|
|
|
154
166
|
}
|
|
155
167
|
```
|
|
156
168
|
|
|
157
|
-
You can also edit this configuration directly. `secrets.password`
|
|
169
|
+
You can also edit this configuration directly. For password authentication in adapter configurations (including `settings.json`, `ATOMIC_STORAGE`, `--storage`, and SDK `{ kind: "adapter" }` selections), set `secrets.password` to `{ "file": "..." }` or `{ "env": "<variable>" }`. Because the adapter declares `liveSecrets: ["password"]`, Atomic rereads `secrets.password` for each new connection and ignores `options.password`, throwing `StorageConfigError` (`reason: "secret-missing"`) when `secrets.password` is omitted.
|
|
158
170
|
|
|
159
171
|
| Option | Default | Description |
|
|
160
172
|
| --- | --- | --- |
|
|
161
173
|
| `url` | Required | `postgres://` or `postgresql://` URL with username and no password |
|
|
162
174
|
| `auth` | `"password"` | `"azure-entra"`, `"aws-iam"`, or `"gcp-iam"` for [cloud identities](#cloud-identities) |
|
|
163
175
|
| `maxConnections` | `8` | Maximum pooled connections per Atomic process |
|
|
164
|
-
| `statementTimeoutMs` | `30000` | Maximum runtime for one statement before server cancellation |
|
|
165
|
-
| `listenUrl` | `url` | Direct endpoint for [wake-ups](#wake-ups) when `url` uses a transaction pooler |
|
|
166
|
-
| `schema` | `"atomic"` |
|
|
176
|
+
| `statementTimeoutMs` | `30000` | Maximum runtime for one statement before server cancellation (client cancels the connection 5,000 ms later if the server stops answering; idle connections close after 10,000 ms, and connect/pool-wait timeout is 10,000 ms) |
|
|
177
|
+
| `listenUrl` | `url` | Direct endpoint for [wake-ups](#wake-ups) when `url` uses a transaction pooler. Enforces the same URL, TLS, proxy, and no-embedded-password rules as `url` (`credential-in-url`) |
|
|
178
|
+
| `schema` | `"atomic"` | Schema name starting with a lowercase ASCII letter or `_`, followed by lowercase letters, digits, or `_` (1 to 63 characters) |
|
|
167
179
|
| `proxy` | From environment | `http://` or `https://` proxy URL for all connections, or `"none"` to connect directly |
|
|
168
180
|
|
|
169
|
-
`atomic team join` supports libSQL URLs only. Use `atomic storage join` for PostgreSQL. SDK
|
|
181
|
+
`atomic team join` supports libSQL URLs only. Use `atomic storage join` for PostgreSQL. For Node.js and TypeScript SDK apps, install `@bastani/atomic-storage-postgres` with `npm install` and import `openPostgresDatabase` directly. See [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) and [SDK session storage](/sdk/storage).
|
|
170
182
|
|
|
171
183
|
### TLS
|
|
172
184
|
|
|
173
185
|
Atomic connects over TLS to every remote host by default and verifies both the server certificate and hostname (`sslmode=verify-full`). If the URL omits the host, Atomic checks `PGHOST`.
|
|
174
186
|
|
|
175
|
-
You can override this by adding a lowercase `sslmode` parameter to the URL. `verify-ca` verifies the CA without checking the hostname, `prefer` and `allow` encrypt without checking the certificate, and `disable` turns TLS off. `require` with `sslrootcert` behaves like `verify-ca`. Without `sslrootcert`, `require` verifies both certificate and hostname like `verify-full`, which is stricter than libpq. Uppercase TLS parameters or unknown `sslmode` values fail with `StorageConfigError`.
|
|
187
|
+
You can override this by adding a lowercase `sslmode` parameter to the URL (`uselibpqcompat` must also be lowercase if used). `verify-ca` verifies the CA without checking the hostname, `prefer` and `allow` encrypt without checking the certificate, and `disable` turns TLS off. `require` with `sslrootcert` behaves like `verify-ca`. Without `sslrootcert`, `require` verifies both certificate and hostname like `verify-full`, which is stricter than libpq. Uppercase TLS parameters or unknown `sslmode` values fail with `StorageConfigError`.
|
|
176
188
|
|
|
177
189
|
Provider CA configuration:
|
|
178
190
|
|
|
@@ -236,9 +248,9 @@ With `--auth` (or `options.auth` in settings), Atomic requests a short-lived tok
|
|
|
236
248
|
|
|
237
249
|
| `--auth` | `options.auth` | Install | Credential source |
|
|
238
250
|
| --- | --- | --- | --- |
|
|
239
|
-
| `azure` | `"azure-entra"` | `atomic install npm:@azure/identity` | `AZURE_*` variables, AKS workload identity, VM/App Service/Container App managed identity (`AZURE_CLIENT_ID` selects user-assigned), or `az login` |
|
|
240
|
-
| `aws` | `"aws-iam"` | `atomic install npm:@aws-sdk/rds-signer` | Default AWS credentials (`AWS_*` variables, profiles, IRSA, or instance profile) |
|
|
241
|
-
| `gcp` | `"gcp-iam"` | `atomic install npm:google-auth-library` | Application Default Credentials (`GOOGLE_APPLICATION_CREDENTIALS`, Compute Engine/GKE/Cloud Run metadata server, or `gcloud auth application-default login`) |
|
|
251
|
+
| `azure` or `azure-entra` | `"azure-entra"` | `atomic install npm:@azure/identity` | `AZURE_*` variables, AKS workload identity, VM/App Service/Container App managed identity (`AZURE_CLIENT_ID` selects user-assigned), or `az login` |
|
|
252
|
+
| `aws` or `aws-iam` | `"aws-iam"` | `atomic install npm:@aws-sdk/rds-signer` | Default AWS credentials (`AWS_*` variables, profiles, IRSA, or instance profile) |
|
|
253
|
+
| `gcp` or `gcp-iam` | `"gcp-iam"` | `atomic install npm:google-auth-library` | Application Default Credentials (`GOOGLE_APPLICATION_CREDENTIALS`, Compute Engine/GKE/Cloud Run metadata server, or `gcloud auth application-default login`) |
|
|
242
254
|
|
|
243
255
|
If the SDK is missing or cannot issue a token, opening fails with `StorageConfigError` (`reason: "auth-unavailable"`). Cloud tokens require TLS, so keep the default `sslmode`.
|
|
244
256
|
|
|
@@ -248,7 +260,7 @@ Map the cloud identity to a PostgreSQL role on your provider:
|
|
|
248
260
|
- **AWS.** Enable IAM database authentication, run `CREATE USER atomic; GRANT rds_iam TO atomic;`, and grant the IAM identity `rds-db:connect` on `arn:aws:rds-db:<region>:<account>:dbuser:<DbiResourceId>/atomic`.
|
|
249
261
|
- **Google Cloud.** Set `cloudsql.iam_authentication=on`, add the service account as an IAM database user, and grant `roles/cloudsql.instanceUser`. Use the service account email without `.gserviceaccount.com` as the URL username. Compute Engine VMs need the `cloud-platform` scope.
|
|
250
262
|
|
|
251
|
-
Grant the mapped identity the runtime privileges from [Set up the database](#set-up-the-database), and run `atomic storage migrate` as the owner role. See
|
|
263
|
+
Grant the mapped identity the runtime privileges from [Set up the database](#set-up-the-database), and run `atomic storage migrate` as the owner role. See [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) for service-specific details and [SDK session storage](/sdk/storage) for SDK integration recipes.
|
|
252
264
|
|
|
253
265
|
Running `atomic install npm:@azure/identity` (or the AWS or Google SDK) installs the package under `~/.atomic/agent/npm`. The PostgreSQL adapter searches both its own directory and `~/.atomic/agent/npm`, so adapters installed from local paths find the SDK too.
|
|
254
266
|
|
|
@@ -257,13 +269,13 @@ Running `atomic install npm:@azure/identity` (or the AWS or Google SDK) installs
|
|
|
257
269
|
- **`credential-in-url`.** Remove the password from the URL and pass `--password-file` or `--token-file`.
|
|
258
270
|
- **`unsupported-url` from `atomic team join`.** `atomic team join` supports libSQL only. Use `atomic storage join` for PostgreSQL.
|
|
259
271
|
- **`unsupported-option`.** `--password-file` and `--auth` apply to PostgreSQL only. libSQL uses `--token-file`.
|
|
260
|
-
- **`unsupported-auth`.** `--auth` accepts `azure
|
|
272
|
+
- **`unsupported-auth`.** `--auth` accepts `azure` (`azure-entra`), `aws` (`aws-iam`), or `gcp` (`gcp-iam`).
|
|
261
273
|
- **`adapter-not-installed`.** Run `atomic install npm:@bastani/atomic-storage-postgres` as the user running Atomic.
|
|
262
274
|
- **`auth-unavailable`.** Install the cloud SDK named in the error and confirm the machine has a valid cloud identity. Atomic does not retry this error.
|
|
263
275
|
- **`missing-privilege` (`42501` or `3F000`).** Run the `GRANT` named in the error for a runtime role (see [Set up the database](#set-up-the-database)), or run `atomic storage migrate` as the owner role if the error mentions ownership or `CREATE`.
|
|
264
276
|
- **"This database was upgraded since this process started".** `atomic storage migrate` moved tables from `public` to `atomic` while this process was running. Restart the process.
|
|
265
277
|
- **Refused token (`28P01` or Azure `28000`).** The token expired, targets the wrong user, or has an invalid format. For Azure, request a token for `https://ossrdbms-aad.database.windows.net` (`az account get-access-token --resource-type oss-rdbms`) or use `--auth azure`.
|
|
266
|
-
- **`StorageUnavailableError` on open.** The server rejected credentials (`28P01` or `28000`), the database does not exist (`3D000`), or the server is older than PostgreSQL 14.
|
|
278
|
+
- **`StorageUnavailableError` on open.** The server rejected credentials (`28P01` or `28000`), the database does not exist (`3D000`), or the server is older than PostgreSQL 14. Atomic sessions require PostgreSQL 16 or newer.
|
|
267
279
|
- **Certificate untrusted (`self-signed certificate in certificate chain` or `unable to get local issuer certificate`).** Add `sslrootcert` pointing to your server CA. See [TLS](#tls).
|
|
268
280
|
- **`INVALID_PURPOSE`.** The certificate in `sslrootcert` lacks `basicConstraints=CA:TRUE` or is restricted to client authentication. Point `sslrootcert` to the signing CA or reissue it with `CA:TRUE`. Not retried.
|
|
269
281
|
- **`PATH_LENGTH_EXCEEDED`.** The certificate chain exceeds its root CA path-length limit. Reissue the root without that limit or sign the server certificate directly. Not retried.
|
|
@@ -297,21 +309,21 @@ atomic install npm:@bastani/atomic-storage-libsql
|
|
|
297
309
|
|
|
298
310
|
- **Self-hosted `sqld`.** Always start `sqld` with `--checkpoint-interval-s 60` (or `SQLD_CHECKPOINT_INTERVAL_S=60`). Without it, `sqld` 0.24.33 and earlier can stall writes during WAL checkpoints. Atomic warns after three consecutive unanswered writes. Interval checkpoints pause writes briefly (up to 5 seconds) while Atomic retries automatically.
|
|
299
311
|
- **Namespaces and headers.** For `sqld --enable-namespaces`, set `"namespace": "<name>"` in `options` (sent as `x-namespace` over `libsql:`, `https:`, or `http:` URLs). SDK callers can also pass extra `headers` to `openLibsqlDatabase`, which Atomic redacts from errors.
|
|
300
|
-
- **Tokens and local files.** Save a Turso token with `turso db tokens create <db> > turso-token && chmod 600 turso-token` (one trailing line ending is stripped
|
|
312
|
+
- **Tokens and local files.** Save a Turso token with `turso db tokens create <db> > turso-token && chmod 600 turso-token` (one trailing line ending is stripped when read from `secrets.authToken.file`, and relative paths resolve against [storage home](#storage-home)), or reference `{ "env": "TURSO_TOKEN" }`. Absolute `file:` URLs need no `secrets`. Add `prefix` to isolate projects or teams.
|
|
301
313
|
- **Retries and WebSockets.** Transient outages, expired streams, and 30-second unanswered requests report `StorageTransientError`. Calls that failed before writing retry up to 5 times over about 4 seconds. Writes with an uncertain outcome fail immediately with `outcome: "unknown"` and are not retried automatically. Over `ws:` or `wss:`, a batch whose `COMMIT` does not run reports `StorageUnavailableError` (`TRANSACTION_CLOSED`).
|
|
302
314
|
|
|
303
|
-
|
|
315
|
+
For Node.js and TypeScript SDK apps, install `@bastani/atomic-storage-libsql` with `npm install` and import `openLibsqlDatabase` directly as plain ESM with TypeScript declarations. See [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql) and [SDK session storage](/sdk/storage). To wrap another driver, see [Bring your own driver](#bring-your-own-driver).
|
|
304
316
|
|
|
305
317
|
## Sharing storage across hosts
|
|
306
318
|
|
|
307
319
|
Share sessions and Intercom across machines or CI fleets by pointing every host at the same [PostgreSQL](#postgresql) or [Turso / libSQL](#turso-and-libsql) database with the same `prefix`. Never put a local SQLite file on a network filesystem.
|
|
308
320
|
|
|
309
321
|
- **Shared `storage` vs. `sessions.storage`.** Configuring top-level `storage` (in global settings, `--storage`, `--storage-file`, or `ATOMIC_STORAGE`) enables multi-node Intercom routing across hosts. Setting only `sessions.storage` shares sessions without enabling multi-node Intercom. On libSQL, single Intercom messages over 5,000,000 bytes fail with `StoragePayloadTooLargeError`.
|
|
310
|
-
- **Data stored and access.** The shared database holds sessions, tool-output blobs, [worktree snapshot](/worktree-snapshots) blobs, and transient Intercom messages. Treat database read access as full read access. To share Intercom while keeping personal sessions local, use `atomic team join` as described in [
|
|
322
|
+
- **Data stored and access.** The shared database holds sessions, tool-output blobs, [worktree snapshot](/worktree-snapshots) blobs, and transient Intercom messages. Treat database read access as full read access. To share Intercom while keeping personal sessions local, use `atomic team join` as described in [Set up teams and CI](/guides/team-setup). To resume sessions across machines, see [Resume sessions on any machine](/guides/resume-on-any-machine).
|
|
311
323
|
|
|
312
324
|
### Joining a machine to a shared database
|
|
313
325
|
|
|
314
|
-
> Want shared Intercom while keeping personal sessions local? Use `atomic team join` instead ([
|
|
326
|
+
> Want shared Intercom while keeping personal sessions local? Use `atomic team join` instead ([Set up teams and CI](/guides/team-setup)).
|
|
315
327
|
|
|
316
328
|
**libSQL / Turso:**
|
|
317
329
|
|
|
@@ -323,11 +335,13 @@ atomic intercom restart
|
|
|
323
335
|
atomic storage status
|
|
324
336
|
```
|
|
325
337
|
|
|
326
|
-
**PostgreSQL:**
|
|
338
|
+
**PostgreSQL (PostgreSQL 16 or newer for sessions):**
|
|
339
|
+
|
|
340
|
+
In two-role deployments, run `atomic storage migrate --db 'postgresql://atomic_owner@db.example.com:5432/atomic' --password-file ~/atomic-owner-password` once as the owner role, and after Atomic upgrades, before joining machines with the runtime role. See [Set up the database](#set-up-the-database).
|
|
327
341
|
|
|
328
342
|
```bash
|
|
329
343
|
atomic install npm:@bastani/atomic-storage-postgres
|
|
330
|
-
atomic storage join
|
|
344
|
+
atomic storage join postgresql://atomic_runtime@db.example.com:5432/atomic?sslmode=verify-full --password-file ~/pg-password
|
|
331
345
|
atomic intercom restart
|
|
332
346
|
atomic storage status
|
|
333
347
|
```
|
|
@@ -335,15 +349,15 @@ atomic storage status
|
|
|
335
349
|
`atomic storage join <url> [options]` runs four steps:
|
|
336
350
|
|
|
337
351
|
1. Validates the URL, adapter installation, and credentials, then runs a read-only `SELECT 1` within 15 seconds. If any check fails, nothing is written.
|
|
338
|
-
2. Stores static credentials (`--token-file` for libSQL, `--password-file` for PostgreSQL) in a mode-`600` `~/.atomic/agent/storage-token.<id>` file, reusing an existing identical file and leaving older files intact for running sessions.
|
|
352
|
+
2. Stores static credentials (`--token-file` for libSQL, trimming surrounding whitespace; `--password-file` for PostgreSQL) in a mode-`600` `~/.atomic/agent/storage-token.<id>` file, reusing an existing identical file and leaving older files intact for running sessions.
|
|
339
353
|
3. Updates only the top-level `storage` key in `~/.atomic/agent/settings.json` (plus optional `--prefix`), preserving all other settings.
|
|
340
354
|
4. Lists any higher-precedence environment variables or project settings and notes if the running Intercom broker still uses the previous store. Run `atomic intercom restart` to switch the broker ([Running Intercom across machines](/intercom/operations#running-intercom-across-machines)).
|
|
341
355
|
|
|
342
356
|
URL and credential rules:
|
|
343
357
|
|
|
344
358
|
- **No embedded secrets.** Userinfo passwords and `authToken=` or `password=` query parameters are refused.
|
|
345
|
-
- **libSQL schemes.** Accepts `libsql://`, `https://`, `wss://`, or an absolute `file:` URL (which needs no token). Relative `file:` URLs, `--password-file`, and `--auth` are refused.
|
|
346
|
-
- **PostgreSQL credentials.** Pass exactly one of `--password-file <path>` (copied to a private file), `--token-file <path>` (external rotated file referenced by path and reread per connection), or `--auth azure|aws|gcp` (
|
|
359
|
+
- **libSQL schemes.** Accepts `libsql://`, `https://`, `http://`, `wss://`, `ws://`, or an absolute `file:` URL (which needs no token). Prefer TLS (`libsql://`, `https://`, or `wss://`) for remote hosts; `http://` and `ws://` are intended for local or private-network `sqld`. Relative `file:` URLs, `--password-file`, and `--auth` are refused.
|
|
360
|
+
- **PostgreSQL credentials.** Pass exactly one of `--password-file <path>` (copied to a private file), `--token-file <path>` (external rotated file referenced by path and reread per connection, stripping only one trailing `\n` or `\r\n`), or `--auth azure|aws|gcp` (also accepts `azure-entra`, `aws-iam`, `gcp-iam`). The same flags work with `atomic storage migrate --db`.
|
|
347
361
|
|
|
348
362
|
### Checking the selected storage
|
|
349
363
|
|
|
@@ -361,11 +375,11 @@ A host launching Atomic processes (such as `atomic --mode rpc` children) can ove
|
|
|
361
375
|
|
|
362
376
|
| Option | Applies to | Equivalent setting |
|
|
363
377
|
| --- | --- | --- |
|
|
364
|
-
| `--storage '<json>'` | Sessions and Intercom | Shared `storage` |
|
|
365
|
-
| `--storage-file <path>` | Sessions and Intercom (reads JSON from a file) | Shared `storage` |
|
|
366
|
-
| `ATOMIC_STORAGE` | Sessions and Intercom | Shared `storage` |
|
|
367
|
-
| `ATOMIC_SESSIONS_STORAGE` | Sessions only (also accepts `{ "dir": "..." }`) | `sessions.storage` |
|
|
368
|
-
| `ATOMIC_PROFILE=ci` with `ATOMIC_TEAM_URL`, `ATOMIC_TEAM_TOKEN` or `ATOMIC_TEAM_TOKEN_FILE`, and optional `ATOMIC_TEAM_PREFIX` | Sessions and Intercom on the team database | See [CI and swarms](/guides/team-setup#ci-and-swarms) |
|
|
378
|
+
| `--storage '<json>'` | Sessions and Intercom (cannot use `{ "dir": "..." }`) | Shared `storage` |
|
|
379
|
+
| `--storage-file <path>` | Sessions and Intercom (reads JSON from a file; cannot use `{ "dir": "..." }`) | Shared `storage` |
|
|
380
|
+
| `ATOMIC_STORAGE` | Sessions and Intercom (cannot use `{ "dir": "..." }`) | Shared `storage` |
|
|
381
|
+
| `ATOMIC_SESSIONS_STORAGE` | Sessions only (also accepts `{ "dir": "..." }` for JSONL) | `sessions.storage` |
|
|
382
|
+
| `ATOMIC_PROFILE=ci` with `ATOMIC_TEAM_URL`, `ATOMIC_TEAM_TOKEN` or `ATOMIC_TEAM_TOKEN_FILE`, and optional `ATOMIC_TEAM_PREFIX` | Sessions and Intercom on the team libSQL database | See [CI and swarms](/guides/team-setup#ci-and-swarms) |
|
|
369
383
|
|
|
370
384
|
```bash
|
|
371
385
|
ATOMIC_STORAGE='{"adapter":"@example/atomic-sqlite","options":{"url":"libsql://team.example"},"secrets":{"authToken":{"env":"TEAM_DB_TOKEN"}},"prefix":"svc_"}' \
|
|
@@ -374,22 +388,23 @@ ATOMIC_STORAGE='{"adapter":"@example/atomic-sqlite","options":{"url":"libsql://t
|
|
|
374
388
|
atomic --mode rpc --storage-file /etc/atomic/storage.json
|
|
375
389
|
```
|
|
376
390
|
|
|
377
|
-
`--storage` and `--storage-file` cannot be combined.
|
|
391
|
+
`--storage` and `--storage-file` cannot be combined. Interactive sessions keep `--storage` active for the session, while spawned child processes inherit environment variables (such as `ATOMIC_STORAGE`) rather than CLI flags.
|
|
378
392
|
|
|
379
393
|
One Intercom broker serves every session in an agent directory and keeps the storage selection of the process that started it until it exits or `atomic intercom restart` replaces it. Project settings never select the broker's storage.
|
|
380
394
|
|
|
381
395
|
Precedence for sessions, highest first:
|
|
382
396
|
|
|
383
|
-
1. SDK `
|
|
384
|
-
2. SDK `
|
|
385
|
-
3.
|
|
386
|
-
4. `--
|
|
387
|
-
5. `
|
|
388
|
-
6. `
|
|
389
|
-
7. `
|
|
390
|
-
8. `
|
|
391
|
-
9.
|
|
392
|
-
10.
|
|
397
|
+
1. Explicit SDK `sessionManager` (bypasses store selection)
|
|
398
|
+
2. SDK `sessionStore`
|
|
399
|
+
3. SDK `createAgentSession({ storage })`
|
|
400
|
+
4. `--session-store`, `--no-session`, or `--session-dir`
|
|
401
|
+
5. `--storage` or `--storage-file`
|
|
402
|
+
6. `ATOMIC_SESSIONS_STORAGE` or `ATOMIC_CODING_AGENT_SESSION_DIR`
|
|
403
|
+
7. `ATOMIC_STORAGE`
|
|
404
|
+
8. `ATOMIC_PROFILE=ci`
|
|
405
|
+
9. `sessions.storage` setting
|
|
406
|
+
10. Shared `storage` setting
|
|
407
|
+
11. Default local SQLite file (`~/.atomic/workflows/journal.sqlite`)
|
|
393
408
|
|
|
394
409
|
Override conflicts and path rules:
|
|
395
410
|
|
|
@@ -398,7 +413,7 @@ Override conflicts and path rules:
|
|
|
398
413
|
- Combining `ATOMIC_SESSIONS_STORAGE` or `--storage` / `--storage-file` with a non-empty `ATOMIC_CODING_AGENT_SESSION_DIR` fails startup with `StorageConfigError` (`reason: "conflicting-overrides"`). Unset one variable or pass an explicit session flag.
|
|
399
414
|
- Relative `path`, `dir`, and `secrets.file` values resolve against [storage home](#storage-home). Relative adapter specifiers resolve from the agent directory. Relative `--storage-file` paths resolve from the current working directory. Empty variables are ignored.
|
|
400
415
|
|
|
401
|
-
Before starting any session (in every mode, including RPC and SDK `createAgentSession()`), Atomic validates `--storage`, `--storage-file`, `ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`, and `ATOMIC_PROFILE=ci`, even when outranked by a higher-precedence override. Invalid JSON, schema violations, unreadable files, or incomplete CI variables
|
|
416
|
+
Before starting any session (in every mode, including RPC and SDK `createAgentSession()`), Atomic validates `--storage`, `--storage-file`, `ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`, and `ATOMIC_PROFILE=ci`, even when outranked by a higher-precedence override. Invalid JSON, schema violations, unreadable files, or incomplete CI variables exit cleanly with `Error: ...` (exit code `1`) on the CLI or throw `StorageConfigError` / `TeamProfileConfigError` in the SDK without falling back to another store. Errors name only the variable or flag, never secret values.
|
|
402
417
|
|
|
403
418
|
Process-level storage options bypass [project trust](/security) because they come from the launching host. Because adapter modules execute code with Atomic's privileges, select only trusted modules and pass credentials through `secrets` instead of `options`. Prefer `--storage-file` or environment variables over `--storage` when the selection itself is sensitive, because command-line arguments can be visible to other local users.
|
|
404
419
|
|
|
@@ -408,7 +423,7 @@ SDK callers can also keep a token strictly in memory with `inMemorySecret(token)
|
|
|
408
423
|
|
|
409
424
|
`atomic storage export <dir>` writes sessions to JSONL files, and `atomic storage import <dir>` restores them. Use these commands to move sessions between machines or migrate from one storage backend to another.
|
|
410
425
|
|
|
411
|
-
```
|
|
426
|
+
```bash
|
|
412
427
|
atomic storage export <dir> [--limit <n>] [--since <time>]
|
|
413
428
|
atomic storage import <dir>
|
|
414
429
|
```
|
|
@@ -426,8 +441,8 @@ Import reads only `*.jsonl` files inside `<dir>/sessions` and ignores everything
|
|
|
426
441
|
|
|
427
442
|
Export writes every session by default:
|
|
428
443
|
|
|
429
|
-
- `--limit <n>` writes only the `n` most recently modified sessions.
|
|
430
|
-
- `--since <time>` writes sessions modified at or after `<time>` (such as `2026-11-01` or `2026-11-01T09:30:00Z`).
|
|
444
|
+
- `--limit <n>` writes only the `n` most recently modified sessions (`n` must be an integer `>= 1` made of ASCII digits).
|
|
445
|
+
- `--since <time>` writes sessions modified at or after `<time>` (parsed with JavaScript `Date.parse()`). ISO date-only strings such as `2026-11-01` mean UTC midnight, whereas date-time strings without an offset such as `2026-11-01T09:30:00` use your local timezone. Add `Z` or an explicit offset (for example `2026-11-01T09:30:00Z`) to avoid timezone ambiguity.
|
|
431
446
|
|
|
432
447
|
Export includes sessions from every project and internal sessions, including fresh subagents' internal sessions (so subagent history transfers with its parent) and workflow-stage internal sessions from earlier releases.
|
|
433
448
|
|
|
@@ -449,7 +464,12 @@ If an import fails partway through writing multiple sessions, it exits `1` and l
|
|
|
449
464
|
|
|
450
465
|
Both commands use `ATOMIC_CODING_AGENT_DIR` and the active session storage for the current directory. Exporting from or importing into a shared libSQL, Turso, or PostgreSQL database (or an in-memory store) is refused by default because joined machines already share that database.
|
|
451
466
|
|
|
452
|
-
Pass `--storage <json>` or `--storage-file <path>` to target a specific store explicitly, including a shared database
|
|
467
|
+
Pass `--storage <json>` or `--storage-file <path>` to target a specific store explicitly, including a shared database:
|
|
468
|
+
|
|
469
|
+
- Relative `"path"` values inside `atomic storage export` / `import --storage` (or `--storage-file`) resolve against the **current working directory (`cwd`)**, not storage home. If you copy a `storage` object from `settings.json` whose `"path"` is relative, convert it to an absolute path first.
|
|
470
|
+
- JSONL `{ "dir": "..." }` and empty `{}` selections are rejected by `export` and `import --storage`.
|
|
471
|
+
|
|
472
|
+
For example, to migrate sessions from libSQL to PostgreSQL:
|
|
453
473
|
|
|
454
474
|
```bash
|
|
455
475
|
atomic storage export ~/moved --storage-file old-storage.json
|
|
@@ -479,7 +499,7 @@ External tools can redact string values (such as replacing a secret with `***`)
|
|
|
479
499
|
|
|
480
500
|
On a runner that caches a directory across jobs:
|
|
481
501
|
|
|
482
|
-
```
|
|
502
|
+
```bash
|
|
483
503
|
# Start of job, after restoring $STATE_DIR
|
|
484
504
|
mkdir -p "$STATE_DIR" && atomic storage import "$STATE_DIR"
|
|
485
505
|
|
|
@@ -506,7 +526,7 @@ Payloads that still exceed a backend's limit fail non-retryably with `StoragePay
|
|
|
506
526
|
- **One-way session schema upgrade.** Writing the first chunked session entry permanently upgrades the session schema from version `1` to `2`. Upgrade every host sharing a database together because older releases reject version 2 stores with `StorageSchemaVersionError`.
|
|
507
527
|
- **Offline local snapshot chunk migration.** On older local SQLite files, background snapshot collection migrates legacy snapshot chunk tables automatically when free disk space allows. To migrate a cleanly closed local SQLite file offline with bounded WAL growth, stop all Atomic processes using that file and run:
|
|
508
528
|
|
|
509
|
-
```
|
|
529
|
+
```bash
|
|
510
530
|
atomic storage move-snapshot-chunks <sqlite-file> [--prefix <prefix>]
|
|
511
531
|
```
|
|
512
532
|
|
|
@@ -525,9 +545,11 @@ To run an older workflow definition with this release, see [Migrating workflows]
|
|
|
525
545
|
|
|
526
546
|
## SDK and local SQLite API
|
|
527
547
|
|
|
528
|
-
|
|
548
|
+
For full SDK recipes covering `createAgentSession`, `createAgentSessionRuntime`, `SqlSessionStore`, `JsonlSessionStore`, `MemorySessionStore`, `openPostgresDatabase`, `openLibsqlDatabase`, and store ownership rules, see [SDK session storage](/sdk/storage). For direct session reading, branching, and listing, see [SessionManager API](/session-format#sessionmanager-api).
|
|
529
549
|
|
|
530
|
-
|
|
550
|
+
This section covers the low-level local SQLite API and storage path helpers exported from `@bastani/atomic` and `@bastani/atomic/storage`, followed by custom adapter and driver authoring:
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
531
553
|
import { openNodeSqliteDatabase } from "@bastani/atomic/storage";
|
|
532
554
|
|
|
533
555
|
const database = await openNodeSqliteDatabase("./data/example.sqlite");
|
|
@@ -551,23 +573,20 @@ try {
|
|
|
551
573
|
|
|
552
574
|
### SDK path helpers
|
|
553
575
|
|
|
554
|
-
`@bastani/atomic/storage` and `@bastani/atomic` export `storageHomeDir(agentDir?, settings?)`, `workflowsStorageDir(agentDir?, settings?)`, `defaultSessionDatabasePath(agentDir?, settings?)`, `defaultSharedStoragePath(agentDir?, settings?)`, and `storagePathBaseDir(path, agentDir, settings?)`. Pass merged settings before opening a store so parent-
|
|
576
|
+
`@bastani/atomic/storage` and `@bastani/atomic` export `storageHomeDir(agentDir?, settings?)`, `workflowsStorageDir(agentDir?, settings?)`, `defaultSessionDatabasePath(agentDir?, settings?)`, `defaultSharedStoragePath(agentDir?, settings?)`, and `storagePathBaseDir(path, agentDir, settings?)`. Pass merged settings before opening a store so legacy parent-directory adoption rules resolve accurately.
|
|
555
577
|
|
|
556
|
-
### Concurrency,
|
|
578
|
+
### Concurrency, options, and diagnostics
|
|
557
579
|
|
|
558
|
-
- **Database options.** `openNodeSqliteDatabase(path, options?)` creates parent directories and
|
|
559
|
-
- **
|
|
560
|
-
- **
|
|
561
|
-
- **
|
|
562
|
-
- **Same-process and cross-process writer queues.** Separate `openNodeSqliteDatabase` handles to the same file share an in-process queue. `wrapNodeSqliteDatabase(conn)` shares a queue per wrapped connection and leaves the underlying connection open on `close()`. Across processes, writers queue FIFO using `<file>-writers`, `<file>-wakes`, and `<file>-holders`.
|
|
563
|
-
- **Group commit and lock wait.** `groupCommitHoldMs` (default `100` ms, exported as `DEFAULT_GROUP_COMMIT_HOLD_MS`, `0` commits individually) batches queued transactions per lock acquisition. Waiting writers refresh every 500 ms and bypass dead processes after 2 seconds. Exceeding `lockWaitMs` (default `30000` ms, or per-transaction `{ lockWaitMs }`) with no commits rejects with `StorageWriteLockTimeoutError`.
|
|
564
|
-
- **Diagnostics.** `getWriterQueueStats(db)` returns 10-second `lockHeldRatio`, `waiters`, `p50WaitMs`, `p95WaitMs`, and `commitsPerSecond`. `getWriterQueueDegradation(db)` returns recorded `StorageWriterQueueDegradedError` entries (also logged in [debug mode](/development#debugging)). Unusable queue directories reject with `StorageWriterQueueUnusableError`, and non-node-sqlite handles throw `StorageUnsupportedOperationError`.
|
|
580
|
+
- **Database options.** `openNodeSqliteDatabase(path, options?)` creates parent directories and enables WAL mode, `FULL` sync, foreign keys, and `busyTimeoutMs: 5000`. Pass `:memory:` for an ephemeral database or `{ readOnly: true }` to inspect a file without creating it or changing its journal mode. File-backed handles run off the main event loop so statements waiting on locks or disk syncs do not block your application.
|
|
581
|
+
- **Wrapping an existing connection.** `wrapNodeSqliteDatabase(conn)` adapts an existing Node `DatabaseSync` handle on the calling thread and leaves the underlying connection open on `close()`. Avoid mixing raw `DatabaseSync` calls with wrapped calls on the same connection.
|
|
582
|
+
- **Writer queuing and timeouts.** Multiple handles in one process and across processes on the same host share FIFO write queues. `groupCommitHoldMs` (default `100` ms, exported as `DEFAULT_GROUP_COMMIT_HOLD_MS`, `0` commits individually) batches queued transactions per lock acquisition. Waiting longer than `lockWaitMs` (default `30000` ms, or per-transaction `{ lockWaitMs }`) with no commits rejects with `StorageWriteLockTimeoutError`.
|
|
583
|
+
- **Diagnostics.** `getWriterQueueStats(db)` returns 10-second lock utilization, waiter count, wait latency percentiles (`p50WaitMs`, `p95WaitMs`), and `commitsPerSecond`. `getWriterQueueDegradation(db)` returns recorded `StorageWriterQueueDegradedError` entries (also logged in [debug mode](/development#debugging)). Passing a non-node-sqlite handle throws `StorageUnsupportedOperationError`.
|
|
565
584
|
|
|
566
585
|
## Selecting an adapter
|
|
567
586
|
|
|
568
587
|
A storage adapter is a module whose default export satisfies `StorageAdapterModule`:
|
|
569
588
|
|
|
570
|
-
```
|
|
589
|
+
```typescript
|
|
571
590
|
import type { StorageAdapterModule } from "@bastani/atomic/storage";
|
|
572
591
|
|
|
573
592
|
export default {
|
|
@@ -578,11 +597,18 @@ export default {
|
|
|
578
597
|
} satisfies StorageAdapterModule;
|
|
579
598
|
```
|
|
580
599
|
|
|
581
|
-
Select an adapter in `sessions.storage` or top-level `storage` in [settings](/settings#sessions), or pass `sessionStore: { kind: "adapter", module, options, secrets, prefix }` in the SDK. Relative module paths resolve from the agent directory (`~/.atomic/agent` by default)
|
|
600
|
+
Select an adapter in `sessions.storage` or top-level `storage` in [settings](/settings#sessions), or pass `sessionStore: { kind: "adapter", module, options, secrets, prefix }` in the SDK. Relative module paths resolve from the agent directory (`~/.atomic/agent` by default). Bare package names resolve from user-scope [Atomic packages](#adapters-from-atomic-packages), host extension directories, or the agent directory, never from an embedding application's `node_modules`. Project settings follow the project trust boundary, and adapter code runs with Atomic's privileges.
|
|
601
|
+
|
|
602
|
+
Choose the installation method that matches how you open the adapter:
|
|
603
|
+
|
|
604
|
+
- **Direct SDK database handles (`{ kind: "database", database }`).** Install the package in your project with `npm install`, call `openPostgresDatabase()` or `openLibsqlDatabase()`, and pass the handle to `sessionStore: { kind: "database", database, prefix? }` or `SqlSessionStore.open(database, { prefix? })`. See [SDK session storage](/sdk/storage).
|
|
605
|
+
- **Adapter-resolved selections (`{ kind: "adapter", module }`, `settings.json`, `ATOMIC_STORAGE`, `ATOMIC_PROFILE=ci`).** Install the package in user scope with `atomic install npm:<package>` (without `-l`), or register a local package directory with `DefaultResourceLoader({ additionalExtensionPaths })` or `--extension`.
|
|
582
606
|
|
|
583
607
|
Adapter modules can import `@bastani/atomic/storage` and `@bastani/atomic` directly in both npm installs and standalone binaries. This works for the adapter entry file and any ES module or TypeScript file it imports relatively (including `.mjs` files and `.js` files in `"type": "module"` packages). CommonJS files outside the entry file resolve from `node_modules` instead. List `@bastani/atomic` under `peerDependencies`, not `dependencies`.
|
|
584
608
|
|
|
585
|
-
`options` holds SQLite scalar values or booleans. `secrets` maps
|
|
609
|
+
`options` holds SQLite scalar values or booleans. `secrets` maps secret names to `{ env }`, `{ file }`, or (in the SDK only) `inMemorySecret(value)` (`{ value }`), overriding same-named keys in `options`. Atomic strips one trailing `\n` or `\r\n` from `{ file }` secrets and keeps other whitespace intact. `inMemorySecret()` serializes as `[redacted]` and is refused outside the SDK (`in-memory-secret-unsupported`).
|
|
610
|
+
|
|
611
|
+
`context` provides `agentDir`, `domain: "sessions" | "intercom"`, an optional `signal`, and `secret(name)` to reread `secrets[name]` on demand. An adapter that reads fresh credentials for each new connection (such as a rotated password file) declares `liveSecrets` on its `StorageAdapterModule` (for example `liveSecrets: ["password"]`). Atomic omits names listed in `liveSecrets` from `options` and expects the adapter to call `context.secret(name)`, which throws `StorageConfigError` (`reason: "secret-missing"`) when the secret is missing from `secrets`.
|
|
586
612
|
|
|
587
613
|
Adapter hooks and lifecycle:
|
|
588
614
|
|
|
@@ -590,7 +616,7 @@ Adapter hooks and lifecycle:
|
|
|
590
616
|
- Implement `openSessionStore(options, context, { prefix? })` for non-SQL session stores. When both hooks exist, `openSessionStore` takes priority for sessions.
|
|
591
617
|
- Missing hooks raise `StorageConfigError` (`reason: "adapter-domain-unsupported"`). Load failures raise `StorageAdapterLoadError`, and driver open failures raise `StorageUnavailableError`.
|
|
592
618
|
- `new StorageProvider().openSessionStore(selection, context)` opens stores programmatically (`kind`: `"memory"`, `"jsonl"`, `"sqlite"`, `"database"`, or `"adapter"`). `loadStorageAdapter(module, context, hostModules)` loads an adapter module.
|
|
593
|
-
-
|
|
619
|
+
- `StorageProvider` instances share one process-wide map of provider-owned databases across matching selections and close each owned database when its last returned store closes. Caller-owned `database` handles passed through `{ kind: "database", database }` are never closed by the provider.
|
|
594
620
|
- If opening storage fails and closing its owned database also fails, Atomic throws the original opening error with a `cleanupCause` field holding the cleanup failure.
|
|
595
621
|
|
|
596
622
|
### Adapters from Atomic packages
|
|
@@ -628,7 +654,7 @@ Atomic resolves adapter package names in this order:
|
|
|
628
654
|
2. Packages in effective global settings (including legacy `~/.pi/agent/settings.json` for the default agent directory). Project packages are not searched.
|
|
629
655
|
3. Module resolution from the agent directory.
|
|
630
656
|
|
|
631
|
-
Child processes that Atomic starts (such as
|
|
657
|
+
Child processes that Atomic starts (such as subagents and the Intercom broker) automatically inherit adapters resolved from the host's packages without reloading the host package. `atomic storage status` shows the resolved path when run inside such a process, and resolves from global settings or the agent directory when run directly from a shell.
|
|
632
658
|
|
|
633
659
|
## Bring your own driver
|
|
634
660
|
|
|
@@ -651,213 +677,99 @@ Transient retry and queue bounds:
|
|
|
651
677
|
- Recognized transient failures reject with `StorageTransientError`. Statements and batches that failed before writing retry up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` (5) times starting at 250 ms with exponential backoff and up to 20% jitter. Writes with `outcome: "unknown"` never retry automatically.
|
|
652
678
|
- Transactions retry (re-running their callback) only when called with `{ retryTransientFailures: true }` and only for callbacks that have no external side effects. Non-boolean values throw `StorageConfigError`. The first retried failure on a database emits a one-time process warning.
|
|
653
679
|
- While one call runs without settling, waiting priority calls (such as heartbeats or lease renewals) fail after `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` (10 seconds), and other waiting calls fail after `STORAGE_QUEUED_CALL_MAX_WAIT_MS` (60 seconds), both with `StorageUnavailableError`. Timers reset for each call that begins running.
|
|
654
|
-
- On a libSQL server, if an outage interrupts an open write transaction, `@bastani/atomic-storage-libsql` retries closing the abandoned stream (250 ms to 8 s backoff, up to 5 minutes) to release the server write lock. If the server already moved past the stream baton, the lock clears when the server expires the stream (about 5 seconds on `sqld`).
|
|
655
680
|
- For shared local SQLite files, enable WAL mode with `switchToWriteAheadLog(exec, busyTimeoutMs)` from `@bastani/atomic/storage`. It retries `SQLITE_BUSY` up to `busyTimeoutMs` and retries Windows `SQLITE_IOERR_TRUNCATE` for up to 5 seconds (or `busyTimeoutMs`, whichever is shorter).
|
|
656
681
|
|
|
657
682
|
You can also implement `SqliteDatabase` directly. In either case, verify your implementation with the [conformance suite](#adapter-conformance).
|
|
658
683
|
|
|
659
|
-
###
|
|
660
|
-
|
|
661
|
-
This module is a complete custom adapter. Install `@libsql/client` where the module can import it, such as in an [Atomic package](#adapters-from-atomic-packages). For local `file:` URLs, create the parent directory first.
|
|
684
|
+
### Custom driver adapter example
|
|
662
685
|
|
|
663
|
-
|
|
686
|
+
For production Turso or `sqld` deployments, install `@bastani/atomic-storage-libsql` (which includes abandoned-stream cleanup, namespace headers, and Windows local-file close safeguards). The minimal example below shows the `createSqliteDatabase` and `StorageAdapterModule` structure for wrapping any SQLite-compatible client:
|
|
664
687
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
import { createRequire } from "node:module";
|
|
668
|
-
import { setFlagsFromString } from "node:v8";
|
|
669
|
-
import { runInNewContext } from "node:vm";
|
|
670
|
-
import type { Client, Transaction } from "@libsql/client";
|
|
688
|
+
```typescript
|
|
689
|
+
import { createClient, type Client, type Transaction } from "@libsql/client";
|
|
671
690
|
import {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
StorageAdapterLoadError,
|
|
678
|
-
type StorageFailureCause,
|
|
691
|
+
createSqliteDatabase,
|
|
692
|
+
redactSecrets,
|
|
693
|
+
type SqliteDatabase,
|
|
694
|
+
type SqliteDriverExecutor,
|
|
695
|
+
type StorageAdapterModule,
|
|
679
696
|
} from "@bastani/atomic/storage";
|
|
680
697
|
|
|
681
|
-
export interface
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/** Credentials a libSQL URL can carry: its userinfo and every `authToken` query value. */
|
|
687
|
-
function urlCredentials(url: string): string[] {
|
|
688
|
-
const secrets: string[] = [];
|
|
689
|
-
// Scan each key/value once, including malformed URLs, without retrying a growing suffix at every '?'.
|
|
690
|
-
for (let index = 0; index < url.length; index++) {
|
|
691
|
-
if (url[index] !== "?" && url[index] !== "&") continue;
|
|
692
|
-
const start = ++index;
|
|
693
|
-
while (index < url.length && !"?&=#".includes(url[index]!)) index++;
|
|
694
|
-
if (url[index] === "=") {
|
|
695
|
-
const valueStart = ++index;
|
|
696
|
-
while (index < url.length && url[index] !== "&" && url[index] !== "#") index++;
|
|
697
|
-
const token = new URLSearchParams(url.slice(start, index)).get("authToken");
|
|
698
|
-
if (token !== null) secrets.push(url.slice(valueStart, index), token);
|
|
699
|
-
}
|
|
700
|
-
index--;
|
|
701
|
-
}
|
|
702
|
-
const userinfo = url.match(/\/\/([^/?#]*)@/)?.[1];
|
|
703
|
-
if (userinfo !== undefined) secrets.push(...userinfo.split(":"));
|
|
704
|
-
return secrets;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
const closesOnce = Symbol.for("@bastani/atomic-storage-libsql.closesOnce");
|
|
708
|
-
|
|
709
|
-
interface LibsqlConnection {
|
|
710
|
-
open: boolean;
|
|
711
|
-
close(): void;
|
|
712
|
-
prepare(sql: string): object;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
interface LibsqlConnectionClass {
|
|
716
|
-
prototype: LibsqlConnection & { [closesOnce]?: true };
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
const statementsHeldWhileClosing = new Set<object>();
|
|
720
|
-
|
|
721
|
-
function statementHoldingConnection(connection: LibsqlConnection): object | undefined {
|
|
722
|
-
if (!connection.open) return undefined;
|
|
723
|
-
try {
|
|
724
|
-
return connection.prepare("SELECT 1");
|
|
725
|
-
} catch {
|
|
726
|
-
return undefined;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function closeEachConnectionOnce(): void {
|
|
731
|
-
const client = createRequire(import.meta.url).resolve("@libsql/client");
|
|
732
|
-
const Connection = createRequire(client)("libsql") as LibsqlConnectionClass;
|
|
733
|
-
if (Connection.prototype[closesOnce]) return;
|
|
734
|
-
const close = Connection.prototype.close;
|
|
735
|
-
Connection.prototype.close = function (this: LibsqlConnection) {
|
|
736
|
-
const statement = statementHoldingConnection(this);
|
|
737
|
-
if (statement) statementsHeldWhileClosing.add(statement);
|
|
738
|
-
try {
|
|
739
|
-
close.call(this);
|
|
740
|
-
} finally {
|
|
741
|
-
if (statement) statementsHeldWhileClosing.delete(statement);
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
Connection.prototype[closesOnce] = true;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
interface GarbageCollectingRuntime {
|
|
748
|
-
gc?: () => void;
|
|
749
|
-
Bun?: { gc(force: boolean): void };
|
|
698
|
+
export interface CustomDriverOptions {
|
|
699
|
+
url: string;
|
|
700
|
+
authToken?: string;
|
|
750
701
|
}
|
|
751
702
|
|
|
752
|
-
function
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
703
|
+
function executor(connection: () => Client | Transaction): SqliteDriverExecutor {
|
|
704
|
+
return {
|
|
705
|
+
async execute(sql, params) {
|
|
706
|
+
const result = await connection().execute({ sql, args: [...params] });
|
|
707
|
+
return { columns: result.columns, rows: result.rows, changes: result.rowsAffected };
|
|
708
|
+
},
|
|
709
|
+
executeMultiple: (sql) => connection().executeMultiple(sql),
|
|
710
|
+
};
|
|
759
711
|
}
|
|
760
712
|
|
|
761
|
-
function
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
executeMultiple: (sql) => connection().executeMultiple(sql),
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
export async function openLibsqlDatabase({ url, authToken }: LibsqlDatabaseOptions): Promise<SqliteDatabase> {
|
|
788
|
-
let createClient: typeof import("@libsql/client").createClient;
|
|
789
|
-
try {
|
|
790
|
-
({ createClient } = await import("@libsql/client"));
|
|
791
|
-
closeEachConnectionOnce();
|
|
792
|
-
} catch (cause) {
|
|
793
|
-
throw new StorageAdapterLoadError("@libsql/client", cause as StorageFailureCause);
|
|
794
|
-
}
|
|
795
|
-
let client: Client | undefined;
|
|
796
|
-
// Create the client inside a driver call, so the facade redacts credentials from its failures.
|
|
797
|
-
const connection = () => (client ??= createClient({ url, authToken, intMode: "bigint" }));
|
|
798
|
-
const database = createSqliteDatabase({
|
|
799
|
-
descriptor: { adapter: "libsql", location: url },
|
|
800
|
-
redact: redactSecrets([authToken ?? "", ...urlCredentials(url)]),
|
|
801
|
-
...statements(connection),
|
|
802
|
-
async beginTransaction() {
|
|
803
|
-
const transaction = await connection().transaction("write");
|
|
804
|
-
return {
|
|
805
|
-
...statements(() => transaction),
|
|
806
|
-
commit: () => transaction.commit(),
|
|
807
|
-
rollback: () => transaction.rollback(),
|
|
808
|
-
close: () => transaction.close(),
|
|
809
|
-
};
|
|
810
|
-
},
|
|
811
|
-
async close() {
|
|
812
|
-
client?.close();
|
|
813
|
-
if (/^file:/i.test(url)) await releaseClosedConnections();
|
|
814
|
-
},
|
|
815
|
-
});
|
|
816
|
-
try {
|
|
817
|
-
await database.exec("PRAGMA foreign_keys = ON");
|
|
818
|
-
return database;
|
|
819
|
-
} catch (error) {
|
|
820
|
-
await database.close().catch(() => {});
|
|
821
|
-
throw error;
|
|
822
|
-
}
|
|
713
|
+
export async function openCustomDatabase({ url, authToken }: CustomDriverOptions): Promise<SqliteDatabase> {
|
|
714
|
+
let client: Client | undefined;
|
|
715
|
+
const connection = () => (client ??= createClient({ url, authToken, intMode: "bigint" }));
|
|
716
|
+
const database = createSqliteDatabase({
|
|
717
|
+
descriptor: { adapter: "custom-libsql", location: url },
|
|
718
|
+
redact: redactSecrets(authToken ? [authToken] : []),
|
|
719
|
+
...executor(connection),
|
|
720
|
+
async beginTransaction() {
|
|
721
|
+
const tx = await connection().transaction("write");
|
|
722
|
+
return {
|
|
723
|
+
...executor(() => tx),
|
|
724
|
+
commit: () => tx.commit(),
|
|
725
|
+
rollback: () => tx.rollback(),
|
|
726
|
+
close: () => tx.close(),
|
|
727
|
+
};
|
|
728
|
+
},
|
|
729
|
+
async close() {
|
|
730
|
+
client?.close();
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
await database.exec("PRAGMA foreign_keys = ON");
|
|
734
|
+
return database;
|
|
823
735
|
}
|
|
824
736
|
|
|
825
737
|
export default {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
738
|
+
atomicStorageAdapter: 1,
|
|
739
|
+
openDatabase: (options) =>
|
|
740
|
+
openCustomDatabase({
|
|
741
|
+
url: String(options.url),
|
|
742
|
+
authToken: typeof options.authToken === "string" ? options.authToken : undefined,
|
|
743
|
+
}),
|
|
832
744
|
} satisfies StorageAdapterModule;
|
|
833
745
|
```
|
|
834
|
-
{/* /custom-driver-example */}
|
|
835
746
|
|
|
836
|
-
The default export lets settings select this module as an [adapter](#selecting-an-adapter). From the SDK, call
|
|
747
|
+
The default export lets settings select this module as an [adapter](#selecting-an-adapter). From the SDK, call your open helper directly and pass the database to `createAgentSession`:
|
|
837
748
|
|
|
838
|
-
```
|
|
839
|
-
import {
|
|
749
|
+
```typescript
|
|
750
|
+
import { openCustomDatabase } from "./custom-adapter.js";
|
|
840
751
|
|
|
841
|
-
const database = await
|
|
842
|
-
|
|
752
|
+
const database = await openCustomDatabase({
|
|
753
|
+
url: "libsql://your-database.turso.io",
|
|
754
|
+
authToken: process.env.TURSO_TOKEN,
|
|
755
|
+
});
|
|
843
756
|
try {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
await tx.run("INSERT INTO notes VALUES (?)", "hello");
|
|
757
|
+
const { session } = await createAgentSession({
|
|
758
|
+
sessionStore: { kind: "database", database, prefix: "project_" },
|
|
847
759
|
});
|
|
848
|
-
|
|
760
|
+
await session.prompt("List the failing tests");
|
|
849
761
|
} finally {
|
|
850
762
|
await database.close();
|
|
851
763
|
}
|
|
852
764
|
```
|
|
853
765
|
|
|
854
|
-
|
|
766
|
+
Multiple stores can share one caller-owned `database` without closing it.
|
|
855
767
|
|
|
856
768
|
### Custom `SessionStore` contracts
|
|
857
769
|
|
|
858
770
|
Non-SQL backends can implement `openSessionStore` directly (each session has one writer):
|
|
859
771
|
|
|
860
|
-
- **Required for `history://`.** Implement `readEntryRange(id, query)` honoring `fromSeq`, `toSeq`, `maxChars`, `largeEntryBytes`, `skipTypes`, and `signal`. Return freshly owned UTF-8 JSON
|
|
772
|
+
- **Required for `history://`.** Implement `readEntryRange(id, query)` honoring `fromSeq`, `toSeq`, `maxChars`, `largeEntryBytes`, `skipTypes`, and `signal`. Return freshly owned UTF-8 JSON buffers and `{ entries: [{ seq, entry }], throughSeq, lastSeq }` without falling back to whole-session `load()`.
|
|
861
773
|
- **Optional fast-path methods.** Implementing these avoids loading entire sessions into memory (stores implementing only `load()` still work with higher memory use):
|
|
862
774
|
|
|
863
775
|
| Method | Purpose |
|
|
@@ -870,7 +782,7 @@ Non-SQL backends can implement `openSessionStore` directly (each session has one
|
|
|
870
782
|
| `readEntrySizes` / `readEntryChunk` / `readScanPage` | Byte-bounded streaming exports and remote page reads |
|
|
871
783
|
|
|
872
784
|
- **Epochs and indexes.** Keep `epoch` constant on appends, rotate it on `replace` or recreate, and reject mismatched `epoch` writes with `SessionConflictError`. Mark read-only stores `readOnly: true` to skip cleanup writes. Set `estimated: true` on `SessionSummary` when metadata is unindexed.
|
|
873
|
-
- **Forks and
|
|
785
|
+
- **Forks and cloning.** `/fork`, `/clone`, and `SessionManager.forkFrom` stream entries in pages (same-store forks copy all branches; cross-store forks copy current context and mark the parent in another store; see [`/tree`, `/fork`, and `/clone`](/sessions#tree-fork-and-clone)).
|
|
874
786
|
|
|
875
787
|
## Storage errors
|
|
876
788
|
|
|
@@ -897,21 +809,21 @@ Coded storage errors carry a stable `code` and actionable `hint`:
|
|
|
897
809
|
| --- | --- | --- | --- | --- |
|
|
898
810
|
| `StorageWriteLockTimeoutError` (subclass of `StorageUnavailableError`) | `write-lock-timeout` | A node-sqlite transaction waited its full `lockWaitMs` with no commits. Nothing ran. | `adapter`, `location`, `timeoutMs`, `elapsedMs`, `phase` (`"queued"` or `"acquiring"`), `holderPid`/`holderHeldMs` or `holderCandidates`, `retryable: true`, `cause` | Check the holding process or raise `lockWaitMs`, then retry. |
|
|
899
811
|
| `StorageUnsupportedOperationError` | `unsupported-operation` | `getWriterQueueStats` or `getWriterQueueDegradation` received a non-node-sqlite handle. | `operation`, `adapter`, `location` | Pass a handle from `openNodeSqliteDatabase` or `wrapNodeSqliteDatabase`. |
|
|
900
|
-
| `StorageWriterQueueDegradedError` | `writer-queue-degraded` | Recorded once per reason (via `getWriterQueueDegradation` and process warning), never thrown. Covers `watch-unavailable`, `wake-failed`, `stale-ticket-kept`, and `holder-record-unavailable`. | `reason`, `adapter`, `location`, `cause`, `hint` | Raise file-watch limits, fix permissions on
|
|
901
|
-
| `StorageWriterQueueUnusableError` (subclass of `StorageUnavailableError`) | `writer-queue-unusable` | A node-sqlite transaction could not use
|
|
812
|
+
| `StorageWriterQueueDegradedError` | `writer-queue-degraded` | Recorded once per reason (via `getWriterQueueDegradation` and process warning), never thrown. Covers `watch-unavailable`, `wake-failed`, `stale-ticket-kept`, and `holder-record-unavailable`. | `reason`, `adapter`, `location`, `cause`, `hint` | Raise file-watch limits, fix permissions on the writer queue directories beside the database file, or remove abandoned entries. |
|
|
813
|
+
| `StorageWriterQueueUnusableError` (subclass of `StorageUnavailableError`) | `writer-queue-unusable` | A node-sqlite transaction could not use its writer queue directories. Nothing ran. | `adapter`, `location`, `errno`, `cause` | Make the database directory and writer queue directories readable and writable for all writers. |
|
|
902
814
|
| `StorageTransientError` (subclass of `StorageUnavailableError`) | `stream-expired`, `transaction-timeout`, `connection-refused`, `connection-lost`, `lock-conflict`, `read-only-server` | A temporary server or network failure ended a call (after up to 5 attempts if nothing was written, or immediately if `outcome` is `"unknown"`). | `adapter`, `location`, `outcome` (`"not-applied"` or `"unknown"`), `attempts`, `retryable: true`, `cause`, optional `hop` and `hopFailure` | Check connectivity to the server or named `hop`, then retry. For `"unknown"`, read state back before retrying non-idempotent writes. |
|
|
903
815
|
| `SessionBlobError` | `blobs-unsupported` | The session store lacks `putBlob` and `getBlob` needed for an import, fork, branch, or `tool-output://` read. | `sessionId`, `adapter` | Use SQLite, libSQL, or PostgreSQL, or implement `putBlob` and `getBlob` on your custom store. |
|
|
904
816
|
| `SessionBlobError` | `blob-missing` | A `tool-output://<sha256>` blob is missing. Copies, forks, and exports continue without it and emit a warning (or call `onMissingBlob`). | `sessionId`, `hash`, optional `missing` count | Run the tool again to regenerate the output. |
|
|
905
817
|
| `SessionBlobError` | `blob-incomplete` | A blob record exists, but part of its content is missing. | `sessionId`, `hash`, `bytes` | Run the tool again to regenerate the output. |
|
|
906
818
|
| `SessionBlobError` | `blob-corrupt` | Imported tool output failed its SHA-256 check. Nothing was written. | `sessionId`, `hash`, `actualHash` | Export the session again from its source. |
|
|
907
|
-
| `SessionSpillError` | `spill-read-failed` | `MemorySessionStore` failed to read a
|
|
908
|
-
| `SessionSpillError` | `spill-missing` | A
|
|
909
|
-
| `SessionSpillError` | `spill-corrupt` | A
|
|
819
|
+
| `SessionSpillError` | `spill-read-failed` | `MemorySessionStore` failed to read a temporary history file under `released-history`. Retryable for `EMFILE`, `ENFILE`, `EAGAIN`, `EBUSY`, and `EINTR`. | `directory`, `sessionId`, `bytes`, `errno`, `cause` | Check directory permissions and file descriptor limits, then reopen the session. |
|
|
820
|
+
| `SessionSpillError` | `spill-missing` | A temporary history file under `released-history` is missing or truncated. History is lost; listings omit it. | `directory`, `sessionId`, `bytes`, optional `foundBytes`, `errno` | Leave `released-history` untouched while Atomic runs, or use a persistent store. |
|
|
821
|
+
| `SessionSpillError` | `spill-corrupt` | A temporary history file failed length, parse, or checksum checks. History is lost; listings omit it. | `directory`, `sessionId`, `bytes`, optional `foundBytes`, optional `cause` | Leave `released-history` untouched while Atomic runs, or use a persistent store. |
|
|
910
822
|
| `SessionSpillError` | `spill-write-failed`, `spill-dir-refused`, `spill-cleanup-failed` | Recorded once on the store and emitted as a process warning, never thrown. History remains in memory when writes or directory creation fail. | `directory`, optional `sessionId`, optional `bytes`, `errno`, optional `cause` | Free disk space or make the agent directory writable. |
|
|
911
823
|
|
|
912
824
|
### Error guards, serialization, and session persistence errors
|
|
913
825
|
|
|
914
|
-
- **Guards.** Each coded error exports a cross-realm guard: `isStorageConfigError`, `isStorageWriteLockTimeoutError`, `isStorageUnsupportedOperationError`, `isStorageWriterQueueDegradedError`, `isStorageWriterQueueUnusableError`, `isStorageTransientError`, `isSessionBlobError`, and `isSessionSpillError`. Constant arrays `STORAGE_TRANSIENT_ERROR_CODES`, `SESSION_BLOB_ERROR_CODES`, and `SESSION_SPILL_ERROR_CODES` list their codes. `isStorageError(error)` matches any storage error above. `findStorageWriteLockTimeoutError(error)` and `isRetryableStorageError(error)` inspect up to
|
|
826
|
+
- **Guards.** Each coded error exports a cross-realm guard: `isStorageConfigError`, `isStorageWriteLockTimeoutError`, `isStorageUnsupportedOperationError`, `isStorageWriterQueueDegradedError`, `isStorageWriterQueueUnusableError`, `isStorageTransientError`, `isSessionBlobError`, and `isSessionSpillError`. Constant arrays `STORAGE_TRANSIENT_ERROR_CODES`, `SESSION_BLOB_ERROR_CODES`, and `SESSION_SPILL_ERROR_CODES` list their codes. `isStorageError(error)` matches any storage error above. `findStorageWriteLockTimeoutError(error)` and `isRetryableStorageError(error)` inspect up to 8 levels of `cause`.
|
|
915
827
|
- **Cross-process serialization.** Use `serializeStorageError(error)` and `rehydrateStorageError(json)` to pass storage errors across process boundaries with their class, fields, `cause` chain, `rollbackCause`, and `cleanupCause`. Unknown future error names rehydrate as `StorageError` keeping `name`, `code`, and fields.
|
|
916
828
|
- **Session store errors.** Session operations can throw `SessionNotFoundError` (`sessionId`), `SessionExistsError` (`sessionId`), `SessionIdMismatchError` (`requested`, `found`), `SessionConflictError` (`sessionId`, `expectedSeq`, `actualSeq`), `SessionFormatVersionError` (`path`, `found`, `supported`), `SessionInvalidTextError` (`field`, `reason`), `SessionInvalidTimestampError` (`field`, `reason`, `value`), and `JsonlStoragePoisonedError` (`location`, `cause`, `rollbackCause`). After a conflict, reopen the session before writing again.
|
|
917
829
|
- **Save failures during a run.** If a running session cannot save a message, Atomic reports `could not persist the <role> message: <cause>` once and halts that run without starting further model requests, tool calls, retries, fallbacks, or compaction. Print and JSON modes print the error on stderr and exit `1` (print mode still prints the received answer). Interactive mode displays the error, stays open, and retries saving on later prompts.
|
|
@@ -919,7 +831,7 @@ Coded storage errors carry a stable `code` and actionable `hint`:
|
|
|
919
831
|
|
|
920
832
|
### Team setup errors
|
|
921
833
|
|
|
922
|
-
`joinTeam()`, `leaveTeam()`, `getTeamProfile()`, `teamProfileSelection()`, `atomic storage join`, `atomic team`, and `ATOMIC_PROFILE=ci` validation throw these classes from `@bastani/atomic/storage`. Cross-process guards `isTeamProfileError()`, `isTeamProfileTimeoutError()`, and `isTeamProfileConfigError()` match by `name` and `code`, and `isRetryableTeamProfileError()` inspects up to
|
|
834
|
+
`joinTeam()`, `leaveTeam()`, `getTeamProfile()`, `teamProfileSelection()`, `atomic storage join`, `atomic team`, and `ATOMIC_PROFILE=ci` validation throw these classes from `@bastani/atomic/storage`. Cross-process guards `isTeamProfileError()`, `isTeamProfileTimeoutError()`, and `isTeamProfileConfigError()` match by `name` and `code`, and `isRetryableTeamProfileError()` inspects up to 8 cause levels. Messages and fields name variables, flags, and files, never token values.
|
|
923
835
|
|
|
924
836
|
`TeamProfileConfigError` extends `StorageConfigError` (`source`: `"sdk"`, `"cli"`, or `"env"`, `field`, `code`, `reason`, `hint`, optional `path` and `missing`, `retryable: false`). Nothing changes when it is thrown:
|
|
925
837
|
|
|
@@ -928,7 +840,7 @@ Coded storage errors carry a stable `code` and actionable `hint`:
|
|
|
928
840
|
| `unknown-profile` | `ATOMIC_PROFILE` or SDK `profile` is not `ci` |
|
|
929
841
|
| `incomplete-profile` | A team variable is set without `ATOMIC_PROFILE`, or `ATOMIC_PROFILE=ci` lacks a URL or token (`missing` lists all missing variables) |
|
|
930
842
|
| `missing-url` | No database URL was passed |
|
|
931
|
-
| `unsupported-url` | URL is not `libsql://`, `https://`, `wss://`, or `file:` |
|
|
843
|
+
| `unsupported-url` | URL is not `libsql://`, `https://`, `http://`, `wss://`, `ws://`, or `file:` |
|
|
932
844
|
| `relative-file-url` | A `file:` URL is relative |
|
|
933
845
|
| `credential-in-url` | URL contains a username, password, or `authToken` |
|
|
934
846
|
| `missing-token` | Non-`file:` URL has no token, or `tokenEnv` names an unset variable |
|
|
@@ -953,13 +865,13 @@ Coded storage errors carry a stable `code` and actionable `hint`:
|
|
|
953
865
|
| `broker-restart-failed` | Returned in `broker`, not thrown: settings saved, but Intercom broker failed to restart (`retryable: true`). | Run `atomic intercom restart`. |
|
|
954
866
|
| `token-delete-failed` | `leaveTeam` removed settings, but could not delete the token file. | Delete the file manually. |
|
|
955
867
|
|
|
956
|
-
`SHARED_STORAGE_JOIN_HINT` exports the canonical hint string `atomic team join <url> --token-file <path>`. Use `serializeTeamError(error)` and `rehydrateTeamError(json)` to preserve team error classes, fields, and up to
|
|
868
|
+
`SHARED_STORAGE_JOIN_HINT` exports the canonical hint string `atomic team join <url> --token-file <path>`. Use `serializeTeamError(error)` and `rehydrateTeamError(json)` to preserve team error classes, fields, and up to 8 cause levels across processes without leaking credentials (non-team causes keep only `name` and `code`).
|
|
957
869
|
|
|
958
870
|
## Adapter conformance
|
|
959
871
|
|
|
960
872
|
Validate any `SqliteDatabase` adapter against the conformance suites exported from `@bastani/atomic/storage/testing`:
|
|
961
873
|
|
|
962
|
-
```
|
|
874
|
+
```typescript
|
|
963
875
|
import {
|
|
964
876
|
registerSqliteConnectionConformance,
|
|
965
877
|
registerSqliteDatabaseConformance,
|
|
@@ -975,6 +887,6 @@ registerSqliteConnectionConformance({ describe, it }, "my adapter connections",
|
|
|
975
887
|
|
|
976
888
|
Helper utilities exported from `@bastani/atomic/storage` for custom adapters:
|
|
977
889
|
|
|
978
|
-
- `validateStoragePrefix(prefix, dialect?)` validates optional table prefixes (ASCII letters, digits, and `_`, not starting with `sqlite_
|
|
890
|
+
- `validateStoragePrefix(prefix, dialect?)` validates optional table prefixes (ASCII letters, digits, and `_`, not starting with `sqlite_`, case-insensitively). Passing `"postgres"` also enforces lowercase and `POSTGRES_MAX_STORAGE_PREFIX_LENGTH` (24).
|
|
979
891
|
- `renderStorageIdentifiers("sessions", names, prefix)` returns a frozen map of table names with the `session_` prefix applied.
|
|
980
892
|
- `assertStorageSchemaVersion(domain, found, supported)` throws `StorageSchemaVersionError` when stored and supported versions differ.
|