@bastani/atomic 0.10.14-alpha.1 → 0.10.15-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- 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 +3 -3
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
- package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
- package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
- package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
- package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
- package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
- package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/auth-cli.code.js +1 -1
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.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 +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +1 -1
- 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 +1 -1
- 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/compaction/compactor.d.ts +0 -8
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- 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 +2 -2
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/sdk.code.js +1 -1
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +3 -3
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- 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/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 +2 -2
- 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 +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +2 -2
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +1 -1
- 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.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +1 -1
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +21 -1
- package/dist/index.js +2 -2
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/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/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +2 -2
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/utils/startup-database-spare.code.js +1 -1
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks/reference.md +182 -0
- package/docs/background-tasks.md +98 -405
- package/docs/build.md +67 -27
- package/docs/changelog.mdx +9 -0
- package/docs/codemode.md +108 -39
- package/docs/compaction/branch-summaries.md +54 -0
- package/docs/compaction/custom-compactors.md +161 -0
- package/docs/compaction/memory-compaction.md +77 -0
- package/docs/compaction/reference.md +86 -38
- package/docs/compaction.md +51 -252
- package/docs/computer-use.md +169 -321
- package/docs/containerization.md +71 -57
- package/docs/custom-provider/api-reference.md +119 -25
- package/docs/custom-provider/oauth.md +114 -132
- package/docs/custom-provider/override.md +37 -27
- package/docs/custom-provider/registration.md +107 -83
- package/docs/custom-provider/streaming.md +85 -71
- package/docs/custom-provider.md +85 -52
- package/docs/development.md +39 -29
- package/docs/docs.json +76 -63
- package/docs/environment-variables.md +94 -44
- package/docs/extensions/api-reference.md +86 -43
- package/docs/extensions/authoring.md +162 -154
- package/docs/extensions/events.md +80 -25
- package/docs/extensions/examples.md +90 -85
- package/docs/extensions/ui.md +206 -82
- package/docs/extensions.md +79 -108
- package/docs/getting-started/authentication.md +67 -36
- package/docs/getting-started/first-session.md +53 -43
- package/docs/getting-started/installation.md +116 -89
- package/docs/getting-started/project-instructions.md +48 -34
- package/docs/guides/configuration.md +82 -20
- package/docs/guides/non-interactive.md +66 -24
- package/docs/guides/resume-on-any-machine.md +135 -82
- package/docs/guides/team-setup.md +114 -105
- package/docs/guides.md +76 -32
- package/docs/herdr.md +15 -16
- package/docs/how-atomic-works.md +140 -0
- package/docs/index.md +58 -44
- package/docs/intercom/operations.md +141 -151
- package/docs/intercom/reference.md +85 -108
- package/docs/intercom.md +84 -145
- package/docs/json.md +120 -67
- package/docs/keybindings.md +85 -49
- package/docs/libraries/agent-core.md +137 -275
- package/docs/libraries/ai.md +100 -84
- package/docs/libraries/codemode.md +210 -300
- package/docs/libraries/schema.md +59 -53
- package/docs/libraries/storage-postgres.md +49 -35
- package/docs/libraries/telemetry.md +153 -354
- package/docs/libraries/tui.md +265 -393
- package/docs/libraries.md +42 -26
- package/docs/llama-cpp.md +171 -161
- package/docs/mcp-servers.md +90 -51
- package/docs/models/choose-a-model.md +188 -0
- package/docs/models/reference.md +74 -30
- package/docs/models.md +153 -88
- package/docs/orchestration/migrating-workflows.md +23 -16
- package/docs/orchestration/patterns.md +39 -44
- package/docs/orchestration.md +65 -26
- package/docs/packages/authoring.md +51 -29
- package/docs/packages/reference.md +42 -21
- package/docs/packages.md +69 -58
- package/docs/programmatic.md +118 -24
- package/docs/prompt-templates.md +84 -83
- package/docs/providers/reference.md +43 -48
- package/docs/providers.md +219 -451
- package/docs/quickstart.md +140 -120
- package/docs/reference/cli.md +135 -97
- package/docs/reference.md +20 -18
- package/docs/rpc/examples.md +76 -20
- package/docs/rpc/extension-ui.md +64 -38
- package/docs/rpc/protocol.md +361 -110
- package/docs/rpc.md +57 -17
- package/docs/sdk/reference.md +409 -534
- package/docs/sdk/storage.md +53 -13
- package/docs/sdk/structured-decisions.md +82 -56
- package/docs/sdk/web-server.md +57 -43
- package/docs/sdk.md +106 -84
- package/docs/security.md +42 -64
- package/docs/session-format.md +62 -38
- package/docs/sessions.md +99 -214
- package/docs/settings.md +165 -195
- package/docs/shell-aliases.md +9 -6
- package/docs/skills/authoring.md +69 -48
- package/docs/skills/reference.md +51 -20
- package/docs/skills.md +99 -148
- package/docs/slash-commands.md +129 -0
- package/docs/storage/custom-adapters.md +160 -85
- package/docs/storage/jsonl.md +81 -66
- package/docs/storage/postgres/pgbouncer.md +120 -126
- package/docs/storage/postgres/tuning.md +120 -143
- package/docs/storage/postgres.md +314 -330
- package/docs/storage/sqlite.md +71 -42
- package/docs/storage.md +298 -302
- package/docs/subagents/authoring.md +55 -38
- package/docs/subagents/reference.md +73 -33
- package/docs/subagents.md +119 -187
- package/docs/terminal-setup.md +50 -38
- package/docs/termux.md +67 -41
- package/docs/themes/reference.md +23 -19
- package/docs/themes.md +142 -127
- package/docs/tmux.md +47 -55
- package/docs/tools.md +147 -109
- package/docs/tui/reference.md +166 -214
- package/docs/tui.md +196 -341
- package/docs/usage.md +118 -138
- package/docs/verification.md +79 -51
- package/docs/web-access.md +121 -101
- package/docs/windows.md +26 -27
- package/docs/worktree-snapshots/reference.md +245 -0
- package/docs/worktree-snapshots.md +71 -259
- package/package.json +8 -8
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
- package/docs/guides/intercom.md +0 -32
- package/docs/guides/orchestration.md +0 -28
- package/docs/guides/subagents.md +0 -37
package/docs/sdk/reference.md
CHANGED
|
@@ -57,40 +57,55 @@ const { session, workspace: binding } = await createAgentSession({
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
`workspace` accepts a `workspace({ ... })` value or an already resolved `BoundWorkspace`. The session's `cwd` becomes the bound worktree, an explicit `cwd` must stay inside it, and a read-only workspace removes and refuses `write`, `edit`, and `todo`. `result.workspace` and `session.workspace` hold the resolved binding.
|
|
60
|
+
`workspace` accepts a `workspace({ ... })` value or an already resolved `BoundWorkspace`. The session's `cwd` becomes the bound worktree, an explicit `cwd` must stay inside it, and a read-only workspace removes and refuses `write`, `edit`, and `todo`. `result.workspace` and `session.workspace` hold the resolved binding.
|
|
61
|
+
|
|
62
|
+
- **`WorkspaceOptions`:** `repo` (local repo root path, `file://` URL, SCP `git@host:owner/repo`, or `host/owner/repo`), `base` (starting ref/branch for new branches), `branch`, `worktree` (`"auto"` or an absolute path), `sandbox` (`"read-write"` default or `"read-only"`), and optional `label`.
|
|
63
|
+
- **Workspace helpers:** `resolveWorkspace(spec, options?)`, `bindSessionWorkspace(workspace, sessionManager, signal?)`, `restoreWorkspace(binding, { recreateMissingBranch?, recordedHeads?, signal? })`, `acquireWorkspaceWriterLease(binding, options?)`, `workspaceChangeSet(binding, options?)` (returns `{ repo, baseCommit, branch, headCommit, diffStat }`), and `publishPullRequest(changeSet, options?)` (requires an authenticated `gh` CLI against a GitHub `origin` remote; idempotently returns `{ url, draft, created }`).
|
|
64
|
+
- **Workspace errors:** All extend `WorkspaceError` (`isWorkspaceError`, `findWorkspaceError`, `isRetryableWorkspaceError`, `serializeWorkspaceError`, `rehydrateWorkspaceError`): `WorkspaceConfigError`, `WorkspaceBindingError`, `WorkspaceRestoreError`, `WorkspacePublicationError`, `WorkspaceTimeoutError`, `WorkspaceSandboxError`, `WorkspaceDriftError`, `WorkspaceGitError`, `WorkspaceSnapshotError`, and `WorkspaceCollectionError`.
|
|
65
|
+
|
|
66
|
+
See [Workspaces](/sdk#workspaces).
|
|
61
67
|
|
|
62
68
|
### Model
|
|
63
69
|
|
|
64
70
|
```typescript
|
|
65
|
-
import {
|
|
66
|
-
import { ModelRuntime } from "@bastani/atomic";
|
|
71
|
+
import { createAgentSession, ModelRuntime } from "@bastani/atomic";
|
|
67
72
|
|
|
68
73
|
const modelRuntime = await ModelRuntime.create();
|
|
69
74
|
|
|
70
|
-
// Find
|
|
71
|
-
const opus = getModel("anthropic", "claude-opus-4-5");
|
|
75
|
+
// Find any model by provider/id, including built-in and custom models from models.json
|
|
76
|
+
const opus = modelRuntime.getModel("anthropic", "claude-opus-4-5");
|
|
72
77
|
if (!opus) throw new Error("Model not found");
|
|
73
78
|
|
|
74
|
-
// Find any model by provider/id, including custom models from models.json
|
|
75
|
-
const customModel = modelRuntime.getModel("my-provider", "my-model");
|
|
76
|
-
|
|
77
79
|
// Get only models whose providers have configured authentication
|
|
78
80
|
const available = await modelRuntime.getAvailable();
|
|
79
81
|
|
|
80
82
|
const { session } = await createAgentSession({
|
|
81
83
|
model: opus,
|
|
82
84
|
thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh, max (when supported by the model)
|
|
83
|
-
|
|
84
|
-
// Models for cycling (
|
|
85
|
+
|
|
86
|
+
// Models for cycling (Ctrl+P in interactive mode)
|
|
85
87
|
scopedModels: [
|
|
86
88
|
{ model: opus, thinkingLevel: "high" },
|
|
87
|
-
{ model: haiku, thinkingLevel: "off" },
|
|
88
89
|
],
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
// Ordered fallback chain (explicit array freezes the chain; omit to track settings.fallbackModels dynamically)
|
|
92
|
+
fallbackModels: ["openai/gpt-5:medium"],
|
|
93
|
+
|
|
90
94
|
modelRuntime,
|
|
91
95
|
});
|
|
92
96
|
```
|
|
93
97
|
|
|
98
|
+
Additional model, prompt, and child-session options on `CreateAgentSessionOptions`:
|
|
99
|
+
|
|
100
|
+
- `fallbackModels?: string[]`: ordered `provider/model[:thinkingLevel]` fallback chain. Passing an explicit array freezes the chain for the session; omitting it tracks `settings.fallbackModels` dynamically (including after project trust resolves).
|
|
101
|
+
- `isFallbackModelAllowed?: (model, effort) => boolean`: hard eligibility filter evaluated before switching to a fallback candidate (intersected with `scopedModels` for child sessions).
|
|
102
|
+
- `systemPromptTransform?: (prompt: string) => string`: transforms the assembled base system prompt at session construction.
|
|
103
|
+
- `initialContextTransform?: (messages: AgentMessage[]) => AgentMessage[]`: filters inherited session messages before they enter the session (and acts as the session's context projection transform).
|
|
104
|
+
- `sessionStartEvent?: SessionStartEvent`: start metadata (`{ type: "session_start", reason, previousSessionId? }`) delivered to extension `session_start` hooks.
|
|
105
|
+
- `parentUsageSink?: (usage: Usage) => void`: receives token usage for every model call made by this session and its children (used to emit `child_session_usage` on a parent session).
|
|
106
|
+
- `resourceAdmissionDelegated?: boolean`: marks this session's `resourceAdmission.acquire("session", ...)` call as a delegated child so the host grants immediately or throws instead of deadlocking behind the parent's permit.
|
|
107
|
+
- `releaseWhenIdle?: { afterMs: number }`: releases the session after `afterMs` of idle time (`0` to `2,147,483,647`). Passing `releaseWhenIdle` together with `sessionManager: SessionManager.inMemory()` rejects immediately with `AgentRehydrateError` (`code: "not-reopenable"`) before constructing the session.
|
|
108
|
+
|
|
94
109
|
`ModelRegistry` keeps synchronous reads for extension compatibility, while catalog refresh is asynchronous. Extensions should await `modelRegistry.refresh()` before synchronous `getAll()`, `find()`, or `getAvailable()` reads when a provider may update its catalog. New SDK integrations use `ModelRuntime`; `await modelRuntime.refresh()` reports `aborted` and per-provider `errors`, and failed providers retain their last-known models.
|
|
95
110
|
|
|
96
111
|
If no model is provided:
|
|
@@ -148,7 +163,7 @@ const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(
|
|
|
148
163
|
|
|
149
164
|
`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.
|
|
150
165
|
|
|
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
|
|
166
|
+
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 still use normal local selection; model discovery never blocks waiting on asynchronous credential reads.
|
|
152
167
|
|
|
153
168
|
```typescript
|
|
154
169
|
const refreshedRuntime = await ModelRuntime.create({
|
|
@@ -213,9 +228,9 @@ const builtinsOnly = await ModelRuntime.create({ modelsPath: null });
|
|
|
213
228
|
|
|
214
229
|
Use `generateStructuredOutput()` for one schema-validated decision without starting an agent session. Pass optional exact `model` and `fallbackModels` IDs, `currentModel`, `modelRegistry`, `instructions`, `state`, and `schema`. Omit `model` to start on `currentModel`, or on `decisionModel` when you pass `settings`; `currentModel` is also the final fallback.
|
|
215
230
|
|
|
216
|
-
|
|
231
|
+
When `settings` is passed **and** `model` is omitted, `generateStructuredOutput()` resolves `decisionModel` and wraps resolution, output, and provider failures into `DecisionError` subclasses (input validation errors still throw plain `Error`). Passing an explicit `model` causes `settings` to be ignored so non-timeout failures throw plain `Error`. Timeouts always throw `DecisionTimeoutError`. Atomic resolves each ID through `modelRegistry`: chat models use chat inference, and registered classifiers use the generic `classify` operation when the schema is a finite Choice (and are skipped otherwise). See [Make structured decisions](/sdk/structured-decisions).
|
|
217
232
|
|
|
218
|
-
Use `decide()` to ask the configured `decisionModel` typed Choice, yes/no, and Score questions over `state`. It returns typed answers, with probabilities when a classifier answered, and rejects with a `DecisionError
|
|
233
|
+
Use `decide()` to ask the configured `decisionModel` typed Choice, yes/no, and Score questions over `state`. It returns typed answers, with probabilities when a classifier answered, and always rejects with a `DecisionError` (or `signal.reason` on caller abort). The `structured_output` tool uses the same decision model unless the calling model supplies an explicit `model`. See [Make typed decisions with `decide()`](/sdk/structured-decisions#decide).
|
|
219
234
|
|
|
220
235
|
### System prompt
|
|
221
236
|
|
|
@@ -318,70 +333,7 @@ Inactive (2)
|
|
|
318
333
|
|
|
319
334
|
Each entry in `tools` has `name`, `active`, `exposure`, `source`, `sourcePath`, `summary`, and, for inactive tools, `inactiveReason`. `missing` and `excluded` list `{ name, reason }` entries; a `missing` name usually means a typo or a failed extension load. Pass `{ heading, dim, warning }` functions as the second argument to `formatToolStatus()` for terminal colors. Interactive mode shows the same report with `/tools`, and RPC clients request it with [`get_tools`](/rpc/protocol#get_tools).
|
|
320
335
|
|
|
321
|
-
The report's `git` field reports which Git Atomic runs: `{ source: "system" | "provisioned", version, path, update? }`, or `{ source: "unavailable", error }` with a serialized [
|
|
322
|
-
|
|
323
|
-
#### Resolving git
|
|
324
|
-
|
|
325
|
-
Atomic runs Git 2.30.0 or newer (`GIT_MINIMUM_VERSION`) from `PATH`, and otherwise a portable Git downloaded into `getBinDir()/git` (see [Git](/getting-started/installation#git)). Use the same resolver for your own Git commands:
|
|
326
|
-
|
|
327
|
-
```typescript
|
|
328
|
-
import { spawnSync } from "node:child_process";
|
|
329
|
-
import { resolveGit } from "@bastani/atomic";
|
|
330
|
-
|
|
331
|
-
const git = await resolveGit();
|
|
332
|
-
spawnSync(git.path, ["status", "--short"], { cwd: projectDir, env: git.env, encoding: "utf8" });
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
| Function | Returns |
|
|
336
|
-
|---|---|
|
|
337
|
-
| `resolveGit({ signal?, onStatus? })` | `Promise<ResolvedGit>`. May download and verify portable Git. `onStatus` receives `{ type: "info" \| "warning", message }` progress. Aborting `signal` rejects with `signal.reason`; concurrent callers share one download, which stops only when every caller aborts. |
|
|
338
|
-
| `resolveGitSync()` | `ResolvedGit` without downloading. Throws in order: `GitUnavailableError` (`unsupported-platform` or `offline`), else the last failed `resolveGit()` error in this process (`GitUnavailableError` or `GitProvisionTimeoutError`), else `GitUnavailableError` (`not-installed`). Check `isRetryableGitProvisionError()` to see whether `await resolveGit()` can help. |
|
|
339
|
-
| `getGitStatus()` | `GitToolStatus`, the value in the tools report. Never downloads. |
|
|
340
|
-
|
|
341
|
-
`ResolvedGit` provides `path` (absolute executable path), `source` (`"system"` or `"provisioned"`), `version`, and `env`. For provisioned Git, `env` copies `process.env` and adds `GIT_EXEC_PATH`, `GIT_TEMPLATE_DIR`, `GIT_CONFIG_SYSTEM` (macOS and Linux), and `GIT_SSL_CAINFO` (Linux and Windows), preserving any `GIT_CONFIG_SYSTEM` or `GIT_SSL_CAINFO` already set. `env` is computed per call so later changes to `process.env` apply.
|
|
342
|
-
|
|
343
|
-
For provisioned Git, the returned `path` and `env` stay valid across automatic updates. Keep them together for a running command, and resolve again when starting work with the latest release. Do not construct executable or helper paths from the cache directory yourself.
|
|
344
|
-
|
|
345
|
-
#### Git errors
|
|
346
|
-
|
|
347
|
-
Every Git resolution failure is a `GitProvisionError` carrying `code`, `hint`, `retryable`, and JSON-safe `fields`. Invalid SDK options fail before provisioning starts. Failed downloads, checksums, and verification never activate a partial install, and failed updates leave earlier resolved paths usable. Branch on `code` or the class, never on `message`.
|
|
348
|
-
|
|
349
|
-
| Class | `code` | When | Fields | What to do |
|
|
350
|
-
|---|---|---|---|---|
|
|
351
|
-
| `GitUnavailableError` | `unsupported-platform` | No portable build for this system: `reason` is `musl`, `glibc-too-old`, `architecture`, or `platform` | `platform`, `arch`, `reason`, `libc?`, `systemGit?` | Run `installCommand` (for example `apk add git` on Alpine) or install Git 2.30.0+ |
|
|
352
|
-
| `GitUnavailableError` | `offline` | `ATOMIC_OFFLINE` is set and no usable Git exists | `platform`, `arch`, `offlineVariable`, `systemGit?` | Unset the variable or install Git 2.30.0+ |
|
|
353
|
-
| `GitUnavailableError` | `not-installed` | `resolveGitSync()` found no usable Git and does not download | `platform`, `arch`, `installDir`, `systemGit?` | Call `await resolveGit()` first, or install Git 2.30.0+ |
|
|
354
|
-
| `GitUnavailableError` | `checksum-mismatch` | Download SHA-256 differs from the pinned value | `platform`, `arch`, `asset`, `url`, `expectedSha256`, `actualSha256` | Check for a proxy altering downloads, or install Git yourself. Not retryable |
|
|
355
|
-
| `GitUnavailableError` | `download-failed` | Download failed; `httpStatus` is absent for network errors | `platform`, `arch`, `asset`, `url`, `httpStatus?` | Check access to github.com and retry. `retryable` is true for network errors and HTTP 408, 425, 429, 500, 502, 503, 504 |
|
|
356
|
-
| `GitUnavailableError` | `install-failed` | Reading, staging, extracting, verifying, or promoting failed (`phase`: `stage`, `extract`, `verify`, `promote`) | `platform`, `arch`, `phase`, `asset`, `installDir`, `detail?` | Free disk space or fix permissions on `installDir`; for `verify`, check cache readability or install Git yourself |
|
|
357
|
-
| `GitProvisionTimeoutError` | `provision-timeout` | A step exceeded its limit (`phase`: `lock`, `download`, `extract`, `verify`) | `phase`, `timeoutMs`, `elapsedMs` | Retry; `retryable` is true |
|
|
358
|
-
| `GitProvisionConfigError` | `invalid-option` | A `resolveGit()` option had the wrong type; checked before any probe | `source` (`"sdk"`), `field`, `expected` | Fix the option |
|
|
359
|
-
|
|
360
|
-
When present, `systemGit` describes the unusable Git found on `PATH`: `{ path, problem: "below-minimum" | "probe-failed", version? }`. `GitUnavailableError` also exposes `platform`. Every `GitUnavailableError` and `GitProvisionTimeoutError` sets `installCommand` when Atomic recognizes the OS or distribution (for example, Linux root commands, using the `git-core` PPA on Ubuntu earlier than 22.04). `hint` ends with `installCommand`, and rehydrated errors preserve the originating machine's command. Cleanup failures attach as `cleanupCause` without replacing the original error.
|
|
361
|
-
|
|
362
|
-
Guards match across realms and processes by `name` and `code`: `isGitProvisionError`, `isGitUnavailableError`, `isGitProvisionTimeoutError`, and `isGitProvisionConfigError`. `findGitProvisionError(error)` searches a cause chain to a bounded depth, and `isRetryableGitProvisionError(error)` checks whether any error in the chain is retryable. `JSON.stringify(error)` outputs `{ name, code, message, hint, retryable, fields, cause? }`, and `rehydrateGitProvisionError(payload)` restores the class and cause chain (unknown names become `GitProvisionError` keeping their `name` and `code`).
|
|
363
|
-
|
|
364
|
-
```typescript
|
|
365
|
-
import { isGitUnavailableError, resolveGit } from "@bastani/atomic";
|
|
366
|
-
|
|
367
|
-
try {
|
|
368
|
-
await resolveGit();
|
|
369
|
-
} catch (error) {
|
|
370
|
-
if (isGitUnavailableError(error) && error.code === "unsupported-platform") console.error(error.hint);
|
|
371
|
-
else throw error;
|
|
372
|
-
}
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
#### fd and ripgrep download errors
|
|
376
|
-
|
|
377
|
-
When `fd` or `ripgrep` is neither in `getBinDir()` nor on `PATH`, the `find` and `search` tools download the latest release from GitHub. If a request fails, the tool call rejects with a `ManagedToolError` naming the request, interactive startup shows the same warning, and nothing is installed. Offline mode, unsupported platforms, and unreadable archives still reject with plain errors.
|
|
378
|
-
|
|
379
|
-
| Class | `code` | When | Fields | What to do |
|
|
380
|
-
|---|---|---|---|---|
|
|
381
|
-
| `ManagedToolDownloadError` | `download-failed` | Release lookup (`phase: "resolve-version"`) or archive download (`phase: "download"`) failed, or the response was unusable (`cause` holds the underlying error) | `tool` (`"fd"` or `"rg"`), `phase`, `url`, `httpStatus?`, `detail?` | Check access to github.com and retry, or install the tool with your package manager. `retryable` is true for network errors and HTTP 408, 425, 429, 500, 502, 503, 504 |
|
|
382
|
-
| `ManagedToolTimeoutError` | `download-timeout` | Request exceeded its limit: 10 s for release lookup, 120 s for archive download | `tool`, `phase`, `url`, `timeoutMs`, `elapsedMs` | Retry; `retryable` is true |
|
|
383
|
-
|
|
384
|
-
`isManagedToolError`, `isManagedToolDownloadError`, and `isManagedToolTimeoutError` match across realms by `name` and `code`. `isRetryableManagedToolError(error)` inspects a cause chain to a bounded depth. Branch on `code` or the class, never on `message`.
|
|
336
|
+
The report's `git` field reports which Git Atomic runs: `{ source: "system" | "provisioned", version, path, update? }`, or `{ source: "unavailable", error }` with a serialized [Git error](#git-errors). A provisioned install of an older pinned release carries `update: { pinnedTag, installedTag?, reason? }`. `reason` appears if a replacement attempt failed in this process; failed replacements are not retried until the next process start. Reading status never downloads Git. For standalone Git resolution and `fd`/`ripgrep` download errors, see [Managed tools and Git](#managed-tools-and-git).
|
|
385
337
|
|
|
386
338
|
#### Bash tool behavior
|
|
387
339
|
|
|
@@ -479,7 +431,7 @@ Inspection preserves optional-property identity (`undefined` stays present when
|
|
|
479
431
|
|
|
480
432
|
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.
|
|
481
433
|
|
|
482
|
-
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 [
|
|
434
|
+
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 [Stopping tasks and `CancelReceipt`](/background-tasks/reference#stop-a-shell-task-from-a-tool-call).
|
|
483
435
|
|
|
484
436
|
#### Detachable tool calls
|
|
485
437
|
|
|
@@ -611,13 +563,22 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
611
563
|
|
|
612
564
|
- **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).
|
|
613
565
|
- **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"]`.
|
|
614
|
-
- **Bindings and startup (`ExtensionBindings`):** Pass `extensionBindings` to `createAgentSession()` to install
|
|
566
|
+
- **Bindings and startup (`ExtensionBindings`):** Pass `extensionBindings` to `createAgentSession()` to install host callbacks before `session_start` runs:
|
|
567
|
+
- `humanInput`: implements the five dialog methods (`confirm`, `select`, `input`, `editor`, `questionnaire`) for headless hosts.
|
|
568
|
+
- `uiContext`: full `ExtensionUIContext` for custom UI hosts; `onStatus` receives `setStatus` updates when `uiContext` is omitted.
|
|
569
|
+
- `mode`: `"interactive" | "print" | "json" | "rpc"` (sets `ctx.mode`).
|
|
570
|
+
- `onDiagnostic`, `onError`, `shutdownHandler`, and `reportStartupErrors` (when `true`, forwards `session_start` and `resources_discover` errors to `onError` and keeps the session open instead of rolling back).
|
|
571
|
+
- `onUIPrompt`: observes dialog start/end lifecycle events (`ui_prompt_start` / `ui_prompt_end`).
|
|
572
|
+
- `commandContextActions`: supplies host actions (`waitForIdle`, `newSession`, `fork`, `navigateTree`, `switchSession`, `reload`) for extension commands.
|
|
573
|
+
- `isPresentationOnly`: marks a display-only binding that cannot answer interactive prompts.
|
|
574
|
+
Later `bindExtensions()` calls update bindings without replaying `session_start`.
|
|
615
575
|
- **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()`.
|
|
576
|
+
- **Bundled extension and tool factories:** `@bastani/atomic` also exports `createCodemodeExtension`, `createCodemodeTool`, `createCodemodeToolDefinition`, `createCodemodeDescription`, `createToolSearchExtension`, `createToolSearchToolDefinition`, `createMcpExtension`, and `McpOAuthCredentialStore` for hosts assembling custom extension sets directly.
|
|
616
577
|
|
|
617
|
-
#### Reload lifecycle and resource ownership
|
|
578
|
+
#### Reload lifecycle and resource ownership {#reload-lifecycle-and-resource-ownership}
|
|
618
579
|
|
|
619
|
-
- **Transactional vs. ordinary reload:**
|
|
620
|
-
- **
|
|
580
|
+
- **Transactional vs. ordinary reload:** When `/reload` (or `session.reload()`) runs transactionally, Atomic loads and initializes the next extension generation before retiring the previous one. If the reload fails, the previous generation stays active; in an ordinary (non-transactional) reload, failure leaves extensions unloaded. Both clean up newly acquired resources and report cleanup failures through an `AggregateError` tagged with `code: "ShutdownFailed"`.
|
|
581
|
+
- **Publishing state safely on reload:** Acquire shared resources in `session_start` (or register `session_shutdown` immediately if acquired earlier). To avoid leaking partial state when a reload rolls back, wrap side effects (such as emitting a "ready" event or registering global handles) with `publishExtensionContextEffect(ctx, effect)` — it runs only if the reload succeeds (`"start"` phase after the old generation retires, or `"commit"` phase synchronously right before the swap). Register synchronous teardown for when a generation retires with `registerExtensionContextRetirementEffect(ctx, dispose)`. Never cache `ctx.ui` across reloads.
|
|
621
582
|
|
|
622
583
|
```typescript
|
|
623
584
|
import { publishExtensionContextEffect, type ExtensionFactory } from "@bastani/atomic";
|
|
@@ -631,32 +592,6 @@ const extension: ExtensionFactory = (atomic) => {
|
|
|
631
592
|
};
|
|
632
593
|
```
|
|
633
594
|
|
|
634
|
-
#### Session disposal and lifecycle
|
|
635
|
-
|
|
636
|
-
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.
|
|
637
|
-
|
|
638
|
-
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.)
|
|
639
|
-
|
|
640
|
-
- Concurrent `dispose()` calls share one promise.
|
|
641
|
-
- 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.
|
|
642
|
-
- Settings persistence failures can reject disposal; repair storage and repeat the write before closing (`dispose()` does not drain `SettingsManager.drainErrors()`).
|
|
643
|
-
- Caller-supplied settings, storage, and model runtimes remain caller-owned. Do not add manual MCP or Intercom teardown.
|
|
644
|
-
- `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.
|
|
645
|
-
- Duplicate `executeBash()` IDs act as correlation IDs: `abortBash(id)` cancels every active call with that ID.
|
|
646
|
-
|
|
647
|
-
For reload, replacement, and resource ownership patterns, see [Draining work on reload and shutdown](/sdk#finishing-admitted-work).
|
|
648
|
-
|
|
649
|
-
#### Prompting options
|
|
650
|
-
|
|
651
|
-
`session.prompt(text, options?)` accepts:
|
|
652
|
-
|
|
653
|
-
- `expandPromptTemplates` (default `true`): expands file-based prompt templates, skill commands, and extension commands.
|
|
654
|
-
- `images`: optional `ImageContent[]` attachments.
|
|
655
|
-
- `streamingBehavior`: `"steer"` or `"followUp"` when sending while a turn is active; omitting it while streaming rejects with `AgentSessionBusyError`.
|
|
656
|
-
- `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`.
|
|
657
|
-
- `source`: `InputSource` metadata for `input` hooks.
|
|
658
|
-
- `preflightResult`: callback `(success, disposition?)` invoked once preflight accepts (`"handled"`, `"queued"`, or `"started"`) or rejects the prompt.
|
|
659
|
-
|
|
660
595
|
Extensions can register tools, subscribe to events, add commands, and more. See [Extensions](/extensions) for the full API.
|
|
661
596
|
|
|
662
597
|
**Event Bus:** Extensions can communicate via `atomic.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
|
|
@@ -756,7 +691,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
756
691
|
|
|
757
692
|
### Session management
|
|
758
693
|
|
|
759
|
-
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching. See
|
|
694
|
+
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching. See [Configure session storage](/sdk/storage) for full recipes across all four storage backends, `createAgentSessionRuntime()` store wiring, ownership rules, `@bastani/atomic/storage/testing` conformance testing, and error handling, and [Storage errors](/storage#storage-errors) for `StorageError` subclasses.
|
|
760
695
|
|
|
761
696
|
```typescript
|
|
762
697
|
import {
|
|
@@ -899,8 +834,8 @@ Coordinate single-writer session ownership across processes with session claims
|
|
|
899
834
|
|
|
900
835
|
When managing multiple sessions that share a working directory (or inside `createAgentSessionRuntime()`), split directory-scoped service initialization from session creation:
|
|
901
836
|
|
|
902
|
-
- **`createAgentSessionServices({ cwd, agentDir?, settingsManager?, modelRuntime?,
|
|
903
|
-
- **`createAgentSessionFromServices(
|
|
837
|
+
- **`createAgentSessionServices(options)`:** Accepts `{ cwd, agentDir?, settingsManager?, modelRuntime?, extensionFlagValues?, resourceLoaderOptions?, resourceLoaderReloadOptions? }` and returns shared `AgentSessionServices` (`cwd`, `agentDir`, `modelRuntime`, `settingsManager`, `resourceLoader`, `diagnostics`).
|
|
838
|
+
- **`createAgentSessionFromServices(options)`:** Creates an `AgentSession` backed by those shared services without re-discovering extensions, skills, or models. Accepts `{ services, sessionManager, sessionStartEvent?, model?, thinkingLevel?, fallbackModels?, isFallbackModelAllowed?, scopedModels?, tools?, builtins?, excludedTools?, noTools?, customTools?, extensionBindings?, releaseWhenIdle?, intercom? }`. It does **not** accept `workspace`, `snapshots`, `storage`, `sessionStore`, `resourceAdmission`, `systemPromptTransform`, or `initialContextTransform` (bind storage via `sessionManager` and scope `resourceAdmission` via `withResourceAdmission()`).
|
|
904
839
|
|
|
905
840
|
`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.
|
|
906
841
|
|
|
@@ -942,7 +877,7 @@ await sm.createBranchedSession(leafId); // Extract path to new file
|
|
|
942
877
|
- **`createAgentSession({ sessionManager })`:** Prepares a supplied session that has worktree snapshots unless `cwd` or `workspace` is passed. A local path with a different tree is restored like a missing checkout. Sessions without snapshots or with `snapshots: { enabled: false }` start as supplied.
|
|
943
878
|
- **Path mapping:** Session tools map recorded checkout paths to restored worktrees. To map paths the same way in host code, run inside `withWorktreeRootMappings(sessionManager.getWorktreeRootMappings(), work, outer)` and call `mapPathForCwd(path, cwd)` (`outer` defaults to `currentWorktreeRootMappings()`).
|
|
944
879
|
- **`prepareSessionResume(sessionManager, options)`:** Runs preparation for a `SessionManager` you opened yourself and returns the opened session plus `notices`.
|
|
945
|
-
- **Non-blocking secondary checkouts:** Only the session's primary checkout needs to be restorable; other missing or changed checkouts emit a warning notice rather than refusing resume (`switchSession()`, `rehydrate()`, and `createAgentSession()` do not print those notices).
|
|
880
|
+
- **Non-blocking secondary checkouts:** Only the session's primary checkout needs to be restorable; other missing or changed checkouts emit a warning notice rather than refusing resume (`switchSession()`, `rehydrate()`, and `createAgentSession()` do not print those notices; retrieve them once via `runtime.takeResumeNotices()`).
|
|
946
881
|
- **Shared-storage timeout:** `switchSession()` and `rehydrate()` bound catalog lookup by `RESUME_CATALOG_TIMEOUT_MS` (15 seconds).
|
|
947
882
|
|
|
948
883
|
Resume errors extend `ResumeError` (`isResumeError`, `findResumeError`, `isResumeFailure`), carry `code`, `hint`, and JSON-safe `fields`, and cross processes via `serializeResumeError` and `rehydrateResumeError`.
|
|
@@ -1065,7 +1000,7 @@ Package MCP servers discovered by `DefaultResourceLoader` connect through the bu
|
|
|
1065
1000
|
|
|
1066
1001
|
### Copying extension handlers in `extensionsOverride`
|
|
1067
1002
|
|
|
1068
|
-
If your
|
|
1003
|
+
If your `extensionsOverride` callback clones an extension object without changing its `resources_discover` handler, copy the handler map directly instead of wrapping each handler in a new closure:
|
|
1069
1004
|
|
|
1070
1005
|
```typescript
|
|
1071
1006
|
const loader = new DefaultResourceLoader({
|
|
@@ -1081,9 +1016,7 @@ const loader = new DefaultResourceLoader({
|
|
|
1081
1016
|
});
|
|
1082
1017
|
```
|
|
1083
1018
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
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.
|
|
1019
|
+
Atomic deduplicates identical handler errors during startup by handler reference. Creating a fresh wrapper `(...args) => handler(...args)` on every load registers a new function identity each time and can display duplicate startup errors. Only create a new wrapper when your override changes behavior or forwards for a distinct installation; never cache handlers across reloads.
|
|
1087
1020
|
|
|
1088
1021
|
## Return value
|
|
1089
1022
|
|
|
@@ -1114,6 +1047,122 @@ interface LoadExtensionsResult {
|
|
|
1114
1047
|
}
|
|
1115
1048
|
```
|
|
1116
1049
|
|
|
1050
|
+
## AgentSession and AgentSessionRuntime
|
|
1051
|
+
|
|
1052
|
+
### Prompting options
|
|
1053
|
+
|
|
1054
|
+
`session.prompt(text, options?)` accepts:
|
|
1055
|
+
|
|
1056
|
+
- `expandPromptTemplates` (default `true`): expands file-based prompt templates, skill commands, and extension commands.
|
|
1057
|
+
- `images`: optional `ImageContent[]` attachments.
|
|
1058
|
+
- `streamingBehavior`: `"steer"` or `"followUp"` when sending while a turn is active; omitting it while streaming rejects with `AgentSessionBusyError`.
|
|
1059
|
+
- `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`.
|
|
1060
|
+
- `source`: `InputSource` metadata for `input` hooks.
|
|
1061
|
+
- `preflightResult`: callback `(success, disposition?)` invoked once preflight accepts (`"handled"`, `"queued"`, or `"started"`) or rejects the prompt.
|
|
1062
|
+
|
|
1063
|
+
### Session disposal and lifecycle
|
|
1064
|
+
|
|
1065
|
+
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.
|
|
1066
|
+
|
|
1067
|
+
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.)
|
|
1068
|
+
|
|
1069
|
+
- Concurrent `dispose()` calls share one promise.
|
|
1070
|
+
- 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.
|
|
1071
|
+
- Settings persistence failures can reject disposal; repair storage and repeat the write before closing (`dispose()` does not drain `SettingsManager.drainErrors()`).
|
|
1072
|
+
- Caller-supplied settings, storage, and model runtimes remain caller-owned. Do not add manual MCP or Intercom teardown.
|
|
1073
|
+
- `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.
|
|
1074
|
+
- Duplicate `executeBash()` IDs act as correlation IDs: `abortBash(id)` cancels every active call with that ID.
|
|
1075
|
+
|
|
1076
|
+
For reload, replacement, and resource ownership patterns, see [Draining work on reload and shutdown](/sdk#finishing-admitted-work).
|
|
1077
|
+
|
|
1078
|
+
### Additional `AgentSession` methods
|
|
1079
|
+
|
|
1080
|
+
Beyond the core methods shown in [Driving a session](/sdk#driving-a-session), `AgentSession` exposes:
|
|
1081
|
+
|
|
1082
|
+
| Category | Methods and properties |
|
|
1083
|
+
| --- | --- |
|
|
1084
|
+
| **Messages & turns** | `sendUserMessage(content, options?)`, `sendCustomMessage(msg, options?)`, `sendCustomMessages(msgs, options?)`, `stopTurns(reason?)` (halts further model calls within the active turn without starting new tool calls), `interruptTurn()`, `pauseTurn()`, `resumeTurn()`, `turnPaused`, `entryReceipt(message)` |
|
|
1085
|
+
| **Shell execution** | `executeBash(command, onChunk?, options?)`, `recordBashResult(command, result, options?)`, `abortBash(id?)`, `isBashRunning`, `hasPendingBashMessages` |
|
|
1086
|
+
| **Tools & models** | `getActiveToolNames()`, `getCallableToolNames()`, `getAllTools()`, `getToolDefinition(name)`, `setActiveToolsByName(names)`, `setScopedModels(models)`, `cacheWarmingStatus`, `setCacheWarmingMode(mode)` |
|
|
1087
|
+
| **Queue, retry & compaction** | `setSteeringMode(mode)`, `setFollowUpMode(mode)`, `setAutoCompactionEnabled(enabled)`, `setAutoRetryEnabled(enabled)`, `abortRetry()`, `abortBranchSummary()`, `abortSessionSummary()` |
|
|
1088
|
+
| **Export, stats & metadata** | `getSessionStats()`, `getContextUsage()`, `getLastAssistantText()`, `getUserMessagesForForking()`, `setSessionName(name)`, `exportToJsonl(outputPath?, { includeShareContext?, snapshotContent?, toolOutputContent? })`, `exportToHtml(outputPath?, { themeName? })`, `reload(options?)`, `getPersistenceFailure()`, `getUnsavedInput()`, `discardUnsavedInput()` |
|
|
1089
|
+
|
|
1090
|
+
### `AgentSessionRuntime` options and methods
|
|
1091
|
+
|
|
1092
|
+
`createAgentSessionRuntime(createRuntime, options)` accepts `{ cwd, agentDir, sessionManager, sessionStartEvent?, interactive? }`. When `interactive` is omitted or `false` (default), resuming a worktree snapshot starts the first turn while its blueprint build runs in the background unless `resume.waitForBlueprint` is set.
|
|
1093
|
+
|
|
1094
|
+
- **`newSession({ parentSession?, setup?, withSession? })`:** Creates and switches to a fresh session.
|
|
1095
|
+
- **`switchSession(sessionId, { cwdOverride?, sessionDirectory?, withSession?, projectTrustContextFactory?, history? })`:** Opens a stored session (`history` defaults to `"tail"`; pass `"full"` to load every branch into memory).
|
|
1096
|
+
- **`fork(entryId, { position?, withSession? })`:** Forks before `entryId` (`position: "before"`, default) or clones through `entryId` (`position: "at"`).
|
|
1097
|
+
- **`importFromJsonl(inputPath, cwdOverride?)`:** Imports a JSONL export into the active store and switches to it.
|
|
1098
|
+
- **`takeResumeNotices()` / `queueResumeNotices(notices)`:** Drains accumulated resume warnings (each returned once) or appends warnings prepared by another process.
|
|
1099
|
+
- **Provider auth & lifecycle hooks:** `loginOAuthProvider()`, `loginApiKeyProvider()`, `logoutProvider()`, `setRebindSession(fn)`, `setBeforeSessionInvalidate(fn)`, `dispose({ fromSignal? })`.
|
|
1100
|
+
|
|
1101
|
+
## Managed tools and Git
|
|
1102
|
+
|
|
1103
|
+
### Resolving Git {#resolving-git}
|
|
1104
|
+
|
|
1105
|
+
Atomic runs Git 2.30.0 or newer (`GIT_MINIMUM_VERSION`) from `PATH`, and otherwise a portable Git downloaded into `<agentDir>/bin/git` (default `~/.atomic/agent/bin/git`; see [Git](/getting-started/installation#git)). Use the same resolver for your own Git commands:
|
|
1106
|
+
|
|
1107
|
+
```typescript
|
|
1108
|
+
import { spawnSync } from "node:child_process";
|
|
1109
|
+
import { resolveGit } from "@bastani/atomic";
|
|
1110
|
+
|
|
1111
|
+
const git = await resolveGit();
|
|
1112
|
+
spawnSync(git.path, ["status", "--short"], { cwd: projectDir, env: git.env, encoding: "utf8" });
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
| Function | Returns |
|
|
1116
|
+
|---|---|
|
|
1117
|
+
| `resolveGit({ signal?, onStatus? })` | `Promise<ResolvedGit>`. May download and verify portable Git. `onStatus` receives `{ type: "info" \| "warning", message }` progress. Aborting `signal` rejects with `signal.reason`; concurrent callers share one download, which stops only when every caller aborts. |
|
|
1118
|
+
| `resolveGitSync()` | `ResolvedGit` without downloading. Throws in order: `GitUnavailableError` (`unsupported-platform` or `offline`), else the last failed `resolveGit()` error in this process (`GitUnavailableError` or `GitProvisionTimeoutError`), else `GitUnavailableError` (`not-installed`). Check `isRetryableGitProvisionError()` to see whether `await resolveGit()` can help. |
|
|
1119
|
+
| `getGitStatus()` | `GitToolStatus`, the value in the tools report. Never downloads. |
|
|
1120
|
+
|
|
1121
|
+
`ResolvedGit` provides `path` (absolute executable path), `source` (`"system"` or `"provisioned"`), `version`, and `env`. For provisioned Git, `env` copies `process.env` and adds `GIT_EXEC_PATH`, `GIT_TEMPLATE_DIR`, `GIT_CONFIG_SYSTEM` (macOS and Linux), and `GIT_SSL_CAINFO` (Linux and Windows), preserving any `GIT_CONFIG_SYSTEM` or `GIT_SSL_CAINFO` already set. `env` is computed per call so later changes to `process.env` apply.
|
|
1122
|
+
|
|
1123
|
+
For provisioned Git, the returned `path` and `env` stay valid across automatic updates. Keep them together for a running command, and resolve again when starting work with the latest release. Do not construct executable or helper paths from the cache directory yourself.
|
|
1124
|
+
|
|
1125
|
+
### Git errors {#git-errors}
|
|
1126
|
+
|
|
1127
|
+
Every Git resolution failure is a `GitProvisionError` carrying `code`, `hint`, `retryable`, and JSON-safe `fields`. Invalid SDK options fail before provisioning starts. Failed downloads, checksums, and verification never activate a partial install, and failed updates leave earlier resolved paths usable. Branch on `code` or the class, never on `message`.
|
|
1128
|
+
|
|
1129
|
+
| Class | `code` | When | Fields | What to do |
|
|
1130
|
+
|---|---|---|---|---|
|
|
1131
|
+
| `GitUnavailableError` | `unsupported-platform` | No portable build for this system: `reason` is `musl`, `glibc-too-old`, `architecture`, or `platform` | `platform`, `arch`, `reason`, `libc?`, `systemGit?` | Run `installCommand` (for example `apk add git` on Alpine) or install Git 2.30.0+ |
|
|
1132
|
+
| `GitUnavailableError` | `offline` | `ATOMIC_OFFLINE` is set and no usable Git exists | `platform`, `arch`, `offlineVariable`, `systemGit?` | Unset the variable or install Git 2.30.0+ |
|
|
1133
|
+
| `GitUnavailableError` | `not-installed` | `resolveGitSync()` found no usable Git and does not download | `platform`, `arch`, `installDir`, `systemGit?` | Call `await resolveGit()` first, or install Git 2.30.0+ |
|
|
1134
|
+
| `GitUnavailableError` | `checksum-mismatch` | Download SHA-256 differs from the pinned value | `platform`, `arch`, `asset`, `url`, `expectedSha256`, `actualSha256` | Check for a proxy altering downloads, or install Git yourself. Not retryable |
|
|
1135
|
+
| `GitUnavailableError` | `download-failed` | Download failed; `httpStatus` is absent for network errors | `platform`, `arch`, `asset`, `url`, `httpStatus?` | Check access to github.com and retry. `retryable` is true for network errors and HTTP 408, 425, 429, 500, 502, 503, 504 |
|
|
1136
|
+
| `GitUnavailableError` | `install-failed` | Reading, staging, extracting, verifying, or promoting failed (`phase`: `stage`, `extract`, `verify`, `promote`) | `platform`, `arch`, `phase`, `asset`, `installDir`, `detail?` | Free disk space or fix permissions on `installDir`; for `verify`, check cache readability or install Git yourself |
|
|
1137
|
+
| `GitProvisionTimeoutError` | `provision-timeout` | A step exceeded its limit (`phase`: `lock`, `download`, `extract`, `verify`) | `phase`, `timeoutMs`, `elapsedMs` | Retry; `retryable` is true |
|
|
1138
|
+
| `GitProvisionConfigError` | `invalid-option` | A `resolveGit()` option had the wrong type; checked before any probe | `source` (`"sdk"`), `field`, `expected` | Fix the option |
|
|
1139
|
+
|
|
1140
|
+
When present, `systemGit` describes the unusable Git found on `PATH`: `{ path, problem: "below-minimum" | "probe-failed", version? }`. `GitUnavailableError` also exposes `platform`. Every `GitUnavailableError` and `GitProvisionTimeoutError` sets `installCommand` when Atomic recognizes the OS or distribution (for example, Linux root commands, using the `git-core` PPA on Ubuntu earlier than 22.04). `hint` ends with `installCommand`, and rehydrated errors preserve the originating machine's command. Cleanup failures attach as `cleanupCause` without replacing the original error.
|
|
1141
|
+
|
|
1142
|
+
Guards match across realms and processes by `name` and `code`: `isGitProvisionError`, `isGitUnavailableError`, `isGitProvisionTimeoutError`, and `isGitProvisionConfigError`. `findGitProvisionError(error)` searches a cause chain to a bounded depth, and `isRetryableGitProvisionError(error)` checks whether any error in the chain is retryable. `JSON.stringify(error)` outputs `{ name, code, message, hint, retryable, fields, cause? }`, and `rehydrateGitProvisionError(payload)` restores the class and cause chain (unknown names become `GitProvisionError` keeping their `name` and `code`).
|
|
1143
|
+
|
|
1144
|
+
```typescript
|
|
1145
|
+
import { isGitUnavailableError, resolveGit } from "@bastani/atomic";
|
|
1146
|
+
|
|
1147
|
+
try {
|
|
1148
|
+
await resolveGit();
|
|
1149
|
+
} catch (error) {
|
|
1150
|
+
if (isGitUnavailableError(error) && error.code === "unsupported-platform") console.error(error.hint);
|
|
1151
|
+
else throw error;
|
|
1152
|
+
}
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
### `fd` and `ripgrep` download errors {#fd-and-ripgrep-download-errors}
|
|
1156
|
+
|
|
1157
|
+
When `fd` or `ripgrep` is neither in `<agentDir>/bin` (default `~/.atomic/agent/bin`) nor on `PATH`, the `find` and `search` tools download the latest release from GitHub. If a request fails, the tool call rejects with a `ManagedToolError` naming the request, interactive startup shows the same warning, and nothing is installed. Offline mode, unsupported platforms, and unreadable archives still reject with plain errors.
|
|
1158
|
+
|
|
1159
|
+
| Class | `code` | When | Fields | What to do |
|
|
1160
|
+
|---|---|---|---|---|
|
|
1161
|
+
| `ManagedToolDownloadError` | `download-failed` | Release lookup (`phase: "resolve-version"`) or archive download (`phase: "download"`) failed, or the response was unusable (`cause` holds the underlying error) | `tool` (`"fd"` or `"rg"`), `phase`, `url`, `httpStatus?`, `detail?` | Check access to github.com and retry, or install the tool with your package manager. `retryable` is true for network errors and HTTP 408, 425, 429, 500, 502, 503, 504 |
|
|
1162
|
+
| `ManagedToolTimeoutError` | `download-timeout` | Request exceeded its limit: 10 s for release lookup, 120 s for archive download | `tool`, `phase`, `url`, `timeoutMs`, `elapsedMs` | Retry; `retryable` is true |
|
|
1163
|
+
|
|
1164
|
+
`isManagedToolError`, `isManagedToolDownloadError`, and `isManagedToolTimeoutError` match across realms by `name` and `code`. `isRetryableManagedToolError(error)` inspects a cause chain to a bounded depth. Branch on `code` or the class, never on `message`.
|
|
1165
|
+
|
|
1117
1166
|
## Run modes
|
|
1118
1167
|
|
|
1119
1168
|
The SDK exports run mode utilities for building custom interfaces on top of `createAgentSession()`:
|
|
@@ -1280,6 +1329,10 @@ try {
|
|
|
1280
1329
|
}
|
|
1281
1330
|
```
|
|
1282
1331
|
|
|
1332
|
+
## Compaction errors {#compaction-errors}
|
|
1333
|
+
|
|
1334
|
+
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).
|
|
1335
|
+
|
|
1283
1336
|
## Session start errors
|
|
1284
1337
|
|
|
1285
1338
|
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:
|
|
@@ -1326,10 +1379,6 @@ Both extend `DebugError`, whose `code` is a `DebugErrorCode` and whose `fields()
|
|
|
1326
1379
|
|
|
1327
1380
|
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`.
|
|
1328
1381
|
|
|
1329
|
-
### Compaction errors
|
|
1330
|
-
|
|
1331
|
-
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).
|
|
1332
|
-
|
|
1333
1382
|
## Nonblocking helpers
|
|
1334
1383
|
|
|
1335
1384
|
Use the asynchronous helpers in a host that must keep accepting input while it reads files, checks trust or resolves tools. Existing synchronous SDK forms remain available.
|
|
@@ -1339,10 +1388,10 @@ Use the asynchronous helpers in a host that must keep accepting input while it r
|
|
|
1339
1388
|
| `getProjectTrustOptionsAsync`, `hasProjectTrustInputsAsync`, `hasTrustRequiringProjectResourcesAsync`, `savedProjectTrustAsync` | Read project trust inputs without synchronous file access; `savedProjectTrustAsync()` returns a predicate whose trust result must be awaited |
|
|
1340
1389
|
| `buildSkillCatalogAsync`, `emptySkillCatalog` | Load a skill catalog asynchronously, or create an empty catalog without reading files |
|
|
1341
1390
|
| `latestSessionSnapshotAsync`, `mapPathForCwdAsync`, `mapRestoredPathAsync`, `workspaceSessionCwdAsync` | Read snapshot metadata and resolve restored paths and workspace working directories asynchronously |
|
|
1342
|
-
| `
|
|
1391
|
+
| `updateMcpServerConfigAsync` | Edit MCP server configuration asynchronously (synchronous form: `updateMcpServerConfig`); await edits before reading their result |
|
|
1343
1392
|
| `AuthStorage.createAsync`, `SettingsManager.createAsync` | Load credential or settings storage asynchronously |
|
|
1344
1393
|
| `ModelRuntime.getCompatibilityRequestConfigAsync`, `ModelRuntime.getCatalogInputsGenerationAsync` | Read provider request configuration or observe catalog input changes asynchronously |
|
|
1345
|
-
| `selectProcessStorageAsync`, `processSharedStorageSelectionAsync`, `processStorageEnvironmentAsync` | Read process storage
|
|
1394
|
+
| `selectProcessStorageAsync`, `processSharedStorageSelectionAsync`, `processStorageEnvironmentAsync` | Read process storage overrides (`ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`, `--storage`, `--storage-file`) asynchronously when building storage selections or child environments |
|
|
1346
1395
|
| `storageHomeDirAsync`, `workflowsStorageDirAsync`, `defaultSessionDatabasePathAsync`, `defaultSharedStoragePathAsync`, `storagePathBaseDirAsync` from `@bastani/atomic/storage` | Resolve storage homes and paths asynchronously while preserving custom agent-directory isolation |
|
|
1347
1396
|
| `readClaimFileAsync`, `claimFileAtomicallyAsync`, `sameDirectoryAsync`, `selectStorageAsync` from `@bastani/atomic/storage` | Read or publish ownership claims, compare directories or resolve a storage selection without blocking the host |
|
|
1348
1397
|
| `takeTakeoverMutexAsync` | Acquire a takeover mutex asynchronously; await the returned mutex's `release()` |
|
|
@@ -1365,408 +1414,245 @@ On Windows, the native module reads directory ownership and access lists directl
|
|
|
1365
1414
|
|
|
1366
1415
|
## Exports
|
|
1367
1416
|
|
|
1368
|
-
|
|
1417
|
+
`@bastani/atomic` exports the main SDK surface from the package root, plus dedicated subpath entry points:
|
|
1369
1418
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
//
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
workspaceSessionCwd, workspaceSessionCwdAsync
|
|
1419
|
-
WorkspaceError, WorkspaceConfigError, WorkspaceBindingError, WorkspaceGitError
|
|
1420
|
-
WorkspaceSnapshotError, WorkspaceRestoreError, WorkspaceDriftError, WorkspacePublicationError
|
|
1421
|
-
WorkspaceSandboxError, WorkspaceTimeoutError, WorkspaceCollectionError
|
|
1422
|
-
isWorkspaceError, findWorkspaceError, isRetryableWorkspaceError, serializeWorkspaceError, rehydrateWorkspaceError
|
|
1423
|
-
isWorkspaceConfigError, isWorkspaceBindingError, isWorkspacePublicationError, isWorkspaceRestoreError
|
|
1424
|
-
isWorkspaceSandboxError, isWorkspaceTimeoutError, isWorkspaceCollectionError
|
|
1425
|
-
isWorkspaceDriftError, isWorkspaceGitError, isWorkspaceSnapshotError
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
type
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
type
|
|
1472
|
-
type
|
|
1473
|
-
type
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
type
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
type
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
type
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
findDecisionError, isRetryableDecisionError, serializeDecisionError, parseSerializedDecisionError, rehydrateDecisionError
|
|
1589
|
-
|
|
1590
|
-
// Session start errors
|
|
1591
|
-
SessionStartError
|
|
1592
|
-
SessionStartTimeoutError
|
|
1593
|
-
SessionStartConfigError
|
|
1594
|
-
isSessionStartError
|
|
1595
|
-
isSessionStartTimeoutError
|
|
1596
|
-
isSessionStartConfigError
|
|
1597
|
-
findSessionStartError
|
|
1598
|
-
isRetryableSessionStartError
|
|
1599
|
-
serializeSessionStartError
|
|
1600
|
-
rehydrateSessionStartError
|
|
1601
|
-
parseSessionStartTimeoutMs
|
|
1602
|
-
MAX_SESSION_START_TIMEOUT_MS
|
|
1603
|
-
type SessionStartErrorCode
|
|
1604
|
-
type SessionStartPhase
|
|
1605
|
-
type SessionStartStep
|
|
1606
|
-
type SessionStartStepTiming
|
|
1607
|
-
type SessionStartEventLoopSample
|
|
1608
|
-
type SessionStartTimeoutDetails
|
|
1609
|
-
type SessionStartConfigSource
|
|
1610
|
-
type SessionStartConfigReason
|
|
1611
|
-
type SerializedSessionStartError
|
|
1612
|
-
type SerializedSessionStartCause
|
|
1613
|
-
|
|
1614
|
-
// Owner-bound task supervisor, cleanup errors, and finished task retention
|
|
1615
|
-
AgentTaskHost, type AgentTaskHostBinding, type AgentTaskRunnerFactory
|
|
1616
|
-
OwnerTaskStore, bindOwnerTaskStore, getOwnerTaskStore, getOwnerTaskSession
|
|
1617
|
-
scopedBackgroundTasks, sessionTasks, belongsToSession, ownerTaskViewSource, bindTaskResumer, type TaskViewSource
|
|
1618
|
-
heldPrompts, watchHeldPromptAttention, isHeldPromptInput, isPresentationHostInput, routeNamesPrompt
|
|
1619
|
-
type HeldPrompt, type HeldPrompts
|
|
1620
|
-
TaskCleanupError, TaskCleanupAdmissionTimeoutError
|
|
1621
|
-
isTaskCleanupError, isTaskCleanupAdmissionTimeoutError, isRetryableTaskError, rehydrateTaskCleanupError
|
|
1622
|
-
type TaskCleanupErrorCode, type TaskCleanupFailure, type TaskCleanupPhase, type TaskCleanupAdmissionTiming
|
|
1623
|
-
FINISHED_TASK_RETENTION
|
|
1624
|
-
TaskEvictedError, isTaskEvictedError, findTaskEvictedError, rehydrateTaskEvictedError
|
|
1625
|
-
type TaskEvictedErrorCode, type TaskEvictedErrorFields
|
|
1626
|
-
TaskToolError, isTaskToolError, rehydrateTaskToolError
|
|
1627
|
-
type TaskToolFailureCode, type TaskToolErrorFields, type SerializedTaskToolError
|
|
1628
|
-
|
|
1629
|
-
// Messages typed into a task's transcript (see "Task transcript references")
|
|
1630
|
-
TaskMessageError, TaskMessageTimeoutError, isTaskMessageError, isTaskMessageTimeoutError
|
|
1631
|
-
findTaskMessageError, isRetryableTaskMessageError, rehydrateTaskMessageError
|
|
1632
|
-
type TaskMessageErrorCode, type TaskMessageErrorFields, type TaskMessageTimeoutErrorFields
|
|
1633
|
-
type TaskMessageTimeoutPhase, type SerializedTaskMessageError
|
|
1634
|
-
|
|
1635
|
-
// Detachable tool calls (see "Detachable tool calls")
|
|
1636
|
-
ToolDetachmentError, isToolDetachmentError, findToolDetachmentError, deserializeToolDetachmentError
|
|
1637
|
-
MAX_TOOL_DETACHMENT_AFTER_MS
|
|
1638
|
-
markToolCallReadyForDetachment, toolCallNeedsDetachmentHandoff
|
|
1639
|
-
type ToolDetachmentErrorCode, type ToolDetachmentErrorFields, type SerializedToolDetachmentError
|
|
1640
|
-
type DetachedCallFailure, type DetachedCallFailureCause
|
|
1641
|
-
|
|
1642
|
-
// Git resolution (see "Resolving git")
|
|
1643
|
-
resolveGit, resolveGitSync, resolveInstalledGit, getGitStatus, getGitStatusAsync, GIT_MINIMUM_VERSION
|
|
1644
|
-
GitProvisionError, GitUnavailableError, GitProvisionTimeoutError, GitProvisionConfigError
|
|
1645
|
-
isGitProvisionError, isGitUnavailableError, isGitProvisionTimeoutError, isGitProvisionConfigError
|
|
1646
|
-
findGitProvisionError, isRetryableGitProvisionError, rehydrateGitProvisionError
|
|
1647
|
-
type ResolvedGit, type ResolveGitOptions, type GitToolStatus, type GitUnavailableCode, type GitUnavailableFields
|
|
1648
|
-
|
|
1649
|
-
// Private temp directories (see "Private temp directories")
|
|
1650
|
-
ensurePrivateTempDirAsync, assertPrivateDirectoryAsync, ensurePrivateTempDir, assertPrivateDirectory, TempDirRefusedError
|
|
1651
|
-
|
|
1652
|
-
// fd and ripgrep download errors (see "fd and ripgrep download errors")
|
|
1653
|
-
ManagedToolError, ManagedToolDownloadError, ManagedToolTimeoutError
|
|
1654
|
-
isManagedToolError, isManagedToolDownloadError, isManagedToolTimeoutError, isRetryableManagedToolError
|
|
1655
|
-
type ManagedToolName, type ManagedToolRequestPhase, type ManagedToolErrorCode, type ManagedToolDownloadFields, type ManagedToolTimeoutFields
|
|
1656
|
-
|
|
1657
|
-
// Debug output
|
|
1658
|
-
isDebugEnabled
|
|
1659
|
-
reportDebug
|
|
1660
|
-
reportDebugAsync
|
|
1661
|
-
appendDebugRecord
|
|
1662
|
-
appendDebugRecordAsync
|
|
1663
|
-
flushDebugLog
|
|
1664
|
-
DEBUG_AREA_VARIABLES
|
|
1665
|
-
getDebugLogFailure
|
|
1666
|
-
setDebugSetting
|
|
1667
|
-
onDebugSettingChange
|
|
1668
|
-
DebugError
|
|
1669
|
-
DebugLogUnwritableError
|
|
1670
|
-
DebugConfigError
|
|
1671
|
-
isDebugError
|
|
1672
|
-
isDebugLogUnwritableError
|
|
1673
|
-
isDebugConfigError
|
|
1674
|
-
serializeDebugError
|
|
1675
|
-
rehydrateDebugError
|
|
1676
|
-
type SerializedDebugError
|
|
1677
|
-
type SerializedErrorCause
|
|
1678
|
-
type DebugConfigErrorFields
|
|
1679
|
-
type DebugArea
|
|
1680
|
-
type DebugFields
|
|
1681
|
-
type DebugValue
|
|
1682
|
-
type DebugErrorCode
|
|
1683
|
-
type DebugSettingSource
|
|
1684
|
-
|
|
1685
|
-
// Session working directory
|
|
1686
|
-
MissingSessionCwdError
|
|
1687
|
-
isMissingSessionCwdError
|
|
1688
|
-
serializeMissingSessionCwdError
|
|
1689
|
-
rehydrateMissingSessionCwdError
|
|
1690
|
-
isSerializedMissingSessionCwdError
|
|
1691
|
-
type SerializedMissingSessionCwdError
|
|
1692
|
-
type MissingSessionCwdErrorCode
|
|
1693
|
-
type MissingSessionCwdFields
|
|
1694
|
-
type SessionCwdIssue
|
|
1695
|
-
|
|
1696
|
-
// Event subscriptions (session.subscribe, ctx.subscribe, ctx.events)
|
|
1697
|
-
type EventSource
|
|
1698
|
-
type SubscriptionEvent
|
|
1699
|
-
type Subscription
|
|
1700
|
-
type SubscriptionStats
|
|
1701
|
-
type SessionEventChild
|
|
1702
|
-
type SessionEventHandler
|
|
1703
|
-
type SessionSubscribeOptions
|
|
1704
|
-
githubChecks, githubReviews, logTail, webhook, interval
|
|
1705
|
-
publishEvent, openEventSubscription
|
|
1706
|
-
createWakeDispatcher, sharedWakeDispatcher
|
|
1707
|
-
SubscriptionError, SubscriptionClosedError, SubscriptionConfigError, SubscriptionEventError
|
|
1708
|
-
EventSourceError, SubscriptionHandlerError, SubscriptionChildUnavailableError
|
|
1709
|
-
SubscriptionSetupError, SubscriptionSubscriberUnavailableError, SubscriptionRecordError, SubscriptionTimeoutError
|
|
1710
|
-
isSubscriptionError, isSubscriptionClosedError, isSubscriptionConfigError, isSubscriptionEventError
|
|
1711
|
-
isEventSourceError, isSubscriptionHandlerError, isSubscriptionChildUnavailableError
|
|
1712
|
-
isSubscriptionSetupError, isSubscriptionSubscriberUnavailableError, isSubscriptionRecordError, isSubscriptionTimeoutError
|
|
1713
|
-
isRetryableSubscriptionError, serializeSubscriptionError, deserializeSubscriptionError
|
|
1714
|
-
type SubscriptionErrorCode, type SubscriptionConfigReason, type SubscriptionSetupMissing, type SubscriberUnavailableReason, type SubscriptionRecordKind, type SubscriptionTimeoutPhase, type WebhookRequestFailures
|
|
1715
|
-
|
|
1716
|
-
// Tool factories and shell/file tool errors
|
|
1717
|
-
createCodingTools
|
|
1718
|
-
createReadOnlyTools
|
|
1719
|
-
createReadTool, createBashTool, createPowerShellTool, createKillTool
|
|
1720
|
-
createEditTool, createWriteTool, createSearchTool, createFindTool, createLsTool
|
|
1721
|
-
ShellToolError, ShellTimeoutError, isShellToolError, isShellTimeoutError, rehydrateShellToolError
|
|
1722
|
-
EditToolError, EditInputError, EditMatchError, EditTargetError, WriteSelectorError, FileToolAbortedError
|
|
1723
|
-
isEditToolError, isEditInputError, isEditMatchError, isEditTargetError, isWriteSelectorError, isFileToolAbortedError
|
|
1724
|
-
serializeFileToolError, rehydrateEditToolError, rehydrateWriteSelectorError
|
|
1725
|
-
|
|
1726
|
-
// Compaction, errors, and custom compactor models
|
|
1727
|
-
type CompactorModel, type CompactorApi
|
|
1728
|
-
type ProviderCompactorModelConfig, type ProviderChatModelConfig, type ProviderClassifierModelConfig, type ProviderImageModelConfig
|
|
1729
|
-
type CompactorRequest, type CompactorMessage, type CompactionModelSelection, type CompactionModelKind
|
|
1730
|
-
CompactionError, CompactionConfigError, CompactionCancelledError, CompactionStateError, CompactorFailure
|
|
1731
|
-
type CompactionErrorCode, type CompactionConfigErrorCode, type CompactionStateErrorCode, type CompactorFailureCode
|
|
1732
|
-
type CompactionConfigSource, type CompactionSettingsScope, type CompactionCancelReason, type CompactionErrorFieldValue
|
|
1733
|
-
type CompactionConfigErrorFields, type CompactionCancelledErrorFields, type CompactionStateErrorFields, type CompactorFailureOptions
|
|
1734
|
-
type SerializedCompactionError
|
|
1735
|
-
isCompactionError, isCompactionConfigError, isCompactionCancelledError, isCompactionStateError, isCompactorFailure
|
|
1736
|
-
findCompactionError, isRetryableCompactionError, serializeCompactionError, parseSerializedCompactionError, rehydrateCompactionError
|
|
1737
|
-
requestCompactorOutput, buildCompactorMessages, compactedOutputTokenCap, classifyCompactionModel, resolveCompactionModel
|
|
1738
|
-
estimateTextTokens, wrapLongLines
|
|
1739
|
-
COMPACTOR_REQUEST_TIMEOUT_MS, COMPACTOR_LINE_WIDTH
|
|
1740
|
-
COMPACTED_OUTPUT_MAX_TOKENS, COMPACTED_OUTPUT_MAX_TRIGGER_SHARE
|
|
1741
|
-
|
|
1742
|
-
// Types
|
|
1743
|
-
type CreateAgentSessionOptions
|
|
1744
|
-
type CreateAgentSessionResult
|
|
1745
|
-
type StructuredOutputCapture
|
|
1746
|
-
type StructuredOutputToolOptions
|
|
1747
|
-
type StructuredOutputRequest
|
|
1748
|
-
type StructuredOutputResult
|
|
1749
|
-
type ExtensionFactory
|
|
1750
|
-
type ExtensionAPI
|
|
1751
|
-
type ToolDefinition
|
|
1752
|
-
type Skill
|
|
1753
|
-
type PromptTemplate
|
|
1754
|
-
type Tool
|
|
1755
|
-
```
|
|
1419
|
+
| Entry point | Primary exports |
|
|
1420
|
+
| --- | --- |
|
|
1421
|
+
| `@bastani/atomic` | Session factories, `AgentSession`, `AgentSessionRuntime`, `ModelRuntime`, `SessionManager`, `SettingsManager`, `DefaultResourceLoader`, `workspace`, `decide`, `generateStructuredOutput`, `RpcClient`, `AgentTaskHost`, tool/extension factories, and typed error families |
|
|
1422
|
+
| `@bastani/atomic/storage` | `openNodeSqliteDatabase`, `StorageProvider`, storage selections, path/claim helpers, and `StorageError` classes (also re-exported from root) |
|
|
1423
|
+
| `@bastani/atomic/storage/testing` | `registerSqliteDatabaseConformance` conformance test suite for custom `SqliteDatabase` adapters |
|
|
1424
|
+
| `@bastani/atomic/typebox` (`/*`) | Atomic's shared TypeBox instance so custom tool formats reach validation |
|
|
1425
|
+
| `@bastani/atomic/rpc-entry` | Standalone Node.js entry script forcing `--mode rpc` for `RpcClient` subprocesses |
|
|
1426
|
+
|
|
1427
|
+
<AccordionGroup>
|
|
1428
|
+
<Accordion title="Sessions, runtime, models, and auth">
|
|
1429
|
+
```typescript
|
|
1430
|
+
// Session factories, runtime, and output
|
|
1431
|
+
createAgentSession, createAgentSessionServices, createAgentSessionFromServices, createAgentSessionRuntime
|
|
1432
|
+
AgentSession, AgentSessionRuntime, CacheWarmer, CACHE_WARMING_MODES
|
|
1433
|
+
AgentSessionBusyError, isAgentSessionBusyError, NativeModuleUnavailableError
|
|
1434
|
+
createTranscript, type Transcript, type TranscriptOptions, type TranscriptPart
|
|
1435
|
+
type CreateAgentSessionOptions, type CreateAgentSessionResult
|
|
1436
|
+
|
|
1437
|
+
// Releasing idle sessions and wake dispatcher
|
|
1438
|
+
AgentWakeDispatcher, agentWakeDispatcher, wakeKeyNamespace
|
|
1439
|
+
AgentRehydrateError, AgentReleaseConfigError
|
|
1440
|
+
isAgentRehydrateError, isAgentReleaseConfigError, isRetryableAgentRehydrateError
|
|
1441
|
+
isLocalOnlySessionStorage, serializeAgentRehydrateError, rehydrateAgentRehydrateError
|
|
1442
|
+
type ReleasedAgentSession, type ReleaseWhenIdleOptions, type AgentWake, type AgentWakeKind
|
|
1443
|
+
type AgentWakeHandler, type AgentWakeHandlerOptions, type AgentWakeSlot, type AgentWakeClock
|
|
1444
|
+
type AgentWakeTimer, type AgentWakeDispatcherOptions, type AgentWakeDispatcherStats, type AgentWakeFailureListener
|
|
1445
|
+
type AgentRehydrateErrorCode, type AgentRehydrateErrorFields, type AgentReleaseConfigSource
|
|
1446
|
+
type AgentSessionActivity, type SerializedAgentRehydrateError, type SerializedAgentErrorCause
|
|
1447
|
+
|
|
1448
|
+
// Auth and models
|
|
1449
|
+
ModelRuntime, type CreateModelRuntimeOptions, type ModelRuntimeAuthOverrides, CredentialSynchronizationError
|
|
1450
|
+
AuthStorage, type AuthStorageBackend, FileAuthStorageBackend, InMemoryAuthStorageBackend, readStoredCredential
|
|
1451
|
+
ModelRegistry, NoUsableModelError, partitionByCredentials, createGatewayBindingFetch
|
|
1452
|
+
resolveAutoModel, resolveRestoredModelReference, resolveModelScopeFromModels, resolveModelScopeWithDiagnostics
|
|
1453
|
+
type ResolveModelScopeResult, type ModelScopeDiagnostic
|
|
1454
|
+
OAuthLoginTransactionError, OAuthRefreshRejectedError, isOAuthRefreshRejectedError
|
|
1455
|
+
GitHubCopilotError, GitHubCopilotAuthenticationError, GitHubCopilotContentFilterError
|
|
1456
|
+
GitHubCopilotEmptyResponseError, GitHubCopilotInvalidRequestError, GitHubCopilotModelUnavailableError
|
|
1457
|
+
GitHubCopilotPromptTooLargeError, GitHubCopilotQuotaExhaustedError, GitHubCopilotRateLimitError
|
|
1458
|
+
GitHubCopilotServiceUnavailableError, GitHubCopilotStreamEndedEarlyError, GitHubCopilotUnrecognizedResponseError
|
|
1459
|
+
LlamaServerError, LlamaServerRequestError, LlamaServerUnreachableError
|
|
1460
|
+
```
|
|
1461
|
+
</Accordion>
|
|
1462
|
+
<Accordion title="Workspaces, Intercom, and event subscriptions">
|
|
1463
|
+
```typescript
|
|
1464
|
+
// Workspaces
|
|
1465
|
+
workspace, bindSessionWorkspace, resolveWorkspace, restoreWorkspace
|
|
1466
|
+
workspaceChangeSet, publishPullRequest, acquireWorkspaceWriterLease, inheritWorkspace
|
|
1467
|
+
isWorkspace, isBoundWorkspace, assertWorkspace, workspaceSessionCwd, workspaceSessionCwdAsync
|
|
1468
|
+
WorkspaceError, WorkspaceConfigError, WorkspaceBindingError, WorkspaceGitError
|
|
1469
|
+
WorkspaceSnapshotError, WorkspaceRestoreError, WorkspaceDriftError, WorkspacePublicationError
|
|
1470
|
+
WorkspaceSandboxError, WorkspaceTimeoutError, WorkspaceCollectionError
|
|
1471
|
+
isWorkspaceError, findWorkspaceError, isRetryableWorkspaceError, serializeWorkspaceError, rehydrateWorkspaceError
|
|
1472
|
+
isWorkspaceConfigError, isWorkspaceBindingError, isWorkspacePublicationError, isWorkspaceRestoreError
|
|
1473
|
+
isWorkspaceSandboxError, isWorkspaceTimeoutError, isWorkspaceCollectionError
|
|
1474
|
+
isWorkspaceDriftError, isWorkspaceGitError, isWorkspaceSnapshotError
|
|
1475
|
+
|
|
1476
|
+
// Intercom policies and errors
|
|
1477
|
+
IntercomPolicyError, MAX_INTERCOM_REACHABLE_GROUPS
|
|
1478
|
+
confinedIntercomChildGroup, readRuntimeIntercomGroup, RUNTIME_INTERCOM_GROUP_ENV
|
|
1479
|
+
type IntercomSessionOptions, type SessionIntercom
|
|
1480
|
+
IntercomBrokerError, IntercomBrokerProtocolError, IntercomBrokerStopTimeoutError
|
|
1481
|
+
IntercomBrokerSuccessorTimeoutError, IntercomBrokerUpgradeError
|
|
1482
|
+
isIntercomBrokerError, isIntercomBrokerProtocolError, isIntercomBrokerStopTimeoutError
|
|
1483
|
+
isIntercomBrokerSuccessorTimeoutError, isIntercomBrokerUpgradeError, isRetryableIntercomBrokerError
|
|
1484
|
+
serializeIntercomBrokerError, rehydrateIntercomBrokerError, type SerializedIntercomBrokerError
|
|
1485
|
+
IntercomRoutingError, IntercomRoutingChangedError, IntercomRoutingMismatchError
|
|
1486
|
+
IntercomRoutingTimeoutError, IntercomRoutingUnavailableError
|
|
1487
|
+
isIntercomRoutingError, isIntercomRoutingChangedError, isIntercomRoutingMismatchError
|
|
1488
|
+
isIntercomRoutingTimeoutError, isIntercomRoutingUnavailableError, isRetryableIntercomRoutingError
|
|
1489
|
+
ProjectGroupError, isProjectGroupError, type ProjectGroupErrorCode
|
|
1490
|
+
|
|
1491
|
+
// Event subscriptions
|
|
1492
|
+
githubChecks, githubReviews, logTail, webhook, interval, publishEvent, openEventSubscription
|
|
1493
|
+
createWakeDispatcher, sharedWakeDispatcher
|
|
1494
|
+
type EventSource, type SubscriptionEvent, type Subscription, type SubscriptionStats
|
|
1495
|
+
type SessionEventChild, type SessionEventHandler, type SessionSubscribeOptions
|
|
1496
|
+
SubscriptionError, SubscriptionClosedError, SubscriptionConfigError, SubscriptionEventError
|
|
1497
|
+
EventSourceError, SubscriptionHandlerError, SubscriptionChildUnavailableError
|
|
1498
|
+
SubscriptionSetupError, SubscriptionSubscriberUnavailableError, SubscriptionRecordError, SubscriptionTimeoutError
|
|
1499
|
+
isSubscriptionError, isSubscriptionClosedError, isSubscriptionConfigError, isSubscriptionEventError
|
|
1500
|
+
isEventSourceError, isSubscriptionHandlerError, isSubscriptionChildUnavailableError
|
|
1501
|
+
isSubscriptionSetupError, isSubscriptionSubscriberUnavailableError, isSubscriptionRecordError, isSubscriptionTimeoutError
|
|
1502
|
+
isRetryableSubscriptionError, serializeSubscriptionError, deserializeSubscriptionError
|
|
1503
|
+
```
|
|
1504
|
+
</Accordion>
|
|
1505
|
+
<Accordion title="Storage, session management, resume, and blueprints">
|
|
1506
|
+
```typescript
|
|
1507
|
+
// Session management and claims
|
|
1508
|
+
SessionManager, SettingsManager, JsonlSessionStore, MemorySessionStore, SqlSessionStore, resolveSessionStore
|
|
1509
|
+
type SessionStorageOptions, claimSession, prepareSessionClaim, attachSessionClaim, SESSION_ALREADY_OPEN_EXIT_CODE
|
|
1510
|
+
SessionAlreadyOpenError, SessionConflictError, SessionDeletedError, SessionEntryError, SessionExistsError
|
|
1511
|
+
SessionFormatVersionError, SessionHistoryNotLoadedError, SessionIdError, SessionIdMismatchError
|
|
1512
|
+
SessionImportFileNotFoundError, SessionInvalidTextError, SessionInvalidTimestampError, SessionNotFoundError
|
|
1513
|
+
SessionOpenElsewhereError, SessionWorkUnsettledError, SettingsFileChangedError, JsonlStoragePoisonedError
|
|
1514
|
+
StorageTransferError, StorageImportIncompleteError
|
|
1515
|
+
MissingSessionCwdError, isMissingSessionCwdError, serializeMissingSessionCwdError
|
|
1516
|
+
rehydrateMissingSessionCwdError, isSerializedMissingSessionCwdError
|
|
1517
|
+
|
|
1518
|
+
// Storage adapters, blobs, history, and StorageError family (also in @bastani/atomic/storage)
|
|
1519
|
+
openNodeSqliteDatabase, wrapNodeSqliteDatabase, sqliteFilePath, createSqliteDatabase
|
|
1520
|
+
getWriterQueueStats, getWriterQueueDegradation, DEFAULT_GROUP_COMMIT_HOLD_MS, type WriterQueueStats
|
|
1521
|
+
StorageProvider, type StorageSelection, type StorageOpenContext, type StorageAdapterModule
|
|
1522
|
+
type AdapterOptions, type SecretRef, type SessionStorageOption, type SessionStore
|
|
1523
|
+
loadStorageAdapter, resolveAdapterOptions, adapterOpenContext, storageSelectionKey
|
|
1524
|
+
secretFilePath, secretFilePathAsync, POSTGRES_ADAPTER_PACKAGE, LOCAL_SESSIONS_STORAGE, REDACTED_SECRET
|
|
1525
|
+
inMemorySecret, type InMemorySecretRef, getTeamProfile, isPostgresUrl
|
|
1526
|
+
selectStorage, selectStorageAsync, selectProcessStorage, selectProcessStorageAsync
|
|
1527
|
+
processSharedStorageSelection, processSharedStorageSelectionAsync, processStorageEnvironment, processStorageEnvironmentAsync
|
|
1528
|
+
configuredSecretRedactor, redactSecrets, switchToWriteAheadLog, validateStoragePrefix
|
|
1529
|
+
storageMigrationTable, assertStorageSchemaVersion, assertStoredSchemaVersion
|
|
1530
|
+
type SqliteDatabase, type SqliteDriver, type StorageDescriptor
|
|
1531
|
+
readSessionHistory, readSessionHistoryChunks, findInSessionHistory
|
|
1532
|
+
readSessionChildCatalog, readExpandedChildDetails, readSavedChildLaunch
|
|
1533
|
+
copySessionBlobs, assertSessionBlobStore, sessionBlobHashes, toolOutputUrl
|
|
1534
|
+
SqlSnapshotBlobStore, MemorySnapshotBlobStore, type SnapshotBlobStore
|
|
1535
|
+
StorageError, StorageUnavailableError, StoreClosedError, StorageTransactionClosedError, StorageRollbackError
|
|
1536
|
+
StorageInvalidTextError, StorageSchemaVersionError, StoragePrefixError, StorageConfigError, StorageAdapterLoadError
|
|
1537
|
+
StorageOutcomeUnknownError, StoragePayloadTooLargeError, StorageWriteLockTimeoutError, StorageUnsupportedOperationError
|
|
1538
|
+
StorageWriterQueueDegradedError, StorageWriterQueueUnusableError, StorageTransientError, SessionBlobError, SessionSpillError
|
|
1539
|
+
TeamProfileError, TeamProfileTimeoutError, TeamProfileConfigError
|
|
1540
|
+
isStorageError, isStorageConfigError, isStorageWriteLockTimeoutError, isStorageUnsupportedOperationError
|
|
1541
|
+
isStorageWriterQueueDegradedError, isStorageWriterQueueUnusableError, isStorageTransientError
|
|
1542
|
+
isSessionBlobError, isSessionSpillError, isStorageResponseRefusal, findStorageWriteLockTimeoutError, isRetryableStorageError
|
|
1543
|
+
isTeamProfileError, isTeamProfileTimeoutError, isTeamProfileConfigError, isRetryableTeamProfileError
|
|
1544
|
+
serializeStorageError, rehydrateStorageError, serializeTeamError, rehydrateTeamError
|
|
1545
|
+
describeStorageError, describeStorageFailure
|
|
1546
|
+
|
|
1547
|
+
// Resume and blueprint errors
|
|
1548
|
+
ResumeError, ResumeNotFoundError, ResumePreconditionError, ResumeCatalogUnavailableError, ResumeCatalogTimeoutError
|
|
1549
|
+
isResumeError, findResumeError, isRetryableResumeError, serializeResumeError, rehydrateResumeError
|
|
1550
|
+
BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError
|
|
1551
|
+
BlueprintUsesUnsupportedError, BlueprintBuildFailedError
|
|
1552
|
+
isBlueprintError, findBlueprintError, serializeBlueprintError, rehydrateBlueprintError
|
|
1553
|
+
```
|
|
1554
|
+
</Accordion>
|
|
1555
|
+
<Accordion title="Structured decisions, compaction, and session start errors">
|
|
1556
|
+
```typescript
|
|
1557
|
+
// Structured decisions and structured_output
|
|
1558
|
+
decide, generateStructuredOutput, STRUCTURED_OUTPUT_TOOL_NAME
|
|
1559
|
+
createStructuredOutputTool, createStructuredOutputCapture
|
|
1560
|
+
type DecisionRequest, type DecisionResult, type DecisionQuestion, type DecisionQuestions
|
|
1561
|
+
type DecisionChoiceQuestion, type DecisionBoolQuestion, type DecisionScoreQuestion
|
|
1562
|
+
type DecisionAnswers, type DecisionChoiceAnswer, type DecisionBoolAnswer, type DecisionScoreAnswer, type DecisionSource
|
|
1563
|
+
type StructuredOutputCapture, type StructuredOutputToolOptions, type StructuredOutputRequest, type StructuredOutputResult
|
|
1564
|
+
DecisionError, DecisionConfigError, DecisionRequestError, DecisionModelUnavailableError
|
|
1565
|
+
DecisionTimeoutError, DecisionOutputError, DecisionProviderError
|
|
1566
|
+
isDecisionError, isDecisionConfigError, isDecisionRequestError, isDecisionModelUnavailableError
|
|
1567
|
+
isDecisionTimeoutError, isDecisionOutputError, isDecisionProviderError
|
|
1568
|
+
findDecisionError, isRetryableDecisionError, serializeDecisionError, parseSerializedDecisionError, rehydrateDecisionError
|
|
1569
|
+
|
|
1570
|
+
// Compaction and custom compactor models
|
|
1571
|
+
type CompactorModel, type CompactorApi
|
|
1572
|
+
type ProviderCompactorModelConfig, type ProviderChatModelConfig, type ProviderClassifierModelConfig, type ProviderImageModelConfig
|
|
1573
|
+
type CompactorRequest, type CompactorMessage, type CompactionModelSelection, type CompactionModelKind
|
|
1574
|
+
CompactionError, CompactionConfigError, CompactionCancelledError, CompactionStateError, CompactorFailure
|
|
1575
|
+
isCompactionError, isCompactionConfigError, isCompactionCancelledError, isCompactionStateError, isCompactorFailure
|
|
1576
|
+
findCompactionError, isRetryableCompactionError, serializeCompactionError, parseSerializedCompactionError, rehydrateCompactionError
|
|
1577
|
+
requestCompactorOutput, buildCompactorMessages, classifyCompactionModel, resolveCompactionModel
|
|
1578
|
+
estimateTextTokens, wrapLongLines, COMPACTOR_REQUEST_TIMEOUT_MS
|
|
1579
|
+
|
|
1580
|
+
// Session start errors
|
|
1581
|
+
SessionStartError, SessionStartTimeoutError, SessionStartConfigError
|
|
1582
|
+
isSessionStartError, isSessionStartTimeoutError, isSessionStartConfigError
|
|
1583
|
+
findSessionStartError, isRetryableSessionStartError, serializeSessionStartError, rehydrateSessionStartError
|
|
1584
|
+
parseSessionStartTimeoutMs, MAX_SESSION_START_TIMEOUT_MS
|
|
1585
|
+
```
|
|
1586
|
+
</Accordion>
|
|
1587
|
+
<Accordion title="Tools, extensions, task supervision, Git, and debug">
|
|
1588
|
+
```typescript
|
|
1589
|
+
// Resource loading, extensions, and bundled factories
|
|
1590
|
+
DefaultResourceLoader, type ResourceLoader, createEventBus, defineTool
|
|
1591
|
+
updateMcpServerConfig, updateMcpServerConfigAsync, type McpServerConfig, type McpServerContribution
|
|
1592
|
+
createCodemodeExtension, createCodemodeTool, createCodemodeToolDefinition, createCodemodeDescription
|
|
1593
|
+
createToolSearchExtension, createToolSearchToolDefinition, createMcpExtension, McpOAuthCredentialStore
|
|
1594
|
+
CONFIG_DIR_NAME, getAgentDir, getPackageDir, getReadmePath, getDocsPath, getExamplesPath
|
|
1595
|
+
generateDiffString, generateUnifiedPatch, type EditDiffResult
|
|
1596
|
+
type ExtensionFactory, type ExtensionAPI, type ToolDefinition, type Skill, type PromptTemplate, type Tool
|
|
1597
|
+
|
|
1598
|
+
// Tool factories and shell/file tool errors
|
|
1599
|
+
createCodingTools, createReadOnlyTools
|
|
1600
|
+
createReadTool, createBashTool, createPowerShellTool, createKillTool
|
|
1601
|
+
createEditTool, createWriteTool, createSearchTool, createFindTool, createLsTool
|
|
1602
|
+
ShellToolError, ShellTimeoutError, isShellToolError, isShellTimeoutError, rehydrateShellToolError
|
|
1603
|
+
EditToolError, EditInputError, EditMatchError, EditTargetError, WriteSelectorError, FileToolAbortedError
|
|
1604
|
+
isEditToolError, isEditInputError, isEditMatchError, isEditTargetError, isWriteSelectorError, isFileToolAbortedError
|
|
1605
|
+
serializeFileToolError, rehydrateEditToolError, rehydrateWriteSelectorError
|
|
1606
|
+
|
|
1607
|
+
// Task supervision, held prompts, and detachable tool calls
|
|
1608
|
+
AgentTaskHost, type AgentTaskHostBinding, type AgentTaskRunnerFactory
|
|
1609
|
+
OwnerTaskStore, bindOwnerTaskStore, getOwnerTaskStore, getOwnerTaskSession
|
|
1610
|
+
scopedBackgroundTasks, sessionTasks, belongsToSession, ownerTaskViewSource, bindTaskResumer, type TaskViewSource
|
|
1611
|
+
heldPrompts, watchHeldPromptAttention, isHeldPromptInput, isPresentationHostInput, routeNamesPrompt
|
|
1612
|
+
type HeldPrompt, type HeldPrompts
|
|
1613
|
+
TaskCleanupError, TaskCleanupAdmissionTimeoutError, isTaskCleanupError, isTaskCleanupAdmissionTimeoutError
|
|
1614
|
+
isRetryableTaskError, rehydrateTaskCleanupError
|
|
1615
|
+
FINISHED_TASK_RETENTION, TaskEvictedError, isTaskEvictedError, findTaskEvictedError, rehydrateTaskEvictedError
|
|
1616
|
+
TaskToolError, isTaskToolError, rehydrateTaskToolError
|
|
1617
|
+
TaskMessageError, TaskMessageTimeoutError, isTaskMessageError, isTaskMessageTimeoutError
|
|
1618
|
+
findTaskMessageError, isRetryableTaskMessageError, rehydrateTaskMessageError
|
|
1619
|
+
ToolDetachmentError, isToolDetachmentError, findToolDetachmentError, deserializeToolDetachmentError
|
|
1620
|
+
MAX_TOOL_DETACHMENT_AFTER_MS, markToolCallReadyForDetachment, toolCallNeedsDetachmentHandoff
|
|
1621
|
+
|
|
1622
|
+
// Git resolution, managed tools, private temp dirs, and debug output
|
|
1623
|
+
resolveGit, resolveGitSync, resolveInstalledGit, getGitStatus, getGitStatusAsync, GIT_MINIMUM_VERSION
|
|
1624
|
+
GitProvisionError, GitUnavailableError, GitProvisionTimeoutError, GitProvisionConfigError
|
|
1625
|
+
isGitProvisionError, isGitUnavailableError, isGitProvisionTimeoutError, isGitProvisionConfigError
|
|
1626
|
+
findGitProvisionError, isRetryableGitProvisionError, rehydrateGitProvisionError
|
|
1627
|
+
ManagedToolError, ManagedToolDownloadError, ManagedToolTimeoutError
|
|
1628
|
+
isManagedToolError, isManagedToolDownloadError, isManagedToolTimeoutError, isRetryableManagedToolError
|
|
1629
|
+
ensurePrivateTempDirAsync, assertPrivateDirectoryAsync, ensurePrivateTempDir, assertPrivateDirectory, TempDirRefusedError
|
|
1630
|
+
isDebugEnabled, reportDebug, reportDebugAsync, appendDebugRecord, appendDebugRecordAsync, flushDebugLog
|
|
1631
|
+
DEBUG_AREA_VARIABLES, getDebugLogFailure, setDebugSetting, onDebugSettingChange
|
|
1632
|
+
DebugError, DebugLogUnwritableError, DebugConfigError, isDebugError, isDebugLogUnwritableError, isDebugConfigError
|
|
1633
|
+
serializeDebugError, rehydrateDebugError
|
|
1634
|
+
```
|
|
1635
|
+
</Accordion>
|
|
1636
|
+
</AccordionGroup>
|
|
1756
1637
|
|
|
1757
1638
|
For extension types, see [Extensions](/extensions) for the full API.
|
|
1758
1639
|
|
|
1759
1640
|
## Owner-bound task supervisor
|
|
1760
1641
|
|
|
1761
|
-
For trusted custom hosts, the package exports `AgentTaskHost` and its integration types rather than the raw native supervisor.
|
|
1642
|
+
For trusted custom hosts, the package exports `AgentTaskHost` and its integration types rather than the raw native supervisor. Instantiate `new AgentTaskHost(binding)` with a host-owned `scope` (`{ kind: "session", sessionId }`) and a mandatory `authorizeLaunch` guard (call `host.updateBinding(binding)` to update callbacks without changing native identity). Never accept ownership or authorization from model input or reconstruct a lease from a task ID or saved history.
|
|
1762
1643
|
|
|
1763
|
-
|
|
1644
|
+
Supervisor operations return a discriminated `Result<T, E>` union (`{ ok: true; value: T } | { ok: false; error: E }`, where failures carry `{ code, message }`), and task waits yield a `WaitOutcome`:
|
|
1764
1645
|
|
|
1765
|
-
|
|
1646
|
+
- `{ kind: "settled"; taskId; result }`: the task finished before the wait budget elapsed.
|
|
1647
|
+
- `{ kind: "yielded"; taskId; waitId; reason }`: the observation returned while the task kept running (`reason` is `"explicit"`, `"default-background"`, `"elapsed"`, `"intercom-coordination"`, or `"input-needed"`).
|
|
1766
1648
|
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1649
|
+
`host.startAgentTask(intent, operation, runnerFactory)` returns `Promise<Result<{ taskId, lease }, StartFailure>>` after setup. The factory receives the original `AbortSignal`, reference, and `reportActivity` context, and returns separate `result` and `cleanup` promises (report cleanup only once confirmed). Replaying the same operation reuses execution without calling another factory.
|
|
1650
|
+
|
|
1651
|
+
Use `observeAgentLaunch(taskId, policy?)`, `waitForTask`, `resolveTask`, `cancelTask`, `watchOwnerTasks`, and `close(cause)` on `AgentTaskHost`:
|
|
1652
|
+
|
|
1653
|
+
- `observeAgentLaunch()` returns once registered, yielding with reason `"explicit"` for `{ kind: "background" }` and `"default-background"` without a policy (subagents run in the background).
|
|
1654
|
+
- `waitForTask(taskId, budgetMs?, onRegistered?, signal?)` waits up to `budgetMs` (or the owner's agent budget if omitted); aborting `signal` ends the wait immediately with `{ ok: false, error: { code: "ObserverCancelled", message } }`.
|
|
1655
|
+
- Yielding or cancelling an observation does not stop execution. Cancellation and cleanup failures stay observable, and `host.close(cause)` stays pending until runners acknowledge cleanup.
|
|
1770
1656
|
|
|
1771
1657
|
### Finished task retention and eviction
|
|
1772
1658
|
|
|
@@ -1775,8 +1661,8 @@ An owner keeps its 256 most recently finished tasks (`FINISHED_TASK_RETENTION`),
|
|
|
1775
1661
|
- Queued, running, stopping, quarantined-cleanup, and failed-cleanup tasks are never evicted.
|
|
1776
1662
|
- Beyond 256 finished tasks, the oldest finished task is evicted, emitting `task-evicted` on `watchOwnerTasks` and omitting it from later snapshots.
|
|
1777
1663
|
- While open or closing, a finished task is evicted only after live owner subscriptions have drained it. Atomic sessions also hold each finished task until its completion notice is delivered.
|
|
1778
|
-
- Custom hosts can hold and release finished records with `retainTaskRecord(taskId)` and `releaseTaskRecord(taskId)` on `AgentTaskHost`. Hold from `onTaskSettled` if needed, because `retainTaskRecord` returns `TaskEvicted` once a task is evicted.
|
|
1779
|
-
-
|
|
1664
|
+
- Custom hosts can hold and release finished records with `retainTaskRecord(taskId)` and `releaseTaskRecord(taskId)` on `AgentTaskHost`. Hold from `onTaskSettled` if needed, because `retainTaskRecord` returns `{ ok: false, error: { code: "TaskEvicted", ... } }` once a task is evicted.
|
|
1665
|
+
- When `host.close(cause)` runs, newly settled tasks stay available until `onTaskSettled` finishes for all of them; closing then trims the closed owner to its 256 most recent finished tasks and sends subscriptions the final retained set before stopping.
|
|
1780
1666
|
- A settled wait registered before eviction still returns its outcome. Operation replay reuses a task only while it is retained; afterward the same operation starts a new task.
|
|
1781
1667
|
|
|
1782
1668
|
`resolveTask`, `waitForTask`, `cancelTask`, `retainTaskRecord`, and output reads for an evicted task fail with `TaskEvicted` (carrying the `TaskEvictedError` message). The `wait` and `kill` tools throw `TaskToolError` with code `TaskEvicted` and a `TaskEvictedError` `cause`.
|
|
@@ -1790,9 +1676,9 @@ Use `isTaskToolError(value)` and `rehydrateTaskToolError(value)` to inspect and
|
|
|
1790
1676
|
|
|
1791
1677
|
### Supervised command SDK
|
|
1792
1678
|
|
|
1793
|
-
For shell integration, use the exported Bash and PowerShell factories with a trusted `taskOwner` binding. Execution timeout and observation budget are separate. The automatic command wait is normally
|
|
1679
|
+
For shell integration, use the exported Bash and PowerShell factories with a trusted `taskOwner` binding. Execution timeout and observation budget are separate. The automatic command wait is normally 10,000 ms; `until-settled` waits for completion. A yielded command remains owned, and later waits can read retained output with explicit omission markers.
|
|
1794
1680
|
|
|
1795
|
-
Without a supported owner, explicit background execution is refused. Native Windows legacy WSL `bash.exe` is not supported for owned commands; run Atomic inside WSL instead. See [Waiting for existing shell tasks](#waiting-for-existing-shell-tasks) and [Background tasks](/background-tasks) for caller usage.
|
|
1681
|
+
Without a supported owner, explicit background execution is refused. Native Windows legacy WSL `bash.exe` is not supported for owned commands; run Atomic inside WSL instead. See [Waiting for existing shell tasks](#waiting-for-existing-shell-tasks), [Background tasks](/background-tasks), and [Background tasks reference](/background-tasks/reference) for caller usage.
|
|
1796
1682
|
|
|
1797
1683
|
### Session-local task prompts
|
|
1798
1684
|
|
|
@@ -1812,26 +1698,17 @@ Without a supported owner, explicit background execution is refused. Native Wind
|
|
|
1812
1698
|
|
|
1813
1699
|
Only Atomic's interactive hosts with a task inspector hold child prompts automatically. Plain RPC and SDK `uiContext` hosts continue presenting dialogs directly; custom hosts needing session-local forms should supply `humanInput` and route by `HostInputOptions.sessionId`.
|
|
1814
1700
|
|
|
1815
|
-
### Task transcript references
|
|
1816
|
-
|
|
1817
|
-
Custom live transcript sources should implement `getEntrySeq(id)` and `entryReceipt(message)` for bounded paging across compaction. Without either, a chat holding an unsaved stateful card keeps the original live transcript rather than discarding or mis-matching the card.
|
|
1701
|
+
### Task transcript references {#task-transcript-references}
|
|
1818
1702
|
|
|
1819
1703
|
Task inspectors display references to the bound child conversation: prompts, responses, provider errors, thinking blocks, tool calls and results, shell commands and output, compaction boundaries, branch summaries, and displayed extension messages. Model-only custom messages and non-rendered entries are excluded. Unbound or empty histories report `Transcript unavailable`, and saved history grants no authority to restart or control a task.
|
|
1820
1704
|
|
|
1821
|
-
`readTaskTranscript(task, cursor?)` returns task-scoped item references and continuation cursors for both saved and live tasks:
|
|
1822
|
-
|
|
1823
|
-
- The first occurrence of a repeated public item ID wins.
|
|
1824
|
-
- Indexed stores check candidate records by sequence; unindexed archives scan earlier metadata in bounded pages only on explicit lookup (never during normal scroll or repaint).
|
|
1825
|
-
- Reference pages hold at most 100 items and normally at most 1 MiB of identifiers (oversized single identifiers are returned whole with their real `source.entryId` without assembling unrelated text, arguments, or results).
|
|
1826
|
-
|
|
1827
1705
|
#### Steering and pausing agent tasks
|
|
1828
1706
|
|
|
1829
|
-
`TaskViewSource`
|
|
1707
|
+
`TaskViewSource` exposes optional methods for sending messages to, clearing queues on, and pausing or resuming running agent tasks:
|
|
1830
1708
|
|
|
1831
1709
|
- **`TaskViewSource.sendTaskMessage(id, text, lane?)`:** Delivers typed text directly to an agent task's session on `lane` (`"steer"` default or `"followUp"`, `TaskMessageLane`). While busy, text waits in the task's queue and is delivered raw at that lane's boundary; idle tasks start a turn, and finished subagents resume. Resolves once the session accepts the text.
|
|
1832
1710
|
- **`TaskViewSource.clearTaskQueue(id)`:** Removes queued typed messages (`QueuedTaskMessages`: `{ steering, followUp }`) for the editor without removing messages from other agents.
|
|
1833
1711
|
- **`TaskViewSource.pauseTask(id)` and `resumeTask(id)`:** `pauseTask(id)` interrupts the task's active turn (like `Esc` in a subagent chat), returns removed typed messages (plus an optional `warning` if pause state could not be persisted), and holds remaining queued work until `resumeTask(id)` releases the queue before the next prompt.
|
|
1834
|
-
- **`TaskTranscriptSource` hooks:** Implement `queueMessage(text, lane)`, `clearQueue()`, `pauseTurn()`, `resumeTurn()`, `turnPaused()`, and `getQueuedMessages()` on custom transcript sources. Sources without `queueMessage` fall back to `sendMessage(text)` over Intercom if available, and otherwise refuse with `messages-unsupported`. Without `pauseTurn()`, `pauseTask` interrupts the turn via `interruptTurn()` without taking queued messages back.
|
|
1835
1712
|
|
|
1836
1713
|
Failures reject with `TaskMessageError` (or `TaskMessageTimeoutError`):
|
|
1837
1714
|
|
|
@@ -1844,5 +1721,3 @@ Failures reject with `TaskMessageError` (or `TaskMessageTimeoutError`):
|
|
|
1844
1721
|
| `TaskMessageError` | `delivery-unconfirmed` | Channel threw or dropped without confirming (`retryable: false`; message may have arrived). | `taskId`, `target?`, `detail`, `hint`, `cause?` | Check the transcript before resending. |
|
|
1845
1722
|
|
|
1846
1723
|
Use `isTaskMessageError(value)`, `isTaskMessageTimeoutError(value)`, `findTaskMessageError(error)`, `isRetryableTaskMessageError(error)`, and `rehydrateTaskMessageError(value)` (restoring from `toJSON()`, or returning `undefined` for invalid payloads).
|
|
1847
|
-
|
|
1848
|
-
An agent task's chat is a `ChatSessionHost`. It queues follow-ups and dequeues messages only on the keys bound to `app.message.followUp` and `app.message.dequeue` (`Alt+Enter` and `Alt+Up` by default; `Ctrl+Q` and `Alt+Q` on Windows and WSL) through its editor's `onAction`, or directly when no editor is attached. `Ctrl+F` moves the cursor right.
|