@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/sdk/reference.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: SDK API reference
|
|
2
|
+
title: "SDK API reference"
|
|
3
3
|
sidebarTitle: "SDK API"
|
|
4
|
-
description: SDK options,
|
|
4
|
+
description: "Complete API reference for Atomic SDK session options, model scoping, session stores, resource loaders, run modes, task supervision, and exports."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# SDK API reference
|
|
8
|
-
|
|
9
7
|
## Options reference
|
|
10
8
|
|
|
11
9
|
### Directories
|
|
@@ -118,15 +116,37 @@ if (auto) {
|
|
|
118
116
|
}
|
|
119
117
|
```
|
|
120
118
|
|
|
119
|
+
#### Resolving scoped models
|
|
120
|
+
|
|
121
|
+
`resolveModelScopeFromModels(patterns, models)` and `resolveModelScopeWithDiagnostics(patterns, modelRuntime)` expand `--models` / `enabledModels` pattern arrays into `{ scopedModels, diagnostics }`. Each pattern resolves in three stages:
|
|
122
|
+
|
|
123
|
+
1. Exact literal reference without a thinking suffix (matches `provider/id` or `id`).
|
|
124
|
+
2. If the pattern contains `*`, `?`, or `[`: strips a valid trailing `:<thinking>` suffix, retries an exact literal match first (so bracketed model IDs like `model[1m]` stay literal), then runs case-insensitive `minimatch` against both `provider/id` and `id`.
|
|
125
|
+
3. Fuzzy substring matching with lenient `:<thinking>` suffix parsing.
|
|
126
|
+
|
|
127
|
+
Matches are deduplicated in order (first match wins). `diagnostics` lists warnings with `code: "no-match" | "invalid-thinking-level"`.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { resolveModelScopeWithDiagnostics } from "@bastani/atomic";
|
|
131
|
+
|
|
132
|
+
const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(
|
|
133
|
+
["anthropic/*sonnet*:high", "openai/o3"],
|
|
134
|
+
modelRuntime,
|
|
135
|
+
);
|
|
136
|
+
```
|
|
137
|
+
|
|
121
138
|
#### Model catalog persistence and refresh
|
|
122
139
|
|
|
123
|
-
`ModelRuntime.create()` restores cached catalogs from local persistence and does not download the models.dev catalog unless you opt in. Pass `catalogBaseUrl` (or set `ATOMIC_MODEL_CATALOG_URL`) to read `<url>/api.json` from your own models.dev mirror instead of https://models.dev
|
|
140
|
+
`ModelRuntime.create()` restores cached catalogs from local persistence and does not download the models.dev catalog unless you opt in. Pass `catalogBaseUrl` (or set `ATOMIC_MODEL_CATALOG_URL`) to read `<url>/api.json` from your own models.dev mirror instead of `https://models.dev`.
|
|
124
141
|
|
|
125
|
-
- `allowModelNetwork` (
|
|
126
|
-
-
|
|
142
|
+
- `allowModelNetwork` (tri-state):
|
|
143
|
+
- **Omitted (`undefined`):** skips create-time network refresh, but still allows a first-prompt GitHub Copilot lookup when no cached Copilot catalog or fallback model exists.
|
|
144
|
+
- **`false`:** disables **both** create-time network refresh and first-prompt GitHub Copilot lookup.
|
|
145
|
+
- **`true`:** enables create-time network refresh (bounded by `modelRefreshTimeoutMs`).
|
|
146
|
+
- `modelRefreshTimeoutMs` (default `15_000`): bounds how long the create-time refresh may run before aborting.
|
|
127
147
|
- `refreshOnCreate: false`: skips the initial catalog and availability refresh entirely; built-in models remain available.
|
|
128
148
|
|
|
129
|
-
`createAgentSession()` does not fetch an account model list at startup. If
|
|
149
|
+
`createAgentSession()` does not fetch an account model list at startup. If cache restore found no GitHub Copilot catalog and the first prompt has no usable model or fallback, the session can look up the exact saved Copilot model unless `allowModelNetwork: false` was passed to `ModelRuntime.create()`. A supplied `model`, a working preset or fallback, and a cached catalog need no lookup. Only that session uses the result; `models-store.json`, credentials, and model listings do not change.
|
|
130
150
|
|
|
131
151
|
The `modelFallbackMessage` returned by `createAgentSession()` describes startup. If the account confirms the model is absent, the first prompt's error says so; a refused, offline, or cancelled lookup keeps the usual error. Pass `signal` to `createAgentSession()` to cancel the lookup, or pass `allowModelNetwork: false` to `ModelRuntime.create()` to disable it. Custom asynchronous-only credential stores keep normal local selection; discovery never waits on their read queue.
|
|
132
152
|
|
|
@@ -220,11 +240,12 @@ Specify which tools to expose by name:
|
|
|
220
240
|
- `find` discovers filesystem paths by glob; `search` searches file contents with regex patterns across files, directories, globs, and internal URLs.
|
|
221
241
|
- `builtins` selects shipped packages independently of tools: keys are `subagents`, `mcp`, `web-access`, and `intercom`. Omitted, `{}`, and omitted keys enable packages. A `false` value removes that package's extensions and resources, including on reload; `true` enables it.
|
|
222
242
|
- The `subagents` builtin ships all 21 bundled subagent skills: `agent-browser`, `agent-desktop`, `bro`, `create-spec`, `feedback`, `herdr`, `how`, `impeccable`, `liteparse`, `prompt-engineer`, `qlty`, `research-codebase`, `show-me`, `skill-creator`, `subagent`, `tdd`, `teach`, `tmux`, `unslop`, `why`, and `workflow-files`. If you want these skills without the delegation tool, keep `subagents` enabled and pass `excludedTools: ["subagent"]`. If you disable the package, install independent copies of the skills you need in your [skills directory](/skills#locations).
|
|
223
|
-
- `tools` accepts an allowlist of coding, extension, and custom tool names or `*` patterns. `tools: []` exposes no tools, including Intercom. A list containing only `+name`/`-name` entries modifies resolved defaults (for example `tools: ["+codemode", "-write"]`). Modifiers require exact names, cannot mix with plain entries, and apply across reloads. Invalid lists throw.
|
|
224
|
-
- `
|
|
243
|
+
- `tools` accepts an allowlist of coding, extension, and custom tool names or `*` patterns. Pattern matching is **case-sensitive** and treats only `*` as a wildcard (matching any characters); `?`, `[]`, and `{}` are matched literally. `tools: []` exposes no tools, including Intercom. A list containing only `+name`/`-name` entries modifies resolved defaults (for example `tools: ["+codemode", "-write"]`). Modifiers require exact names (no `*`), cannot mix with plain entries, and apply across reloads. Invalid lists throw.
|
|
244
|
+
- **MCP retention with allowlists:** When `tools` is a non-empty allowlist with no `mcp__*` entry, MCP tools remain registered for `codemode` and `tool_search`. Adding any `mcp__*` entry switches MCP tools to explicit allowlisting too.
|
|
245
|
+
- `excludedTools` removes matching names (using the same case-sensitive `*`-only matching) from the registry and active selection. Exclusions win over `tools`; unknown names are ignored.
|
|
225
246
|
- `noTools: "all"` exposes no tools, even with a nonempty `tools` list. It does not remove package resources or authorize services.
|
|
226
247
|
- `noTools: "builtin"` suppresses the built-in selection, including `codemode`, when `tools` is omitted. Other extension and custom tools keep their default activation unless excluded. An explicit `tools` list wins over this mode.
|
|
227
|
-
- Configured `defaultTools`
|
|
248
|
+
- Configured `defaultTools` narrows only the initial built-in coding selection when `tools` and `noTools` are omitted (it never disables extension or custom tools). Plain names replace defaults; modifier-only lists such as `["-bash", "+ls"]` modify defaults, and project modifier-only lists layer over global settings. See [defaultTools](/settings#tools).
|
|
228
249
|
|
|
229
250
|
Subagent children inherit these restrictions. Child allowlists intersect with parent selections, including during model fallback, and a child cannot restore a parent-disabled package or excluded tool. See [child configuration](/sdk#subagent-children) for model, auth, host callback, and working-directory inheritance.
|
|
230
251
|
|
|
@@ -383,7 +404,7 @@ Do not mix wait arguments with launch fields. Unknown IDs, foreign IDs, and unbo
|
|
|
383
404
|
|
|
384
405
|
PowerShell tools and local operations accept a trusted `taskOwner` binding and the same `wait` observation policy as `bash`. Owned native Windows runs auto-yield after the owner's command budget (normally 10000 ms); explicit per-call budgets override it, while execution timeout stays separate. Without a supported owner, explicit background requests reject and foreground execution waits for completion.
|
|
385
406
|
|
|
386
|
-
On native Windows,
|
|
407
|
+
On native Windows, a `bash` or `powershell` tool call without a `taskOwner` binding runs in its own job object so a timeout or abort terminates child processes even after the shell exits. Processes that break away (`CREATE_BREAKAWAY_FROM_JOB`), including commands started by Git Bash, are terminated on timeout or abort only while still under the running shell; detached children left behind by a finished command continue running.
|
|
387
408
|
|
|
388
409
|
```typescript
|
|
389
410
|
import { createPowerShellTool } from "@bastani/atomic";
|
|
@@ -446,7 +467,7 @@ Use `defineTool()` for standalone definitions and arrays like `customTools: [myT
|
|
|
446
467
|
|
|
447
468
|
Custom tools passed via `customTools` combine with extension-registered tools. When you pass a plain-name `tools` allowlist, include each custom or extension tool you want active (for example `tools: ["read", "bash", "my_tool"]`). Modifier-only lists keep default activation and can enable inactive tools with `+name`. `excludedTools` removes any matching tool from the active set.
|
|
448
469
|
|
|
449
|
-
`ToolDefinition.constrainedSampling` survives `defineTool()`, `customTools`, tool wrappers, inspection, and
|
|
470
|
+
`ToolDefinition.constrainedSampling` survives `defineTool()`, `customTools`, tool wrappers, inspection, and interactive terminal execution:
|
|
450
471
|
|
|
451
472
|
- `{ type: "json_schema", strict: "prefer" | "require" }`: `prefer` may fall back; `require` fails if the active model cannot enforce strict JSON Schema.
|
|
452
473
|
- `{ type: "grammar", variants: { openai_lark?: string, openai_regex?: string } }`: requires one required string parameter and capable model metadata.
|
|
@@ -454,7 +475,7 @@ Custom tools passed via `customTools` combine with extension-registered tools. W
|
|
|
454
475
|
|
|
455
476
|
Inspection preserves optional-property identity (`undefined` stays present when explicitly set). See `ConstrainedSamplingConfig`, [Constrained sampling](/extensions/authoring#constrained-sampling), and `ModelInfo.compat` in [RPC](/rpc/protocol#get_available_models).
|
|
456
477
|
|
|
457
|
-
Factory-created `createBashTool()` instances receive the same execution-time `ATOMIC_SESSION_*` and `PI_SESSION_*` snapshot as the built-in `bash` tool unless you pass `exposeSessionEnvironment: false`. `MessageRenderOptions.outputPad` is
|
|
478
|
+
Factory-created `createBashTool()` instances receive the same execution-time `ATOMIC_SESSION_*` and `PI_SESSION_*` snapshot as the built-in `bash` tool unless you pass `exposeSessionEnvironment: false`. `MessageRenderOptions.outputPad` is forwarded to all custom message renderers.
|
|
458
479
|
|
|
459
480
|
Normal sessions expose `kill({ id: taskId })` for owned `bash` and `powershell` background tasks. Include `kill` in any explicit `tools` allowlist if the agent should be able to stop tasks. `createKillTool` and `createKillToolDefinition` accept `KillToolOptions.taskOwner` (the same trusted binding used by shell launches) and reject without one. Result details carry the supervisor's `CancelReceipt`. See [Stop a shell task from a tool call](/background-tasks#stop-a-shell-task-from-a-tool-call).
|
|
460
481
|
|
|
@@ -477,12 +498,12 @@ const waitForCi = defineTool({
|
|
|
477
498
|
|
|
478
499
|
A detachable call follows its message's `concurrency` ordering before starting. If a tool must save a durable handoff first, set `detachmentRequiresReady: true`: check `toolCallNeedsDetachmentHandoff(signal)` while running, then call `markToolCallReadyForDetachment(signal)` once saved. The call detaches only after both that signal and the host's delay (or returns inline if it finishes sooner).
|
|
479
500
|
|
|
480
|
-
Without a detachment policy, detachable calls run inline. A host using persistent storage enables detachment with `session.setToolDetachment({ afterMs })`, where `afterMs` is `0` to `MAX_TOOL_DETACHMENT_AFTER_MS` (`2,147,483,647`):
|
|
501
|
+
Without a detachment policy, detachable calls run inline. A host using persistent storage enables detachment with `session.setToolDetachment({ afterMs })`, where `afterMs` is any finite number from `0` to `MAX_TOOL_DETACHMENT_AFTER_MS` (`2,147,483,647`):
|
|
481
502
|
|
|
482
503
|
- **Inline vs. detached:** Calls finishing within `afterMs` complete inline. Calls still running detach: the turn's other results save, the detached call remains pending, and `prompt()` resolves so the host can release or dispose of the session.
|
|
483
504
|
- **Interrupts:** Once a turn is interrupted, inline calls no longer detach (even if marked ready in the same tick). They keep their result if they stop within `ATOMIC_TOOL_ABORT_GRACE_MS` (default 10 s); otherwise they record `Operation aborted` and later outcomes are discarded. Queued calls fail immediately with `Operation aborted`. Calls that detached before the interrupt are unaffected and remain available from `takeDetachedToolCalls()`.
|
|
484
505
|
- **`session.takeDetachedToolCalls()`:** Returns each detached call once as a `DetachedToolCall` (`toolCallId`, `toolName`, non-rejecting `result` promise, `abort(reason)`). Calls whose turn the transcript has moved past are cancelled, dropped, and logged as `stale-detached-call`. Thrown errors become `isError` results; errors with a string `code` populate `details.error` via `toJSON()` (or a fallback object with `serialization: "fallback"` if `toJSON()` throws). Unrecordable payloads record a call error instead, while session-store failures still reject resume.
|
|
485
|
-
- **`session.resumeDetachedTurn(results)`:** On a reopened session, records each result after its call and continues the turn
|
|
506
|
+
- **`session.resumeDetachedTurn(results, onRecorded?)`:** On a reopened session, records each result after its call (invoking optional `onRecorded(toolCallIds)` once recorded) and continues the turn without a new user message once every detachable call of that turn has a result. You can supply results across multiple calls; until the last arrives, `hasPendingDetachedTurn()` stays `true`. Duplicate, already-answered, or stale results are ignored (stale ones log `stale-detached-call`), while results for nonexistent calls throw `unknown-tool-call`. Calling with no new results continues a turn whose calls already have results.
|
|
486
507
|
- **`session.isWaitingOnDetachedResults()`:** Reports whether the transcript still awaits a detached result. While waiting under a detachment policy, nothing starts a turn on the idle session (including subagent notices, steering, follow-ups, and post-compaction continuations); held custom messages are persisted and replayed after `resumeDetachedTurn()` continues the turn. Do not call `prompt()` while waiting on results.
|
|
487
508
|
- **`session.hasPendingDetachedTurn()` and `session.redispatchDetachedToolCalls()`:** `hasPendingDetachedTurn()` reports whether a reopened transcript ends on a detached turn; continue it with `redispatchDetachedToolCalls()` and `resumeDetachedTurn()` instead of prompting again. `redispatchDetachedToolCalls()` restarts unanswered detachable calls with their original IDs and arguments and emits `tool_execution_start` before returning.
|
|
488
509
|
|
|
@@ -541,12 +562,17 @@ The tool infers the answer through the session's model registry rather than capt
|
|
|
541
562
|
|
|
542
563
|
Each call shares one wall-clock deadline covering repairs, retries, and fallbacks. It defaults to the session's [`httpIdleTimeoutMs`](/settings#http) setting; pass `timeoutMs` (a positive integer in milliseconds) to `createStructuredOutputTool()` to override it. See [Structured decisions](/sdk/structured-decisions#cancellation-and-failures).
|
|
543
564
|
|
|
544
|
-
To register under a custom name
|
|
565
|
+
To register under a custom name or capture the validated value in memory or to a private file (`0600`), pass `name`, `capture`, or `output`:
|
|
545
566
|
|
|
546
567
|
```typescript
|
|
568
|
+
import { createStructuredOutputCapture, createStructuredOutputTool } from "@bastani/atomic";
|
|
569
|
+
|
|
570
|
+
const capture = createStructuredOutputCapture<{ category: "question" | "statement" }>();
|
|
547
571
|
const finalDecision = createStructuredOutputTool({
|
|
548
572
|
name: "final_decision",
|
|
549
573
|
schema: DecisionSchema,
|
|
574
|
+
capture, // sets capture.value and capture.called = true on success
|
|
575
|
+
output: { outputPath: "/tmp/decision.json" }, // writes JSON with mode 0600
|
|
550
576
|
});
|
|
551
577
|
|
|
552
578
|
await createAgentSession({
|
|
@@ -583,9 +609,26 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
583
609
|
|
|
584
610
|
- **Synthetic builtin factories:** Named `extensionFactories` descriptors may set `builtin: true` to expose a `builtin:<name>` resource and `replaceable: true` to yield if another extension registers the same tool, command, or flag. Pass `additionalExtensionPaths: ["builtin:codemode"]` for explicit loading even with `noExtensions: true`. See [built-in extension resources](/extensions#built-in-extension-resources).
|
|
585
611
|
- **Inline built-in extensions:** `DefaultResourceLoader` includes `codemode`, `tool-search`, and `llama.cpp` as `builtin:<name>` paths. `codemode` is active by default (opt out with `tools: ["-codemode"]`), while `tool_search` is opt-in. Turn off an inline builtin with `noExtensions: true`, `disabledBuiltinExtensions: ["codemode"]`, or `extensions: ["-builtin:codemode"]`.
|
|
586
|
-
- **Bindings and startup:** Pass `extensionBindings` to `createAgentSession()` to install `
|
|
612
|
+
- **Bindings and startup (`ExtensionBindings`):** Pass `extensionBindings` to `createAgentSession()` to install bindings before `session_start` runs: `humanInput`, `onDiagnostic`, `onUIPrompt`, `uiContext`, `onStatus` (receives extension `setStatus` writes when no `uiContext` is bound), `isPresentationOnly`, `mode`, `commandContextActions`, `shutdownHandler`, `onError`, and `reportStartupErrors` (when `true`, forwards `session_start` and `resources_discover` errors to `onError` and keeps the session open instead of rolling back). Later `bindExtensions()` calls update bindings without replaying `session_start`.
|
|
587
613
|
- **Strict reloads:** `failOnExtensionErrors: true` requires transactional `prepareReload()` support (`DefaultResourceLoader` implements it). Custom loaders without `prepareReload()` work for ordinary reloads, while strict reload fails before calling their mutating `reload()`.
|
|
588
614
|
|
|
615
|
+
#### Reload lifecycle and resource ownership
|
|
616
|
+
|
|
617
|
+
- **Transactional vs. ordinary reload:** Failed transactional reloads keep the previous extension generation active; failed ordinary reloads do not. Both clean up newly acquired resources and report cleanup failures through an `AggregateError` tagged with `code: "ShutdownFailed"`.
|
|
618
|
+
- **Lifecycle effects:** Acquire shared resources in `session_start` (or register `session_shutdown` immediately if acquired earlier). Use `publishExtensionContextEffect(ctx, effect)` (default `"start"` phase after retirement, or synchronous `"commit"` phase before revocation) to publish shared state only on commit, and `registerExtensionContextRetirementEffect(ctx, dispose)` for synchronous pre-revocation cleanup. Never cache `ctx.ui` across reloads.
|
|
619
|
+
|
|
620
|
+
```typescript
|
|
621
|
+
import { publishExtensionContextEffect, type ExtensionFactory } from "@bastani/atomic";
|
|
622
|
+
|
|
623
|
+
const extension: ExtensionFactory = (atomic) => {
|
|
624
|
+
atomic.on("session_start", (_event, ctx) =>
|
|
625
|
+
publishExtensionContextEffect(ctx, () => {
|
|
626
|
+
atomic.events.emit("example:session-ready", { sessionId: ctx.sessionManager.getSessionId() });
|
|
627
|
+
}),
|
|
628
|
+
);
|
|
629
|
+
};
|
|
630
|
+
```
|
|
631
|
+
|
|
589
632
|
#### Session disposal and lifecycle
|
|
590
633
|
|
|
591
634
|
Always `await session.dispose()`. Disposal seals new admission immediately and waits for active work, extension shutdown handlers, pending settings writes, pending notice-line saves, lease release, and up to 5 seconds for in-flight extension transpile-cache writes started by that session.
|
|
@@ -593,13 +636,13 @@ Always `await session.dispose()`. Disposal seals new admission immediately and w
|
|
|
593
636
|
Once `dispose()` resolves, nothing the session started is still writing to its session store or extension transpile cache, so deleting `agentDir` or a caller-owned store directory right afterward will not race. (Transpile-cache writes still unfinished after 5 seconds are logged to debug output and left to finish asynchronously.)
|
|
594
637
|
|
|
595
638
|
- Concurrent `dispose()` calls share one promise.
|
|
596
|
-
-
|
|
639
|
+
- Disposal failures reject with an `AggregateError` tagged with `code: "ShutdownFailed"` (not an exported class); inspect `error.errors` for individual component failures. A failed close still leaves the session closed.
|
|
597
640
|
- Settings persistence failures can reject disposal; repair storage and repeat the write before closing (`dispose()` does not drain `SettingsManager.drainErrors()`).
|
|
598
641
|
- Caller-supplied settings, storage, and model runtimes remain caller-owned. Do not add manual MCP or Intercom teardown.
|
|
599
642
|
- `AgentSessionRuntime` uses the same awaited close during session replacement and transfers bindings before the replacement starts. Reload invalidates stale input requests and subscriptions so late replies cannot authorize new work.
|
|
600
643
|
- Duplicate `executeBash()` IDs act as correlation IDs: `abortBash(id)` cancels every active call with that ID.
|
|
601
644
|
|
|
602
|
-
For reload, replacement, and resource ownership patterns, see [
|
|
645
|
+
For reload, replacement, and resource ownership patterns, see [Draining work on reload and shutdown](/sdk#finishing-admitted-work).
|
|
603
646
|
|
|
604
647
|
#### Prompting options
|
|
605
648
|
|
|
@@ -608,7 +651,7 @@ For reload, replacement, and resource ownership patterns, see [Finishing admitte
|
|
|
608
651
|
- `expandPromptTemplates` (default `true`): expands file-based prompt templates, skill commands, and extension commands.
|
|
609
652
|
- `images`: optional `ImageContent[]` attachments.
|
|
610
653
|
- `streamingBehavior`: `"steer"` or `"followUp"` when sending while a turn is active; omitting it while streaming rejects with `AgentSessionBusyError`.
|
|
611
|
-
- `startTurnOnly`: when `true`, starts a turn only if the session is idle and queued messages are not paused. When a turn is already running or queued input is paused, nothing is sent or queued and `prompt()` resolves
|
|
654
|
+
- `startTurnOnly`: when `true`, starts a turn only if the session is idle and queued messages are not paused. When a turn is already running or queued input is paused, nothing is sent or queued, `preflightResult` is called with `(true, "handled")`, and `prompt()` resolves with `undefined`.
|
|
612
655
|
- `source`: `InputSource` metadata for `input` hooks.
|
|
613
656
|
- `preflightResult`: callback `(success, disposition?)` invoked once preflight accepts (`"handled"`, `"queued"`, or `"started"`) or rejects the prompt.
|
|
614
657
|
|
|
@@ -711,7 +754,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
711
754
|
|
|
712
755
|
### Session management
|
|
713
756
|
|
|
714
|
-
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching.
|
|
757
|
+
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching. See the **[SDK storage guide](/sdk/storage)** for full recipes across all five storage backends, `createAgentSessionRuntime()` store wiring, ownership rules, and error handling, and [Storage errors](/storage#storage-errors) for `StorageError` subclasses.
|
|
715
758
|
|
|
716
759
|
```typescript
|
|
717
760
|
import {
|
|
@@ -721,6 +764,7 @@ import {
|
|
|
721
764
|
createAgentSessionRuntime,
|
|
722
765
|
createAgentSessionServices,
|
|
723
766
|
getAgentDir,
|
|
767
|
+
resolveSessionStore,
|
|
724
768
|
SessionManager,
|
|
725
769
|
} from "@bastani/atomic";
|
|
726
770
|
|
|
@@ -729,31 +773,52 @@ const { session } = await createAgentSession({
|
|
|
729
773
|
sessionManager: SessionManager.inMemory(),
|
|
730
774
|
});
|
|
731
775
|
|
|
732
|
-
// New persistent session
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
}
|
|
776
|
+
// New persistent session in a caller-managed store (close the store in finally)
|
|
777
|
+
const store = await resolveSessionStore(process.cwd());
|
|
778
|
+
try {
|
|
779
|
+
const { session: persisted } = await createAgentSession({
|
|
780
|
+
sessionManager: await SessionManager.create(store, process.cwd()),
|
|
781
|
+
});
|
|
782
|
+
await persisted.dispose();
|
|
783
|
+
|
|
784
|
+
// Open an existing session by exact ID from a store
|
|
785
|
+
const { session: reopened } = await createAgentSession({
|
|
786
|
+
sessionManager: await SessionManager.open(store, savedSessionId),
|
|
787
|
+
});
|
|
788
|
+
await reopened.dispose();
|
|
789
|
+
|
|
790
|
+
// Continue the most recent session in a store
|
|
791
|
+
const { session: continued, modelFallbackMessage } = await createAgentSession({
|
|
792
|
+
sessionManager: await SessionManager.continueRecent(store, process.cwd()),
|
|
793
|
+
});
|
|
794
|
+
if (modelFallbackMessage) {
|
|
795
|
+
console.log("Note:", modelFallbackMessage);
|
|
796
|
+
}
|
|
797
|
+
await continued.dispose();
|
|
736
798
|
|
|
737
|
-
//
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
console.log("Note:", modelFallbackMessage);
|
|
799
|
+
// List sessions in an explicit store
|
|
800
|
+
const storeProjectSessions = await SessionManager.list(process.cwd(), store);
|
|
801
|
+
const storeAllSessions = await SessionManager.listAll(store);
|
|
802
|
+
} finally {
|
|
803
|
+
await store.close();
|
|
743
804
|
}
|
|
744
805
|
|
|
745
|
-
// Open specific file
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
});
|
|
806
|
+
// Open a specific JSONL file directly
|
|
807
|
+
const fileManager = await SessionManager.open("/path/to/session.jsonl");
|
|
808
|
+
try {
|
|
809
|
+
const { session: opened } = await createAgentSession({ sessionManager: fileManager });
|
|
810
|
+
await opened.dispose();
|
|
811
|
+
} finally {
|
|
812
|
+
await fileManager.getSessionStore().close();
|
|
813
|
+
}
|
|
749
814
|
|
|
750
|
-
// List sessions
|
|
815
|
+
// List sessions in the active resolved store (passing a string to listAll() scans that path as a JSONL directory)
|
|
751
816
|
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
752
|
-
const allSessions = await SessionManager.listAll(
|
|
817
|
+
const allSessions = await SessionManager.listAll();
|
|
753
818
|
|
|
754
819
|
// Session replacement API for /new, /resume, /fork, /clone, and import flows.
|
|
755
|
-
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
756
|
-
const services = await createAgentSessionServices({ cwd });
|
|
820
|
+
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent, services: incoming }) => {
|
|
821
|
+
const services = incoming ?? (await createAgentSessionServices({ cwd }));
|
|
757
822
|
return {
|
|
758
823
|
...(await createAgentSessionFromServices({
|
|
759
824
|
services,
|
|
@@ -765,10 +830,11 @@ const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionMan
|
|
|
765
830
|
};
|
|
766
831
|
};
|
|
767
832
|
|
|
833
|
+
const runtimeStore = await resolveSessionStore(process.cwd());
|
|
768
834
|
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
769
835
|
cwd: process.cwd(),
|
|
770
836
|
agentDir: getAgentDir(),
|
|
771
|
-
sessionManager: await SessionManager.create(process.cwd()),
|
|
837
|
+
sessionManager: await SessionManager.create(runtimeStore, process.cwd()),
|
|
772
838
|
});
|
|
773
839
|
|
|
774
840
|
// Replace the active session with a fresh one
|
|
@@ -784,7 +850,11 @@ await runtime.fork("entry-id");
|
|
|
784
850
|
await runtime.fork("entry-id", { position: "at" });
|
|
785
851
|
```
|
|
786
852
|
|
|
787
|
-
`
|
|
853
|
+
**Store-closing ownership.** Calling `SessionManager.create(cwd)`, `SessionManager.continueRecent(cwd)`, or `SessionManager.open("/path/to/session.jsonl")` opens a `SessionStore` internally. Passing a caller-created `sessionManager` to `createAgentSession({ sessionManager })` or `createAgentSessionRuntime()` does not transfer store ownership to `dispose()`, so close `sessionManager.getSessionStore().close()` (or the explicit `store` you passed) in `finally` after disposing the session or runtime. When you omit `sessionManager` and pass a selection object such as `sessionStore: { kind: "sqlite", path }` to `createAgentSession()`, `session.dispose()` closes the store it opened automatically.
|
|
854
|
+
|
|
855
|
+
**`SessionManager.listAll()` arguments.** Call `SessionManager.listAll()` with no path to list across the active configured store (SQLite by default), or pass a `SessionStore` (`SessionManager.listAll(store)`). Passing a string path such as `process.cwd()` scans that directory as JSONL files instead of querying SQLite or a configured database.
|
|
856
|
+
|
|
857
|
+
`runtime.switchSession(id, options?)` and `runtime.rehydrate(id, options?)` resume at the current context window, so `getEntries()` and `getTree()` return only the loaded context window.
|
|
788
858
|
|
|
789
859
|
To visit older entries without loading them into memory, iterate `for await (const page of sessionManager.readHistory({ fromSeq, toSeq, signal }))`:
|
|
790
860
|
|
|
@@ -807,7 +877,28 @@ for await (const page of sessionManager.readHistory()) {
|
|
|
807
877
|
const entry = await sessionManager.readEntry("entry-id");
|
|
808
878
|
```
|
|
809
879
|
|
|
810
|
-
`sessionManager.loadFullHistory()` and `{ history: "full" }` on `SessionManager.open()`, `openSessionById()`, `continueRecent()`, `switchSession()`, and `rehydrate()` load every stored entry across every branch into memory so `getEntries()` and `getTree()` cover the whole session. Use them only when you need all entries
|
|
880
|
+
`sessionManager.loadFullHistory()` and `{ history: "full" }` on `SessionManager.open()`, `openSessionById()`, `continueRecent()`, `switchSession()`, and `rehydrate()` load every stored entry across every branch into memory so `getEntries()` and `getTree()` cover the whole session. Use them only when you need all entries loaded in memory at once.
|
|
881
|
+
|
|
882
|
+
#### Session stores and claims
|
|
883
|
+
|
|
884
|
+
Construct or open concrete `SessionStore` implementations directly when you manage store lifetimes yourself (see [SDK storage guide](/sdk/storage) and [Storage errors](/storage#storage-errors)):
|
|
885
|
+
|
|
886
|
+
- **`SqlSessionStore.open(database, { prefix?, cwdMatcher? })`:** Opens a SQL-backed session store on a caller-owned `SqliteDatabase` or storage adapter handle. Close the store, then close the database handle.
|
|
887
|
+
- **`JsonlSessionStore.open(directory, { exactDirectory?, scanExisting?, lockFs?, createDirectory? })`:** Opens a JSONL session directory store (creates `directory` unless `createDirectory: false`). `exactDirectory` defaults to `false` and creates per-`cwd` `--<encoded-cwd>--` subdirectories under `directory`. By contrast, `sessionStore: { kind: "jsonl", dir }` opens `JsonlSessionStore.open(dir, { exactDirectory: true })` and writes `.jsonl` files directly in `dir`. Pass `{ exactDirectory: true }` when opening the same flat layout directly.
|
|
888
|
+
- **`new MemorySessionStore(cwdMatcher?, historyFiles?)`:** Creates a caller-owned in-memory store that preserves history in RAM across `session.release()` and `runtime.rehydrate()`. To enable disk spilling of released history under `<agentDir>/released-history/`, open the memory store via `resolveSessionStore(cwd, { agentDir, sessionStore: { kind: "memory" } })`.
|
|
889
|
+
|
|
890
|
+
Coordinate single-writer session ownership across processes with session claims (stored at `<agentDir>/session-claims/<sessionId>.json`, refreshed on a 15-second heartbeat, with a 60-second staleness window for remote hosts and automatic dead-claim takeover):
|
|
891
|
+
|
|
892
|
+
- **`await prepareSessionClaim(sessionId, { agentDir })`:** Awaits any in-flight asynchronous claim release in this process and prepares stale-claim takeover locking. Always await `prepareSessionClaim()` before `claimSession()` when re-claiming a session right after closing or releasing it.
|
|
893
|
+
- **`claimSession(sessionId, { agentDir })`:** Synchronously acquires the claim and returns a `release()` function (throws `SessionAlreadyOpenError` if another live process holds the session or if a prior release in this process is still pending).
|
|
894
|
+
- **`attachSessionClaim(sessionId)`:** Transfers an active claim to the opened session's lifetime marker, returning a `() => Promise<void>` disposer (after attaching, the earlier `release()` callback becomes a no-op).
|
|
895
|
+
|
|
896
|
+
#### Session services (`createAgentSessionServices` and `createAgentSessionFromServices`)
|
|
897
|
+
|
|
898
|
+
When managing multiple sessions that share a working directory (or inside `createAgentSessionRuntime()`), split directory-scoped service initialization from session creation:
|
|
899
|
+
|
|
900
|
+
- **`createAgentSessionServices({ cwd, agentDir?, settingsManager?, modelRuntime?, ... })`:** Builds shared `AgentSessionServices` (`cwd`, `agentDir`, `modelRuntime`, `settingsManager`, `resourceLoader`, `diagnostics`).
|
|
901
|
+
- **`createAgentSessionFromServices({ services, sessionManager, sessionStartEvent?, ... })`:** Creates an `AgentSession` backed by those shared services without re-discovering extensions, skills, or models.
|
|
811
902
|
|
|
812
903
|
`SessionManager.create()`, `open()`, `continueRecent()`, `forkFrom()`, and all mutations are asynchronous. `SessionManager.inMemory()` with no entries is synchronous; when supplying entries, await `SessionManager.inMemory(cwd, options, entries)` and keep the input array stable until it resolves. A resolved write is committed (there is no `flush()` method), and a failed write rejects with the store's typed error without publishing the entry. Reads remain synchronous.
|
|
813
904
|
|
|
@@ -816,14 +907,15 @@ const entry = await sessionManager.readEntry("entry-id");
|
|
|
816
907
|
```typescript
|
|
817
908
|
const sm = await SessionManager.open("/path/to/session.jsonl");
|
|
818
909
|
|
|
819
|
-
// Session listing
|
|
910
|
+
// Session listing (pass a SessionStore to listAll(store), or omit arguments for the active resolved store;
|
|
911
|
+
// passing a string scans that directory as JSONL files)
|
|
820
912
|
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
821
|
-
const allSessions = await SessionManager.listAll(
|
|
913
|
+
const allSessions = await SessionManager.listAll();
|
|
822
914
|
|
|
823
915
|
// Tree traversal
|
|
824
916
|
const entries = sm.getEntries(); // Entries in the current window, without the header
|
|
825
917
|
const tree = sm.getTree(); // Tree structure for the current window
|
|
826
|
-
const
|
|
918
|
+
const branch = sm.getBranch(); // Path from root to current leaf
|
|
827
919
|
const leaf = sm.getLeafEntry(); // Current leaf entry
|
|
828
920
|
const entry = sm.getEntry(id); // Get entry by ID
|
|
829
921
|
const children = sm.getChildren(id); // Direct children of entry
|
|
@@ -868,7 +960,7 @@ An unrebuildable snapshot produces a `WorkspaceDriftError` carrying the restore
|
|
|
868
960
|
|
|
869
961
|
| Class | `code` | When | Fields | What to do |
|
|
870
962
|
|---|---|---|---|---|
|
|
871
|
-
| `MissingSessionCwdError` | `session-cwd-missing` | The session's working directory does not exist (`retryable: false`). | `sessionCwd`, `fallbackCwd`, `sessionFile` (JSONL only), `hint` | Retry with `{ cwdOverride }` (`switchSession`) or `importFromJsonl(path, cwdOverride)`, or fork there with `
|
|
963
|
+
| `MissingSessionCwdError` | `session-cwd-missing` | The session's working directory does not exist (`retryable: false`). | `sessionCwd`, `fallbackCwd`, `sessionFile` (JSONL only), `hint` | Retry with `{ cwdOverride }` (`switchSession`) or `importFromJsonl(path, cwdOverride)`, or fork there with `sessionManager.forkTo(cwd, store)`. |
|
|
872
964
|
|
|
873
965
|
Use `isMissingSessionCwdError(error)`, `serializeMissingSessionCwdError(error)`, `isSerializedMissingSessionCwdError(value)`, and `rehydrateMissingSessionCwdError(serialized)` across process boundaries. `RpcClient` rehydrates this error for `switch_session` and `import_session`. Interactive mode prompts to continue in the current directory, fork there, or cancel (see [Sessions](/sessions#resuming-and-deleting-sessions)).
|
|
874
966
|
|
|
@@ -948,6 +1040,8 @@ import {
|
|
|
948
1040
|
const loader = new DefaultResourceLoader({
|
|
949
1041
|
cwd,
|
|
950
1042
|
agentDir: getAgentDir(),
|
|
1043
|
+
additionalSkillPaths: ["/path/to/extra-skills"],
|
|
1044
|
+
noSkills: false,
|
|
951
1045
|
});
|
|
952
1046
|
await loader.reload();
|
|
953
1047
|
|
|
@@ -958,7 +1052,14 @@ const themes = loader.getThemes();
|
|
|
958
1052
|
const contextFiles = loader.getAgentsFiles().agentsFiles;
|
|
959
1053
|
```
|
|
960
1054
|
|
|
961
|
-
|
|
1055
|
+
Key `DefaultResourceLoader` discovery options:
|
|
1056
|
+
|
|
1057
|
+
- `additionalSkillPaths`: extra directories or `SKILL.md` paths loaded in addition to default user, project, and package skill discovery.
|
|
1058
|
+
- `noSkills`: set `true` to disable automatic skill discovery (paths in `additionalSkillPaths` still load).
|
|
1059
|
+
- `additionalExtensionPaths`, `noExtensions`, `disabledBuiltinExtensions`, `extensionFactories`: control extension loading and inline builtin extensions.
|
|
1060
|
+
- `additionalPromptTemplatePaths`, `noPromptTemplates`, `additionalThemePaths`, `noThemes`, `noContextFiles`: add or disable prompt templates, themes, and `AGENTS.md` context files.
|
|
1061
|
+
|
|
1062
|
+
Package MCP servers discovered by `DefaultResourceLoader` connect through the bundled MCP client extension and register their tools as `mcp__<server>__<tool>` (defaulting to `codemode` exposure). Extensions can also register MCP servers dynamically with `atomic.registerMcpServer(name, config)` and inspect the merged package and extension list via `atomic.getMcpServerContributions()` (or subscribe with `atomic.onMcpServerContributionsChanged(listener)`). Custom `ResourceLoader` implementations can provide `getMcpServerContributions()` returning `McpServerContribution[]`; return only contributions allowed by your loader's trust policy. Normal MCP configuration overrides still apply. See [MCP servers](/mcp-servers) for connection and tool invocation.
|
|
962
1063
|
|
|
963
1064
|
### Copying extension handlers in `extensionsOverride`
|
|
964
1065
|
|
|
@@ -978,7 +1079,7 @@ const loader = new DefaultResourceLoader({
|
|
|
978
1079
|
});
|
|
979
1080
|
```
|
|
980
1081
|
|
|
981
|
-
During interactive startup,
|
|
1082
|
+
During interactive startup, Atomic can run resource discovery twice (before and after optional extensions finish loading). Both calls run, and if the same registration reports the same error, the terminal shows it once. A later `/reload` reports the failure again.
|
|
982
1083
|
|
|
983
1084
|
Creating `(...args) => handler(...args)` on every load registers a new callback each time, so you can see two startup errors. Keep separate callbacks when your override changes the handler, adds a step that can fail, or forwards on behalf of separate installations. Don't cache a previous load's handler or share a forwarder by extension name.
|
|
984
1085
|
|
|
@@ -990,13 +1091,16 @@ Creating `(...args) => handler(...args)` on every load registers a new callback
|
|
|
990
1091
|
interface CreateAgentSessionResult {
|
|
991
1092
|
// The session
|
|
992
1093
|
session: AgentSession;
|
|
993
|
-
|
|
1094
|
+
|
|
994
1095
|
// Extensions result (for runner setup)
|
|
995
1096
|
extensionsResult: LoadExtensionsResult;
|
|
996
|
-
|
|
1097
|
+
|
|
997
1098
|
// Warning if session model couldn't be restored
|
|
998
1099
|
modelFallbackMessage?: string;
|
|
999
1100
|
|
|
1101
|
+
// Machine-readable fallback reason when startup fell back from a requested or saved model
|
|
1102
|
+
modelFallbackReason?: ModelFallbackReason;
|
|
1103
|
+
|
|
1000
1104
|
// The resolved binding when the session was created with `workspace`
|
|
1001
1105
|
workspace?: BoundWorkspace;
|
|
1002
1106
|
}
|
|
@@ -1052,13 +1156,13 @@ const mode = new InteractiveMode(runtime, {
|
|
|
1052
1156
|
await mode.run();
|
|
1053
1157
|
```
|
|
1054
1158
|
|
|
1055
|
-
If you quit the host or call `session.dispose()` during the initial interactive extension bind, `await mode.init()` or `await mode.run()` returns normally. The disposed session does not enter the input loop. This also applies when an incoming event or a pending provider retry started the UI. Track your own shutdown request instead of
|
|
1159
|
+
If you quit the host or call `session.dispose()` during the initial interactive extension bind, `await mode.init()` or `await mode.run()` returns normally. The disposed session does not enter the input loop. This also applies when an incoming event or a pending provider retry started the UI. Track your own shutdown request instead of checking for `code: "SessionClosed"` errors to detect it.
|
|
1056
1160
|
|
|
1057
|
-
Replacing the session during the initial bind is not a quit: the interrupted startup still rejects. If you dispose only the session and then create a replacement with `await runtime.newSession()`, call `mode.run()` again to accept input for the replacement. Direct `session.bindExtensions()` and `mode.handleEvent(event)` calls still reject on close, so custom handlers can catch startup failures and report errors from their recovery work.
|
|
1161
|
+
Replacing the session during the initial bind is not a quit: the interrupted startup still rejects. If you dispose only the session and then create a replacement with `await runtime.newSession()`, call `mode.run()` again to accept input for the replacement. Direct `session.bindExtensions()` and `mode.handleEvent(event)` calls still reject on close (with an `Error` tagged `code: "SessionClosed"`), so custom handlers can catch startup failures and report errors from their recovery work.
|
|
1058
1162
|
|
|
1059
1163
|
### runPrintMode
|
|
1060
1164
|
|
|
1061
|
-
Single-shot mode: send prompts, output
|
|
1165
|
+
Single-shot mode: send prompts, output text or JSONL events, and return the exit code (`Promise<number>`, `0` on success or `1` on fatal error):
|
|
1062
1166
|
|
|
1063
1167
|
```typescript
|
|
1064
1168
|
import {
|
|
@@ -1085,7 +1189,7 @@ const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
|
1085
1189
|
sessionManager: await SessionManager.create(process.cwd()),
|
|
1086
1190
|
});
|
|
1087
1191
|
|
|
1088
|
-
await runPrintMode(runtime, {
|
|
1192
|
+
const exitCode = await runPrintMode(runtime, {
|
|
1089
1193
|
mode: "text",
|
|
1090
1194
|
initialMessage: "Hello",
|
|
1091
1195
|
initialImages: [],
|
|
@@ -1129,7 +1233,7 @@ See [RPC documentation](/rpc) for the JSON protocol.
|
|
|
1129
1233
|
|
|
1130
1234
|
## Session and storage errors
|
|
1131
1235
|
|
|
1132
|
-
SDK callers working with `SessionManager`, `SessionStore`, `AgentSessionRuntime`, `SettingsManager`, or `ModelRuntime.login()` can branch directly on exported error classes
|
|
1236
|
+
SDK callers working with `SessionManager`, `SessionStore`, `AgentSessionRuntime`, `SettingsManager`, or `ModelRuntime.login()` can branch directly on exported error classes. For backend, adapter, lock, payload, spill, and team-profile errors (`StorageError` and its subclasses, exported from both `@bastani/atomic` and `@bastani/atomic/storage`), see [Storage errors](/storage#storage-errors) and the [SDK storage guide](/sdk/storage).
|
|
1133
1237
|
|
|
1134
1238
|
| Class | When | Key fields |
|
|
1135
1239
|
|---|---|---|
|
|
@@ -1176,7 +1280,7 @@ try {
|
|
|
1176
1280
|
|
|
1177
1281
|
## Session start errors
|
|
1178
1282
|
|
|
1179
|
-
|
|
1283
|
+
A subagent that does not start within its start budget fails with a `SessionStartTimeoutError`; see [Subagent start timeouts](/subagents#subagent-start-timeouts) for the budget and how to change it. The child's result carries it serialized as `startError`, and its `error` text is the error's `message`. Every error in this family extends `SessionStartError`. Branch on the class, a guard, or `code`, never on the message:
|
|
1180
1284
|
|
|
1181
1285
|
| Class | `code` | When | Fields | What to do |
|
|
1182
1286
|
| --- | --- | --- | --- | --- |
|
|
@@ -1201,9 +1305,9 @@ if (startError && isRetryableSessionStartError(startError)) {
|
|
|
1201
1305
|
These helpers let extensions and SDK code follow [debug mode](/development#debugging):
|
|
1202
1306
|
|
|
1203
1307
|
- `isDebugEnabled(area?, env?)` returns whether debug mode is on. The same setting applies to every area. `env` defaults to `process.env`.
|
|
1204
|
-
- `reportDebug(area, event, fields,
|
|
1205
|
-
- `appendDebugRecord(path, record)` appends one redacted JSON line to another debug file, such as a trace file.
|
|
1206
|
-
- `appendDebugRecordAsync(path, record)` and `reportDebugAsync(area, event, fields,
|
|
1308
|
+
- `reportDebug(area, event, fields, env?)` records one event. In debug mode it appends a JSON line to the debug log, with credentials redacted and long text cut to 2,000 characters. `fields` holds strings, numbers, booleans, `null`, or lists of strings and numbers, never objects.
|
|
1309
|
+
- `appendDebugRecord(path, record)` appends one redacted JSON line to another debug file, such as a trace file. Both `appendDebugRecord()` and `reportDebug()` write synchronously and report failures immediately.
|
|
1310
|
+
- `appendDebugRecordAsync(path, record)` and `reportDebugAsync(area, event, fields, env?)` provide the same redaction and reporting without blocking the host. Await their promises to observe the completed write, or call `flushDebugLog()` to wait for all queued debug records.
|
|
1207
1311
|
- `DEBUG_AREA_VARIABLES` lists `decision`, `storage` and `engine`. All have value `undefined`: there are no separate environment switches for these areas.
|
|
1208
1312
|
- `getDebugLogFailure()` returns the first `DebugLogUnwritableError` of this process, if writing a debug log ever failed.
|
|
1209
1313
|
- `setDebugSetting(enabled)` turns debug mode on or off for this process and for child processes it starts afterwards. It does not save the `debug` setting.
|
|
@@ -1218,7 +1322,11 @@ These helpers let extensions and SDK code follow [debug mode](/development#debug
|
|
|
1218
1322
|
|
|
1219
1323
|
Both extend `DebugError`, whose `code` is a `DebugErrorCode` and whose `fields()` returns the fields above. Branch on the class or `code`, not the message. `isDebugError`, `isDebugLogUnwritableError` and `isDebugConfigError` recognize them, including an error that crossed a process boundary as a plain object with the same `name` and `code`.
|
|
1220
1324
|
|
|
1221
|
-
To pass one between processes, `serializeDebugError(error)` turns it into a `SerializedDebugError` (`name`, `code`, `message`, `hint`, `retryable`, `fields`, and a cause chain of at most eight errors), and `rehydrateDebugError(serialized)` rebuilds the same class with the same fields. An unknown `name` comes back as a `DebugError` that keeps its `name`, `code`, `fields` and `retryable`. The RPC client does this for you: when
|
|
1325
|
+
To pass one between processes, `serializeDebugError(error)` turns it into a `SerializedDebugError` (`name`, `code`, `message`, `hint`, `retryable`, `fields`, and a cause chain of at most eight errors), and `rehydrateDebugError(serialized)` rebuilds the same class with the same fields. An unknown `name` comes back as a `DebugError` that keeps its `name`, `code`, `fields` and `retryable`. The RPC client does this for you: when Atomic refuses `set_debug`, `setDebug()` rejects with the `DebugConfigError`.
|
|
1326
|
+
|
|
1327
|
+
### Compaction errors
|
|
1328
|
+
|
|
1329
|
+
Compaction settings, session compaction calls, and direct `requestCompactorOutput()` calls throw subclasses of `CompactionError` (`CompactionConfigError`, `CompactionCancelledError`, `CompactionStateError`, and `CompactorFailure`). Branch on the class or `code`, not the message. Every `CompactionError` exposes `code`, `hint`, `retryable`, and `fields()`, and comes with cross-realm guards (`isCompactionError`, `isCompactionConfigError`, `isCompactionCancelledError`, `isCompactionStateError`, `isCompactorFailure`, `findCompactionError`, `isRetryableCompactionError`) plus `serializeCompactionError()`, `parseSerializedCompactionError()`, and `rehydrateCompactionError()`. The RPC client automatically rehydrates `compaction_error` responses (for example when `set_compaction_model` or `compact` rejects). See [Compaction errors](/compaction/reference#compaction-errors).
|
|
1222
1330
|
|
|
1223
1331
|
## Nonblocking helpers
|
|
1224
1332
|
|
|
@@ -1258,24 +1366,79 @@ On Windows, the native module reads directory ownership and access lists directl
|
|
|
1258
1366
|
The main entry point exports:
|
|
1259
1367
|
|
|
1260
1368
|
```typescript
|
|
1261
|
-
//
|
|
1369
|
+
// Session factories and runtime
|
|
1262
1370
|
createAgentSession
|
|
1371
|
+
createAgentSessionServices
|
|
1372
|
+
createAgentSessionFromServices
|
|
1263
1373
|
createAgentSessionRuntime
|
|
1374
|
+
AgentSession
|
|
1264
1375
|
AgentSessionRuntime
|
|
1376
|
+
AgentSessionBusyError, isAgentSessionBusyError
|
|
1377
|
+
NativeModuleUnavailableError
|
|
1265
1378
|
|
|
1266
1379
|
// Auth and Models
|
|
1380
|
+
ModelRuntime
|
|
1381
|
+
type CreateModelRuntimeOptions
|
|
1382
|
+
type ModelRuntimeAuthOverrides
|
|
1383
|
+
CredentialSynchronizationError
|
|
1267
1384
|
AuthStorage
|
|
1385
|
+
type AuthStorageBackend
|
|
1386
|
+
FileAuthStorageBackend
|
|
1387
|
+
InMemoryAuthStorageBackend
|
|
1388
|
+
readStoredCredential
|
|
1268
1389
|
ModelRegistry
|
|
1390
|
+
NoUsableModelError, partitionByCredentials
|
|
1391
|
+
createGatewayBindingFetch
|
|
1269
1392
|
resolveAutoModel
|
|
1393
|
+
resolveRestoredModelReference
|
|
1270
1394
|
resolveModelScopeFromModels
|
|
1271
1395
|
resolveModelScopeWithDiagnostics
|
|
1272
1396
|
type ResolveModelScopeResult
|
|
1273
1397
|
type ModelScopeDiagnostic
|
|
1274
1398
|
OAuthLoginTransactionError
|
|
1275
|
-
|
|
1276
|
-
|
|
1399
|
+
OAuthRefreshRejectedError, isOAuthRefreshRejectedError
|
|
1400
|
+
GitHubCopilotError, GitHubCopilotAuthenticationError, GitHubCopilotContentFilterError
|
|
1401
|
+
GitHubCopilotEmptyResponseError, GitHubCopilotInvalidRequestError, GitHubCopilotModelUnavailableError
|
|
1402
|
+
GitHubCopilotPromptTooLargeError, GitHubCopilotQuotaExhaustedError, GitHubCopilotRateLimitError
|
|
1403
|
+
GitHubCopilotServiceUnavailableError, GitHubCopilotStreamEndedEarlyError, GitHubCopilotUnrecognizedResponseError
|
|
1404
|
+
LlamaServerError, LlamaServerRequestError, LlamaServerUnreachableError
|
|
1405
|
+
|
|
1406
|
+
// Workspaces and Intercom policy / errors
|
|
1407
|
+
workspace
|
|
1408
|
+
bindSessionWorkspace
|
|
1409
|
+
resolveWorkspace
|
|
1410
|
+
restoreWorkspace
|
|
1411
|
+
workspaceChangeSet
|
|
1412
|
+
publishPullRequest
|
|
1413
|
+
acquireWorkspaceWriterLease
|
|
1414
|
+
inheritWorkspace
|
|
1415
|
+
isWorkspace, isBoundWorkspace, assertWorkspace
|
|
1416
|
+
workspaceSessionCwd, workspaceSessionCwdAsync
|
|
1417
|
+
WorkspaceError, WorkspaceConfigError, WorkspaceBindingError, WorkspaceGitError
|
|
1418
|
+
WorkspaceSnapshotError, WorkspaceRestoreError, WorkspaceDriftError, WorkspacePublicationError
|
|
1419
|
+
WorkspaceSandboxError, WorkspaceTimeoutError, WorkspaceCollectionError
|
|
1420
|
+
isWorkspaceError, findWorkspaceError, isRetryableWorkspaceError, serializeWorkspaceError, rehydrateWorkspaceError
|
|
1421
|
+
isWorkspaceConfigError, isWorkspaceBindingError, isWorkspacePublicationError, isWorkspaceRestoreError
|
|
1422
|
+
isWorkspaceSandboxError, isWorkspaceTimeoutError, isWorkspaceCollectionError
|
|
1423
|
+
isWorkspaceDriftError, isWorkspaceGitError, isWorkspaceSnapshotError
|
|
1424
|
+
IntercomPolicyError, MAX_INTERCOM_REACHABLE_GROUPS
|
|
1425
|
+
confinedIntercomChildGroup, readRuntimeIntercomGroup, RUNTIME_INTERCOM_GROUP_ENV
|
|
1426
|
+
type IntercomSessionOptions, type SessionIntercom
|
|
1427
|
+
IntercomBrokerError, IntercomBrokerProtocolError, IntercomBrokerStopTimeoutError
|
|
1428
|
+
IntercomBrokerSuccessorTimeoutError, IntercomBrokerUpgradeError
|
|
1429
|
+
isIntercomBrokerError, isIntercomBrokerProtocolError, isIntercomBrokerStopTimeoutError
|
|
1430
|
+
isIntercomBrokerSuccessorTimeoutError, isIntercomBrokerUpgradeError, isRetryableIntercomBrokerError
|
|
1431
|
+
serializeIntercomBrokerError, rehydrateIntercomBrokerError, type SerializedIntercomBrokerError
|
|
1432
|
+
IntercomRoutingError, IntercomRoutingChangedError, IntercomRoutingMismatchError
|
|
1433
|
+
IntercomRoutingTimeoutError, IntercomRoutingUnavailableError
|
|
1434
|
+
isIntercomRoutingError, isIntercomRoutingChangedError, isIntercomRoutingMismatchError
|
|
1435
|
+
isIntercomRoutingTimeoutError, isIntercomRoutingUnavailableError, isRetryableIntercomRoutingError
|
|
1436
|
+
ProjectGroupError, isProjectGroupError, type ProjectGroupErrorCode
|
|
1437
|
+
|
|
1438
|
+
// Resource loading and MCP configuration
|
|
1277
1439
|
DefaultResourceLoader
|
|
1278
1440
|
type ResourceLoader
|
|
1441
|
+
type McpServerConfig, type McpServerContribution
|
|
1279
1442
|
createEventBus
|
|
1280
1443
|
|
|
1281
1444
|
// Constants and helpers
|
|
@@ -1332,7 +1495,44 @@ type Transcript
|
|
|
1332
1495
|
type TranscriptOptions
|
|
1333
1496
|
type TranscriptPart
|
|
1334
1497
|
|
|
1335
|
-
//
|
|
1498
|
+
// Storage, adapters, team profiles, history, blobs, and StorageError family
|
|
1499
|
+
// (re-exported from @bastani/atomic/storage, plus root process-selection and blob-copy helpers)
|
|
1500
|
+
openNodeSqliteDatabase, wrapNodeSqliteDatabase, sqliteFilePath
|
|
1501
|
+
getWriterQueueStats, getWriterQueueDegradation, DEFAULT_GROUP_COMMIT_HOLD_MS, type WriterQueueStats
|
|
1502
|
+
StorageProvider, type StorageSelection, type StorageOpenContext, type StorageAdapterModule
|
|
1503
|
+
type AdapterOptions, type SecretRef, type SessionStorageOption, type SessionStore
|
|
1504
|
+
loadStorageAdapter, resolveAdapterOptions, adapterOpenContext, storageSelectionKey
|
|
1505
|
+
secretFilePath, secretFilePathAsync
|
|
1506
|
+
LIBSQL_ADAPTER_PACKAGE, POSTGRES_ADAPTER_PACKAGE, LOCAL_SESSIONS_STORAGE, REDACTED_SECRET
|
|
1507
|
+
inMemorySecret, type InMemorySecretRef
|
|
1508
|
+
teamProfileSelection, type TeamProfileSelectionOptions, type TeamStorageSelection
|
|
1509
|
+
joinTeam, leaveTeam, getTeamProfile, isPostgresUrl
|
|
1510
|
+
selectStorage, selectStorageAsync, type StorageInputSelection, type StorageSettingsSelection
|
|
1511
|
+
selectProcessStorage, selectProcessStorageAsync, type ProcessStorageChoice, type StorageDomain
|
|
1512
|
+
processSharedStorageSelection, processSharedStorageSelectionAsync
|
|
1513
|
+
processStorageEnvironment, processStorageEnvironmentAsync
|
|
1514
|
+
createSqliteDatabase, configuredSecretRedactor, redactSecrets, switchToWriteAheadLog
|
|
1515
|
+
validateStoragePrefix, storageMigrationTable, assertStorageSchemaVersion, assertStoredSchemaVersion
|
|
1516
|
+
type SqliteDatabase, type SqliteDriver, type StorageDescriptor
|
|
1517
|
+
readSessionHistory, readSessionHistoryChunks, findInSessionHistory
|
|
1518
|
+
readSessionChildCatalog, readExpandedChildDetails, readSavedChildLaunch
|
|
1519
|
+
copySessionBlobs, assertSessionBlobStore, sessionBlobHashes, toolOutputUrl
|
|
1520
|
+
SqlSnapshotBlobStore, MemorySnapshotBlobStore, type SnapshotBlobStore
|
|
1521
|
+
StorageError, StorageUnavailableError, StoreClosedError, StorageTransactionClosedError
|
|
1522
|
+
StorageRollbackError, StorageInvalidTextError, StorageSchemaVersionError, StoragePrefixError
|
|
1523
|
+
StorageConfigError, StorageAdapterLoadError, StorageOutcomeUnknownError, StoragePayloadTooLargeError
|
|
1524
|
+
StorageWriteLockTimeoutError, StorageUnsupportedOperationError, StorageWriterQueueDegradedError
|
|
1525
|
+
StorageWriterQueueUnusableError, StorageTransientError, SessionBlobError, SessionSpillError
|
|
1526
|
+
TeamProfileError, TeamProfileTimeoutError, TeamProfileConfigError
|
|
1527
|
+
isStorageError, isStorageConfigError, isStorageWriteLockTimeoutError, isStorageUnsupportedOperationError
|
|
1528
|
+
isStorageWriterQueueDegradedError, isStorageWriterQueueUnusableError, isStorageTransientError
|
|
1529
|
+
isSessionBlobError, isSessionSpillError, isStorageResponseRefusal
|
|
1530
|
+
findStorageWriteLockTimeoutError, isRetryableStorageError
|
|
1531
|
+
isTeamProfileError, isTeamProfileTimeoutError, isTeamProfileConfigError, isRetryableTeamProfileError
|
|
1532
|
+
serializeStorageError, rehydrateStorageError, serializeTeamError, rehydrateTeamError
|
|
1533
|
+
describeStorageError, describeStorageFailure, type SerializedStorageError, type SerializedTeamError
|
|
1534
|
+
|
|
1535
|
+
// Session management and resume
|
|
1336
1536
|
SessionManager
|
|
1337
1537
|
SettingsManager
|
|
1338
1538
|
JsonlSessionStore
|
|
@@ -1363,6 +1563,10 @@ SettingsFileChangedError
|
|
|
1363
1563
|
JsonlStoragePoisonedError
|
|
1364
1564
|
StorageTransferError
|
|
1365
1565
|
StorageImportIncompleteError
|
|
1566
|
+
ResumeError, ResumeNotFoundError, ResumePreconditionError, ResumeCatalogUnavailableError, ResumeCatalogTimeoutError
|
|
1567
|
+
isResumeError, findResumeError, isRetryableResumeError, serializeResumeError, rehydrateResumeError
|
|
1568
|
+
BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError, BlueprintUsesUnsupportedError, BlueprintBuildFailedError
|
|
1569
|
+
isBlueprintError, findBlueprintError, serializeBlueprintError, rehydrateBlueprintError
|
|
1366
1570
|
type SessionJsonValue
|
|
1367
1571
|
type SessionTextField
|
|
1368
1572
|
type SessionTimestampField
|
|
@@ -1380,7 +1584,7 @@ DecisionTimeoutError, DecisionOutputError, DecisionProviderError
|
|
|
1380
1584
|
type DecisionErrorCode, DecisionConfigErrorCode, DecisionRequestErrorReason, DecisionModelUnavailableReason
|
|
1381
1585
|
isDecisionError, isDecisionConfigError, isDecisionRequestError, isDecisionModelUnavailableError
|
|
1382
1586
|
isDecisionTimeoutError, isDecisionOutputError, isDecisionProviderError
|
|
1383
|
-
findDecisionError, isRetryableDecisionError, serializeDecisionError, rehydrateDecisionError
|
|
1587
|
+
findDecisionError, isRetryableDecisionError, serializeDecisionError, parseSerializedDecisionError, rehydrateDecisionError
|
|
1384
1588
|
|
|
1385
1589
|
// Session start errors
|
|
1386
1590
|
SessionStartError
|
|
@@ -1405,19 +1609,35 @@ type SessionStartConfigSource
|
|
|
1405
1609
|
type SessionStartConfigReason
|
|
1406
1610
|
type SerializedSessionStartError
|
|
1407
1611
|
type SerializedSessionStartCause
|
|
1408
|
-
|
|
1612
|
+
|
|
1613
|
+
// Owner-bound task supervisor, cleanup errors, and finished task retention
|
|
1614
|
+
AgentTaskHost, type AgentTaskHostBinding, type AgentTaskRunnerFactory
|
|
1615
|
+
OwnerTaskStore, bindOwnerTaskStore, getOwnerTaskStore, getOwnerTaskSession
|
|
1616
|
+
scopedBackgroundTasks, sessionTasks, belongsToSession, ownerTaskViewSource, bindTaskResumer, type TaskViewSource
|
|
1617
|
+
heldPrompts, watchHeldPromptAttention, isHeldPromptInput, isPresentationHostInput, routeNamesPrompt
|
|
1618
|
+
type HeldPrompt, type HeldPrompts
|
|
1619
|
+
TaskCleanupError, TaskCleanupAdmissionTimeoutError
|
|
1620
|
+
isTaskCleanupError, isTaskCleanupAdmissionTimeoutError, isRetryableTaskError, rehydrateTaskCleanupError
|
|
1621
|
+
type TaskCleanupErrorCode, type TaskCleanupFailure, type TaskCleanupPhase, type TaskCleanupAdmissionTiming
|
|
1409
1622
|
FINISHED_TASK_RETENTION
|
|
1410
1623
|
TaskEvictedError, isTaskEvictedError, findTaskEvictedError, rehydrateTaskEvictedError
|
|
1411
1624
|
type TaskEvictedErrorCode, type TaskEvictedErrorFields
|
|
1412
1625
|
TaskToolError, isTaskToolError, rehydrateTaskToolError
|
|
1413
1626
|
type TaskToolFailureCode, type TaskToolErrorFields, type SerializedTaskToolError
|
|
1627
|
+
|
|
1414
1628
|
// Messages typed into a task's transcript (see "Task transcript references")
|
|
1415
1629
|
TaskMessageError, TaskMessageTimeoutError, isTaskMessageError, isTaskMessageTimeoutError
|
|
1416
1630
|
findTaskMessageError, isRetryableTaskMessageError, rehydrateTaskMessageError
|
|
1417
1631
|
type TaskMessageErrorCode, type TaskMessageErrorFields, type TaskMessageTimeoutErrorFields
|
|
1418
1632
|
type TaskMessageTimeoutPhase, type SerializedTaskMessageError
|
|
1419
|
-
|
|
1633
|
+
|
|
1634
|
+
// Detachable tool calls (see "Detachable tool calls")
|
|
1635
|
+
ToolDetachmentError, isToolDetachmentError, findToolDetachmentError, deserializeToolDetachmentError
|
|
1636
|
+
MAX_TOOL_DETACHMENT_AFTER_MS
|
|
1637
|
+
markToolCallReadyForDetachment, toolCallNeedsDetachmentHandoff
|
|
1638
|
+
type ToolDetachmentErrorCode, type ToolDetachmentErrorFields, type SerializedToolDetachmentError
|
|
1420
1639
|
type DetachedCallFailure, type DetachedCallFailureCause
|
|
1640
|
+
|
|
1421
1641
|
// Git resolution (see "Resolving git")
|
|
1422
1642
|
resolveGit, resolveGitSync, resolveInstalledGit, getGitStatus, getGitStatusAsync, GIT_MINIMUM_VERSION
|
|
1423
1643
|
GitProvisionError, GitUnavailableError, GitProvisionTimeoutError, GitProvisionConfigError
|
|
@@ -1436,7 +1656,10 @@ type ManagedToolName, type ManagedToolRequestPhase, type ManagedToolErrorCode, t
|
|
|
1436
1656
|
// Debug output
|
|
1437
1657
|
isDebugEnabled
|
|
1438
1658
|
reportDebug
|
|
1659
|
+
reportDebugAsync
|
|
1439
1660
|
appendDebugRecord
|
|
1661
|
+
appendDebugRecordAsync
|
|
1662
|
+
flushDebugLog
|
|
1440
1663
|
DEBUG_AREA_VARIABLES
|
|
1441
1664
|
getDebugLogFailure
|
|
1442
1665
|
setDebugSetting
|
|
@@ -1489,17 +1712,32 @@ isSubscriptionSetupError, isSubscriptionSubscriberUnavailableError, isSubscripti
|
|
|
1489
1712
|
isRetryableSubscriptionError, serializeSubscriptionError, deserializeSubscriptionError
|
|
1490
1713
|
type SubscriptionErrorCode, type SubscriptionConfigReason, type SubscriptionSetupMissing, type SubscriberUnavailableReason, type SubscriptionRecordKind, type SubscriptionTimeoutPhase, type WebhookRequestFailures
|
|
1491
1714
|
|
|
1492
|
-
// Tool factories
|
|
1715
|
+
// Tool factories and shell/file tool errors
|
|
1493
1716
|
createCodingTools
|
|
1494
1717
|
createReadOnlyTools
|
|
1495
1718
|
createReadTool, createBashTool, createPowerShellTool, createKillTool
|
|
1496
1719
|
createEditTool, createWriteTool, createSearchTool, createFindTool, createLsTool
|
|
1497
|
-
|
|
1498
|
-
// Edit and write errors (see Built-in tools: Edit and write errors)
|
|
1720
|
+
ShellToolError, ShellTimeoutError, isShellToolError, isShellTimeoutError, rehydrateShellToolError
|
|
1499
1721
|
EditToolError, EditInputError, EditMatchError, EditTargetError, WriteSelectorError, FileToolAbortedError
|
|
1500
1722
|
isEditToolError, isEditInputError, isEditMatchError, isEditTargetError, isWriteSelectorError, isFileToolAbortedError
|
|
1501
1723
|
serializeFileToolError, rehydrateEditToolError, rehydrateWriteSelectorError
|
|
1502
1724
|
|
|
1725
|
+
// Compaction, errors, and custom compactor models
|
|
1726
|
+
type CompactorModel, type CompactorApi
|
|
1727
|
+
type ProviderCompactorModelConfig, type ProviderChatModelConfig, type ProviderClassifierModelConfig, type ProviderImageModelConfig
|
|
1728
|
+
type CompactorRequest, type CompactorMessage, type CompactionModelSelection, type CompactionModelKind
|
|
1729
|
+
CompactionError, CompactionConfigError, CompactionCancelledError, CompactionStateError, CompactorFailure
|
|
1730
|
+
type CompactionErrorCode, type CompactionConfigErrorCode, type CompactionStateErrorCode, type CompactorFailureCode
|
|
1731
|
+
type CompactionConfigSource, type CompactionSettingsScope, type CompactionCancelReason, type CompactionErrorFieldValue
|
|
1732
|
+
type CompactionConfigErrorFields, type CompactionCancelledErrorFields, type CompactionStateErrorFields, type CompactorFailureOptions
|
|
1733
|
+
type SerializedCompactionError
|
|
1734
|
+
isCompactionError, isCompactionConfigError, isCompactionCancelledError, isCompactionStateError, isCompactorFailure
|
|
1735
|
+
findCompactionError, isRetryableCompactionError, serializeCompactionError, parseSerializedCompactionError, rehydrateCompactionError
|
|
1736
|
+
requestCompactorOutput, buildCompactorMessages, compactedOutputTokenCap, classifyCompactionModel, resolveCompactionModel
|
|
1737
|
+
estimateTextTokens, wrapLongLines
|
|
1738
|
+
COMPACTOR_REQUEST_TIMEOUT_MS, COMPACTOR_LINE_WIDTH
|
|
1739
|
+
COMPACTED_OUTPUT_MAX_TOKENS, COMPACTED_OUTPUT_MAX_TRIGGER_SHARE
|
|
1740
|
+
|
|
1503
1741
|
// Types
|
|
1504
1742
|
type CreateAgentSessionOptions
|
|
1505
1743
|
type CreateAgentSessionResult
|
|
@@ -1517,8 +1755,6 @@ type Tool
|
|
|
1517
1755
|
|
|
1518
1756
|
For extension types, see [Extensions](/extensions) for the full API.
|
|
1519
1757
|
|
|
1520
|
-
<a id="owner-bound-task-supervisor-s1" />
|
|
1521
|
-
|
|
1522
1758
|
## Owner-bound task supervisor
|
|
1523
1759
|
|
|
1524
1760
|
For trusted custom hosts, the package exports `AgentTaskHost` and its integration types rather than the raw native supervisor. Bind the host scope and a mandatory `authorizeLaunch` guard. Never accept ownership or authorization from model input or reconstruct a lease from a task ID or saved history.
|