@bastani/atomic 0.10.10-alpha.1 → 0.10.10-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +22 -15
- 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 +2 -2
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +2 -2
- package/dist/_shared/mode-shared-2QJSCUM6.js +2 -2
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/sdk-RRLVN7ER.js +2 -2
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-4VG2G44V.js +2 -2
- package/dist/_shared/startup-0-1-XTIL65D4.js +2 -2
- package/dist/_shared/startup-0-2-27OWFHV6.js +7 -6
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -1
- package/dist/_shared/startup-0-3-T4DVFYWX.js +2 -2
- package/dist/_shared/startup-0-4-ZMJV547D.js +2 -2
- package/dist/_shared/startup-0-5-FD2P735I.js +2 -2
- package/dist/_shared/startup-10-0-TDQNBDDL.js +2 -2
- package/dist/_shared/startup-15-1-4S7FLMNG.js +2 -2
- package/dist/_shared/startup-8-0-34CBHPZH.js +2 -2
- package/dist/_shared/startup-8-1-4KANEHRA.js +2 -2
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/README.md +28 -4
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/README.md +3 -3
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/README.md +2 -2
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +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 +2 -2
- 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.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- 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.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- 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/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.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.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +2 -2
- 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.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.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.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.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.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.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.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- 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/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/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.md +8 -5
- package/docs/build.md +11 -6
- package/docs/changelog.mdx +1 -1
- package/docs/codemode.md +10 -2
- package/docs/compaction/reference.md +6 -4
- package/docs/compaction.md +3 -3
- package/docs/containerization.md +13 -5
- package/docs/custom-provider/api-reference.md +8 -6
- package/docs/custom-provider/oauth.md +4 -4
- package/docs/custom-provider/registration.md +3 -3
- package/docs/custom-provider.md +8 -8
- package/docs/development.md +40 -5
- package/docs/docs.json +21 -5
- package/docs/environment-variables.md +20 -18
- package/docs/extensions/api-reference.md +8 -6
- package/docs/extensions/authoring.md +4 -4
- package/docs/extensions.md +43 -6
- package/docs/guides/configuration.md +21 -1
- package/docs/guides/intercom.md +4 -0
- package/docs/guides/non-interactive.md +4 -2
- package/docs/guides/orchestration.md +4 -2
- package/docs/guides/resume-on-any-machine.md +12 -6
- package/docs/guides/subagents.md +4 -0
- package/docs/guides/team-setup.md +13 -2
- package/docs/guides.md +10 -4
- package/docs/herdr.md +4 -4
- package/docs/index.md +12 -4
- package/docs/intercom/operations.md +26 -4
- package/docs/intercom/reference.md +25 -3
- package/docs/intercom.md +13 -5
- package/docs/json.md +2 -0
- package/docs/keybindings.md +17 -4
- package/docs/libraries/agent-core.md +4 -2
- package/docs/libraries/ai.md +71 -53
- package/docs/libraries/codemode.md +3 -2
- package/docs/libraries/schema.md +5 -2
- package/docs/libraries/storage-libsql.md +92 -0
- package/docs/libraries/storage-postgres.md +119 -0
- package/docs/libraries/telemetry.md +35 -2
- package/docs/libraries.md +23 -6
- package/docs/llama-cpp.md +2 -2
- package/docs/mcp-servers.md +50 -4
- package/docs/models/reference.md +13 -9
- package/docs/models-configuration.md +7 -7
- package/docs/models.md +18 -8
- package/docs/orchestration/migrating-workflows.md +2 -2
- package/docs/orchestration/patterns.md +8 -8
- package/docs/orchestration.md +5 -3
- package/docs/packages/authoring.md +3 -1
- package/docs/packages/reference.md +3 -1
- package/docs/packages.md +5 -3
- package/docs/programmatic.md +14 -8
- package/docs/prompt-templates.md +5 -3
- package/docs/providers/reference.md +7 -7
- package/docs/providers.md +22 -10
- package/docs/quickstart.md +13 -11
- package/docs/reference/cli.md +10 -5
- package/docs/reference.md +8 -4
- package/docs/rpc/examples.md +47 -0
- package/docs/rpc/extension-ui.md +7 -1
- package/docs/rpc/protocol.md +3 -2
- package/docs/rpc.md +3 -1
- package/docs/sdk/reference.md +144 -38
- package/docs/sdk/storage.md +614 -0
- package/docs/sdk/structured-decisions.md +77 -4
- package/docs/sdk/web-server.md +3 -2
- package/docs/sdk.md +26 -115
- package/docs/security.md +17 -7
- package/docs/session-format.md +38 -24
- package/docs/sessions.md +21 -15
- package/docs/settings.md +17 -14
- package/docs/skills.md +47 -3
- package/docs/storage.md +38 -24
- package/docs/subagents/authoring.md +3 -1
- package/docs/subagents/reference.md +8 -2
- package/docs/subagents.md +35 -6
- package/docs/terminal-setup.md +1 -1
- package/docs/themes.md +5 -3
- package/docs/tmux.md +4 -4
- package/docs/tools.md +11 -0
- package/docs/usage.md +25 -15
- package/docs/web-access.md +35 -0
- package/docs/windows.md +9 -6
- package/docs/worktree-snapshots.md +22 -11
- package/examples/sdk/11-sessions.ts +4 -4
- package/package.json +8 -8
- package/schemas/models.schema.json +7 -7
|
@@ -22,13 +22,20 @@ None of these APIs starts a child agent, invokes other tools, authorizes an acti
|
|
|
22
22
|
|
|
23
23
|
`decide()` resolves `decisionModel` once. When a classifier answers, `source` is `"classifier"` and answers include probabilities and confidence scores. If the classifier fails, the current chat model answers without probabilities, sets `source: "chat"`, and populates `result.fallback`. An empty or `"auto"` `decisionModel` uses `currentModel` directly. Pass `requireProbabilities: true` to restrict answers to classifiers so chat models or classifier failures reject instead of falling back.
|
|
24
24
|
|
|
25
|
+
Standalone SDK usage with `ModelRuntime`, `ModelRegistry`, and `SettingsManager`:
|
|
26
|
+
|
|
25
27
|
```typescript
|
|
26
|
-
import { decide,
|
|
28
|
+
import { decide, ModelRegistry, ModelRuntime, SettingsManager } from "@bastani/atomic";
|
|
29
|
+
|
|
30
|
+
const modelRuntime = await ModelRuntime.create();
|
|
31
|
+
const modelRegistry = new ModelRegistry(modelRuntime);
|
|
32
|
+
const settings = await SettingsManager.createAsync(process.cwd());
|
|
33
|
+
const currentModel = modelRegistry.getAvailable()[0];
|
|
27
34
|
|
|
28
35
|
const result = await decide({
|
|
29
|
-
settings
|
|
30
|
-
modelRegistry
|
|
31
|
-
currentModel
|
|
36
|
+
settings,
|
|
37
|
+
modelRegistry,
|
|
38
|
+
currentModel,
|
|
32
39
|
state: { message: "Ship it once the tests pass." },
|
|
33
40
|
questions: {
|
|
34
41
|
intent: {
|
|
@@ -45,12 +52,15 @@ const result = await decide({
|
|
|
45
52
|
deadline: 30_000,
|
|
46
53
|
requireProbabilities: true,
|
|
47
54
|
});
|
|
55
|
+
|
|
48
56
|
const approve = result.answers.intent.probabilities?.approve ?? 0;
|
|
49
57
|
if (approve >= 0.9 && (result.answers.complete.probability ?? 0) >= 0.8) {
|
|
50
58
|
// Application code decides what to do at each threshold.
|
|
51
59
|
}
|
|
52
60
|
```
|
|
53
61
|
|
|
62
|
+
Inside an extension handler, pass `settings: { getDecisionModel: () => ctx.getDecisionModel() }`, `modelRegistry: ctx.modelRegistry`, and `currentModel: ctx.model`. To override `decisionModel` without reading settings files, pass `SettingsManager.inMemory({ decisionModel: "typesafe/jev-latest" })` or pass `model: "typesafe/jev-latest"` directly on the request.
|
|
63
|
+
|
|
54
64
|
### Request options
|
|
55
65
|
|
|
56
66
|
- `state`: non-empty plain JSON object containing the facts to evaluate.
|
|
@@ -112,11 +122,74 @@ Legacy `routerModel` settings migrate to `decisionModel` automatically. An exist
|
|
|
112
122
|
| `DecisionOutputError` | `invalid-output` | The model responded, but output failed schema validation after repairs | `model`, `detail` | Clarify questions or pick another model. |
|
|
113
123
|
| `DecisionProviderError` | `provider-failure` | The provider request failed | `model`, `providerStatus`, `providerCode`, `retryAfterMs`, `detail` | Retryable on rate limits or quota exhaustion (`providerCode`); otherwise check provider status and auth. |
|
|
114
124
|
|
|
125
|
+
```typescript
|
|
126
|
+
import { decide, isDecisionError, isDecisionProviderError, isDecisionTimeoutError } from "@bastani/atomic";
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const result = await decide({
|
|
130
|
+
settings,
|
|
131
|
+
modelRegistry,
|
|
132
|
+
currentModel,
|
|
133
|
+
state: { message: "Ship it once the tests pass." },
|
|
134
|
+
questions: {
|
|
135
|
+
ready: {
|
|
136
|
+
type: "bool",
|
|
137
|
+
instructions: "Is this an explicit approval to ship?",
|
|
138
|
+
criteria: { true: "Explicit approval to proceed.", false: "Not an approval or requests changes." },
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
deadline: 30_000,
|
|
142
|
+
});
|
|
143
|
+
console.log(result.answers.ready.value, result.source);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (!isDecisionError(error)) throw error;
|
|
146
|
+
|
|
147
|
+
switch (error.code) {
|
|
148
|
+
case "timeout":
|
|
149
|
+
if (isDecisionTimeoutError(error)) {
|
|
150
|
+
console.error(`Timed out after ${error.elapsedMs}ms in ${error.phase}. ${error.hint}`);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case "provider-failure":
|
|
154
|
+
if (isDecisionProviderError(error) && error.retryable) {
|
|
155
|
+
console.error(`Retryable provider error (${error.providerCode ?? "transient"}); wait ${error.retryAfterMs ?? 0}ms.`);
|
|
156
|
+
} else {
|
|
157
|
+
console.error(error.hint);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case "model-unavailable":
|
|
161
|
+
case "invalid-setting":
|
|
162
|
+
case "invalid-request":
|
|
163
|
+
case "invalid-output":
|
|
164
|
+
case "renamed-setting":
|
|
165
|
+
console.error(`${error.code}: ${error.hint}`);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
115
171
|
## How `decisionModel` applies across APIs
|
|
116
172
|
|
|
117
173
|
- **The `structured_output` tool** (when called without its own `model`) starts on `decisionModel`. A classifier answers when the schema is a finite Choice; otherwise Atomic tries `fallbackModels` and then `currentModel`. Failures always reject with a `DecisionError`.
|
|
118
174
|
- **`generateStructuredOutput()`** uses only the models you pass (`model`, `fallbackModels`, `currentModel`) unless you pass `settings`, in which case omitting `model` starts on `decisionModel` like the tool. Note: calling `generateStructuredOutput()` **without `settings`** throws plain `Error` instances rather than `DecisionError` subclasses; `DecisionError` wrapping applies whenever `settings` is passed or when calling `decide()` or `structured_output`.
|
|
119
175
|
|
|
176
|
+
### Switch `decisionModel` on a live session
|
|
177
|
+
|
|
178
|
+
Call `session.setDecisionModel(model, scope?, options?)` on an `AgentSession` to update `decisionModel` immediately without restarting or reloading:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// Persist to global settings (default scope: "global")
|
|
182
|
+
session.setDecisionModel("typesafe/jev-latest", "global");
|
|
183
|
+
|
|
184
|
+
// Update only in-memory state for the current session without writing settings.json
|
|
185
|
+
session.setDecisionModel("auto", "project", { persist: false });
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- Pass `""` or `"auto"` to use the active chat model, or an exact registered classifier or chat `provider/model` ID.
|
|
189
|
+
- `scope` accepts `"global"` (default) or `"project"`. Pass `{ persist: false }` to update only the in-memory settings layer.
|
|
190
|
+
- Passing a non-string value or a string with leading or trailing whitespace throws `DecisionConfigError` (`code: "invalid-setting"`) synchronously.
|
|
191
|
+
- RPC clients can call `set_decision_model` (`client.setDecisionModel(model, scope?, options?)`); see [RPC protocol](/rpc/protocol#set_decision_model).
|
|
192
|
+
|
|
120
193
|
## Select the inference model
|
|
121
194
|
|
|
122
195
|
Pass an optional exact `provider/model` string (not a `Model` object and not `"auto"`):
|
package/docs/sdk/web-server.md
CHANGED
|
@@ -33,7 +33,7 @@ const nextConfig: NextConfig = {
|
|
|
33
33
|
export default nextConfig;
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Once `@bastani/atomic` is external, its dependencies load from `node_modules`. List any other Atomic packages your application imports directly.
|
|
36
|
+
Once `@bastani/atomic` is external, its dependencies load from `node_modules`. List any other Atomic packages your application imports directly, including [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) or [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql) when using remote SQL storage (see [SDK storage guide](/sdk/storage)).
|
|
37
37
|
|
|
38
38
|
Import TypeBox for custom tool schemas from `@bastani/atomic/typebox` (and its subpaths such as `/value`, `/compile`, and `/format`) rather than `typebox` directly so custom formats and settings share Atomic's TypeBox registry.
|
|
39
39
|
|
|
@@ -128,7 +128,7 @@ if (!state.shutdownRegistered) {
|
|
|
128
128
|
}
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
`SessionManager.inMemory()` keeps history in process memory. To persist conversations across restarts, pass a SQLite, JSONL, or
|
|
131
|
+
`SessionManager.inMemory()` keeps history in process memory. To persist conversations across restarts, pass a SQLite, JSONL, libSQL, or PostgreSQL `SessionManager` or `sessionStore` (see [SDK storage guide](/sdk/storage)). Call `closeConversation()` when a conversation finishes or goes idle, and run `closeAllConversations()` on `SIGTERM`/`SIGINT` so session stores and child processes close cleanly.
|
|
132
132
|
|
|
133
133
|
Sessions on `globalThis` live in one server process. Run this on a long-lived Node.js server with sticky routing per conversation if you scale to multiple instances; short-lived serverless functions discard process memory between requests.
|
|
134
134
|
|
|
@@ -280,6 +280,7 @@ Any route driving an agent session lets callers run tools with the server proces
|
|
|
280
280
|
## Next steps
|
|
281
281
|
|
|
282
282
|
- [TypeScript SDK](/sdk): sessions, prompting, storage, and events.
|
|
283
|
+
- [SDK storage guide](/sdk/storage): persist server sessions in SQLite, JSONL, libSQL, or PostgreSQL and wire `createAgentSessionRuntime()`.
|
|
283
284
|
- [SDK API reference](/sdk/reference): every `createAgentSession()` option and export.
|
|
284
285
|
- [Orchestration](/orchestration): multi-step workflows with codemode and subagents.
|
|
285
286
|
- [Migrating workflows](/orchestration/migrating-workflows): replacing older workflow definitions.
|
package/docs/sdk.md
CHANGED
|
@@ -8,7 +8,7 @@ Embed Atomic in Node.js applications (Node.js 22.19 or newer) to build custom UI
|
|
|
8
8
|
|
|
9
9
|
- **Full options and exports:** [SDK API reference](/sdk/reference) (includes [Owner-bound task supervisor](/sdk/reference#owner-bound-task-supervisor), [Supervised command SDK](/sdk/reference#supervised-command-sdk), and [Task transcript references](/sdk/reference#task-transcript-references)).
|
|
10
10
|
- **Typed decisions:** [Structured decisions API](/sdk/structured-decisions).
|
|
11
|
-
- **
|
|
11
|
+
- **Session storage:** [SDK storage guide](/sdk/storage) and [Storage backends](/storage).
|
|
12
12
|
- **HTTP streaming servers:** [Embed Atomic in a web server](/sdk/web-server) (Next.js App Router guide).
|
|
13
13
|
- **Compare modes:** [Programmatic integration](/programmatic).
|
|
14
14
|
|
|
@@ -53,7 +53,7 @@ try {
|
|
|
53
53
|
- **Exact model restoration:** Call `await resolveRestoredModelReference(provider, modelId, modelRuntime)` to resolve an authenticated saved model (including custom or dynamic IDs) or receive `undefined` without falling back to a default.
|
|
54
54
|
- **Context helpers:** Root exports include `InlineExtension`, `buildContextEntries`, `sessionEntryToContextMessages`, `CompactionEntry`, and `sessionManager.buildContextEntries()`.
|
|
55
55
|
|
|
56
|
-
### Sharing Atomic's TypeBox registry
|
|
56
|
+
### Sharing Atomic's TypeBox registry {#sharing-atomics-typebox-registry}
|
|
57
57
|
|
|
58
58
|
Atomic ships its own TypeBox instance. If your app imports `typebox` directly, custom formats, settings, or locales will not reach Atomic's tool validation. Import from `@bastani/atomic/typebox` and its subpaths instead:
|
|
59
59
|
|
|
@@ -139,61 +139,39 @@ const { session } = await createAgentSession({ resourceAdmission });
|
|
|
139
139
|
|
|
140
140
|
### Session storage
|
|
141
141
|
|
|
142
|
-
Sessions default to local SQLite at `~/.atomic/workflows/journal.sqlite`
|
|
142
|
+
Sessions default to local SQLite at `~/.atomic/workflows/journal.sqlite` with the `session_` table prefix. Override storage per session with `sessionStore`, `storage`, or an explicit `sessionManager`. Read the **[SDK storage guide](/sdk/storage)** for complete recipes across all five backends, `createAgentSessionRuntime()` wiring, `SessionManager` CRUD, `JsonlSessionStore` `exactDirectory` behavior, `npm install` vs `atomic install` adapter resolution, ownership and close rules, and `StorageError` handling.
|
|
143
143
|
|
|
144
144
|
| Backend | Package | How to pass it to `createAgentSession()` |
|
|
145
145
|
| --- | --- | --- |
|
|
146
|
-
| Local SQLite (default) | Built into `@bastani/atomic` (`@bastani/atomic/storage`) | `{ kind: "sqlite", path, prefix? }` or caller-owned `openNodeSqliteDatabase()`
|
|
146
|
+
| Local SQLite (default) | Built into `@bastani/atomic` (`@bastani/atomic/storage`) | `{ kind: "sqlite", path, prefix? }` or caller-owned `openNodeSqliteDatabase()` and `SqlSessionStore.open()` |
|
|
147
147
|
| JSONL directory | Built into `@bastani/atomic` | `{ kind: "jsonl", dir }` or caller-owned `JsonlSessionStore.open()` |
|
|
148
148
|
| In-memory | Built into `@bastani/atomic` | `new MemorySessionStore()` (caller-owned) or `{ kind: "memory" }` (discarded on `dispose()`) |
|
|
149
|
-
| libSQL / Turso | `@bastani/atomic-storage-libsql` | `{ kind: "adapter", module: LIBSQL_ADAPTER_PACKAGE, ... }` or caller-owned `openLibsqlDatabase()` |
|
|
150
|
-
| PostgreSQL (16+ for sessions) | `@bastani/atomic-storage-postgres` | `{ kind: "adapter", module: POSTGRES_ADAPTER_PACKAGE, ... }` or caller-owned `openPostgresDatabase()` |
|
|
149
|
+
| libSQL / Turso | [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql) | `{ kind: "adapter", module: LIBSQL_ADAPTER_PACKAGE, ... }` or caller-owned `openLibsqlDatabase()` |
|
|
150
|
+
| PostgreSQL (16+ for sessions) | [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) | `{ kind: "adapter", module: POSTGRES_ADAPTER_PACKAGE, ... }` or caller-owned `openPostgresDatabase()` |
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Quick local SQLite session. Atomic opens the store and closes it in `dispose()`:
|
|
153
153
|
|
|
154
154
|
```typescript
|
|
155
|
-
import {
|
|
156
|
-
createAgentSession,
|
|
157
|
-
JsonlSessionStore,
|
|
158
|
-
MemorySessionStore,
|
|
159
|
-
SqlSessionStore,
|
|
160
|
-
} from "@bastani/atomic";
|
|
161
|
-
import { openNodeSqliteDatabase } from "@bastani/atomic/storage";
|
|
155
|
+
import { createAgentSession } from "@bastani/atomic";
|
|
162
156
|
|
|
163
|
-
|
|
164
|
-
const sqlite = await createAgentSession({
|
|
157
|
+
const { session } = await createAgentSession({
|
|
165
158
|
sessionStore: { kind: "sqlite", path: "./sessions.sqlite", prefix: "project_" },
|
|
166
159
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// 3. Caller-owned in-memory store (preserves history across session.release() / runtime.rehydrate())
|
|
174
|
-
const memoryStore = new MemorySessionStore();
|
|
175
|
-
const mem = await createAgentSession({ sessionStore: memoryStore });
|
|
176
|
-
|
|
177
|
-
// 4. Caller-owned SQLite or JSONL store (share across sessions; close it yourself)
|
|
178
|
-
const db = await openNodeSqliteDatabase("./shared.sqlite");
|
|
179
|
-
const sqlStore = await SqlSessionStore.open(db, { prefix: "project_" });
|
|
180
|
-
const jsonlStore = await JsonlSessionStore.open("./shared-jsonl");
|
|
160
|
+
try {
|
|
161
|
+
await session.prompt("Summarize recent commits");
|
|
162
|
+
} finally {
|
|
163
|
+
await session.dispose();
|
|
164
|
+
}
|
|
181
165
|
```
|
|
182
166
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
Install the adapter package alongside `@bastani/atomic` in your application (`npm install @bastani/atomic-storage-postgres` or `npm install @bastani/atomic-storage-libsql`). For CLI-resolved `{ kind: "adapter" }` loading outside `node_modules`, install in user scope with `atomic install npm:@bastani/atomic-storage-postgres` or `atomic install npm:@bastani/atomic-storage-libsql`. Both packages ship plain ESM with TypeScript declarations.
|
|
186
|
-
|
|
187
|
-
**Option A — Pass a caller-owned database handle directly (recommended for SDK hosts sharing one pool):**
|
|
167
|
+
Quick PostgreSQL session with a caller-owned database pool (`npm install @bastani/atomic-storage-postgres`):
|
|
188
168
|
|
|
189
169
|
```typescript
|
|
190
170
|
import { readFile } from "node:fs/promises";
|
|
191
171
|
import { createAgentSession } from "@bastani/atomic";
|
|
192
172
|
import { openPostgresDatabase } from "@bastani/atomic-storage-postgres";
|
|
193
|
-
import { openLibsqlDatabase } from "@bastani/atomic-storage-libsql";
|
|
194
173
|
|
|
195
|
-
//
|
|
196
|
-
// `password` accepts a string or an async callback invoked per new connection for secret rotation.
|
|
174
|
+
// Pass a username-only URL (embedded passwords reject with credential-in-url).
|
|
197
175
|
const pgDb = await openPostgresDatabase({
|
|
198
176
|
url: "postgresql://atomic_runtime@db.example.com:5432/atomic",
|
|
199
177
|
password: async () => (await readFile("/run/secrets/postgres-password", "utf8")).trim(),
|
|
@@ -210,83 +188,13 @@ try {
|
|
|
210
188
|
} finally {
|
|
211
189
|
await pgDb.close();
|
|
212
190
|
}
|
|
213
|
-
|
|
214
|
-
// libSQL / Turso:
|
|
215
|
-
const libsqlDb = await openLibsqlDatabase({
|
|
216
|
-
url: "libsql://<db>.turso.io",
|
|
217
|
-
authToken: process.env.TURSO_AUTH_TOKEN,
|
|
218
|
-
});
|
|
219
|
-
try {
|
|
220
|
-
const { session } = await createAgentSession({
|
|
221
|
-
sessionStore: { kind: "database", database: libsqlDb, prefix: "project_" },
|
|
222
|
-
});
|
|
223
|
-
await session.dispose();
|
|
224
|
-
} finally {
|
|
225
|
-
await libsqlDb.close();
|
|
226
|
-
}
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
**Option B — Let Atomic open and close the adapter per session via `{ kind: "adapter" }`:**
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
import {
|
|
233
|
-
createAgentSession,
|
|
234
|
-
LIBSQL_ADAPTER_PACKAGE,
|
|
235
|
-
POSTGRES_ADAPTER_PACKAGE,
|
|
236
|
-
} from "@bastani/atomic";
|
|
237
|
-
|
|
238
|
-
// PostgreSQL via adapter selection (pass credentials through `secrets`, never inside `url`)
|
|
239
|
-
const pg = await createAgentSession({
|
|
240
|
-
sessionStore: {
|
|
241
|
-
kind: "adapter",
|
|
242
|
-
module: POSTGRES_ADAPTER_PACKAGE,
|
|
243
|
-
options: { url: "postgresql://atomic_runtime@db.example.com:5432/atomic" },
|
|
244
|
-
secrets: { password: { env: "PGPASSWORD" } },
|
|
245
|
-
prefix: "project_",
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// libSQL / Turso via adapter selection
|
|
250
|
-
const libsql = await createAgentSession({
|
|
251
|
-
sessionStore: {
|
|
252
|
-
kind: "adapter",
|
|
253
|
-
module: LIBSQL_ADAPTER_PACKAGE,
|
|
254
|
-
options: { url: "libsql://<db>.turso.io" },
|
|
255
|
-
secrets: { authToken: { env: "TURSO_AUTH_TOKEN" } },
|
|
256
|
-
prefix: "project_",
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
191
|
```
|
|
260
192
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
-
|
|
264
|
-
- `sessionStore` accepts a `SessionStore` instance (`SqlSessionStore`, `JsonlSessionStore`, `MemorySessionStore`) or a tagged selection object: `{ kind: "sqlite", path, prefix? }`, `{ kind: "jsonl", dir }`, `{ kind: "memory" }`, `{ kind: "database", database, prefix? }`, or `{ kind: "adapter", module, options?, secrets?, prefix? }`.
|
|
265
|
-
- `storage` uses the `settings.json` shape (also returned by `teamProfileSelection()`, see [Team and CI setup](/guides/team-setup#from-the-sdk)): `{ path, prefix? }`, `{ database, prefix? }`, `{ memory: true }`, or `{ adapter, options?, secrets?, prefix? }`. `storage` does not support JSONL; use `sessionStore: { kind: "jsonl", dir }` for JSONL directories.
|
|
266
|
-
- Legacy `sessionDir` was removed.
|
|
267
|
-
- **Precedence:** Resolved in order from `sessionManager`, `sessionStore`, `storage`, process environment/flags (`ATOMIC_SESSIONS_STORAGE` and `ATOMIC_STORAGE`; see [Selecting storage per process](/storage#selecting-storage-per-process)), settings (`sessions.storage` before `storage`; see [Session settings](/settings#sessions)), and finally default SQLite. Memory is never an automatic fallback.
|
|
268
|
-
- **Ownership and resume:** Atomic closes stores it opened from selection objects (`sqlite`, `jsonl`, `adapter`, `memory`) during `dispose()`, while leaving caller-owned `SessionStore`, `SessionManager`, and `database` instances open. Because session-owned `{ kind: "memory" }` and `storage: { memory: true }` stores are closed and discarded on `dispose()`, pass a caller-owned `new MemorySessionStore()` if you plan to call `session.release()` and later `runtime.rehydrate()`.
|
|
269
|
-
- **Package adapters:** Pass `additionalExtensionPaths: [packageRoot]` on `DefaultResourceLoader` before opening storage to select an embedded package adapter by name ([Adapters from Atomic packages](/storage#adapters-from-atomic-packages)).
|
|
270
|
-
- **Await mutations:** Await every `SessionManager` write and every `atomic.appendEntry`, `setSessionName`, `setLabel`, `setThinkingLevel`, and `cycleThinkingLevel` call (there is no `flush()`; see [Storage errors](/storage#storage-errors)):
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
import { createAgentSession, resolveSessionStore, SessionManager } from "@bastani/atomic";
|
|
274
|
-
|
|
275
|
-
const store = await resolveSessionStore(process.cwd());
|
|
276
|
-
try {
|
|
277
|
-
const manager = await SessionManager.open(store, savedSessionId);
|
|
278
|
-
const { session } = await createAgentSession({ sessionManager: manager });
|
|
279
|
-
try {
|
|
280
|
-
await session.prompt("Continue the task");
|
|
281
|
-
} finally {
|
|
282
|
-
await session.dispose();
|
|
283
|
-
}
|
|
284
|
-
} finally {
|
|
285
|
-
await store.close();
|
|
286
|
-
}
|
|
287
|
-
```
|
|
193
|
+
- **`sessionStore` vs. `storage`:** `sessionStore` accepts a `SessionStore` instance (`SqlSessionStore`, `JsonlSessionStore`, `MemorySessionStore`) or a tagged selection (`{ kind: "sqlite" | "jsonl" | "memory" | "database" | "adapter", ... }`). `storage` uses the `settings.json` shape returned by `teamProfileSelection()` (`{ path, prefix? }`, `{ database, prefix? }`, `{ memory: true }`, or `{ adapter, options?, secrets?, prefix? }`) and does not support JSONL.
|
|
194
|
+
- **Precedence:** Atomic resolves storage in order from `sessionManager`, `sessionStore`, `storage`, process flags and variables (`ATOMIC_SESSIONS_STORAGE` and `ATOMIC_STORAGE`), settings (`sessions.storage` before `storage`), and default SQLite. Memory is never an automatic fallback.
|
|
195
|
+
- **Ownership and mutations:** Atomic closes stores it opened from selection objects during `dispose()`, while leaving caller-owned `SessionStore`, `SessionManager`, and `database` instances open. Await every `SessionManager` write and every `atomic.appendEntry`, `setSessionName`, `setLabel`, `setThinkingLevel`, and `cycleThinkingLevel` call; there is no `flush()` method. `ExtensionContext.sessionSignal` aborts when reload or shutdown starts so extensions can cancel waits while finishing in-flight writes.
|
|
288
196
|
|
|
289
|
-
`
|
|
197
|
+
See the **[SDK storage guide](/sdk/storage)** for all five backends, `createAgentSessionRuntime()` wiring, `SessionManager` CRUD, `JsonlSessionStore` `exactDirectory` behavior, `npm install` vs `atomic install` adapter resolution, ownership and close rules, and `StorageError` handling. For CLI session commands, the full `SessionManager` method list, operator setup, and cross-machine resume, see [Sessions](/sessions), [SessionManager API](/session-format#sessionmanager-api), [Storage backends](/storage), and [Resume on any machine](/guides/resume-on-any-machine).
|
|
290
198
|
|
|
291
199
|
### Human input without a terminal
|
|
292
200
|
|
|
@@ -388,6 +296,8 @@ interface AgentSession {
|
|
|
388
296
|
setThinkingLevel(level: ThinkingLevel, options?: { persist?: boolean }): Promise<void>;
|
|
389
297
|
cycleModel(direction?: "forward" | "backward", options?: { persist?: boolean }): Promise<ModelCycleResult | undefined>;
|
|
390
298
|
cycleThinkingLevel(options?: { persist?: boolean }): Promise<ThinkingLevel | undefined>;
|
|
299
|
+
setCompactionModel(model: string, scope?: "global" | "project", options?: { persist?: boolean }): void;
|
|
300
|
+
setDecisionModel(model: string, scope?: "global" | "project", options?: { persist?: boolean }): void;
|
|
391
301
|
|
|
392
302
|
agent: Agent;
|
|
393
303
|
sessionManager: SessionManager;
|
|
@@ -420,6 +330,7 @@ try {
|
|
|
420
330
|
```
|
|
421
331
|
|
|
422
332
|
- `setModel(model, { thinkingLevel: "high", persist: true })` clamps unsupported thinking levels and optionally writes global defaults (project overrides still win at startup).
|
|
333
|
+
- `setCompactionModel(model, scope?, options?)` and `setDecisionModel(model, scope?, options?)` update the active session's compaction or decision model immediately without restarting or reloading. They save to `"global"` (default) or `"project"` settings unless `{ persist: false }` is passed. Pass `""` or `"auto"` for automatic selection, or an exact `provider/model` ID. Invalid values throw `CompactionConfigError` or `DecisionConfigError` synchronously. See [Compaction](/compaction) and [Structured decisions API](/sdk/structured-decisions).
|
|
423
334
|
- Extension APIs reject new actions with an `Error` tagged with `code: "SessionClosed"` once close or reload starts. Give `atomic.exec()` calls timeouts or abort signals. Custom messages with `persistWhenStreaming: true` survive reload.
|
|
424
335
|
|
|
425
336
|
#### Event subscriptions
|
|
@@ -453,7 +364,7 @@ Disposal and reload drain admitted callbacks, model refreshes, and `atomic.exec(
|
|
|
453
364
|
|
|
454
365
|
#### Compaction and tree navigation
|
|
455
366
|
|
|
456
|
-
`session.compact({ query?, compactionModel? })` stops active runs, clears context
|
|
367
|
+
`session.compact({ query?, compactionModel? })` stops active runs, clears context or replaces it with output from a configured compactor model such as `morph/morph-compactor`, appends a `verbatim-lines` `compaction` entry, and returns `VerbatimCompactionResult` (`form: "cleared" | "compacted"`). It rejects with `CompactionStateError` (`code: "nothing-to-compact"`) when nothing new has entered context since the last boundary; concurrent calls coalesce. Call `session.setCompactionModel(model, scope?, options?)` to change the configured compactor live. A chat, classifier, or unknown `compactionModel` ID clears the context with a notice instead of failing. See [Compaction errors](/compaction/reference#compaction-errors), [Compaction](/compaction), and [Session format](/session-format#compactionentry).
|
|
457
368
|
|
|
458
369
|
```typescript
|
|
459
370
|
const result = await session.compact({ query: "keep the auth decisions" });
|
|
@@ -507,7 +418,7 @@ await live.release();
|
|
|
507
418
|
|
|
508
419
|
- **Auto-release:** Pass `releaseWhenIdle: { afterMs }` (`0` to `2,147,483,647` ms; invalid values throw `AgentReleaseConfigError`) to `createAgentSession()` or `createAgentSessionFromServices()`. If the session is still busy when the timer fires, Atomic reschedules for another `afterMs` instead of failing. Managed by the process-wide `agentWakeDispatcher()` (`handle`, `deliver`, `onUnobservedFailure`, `whenIdle`, `stats()`).
|
|
509
420
|
- **Lifecycle:** Emits `session_released` before closing. Rejects with retryable `session-busy` if streaming, compacting, running shells or background tasks, or holding queued messages. `rehydrate()` opens at the current context window (`readHistory()` and `readEntry()` fetch older entries), shares matching-cwd `services`, runs alongside `runtime.session` without replacing it, deduplicates concurrent calls, and closes on `runtime.dispose()`.
|
|
510
|
-
- **In-memory store spilling:**
|
|
421
|
+
- **In-memory store spilling:** A directly constructed `new MemorySessionStore()` has no spill directory and keeps released session history in RAM. Opening a memory store through `resolveSessionStore(cwd, { agentDir, sessionStore: { kind: "memory" } })` enables disk spilling to private owner-only files (`0700`/`0600`) under `<agentDir>/released-history/` with integrity verification (`SessionSpillError` on missing or corrupt files; see [Storage errors](/storage#storage-errors)). Spill files clean up on exit and sweep on restart after crashes; worker-only hosts must close stores before `worker.terminate()`. Custom stores can implement `releaseSession(id)`, `readEntryRange(id, query)`, and `readForkWindow(id, entryId)`.
|
|
511
422
|
|
|
512
423
|
Release and wake errors throw `AgentRehydrateError` (guards `isAgentRehydrateError`, `isAgentReleaseConfigError`, `isRetryableAgentRehydrateError`; cross-process `serializeAgentRehydrateError` and `rehydrateAgentRehydrateError`):
|
|
513
424
|
|
|
@@ -545,7 +456,7 @@ interface PromptOptions {
|
|
|
545
456
|
|
|
546
457
|
Access the underlying [`@bastani/atomic-agent-core`](/libraries/agent-core) `Agent` through `session.agent` (`state.messages`, `model`, `thinkingLevel`, `systemPrompt`, `tools`, `streamingMessage`, `errorMessage`, and `waitForIdle()`).
|
|
547
458
|
|
|
548
|
-
`session.sessionManager` is the source of truth for model context. Never mutate `session.agent.state.messages` directly to restore history. Instead, pass entries to `SessionManager.inMemory(cwd, { id }, entries)` before `createAgentSession()`, call `session.navigateTree()`, or append via `session.sessionManager.appendMessage()` followed by `session.refreshContext()`.
|
|
459
|
+
`session.sessionManager` is the source of truth for model context (see [SessionManager API](/session-format#sessionmanager-api)). Never mutate `session.agent.state.messages` directly to restore history. Instead, pass entries to `SessionManager.inMemory(cwd, { id }, entries)` before `createAgentSession()`, call `session.navigateTree()`, or append via `session.sessionManager.appendMessage()` followed by `session.refreshContext()`.
|
|
549
460
|
|
|
550
461
|
### Events and transcript collection
|
|
551
462
|
|
package/docs/security.md
CHANGED
|
@@ -48,8 +48,8 @@ Trusting a project lets Atomic load:
|
|
|
48
48
|
- Project-local `AGENTS.override.md`, `AGENTS.md`, `AGENTS.MD`, `CLAUDE.md`, and `CLAUDE.MD`, plus project `.agents/skills`
|
|
49
49
|
- Project subagent definitions and agent overrides (`.atomic/agents`, `.pi/agents`, and `.agents`)
|
|
50
50
|
- Earlier workflow files for on-demand [conversion to skills](/orchestration/migrating-workflows) (read as text only, never executed, modified, or deleted)
|
|
51
|
-
- Project MCP server config (`.atomic/mcp.json`) and blueprint builds (`.atomic/blueprint.yaml`)
|
|
52
|
-
- Project-configured packages, automatic installation of missing project packages, and package-managed extensions
|
|
51
|
+
- Project MCP server config ([`.atomic/mcp.json`](/mcp-servers); `auth.provider` is forbidden in project configs and package manifests, and `!command` values run shell commands) and blueprint builds ([`.atomic/blueprint.yaml`](/guides/resume-on-any-machine#set-the-environment-up-with-a-blueprint))
|
|
52
|
+
- Project-configured [packages](/packages) (`atomic install -l` requires project trust or `--approve`), automatic installation of missing project packages, and package-managed extensions
|
|
53
53
|
|
|
54
54
|
Declining trust skips all of these project inputs. Global instructions, global skills, global settings, and explicit CLI resources remain available. Interactive sessions in an untrusted project display a warning; run `/trust` to save a decision, then restart Atomic.
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ Declining trust skips all of these project inputs. Global instructions, global s
|
|
|
57
57
|
|
|
58
58
|
- **Per-folder trust:** Trust belongs to the folder a session works in, not the directory you started Atomic from. Resuming a session (`--resume`, `--continue`, `--session`, or `/resume`) applies that folder's trust decision and prompts if none is saved. Session-only choices last until Atomic exits and are never written to `trust.json`.
|
|
59
59
|
- **Git worktrees:** A worktree outside its main repository folder has its own trust decision because it can check out different `.atomic` content. Choose **Trust parent folder** (at the prompt or in `/trust`) to trust sibling worktrees under one parent directory.
|
|
60
|
-
- **Extension `project_trust` hooks:** Global extensions and explicit CLI `-e` extensions can handle the `project_trust` event ahead of `trust.json` and `defaultProjectTrust
|
|
60
|
+
- **Extension `project_trust` hooks:** Global extensions and explicit CLI `-e` extensions can handle the [`project_trust`](/extensions/events#project_trust) event ahead of `trust.json` and `defaultProjectTrust` (see `project-trust.ts` in [Extension examples](/extensions/examples#events-and-gates)). When such extensions are installed, Atomic waits for them before applying project settings, resources, or a project-configured session store. Handlers run in extension load order: returning `{ trusted: "undecided" }` passes to the next handler, and the first `{ trusted: "yes" }` or `{ trusted: "no" }` wins (and writes to `trust.json` when `remember: true`). If a handler throws an error, Atomic logs a warning and continues to the next handler, or falls back to `trust.json`, `defaultProjectTrust`, and the prompt. Hooks do not run when a folder has no trust-gated inputs or when `--approve` or `--no-approve` overrides trust. Switching to a resumed session in another folder shuts down the previous folder's extensions (waiting up to 5 seconds before continuing) before loading the resumed folder's extensions.
|
|
61
61
|
- **Borrowed `-e` sources:** If `-e <dir>` discovers resources from that directory's `.atomic`, legacy `.pi`, or `.agents/skills`, Atomic checks `trust.json` under that source's canonical path (cached for the session) before loading them, because borrowed extensions run with your user permissions. Passing `--approve` (`-a`) or `--no-approve` (`-na`) also overrides trust for borrowed `-e` sources.
|
|
62
62
|
- **Non-interactive runs:** Print mode (`-p`), `--mode json`, and `--mode rpc` never open a trust prompt. Without a saved decision, `defaultProjectTrust: "ask"` and `"never"` leave the project untrusted and skip project resources, while `"always"` trusts the project. Pass `--approve` (`-a`) or `--no-approve` (`-na`) to override trust for one run.
|
|
63
63
|
|
|
@@ -75,15 +75,25 @@ You can narrow which tools a session exposes:
|
|
|
75
75
|
|
|
76
76
|
- **CLI flags:** Pass `--tools` (`-t`) to set an allowlist or apply `+name`/`-name` modifiers, `--exclude-tools` (`-xt`) to remove specific tools, `--no-builtin-tools` (`-nbt`) to omit default coding tools, or `--no-tools` (`-nt`) to disable every tool (including extension tools such as `intercom`).
|
|
77
77
|
- **Settings:** Configure `defaultTools` in [Settings](/settings#tools) globally or in a trusted project.
|
|
78
|
-
- **SDK:** Pass `tools`, `excludedTools`, or `noTools` when creating a session.
|
|
78
|
+
- **SDK:** Pass `tools`, `excludedTools`, or `noTools` when creating a session ([SDK tools reference](/sdk/reference#tools)).
|
|
79
79
|
|
|
80
|
-
On native Windows, Atomic enables the `powershell` tool alongside `bash` whenever PowerShell is installed. Excluding `bash` alone still leaves `powershell` enabled. Exclude both when you want no shell execution:
|
|
80
|
+
On native Windows, Atomic enables the [`powershell` tool](/windows#powershell-tool) alongside `bash` whenever PowerShell is installed. Excluding `bash` alone still leaves `powershell` enabled. Exclude both when you want no shell execution:
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
83
|
atomic --exclude-tools bash,powershell
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Use a container, VM, remote sandbox, restricted OS account, or custom
|
|
86
|
+
Use a container, VM, remote sandbox, restricted OS account, or custom extension gate when you need command allowlisting or filesystem isolation. Extensions can inspect and block calls in [`tool_call` hooks](/extensions/events#tool_call); see `permission-gate.ts` and `protected-paths.ts` in [Extension examples](/extensions/examples#events-and-gates).
|
|
87
|
+
|
|
88
|
+
## Built-in data and network protections
|
|
89
|
+
|
|
90
|
+
Atomic enforces several local guardrails by default:
|
|
91
|
+
|
|
92
|
+
- **SSRF blocking on URL reads.** `read` blocks `localhost`, `.localhost`, private IP ranges, cloud metadata endpoints, and redirects to them ([Documents and URLs](/tools#documents-and-urls)). Set `ATOMIC_ALLOW_PRIVATE_URL_READS=1` only when a workflow must read private URLs ([Environment variables](/environment-variables)). Bundled `@bastani/web-access` also keeps local or intranet hosts and credentialed URLs out of remote fallbacks ([Web access](/web-access)).
|
|
93
|
+
- **Opt-in browser cookies.** Gemini Web cookie lookup is disabled by default and activates only when you set `allowBrowserCookies: true` in `~/.atomic/web-search.json` or `ATOMIC_ALLOW_BROWSER_COOKIES=1` ([Web access](/web-access)).
|
|
94
|
+
- **Worktree snapshot secret deny list.** [Worktree snapshots](/worktree-snapshots) exclude `.env*`, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `credentials`, `credentials.json`, `.netrc`, `_netrc`, `.git-credentials`, `.pgpass`, and private SSH key files before `.atomic/snapshot-ignore` or Git staging. This deny list cannot be overridden ([What is left out](/worktree-snapshots#what-is-left-out)).
|
|
95
|
+
- **Storage credentials and process overrides.** Shared storage rejects credentials embedded in URLs and saves static tokens in mode-`600` files. Process-level storage overrides (`--storage`, `--storage-file`, `ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`, `ATOMIC_PROFILE=ci`) come from the launching host and bypass project trust ([Selecting storage per process](/storage#selecting-storage-per-process)).
|
|
96
|
+
- **Session sharing and debug snapshots.** `/share` uploads a private GitHub gist and strips worktree snapshots and large tool-output blobs, while keeping the rest of the transcript ([Exporting and sharing sessions](/usage#exporting-and-sharing-sessions)). `/debug` writes all current session messages unredacted to `~/.atomic/agent/atomic-debug.log` ([Diagnostics and debugging](/development#debugging)).
|
|
87
97
|
|
|
88
98
|
## Running untrusted or unattended work
|
|
89
99
|
|
|
@@ -103,7 +113,7 @@ If you bind-mount a host directory read/write, writes inside the container or VM
|
|
|
103
113
|
|
|
104
114
|
## Credential export
|
|
105
115
|
|
|
106
|
-
`atomic auth print-api-key`, `atomic auth print-bearer-token`, and `atomic auth check --credentials` export a resolved credential to stdout so external clients can reuse your Atomic authentication without reading `auth.json`. `atomic auth check` without `--credentials` stays status-only and never prints a secret.
|
|
116
|
+
`atomic auth print-api-key`, `atomic auth print-bearer-token`, and `atomic auth check --credentials` export a resolved credential to stdout so external clients can reuse your Atomic authentication without reading `auth.json`. `atomic auth check` without `--credentials` stays status-only and never prints a secret. See [CLI credential commands](/reference/cli#credential-commands) and [Providers](/providers) for full command flags and provider auth setup.
|
|
107
117
|
|
|
108
118
|
```bash
|
|
109
119
|
TOKEN=$(atomic auth print-bearer-token --provider openai-codex --model gpt-5.4 --min-expiry 45m)
|
package/docs/session-format.md
CHANGED
|
@@ -4,17 +4,26 @@ sidebarTitle: "Session format"
|
|
|
4
4
|
description: "Format-4 JSONL session schema, message and entry types, context rebuilding rules, and the SessionManager API."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
This reference describes format-4 JSONL files used by explicit JSONL stores and session exports. Sessions default to local SQLite; see [Session storage](/sessions#session-storage) to choose a store.
|
|
7
|
+
This reference describes format-4 JSONL files used by explicit JSONL stores and session exports. Sessions default to local SQLite; see [Session storage](/sessions#session-storage), [Storage backends](/storage), and [SDK session storage](/sdk/storage) to choose or open a store.
|
|
8
8
|
|
|
9
9
|
In JSONL, each line is a JSON object with a `type` field. Session entries form a tree through `id` and `parentId`.
|
|
10
10
|
|
|
11
11
|
## File location
|
|
12
12
|
|
|
13
|
+
JSONL stores use one of two directory layouts depending on `exactDirectory`:
|
|
14
|
+
|
|
13
15
|
```text
|
|
14
|
-
|
|
16
|
+
# Flat layout (exactDirectory: true)
|
|
17
|
+
<dir>/<timestamp>_<sha256-of-id>.jsonl
|
|
18
|
+
|
|
19
|
+
# Nested per-project layout (exactDirectory: false)
|
|
20
|
+
<dir>/--<encoded-cwd>--/<timestamp>_<sha256-of-id>.jsonl
|
|
15
21
|
```
|
|
16
22
|
|
|
17
|
-
`sessions.storage.dir
|
|
23
|
+
- **Flat layout (`exactDirectory: true`).** `sessions.storage.dir`, `--session-dir`, `ATOMIC_SESSIONS_STORAGE`, SDK `{ kind: "jsonl", dir }`, `SessionManager` string-directory overloads, and `JsonlSessionStore.open(dir, { exactDirectory: true })` write files directly inside `<dir>` and do not scan subdirectories.
|
|
24
|
+
- **Nested layout (`exactDirectory: false`).** Legacy `~/.atomic/agent/sessions` and direct `JsonlSessionStore.open(dir)` calls (where `exactDirectory` defaults to `false`) group files into a per-project subdirectory named `--<encoded-cwd>--`, falling back to `--<sha256-of-cwd>--` when the encoded directory name exceeds 180 UTF-8 bytes.
|
|
25
|
+
|
|
26
|
+
Do not mix both layouts on the same directory. Files stored under `--<encoded-cwd>--` are invisible to `exactDirectory: true` stores. In both layouts, each filename combines the session creation timestamp and the 64-character hex SHA-256 hash of the session ID.
|
|
18
27
|
|
|
19
28
|
Resume and fork selection match by session ID rather than file path. Local artifacts and tool-result files stay on the filesystem even when a session is stored in a database.
|
|
20
29
|
|
|
@@ -531,16 +540,18 @@ for (const line of lines) {
|
|
|
531
540
|
|
|
532
541
|
Await `create`, `open`, `continueRecent`, `forkFrom`, and every session mutation. A resolved mutation has committed to its store, and a failed write rejects with a typed storage error without publishing the entry. There is no `flush` method.
|
|
533
542
|
|
|
534
|
-
`inMemory()` selects memory storage explicitly without filesystem I/O. Factories without an explicit store or directory resolve configured storage, defaulting to the shared local SQLite database. Passing a directory selects JSONL explicitly. Store-open failures never fall back to memory.
|
|
543
|
+
`inMemory()` selects memory storage explicitly without filesystem I/O. Factories without an explicit store or directory resolve configured storage, defaulting to the shared local SQLite database. Passing a directory selects JSONL explicitly. Store-open failures never fall back to memory. To open SQLite, PostgreSQL, libSQL, JSONL, or memory stores, see [SDK session storage](/sdk/storage), [Storage backends](/storage), and [Session management](/sdk/reference#session-management).
|
|
544
|
+
|
|
545
|
+
**Store ownership and closing.** `SessionManager` has no `close()` method. Calling `SessionManager.create(cwd)`, `SessionManager.continueRecent(cwd)`, or `SessionManager.open(filePath)` without passing a `SessionStore` opens an internal store that `createAgentSession({ sessionManager })` does **not** close during `session.dispose()`. Close `sessionManager.getSessionStore().close()` when finished, or open and close a `SessionStore` explicitly and pass it to `SessionManager.create(store, cwd)` or `SessionManager.open(store, sessionId)`. Calling `close()` twice on a direct `SqlSessionStore`, `JsonlSessionStore`, or `MemorySessionStore` throws `StoreClosedError`, and `SqlSessionStore.close()` leaves a caller-owned `database` open. See [SDK session storage](/sdk/storage) for the ownership matrix.
|
|
535
546
|
|
|
536
547
|
By default, opening an existing session loads only the active tail window (entries from the latest compaction boundary onward, plus required branch metadata) into memory rather than the entire history. Methods below note whether they inspect only entries loaded in memory or read older entries from storage on demand.
|
|
537
548
|
|
|
538
549
|
### Static creation methods
|
|
539
550
|
|
|
540
|
-
- `SessionManager.create(cwd, sessionDir?, options?)`: create a new session in configured storage, or in JSONL when `sessionDir` is provided.
|
|
551
|
+
- `SessionManager.create(cwd, sessionDir?, options?)`: create a new session in configured storage, or in flat-layout JSONL when `sessionDir` is provided.
|
|
541
552
|
- `SessionManager.create(store, cwd, options?)`: create a new session in a supplied `SessionStore`.
|
|
542
|
-
- `SessionManager.open(store, sessionId, cwdOverride?, options?)`: open an existing session by exact ID, raising `SessionNotFoundError` if missing. Defaults to `{ history: "tail" }`, loading from the latest compaction window; pass `{ history: "full" }` only when every stored entry must be loaded into memory. `
|
|
543
|
-
- `SessionManager.open(path, sessionDir?, cwdOverride?)`: open a JSONL file directly, creating it if missing. This is a file API
|
|
553
|
+
- `SessionManager.open(store, sessionId, cwdOverride?, options?)`: open an existing session by exact ID in any `SessionStore` (required for SQLite, PostgreSQL, and libSQL sessions), raising `SessionNotFoundError` if missing. Defaults to `{ history: "tail" }`, loading from the latest compaction window; pass `{ history: "full" }` only when every stored entry must be loaded into memory. `continueRecent(store, cwd, options?)` and instance method `openSessionById()` share the same behavior.
|
|
554
|
+
- `SessionManager.open(path, sessionDir?, cwdOverride?, options?)`: open a JSONL file directly by filesystem path, creating it if missing. This is a JSONL file API only and cannot open a SQLite, PostgreSQL, or libSQL session ID.
|
|
544
555
|
- `SessionManager.continueRecent(cwd, sessionDir?, options?)` or `continueRecent(store, cwd, options?)`: continue the most recent regular session or create a new one. Pass `{ includeInternal: true }` to include internal sessions.
|
|
545
556
|
- `SessionManager.inMemory(cwd?, options?)`: create an empty memory-only session synchronously. To seed entries, await `SessionManager.inMemory(cwd, options, entries)` without mutating the supplied array until it resolves.
|
|
546
557
|
- `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?, options?)`: fork a JSONL file into the target store. For database sessions, open the session by ID and await `manager.forkTo(targetCwd, targetStore?, options?)`.
|
|
@@ -548,15 +559,16 @@ By default, opening an existing session loads only the active tail window (entri
|
|
|
548
559
|
|
|
549
560
|
### Static listing methods
|
|
550
561
|
|
|
551
|
-
- `SessionManager.list(cwd, storeOrDir?, onProgress?, options?)`: list sessions for one project, excluding internal sessions by default.
|
|
552
|
-
- `SessionManager.listAll(storeOrDir?, onProgress?, options?)`: list sessions across all projects in the store.
|
|
562
|
+
- `SessionManager.list(cwd, storeOrDir?, onProgress?, options?)`: list sessions for one project (`cwd` is always the first argument), excluding internal sessions by default. When `storeOrDir` is omitted, Atomic opens and closes configured storage automatically.
|
|
563
|
+
- `SessionManager.listAll(storeOrDir?, onProgress?, options?)` or `SessionManager.listAll(onProgress?, signal?)`: list sessions across all projects in the store. The first argument is `storeOrDir` or `onProgress`, never `cwd`; passing a string scans that string as a JSONL directory instead of filtering by project. When `storeOrDir` is omitted, Atomic opens and closes configured storage automatically.
|
|
553
564
|
|
|
554
|
-
Select sessions by `SessionInfo.id`. `SessionInfo.path` holds a JSONL path when available and otherwise the session ID; do not treat it as a filesystem path.
|
|
565
|
+
Both methods accept `{ includeInternal: true, signal }`. Select sessions by `SessionInfo.id`. `SessionInfo.path` holds a JSONL path when available and otherwise the session ID; do not treat it as a filesystem path.
|
|
555
566
|
|
|
556
567
|
### Session management methods
|
|
557
568
|
|
|
558
569
|
- `newSession(options?)`: start a new session. `NewSessionOptions` accepts `id`, `parentSession`, and `internal` (`internal: true` hides the session from `/resume`, `atomic -r`, `-c`, and `history://sessions` while keeping it openable by ID).
|
|
559
|
-
- `
|
|
570
|
+
- `openSessionById(sessionId, cwdOverride?, sessionDirectory?, options?)`: open an existing session by exact ID from this manager's active store (or from a flat-layout JSONL directory when `sessionDirectory` is passed), returning a new `SessionManager`. Defaults to `{ history: "tail" }`; pass `{ history: "full" }` only when every stored entry must be loaded into memory.
|
|
571
|
+
- `setSessionFile(path)`: switch directly to a JSONL file. For ID-based loading, create a new manager with `SessionManager.open(store, sessionId)` or `manager.openSessionById(sessionId)`.
|
|
560
572
|
- `createBranchedSession(leafId)`: extract a branch into a new session in the same store.
|
|
561
573
|
- `forkTo(cwd, targetStoreOrDir?, options?)`: copy the session into a new session at the destination.
|
|
562
574
|
- `deleteSession(sessionId)`: delete another session and its entries from the active store. Deleting a missing ID is a no-op. Rejects for the currently open session, and raises `SessionOpenElsewhereError` if another live Atomic session holds it open (tracked by an active heartbeat that expires after 60 seconds on another host). A session deleted while running fails its next save once with `SessionDeletedError`. `SessionStore.delete(sessionId)` is the unguarded store-level operation underneath.
|
|
@@ -581,19 +593,21 @@ All append methods below return `Promise<string>` resolving to the new entry ID,
|
|
|
581
593
|
|
|
582
594
|
### Tree navigation methods
|
|
583
595
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
|
587
|
-
|
|
|
588
|
-
| `
|
|
589
|
-
| `
|
|
590
|
-
| `
|
|
591
|
-
| `
|
|
592
|
-
| `
|
|
593
|
-
| `
|
|
594
|
-
| `
|
|
595
|
-
| `
|
|
596
|
-
| `
|
|
596
|
+
Await `branch`, `resetLeaf`, `recordBranch`, and `branchWithSummary`. All read methods below are synchronous:
|
|
597
|
+
|
|
598
|
+
| Method | Returns | Action |
|
|
599
|
+
| --- | --- | --- |
|
|
600
|
+
| `getLeafId()` | `string \| null` | Return the current leaf entry ID |
|
|
601
|
+
| `getLeafEntry()` | `SessionEntry \| undefined` | Return the current leaf entry |
|
|
602
|
+
| `getEntry(id)` | `SessionEntry \| undefined` | Return an entry loaded in memory by ID |
|
|
603
|
+
| `getBranch(fromId?)` | `SessionEntry[]` | Walk from an entry to the root |
|
|
604
|
+
| `getTree()` | `SessionTreeNode[]` | Return the tree of entries loaded in memory; use `readHistory()` or `loadFullHistory()` for older entries |
|
|
605
|
+
| `getChildren(parentId)` | `SessionEntry[]` | Return direct child entries currently loaded in memory |
|
|
606
|
+
| `getLabel(id)` | `string \| undefined` | Return the label for an entry |
|
|
607
|
+
| `branch(entryId)` | `Promise<void>` (async) | Move the leaf to an earlier entry in memory only (the session reopens at its last saved entry) |
|
|
608
|
+
| `resetLeaf()` | `Promise<void>` (async) | Reset the leaf to `null` in memory only |
|
|
609
|
+
| `recordBranch(entryId \| null)` | `Promise<void>` (async) | Move the leaf like `branch()` or `resetLeaf()` and persist the move so the session reopens there |
|
|
610
|
+
| `branchWithSummary(entryId, summary, details?, fromHook?, usage?, fromId?)` | `Promise<string>` (async) | Branch with a context summary and return the new entry ID |
|
|
597
611
|
|
|
598
612
|
### Context, history, and metadata methods
|
|
599
613
|
|