@bastani/atomic 0.10.10-alpha.1 → 0.10.10
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 +85 -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/CHANGELOG.md +6 -0
- 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/CHANGELOG.md +8 -0
- 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/CHANGELOG.md +9 -0
- 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
package/docs/sdk/reference.md
CHANGED
|
@@ -754,7 +754,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
754
754
|
|
|
755
755
|
### Session management
|
|
756
756
|
|
|
757
|
-
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching.
|
|
757
|
+
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching. See the **[SDK storage guide](/sdk/storage)** for full recipes across all five storage backends, `createAgentSessionRuntime()` store wiring, ownership rules, and error handling, and [Storage errors](/storage#storage-errors) for `StorageError` subclasses.
|
|
758
758
|
|
|
759
759
|
```typescript
|
|
760
760
|
import {
|
|
@@ -764,6 +764,7 @@ import {
|
|
|
764
764
|
createAgentSessionRuntime,
|
|
765
765
|
createAgentSessionServices,
|
|
766
766
|
getAgentDir,
|
|
767
|
+
resolveSessionStore,
|
|
767
768
|
SessionManager,
|
|
768
769
|
} from "@bastani/atomic";
|
|
769
770
|
|
|
@@ -772,33 +773,52 @@ const { session } = await createAgentSession({
|
|
|
772
773
|
sessionManager: SessionManager.inMemory(),
|
|
773
774
|
});
|
|
774
775
|
|
|
775
|
-
// New persistent session
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
776
|
+
// New persistent session in a caller-managed store (close the store in finally)
|
|
777
|
+
const store = await resolveSessionStore(process.cwd());
|
|
778
|
+
try {
|
|
779
|
+
const { session: persisted } = await createAgentSession({
|
|
780
|
+
sessionManager: await SessionManager.create(store, process.cwd()),
|
|
781
|
+
});
|
|
782
|
+
await persisted.dispose();
|
|
783
|
+
|
|
784
|
+
// Open an existing session by exact ID from a store
|
|
785
|
+
const { session: reopened } = await createAgentSession({
|
|
786
|
+
sessionManager: await SessionManager.open(store, savedSessionId),
|
|
787
|
+
});
|
|
788
|
+
await reopened.dispose();
|
|
789
|
+
|
|
790
|
+
// Continue the most recent session in a store
|
|
791
|
+
const { session: continued, modelFallbackMessage } = await createAgentSession({
|
|
792
|
+
sessionManager: await SessionManager.continueRecent(store, process.cwd()),
|
|
793
|
+
});
|
|
794
|
+
if (modelFallbackMessage) {
|
|
795
|
+
console.log("Note:", modelFallbackMessage);
|
|
796
|
+
}
|
|
797
|
+
await continued.dispose();
|
|
781
798
|
|
|
782
|
-
//
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
console.log("Note:", modelFallbackMessage);
|
|
799
|
+
// List sessions in an explicit store
|
|
800
|
+
const storeProjectSessions = await SessionManager.list(process.cwd(), store);
|
|
801
|
+
const storeAllSessions = await SessionManager.listAll(store);
|
|
802
|
+
} finally {
|
|
803
|
+
await store.close();
|
|
788
804
|
}
|
|
789
805
|
|
|
790
|
-
// Open specific file
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
});
|
|
806
|
+
// Open a specific JSONL file directly
|
|
807
|
+
const fileManager = await SessionManager.open("/path/to/session.jsonl");
|
|
808
|
+
try {
|
|
809
|
+
const { session: opened } = await createAgentSession({ sessionManager: fileManager });
|
|
810
|
+
await opened.dispose();
|
|
811
|
+
} finally {
|
|
812
|
+
await fileManager.getSessionStore().close();
|
|
813
|
+
}
|
|
794
814
|
|
|
795
|
-
// List sessions
|
|
815
|
+
// List sessions in the active resolved store (passing a string to listAll() scans that path as a JSONL directory)
|
|
796
816
|
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
797
|
-
const allSessions = await SessionManager.listAll(
|
|
817
|
+
const allSessions = await SessionManager.listAll();
|
|
798
818
|
|
|
799
819
|
// Session replacement API for /new, /resume, /fork, /clone, and import flows.
|
|
800
|
-
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
801
|
-
const services = await createAgentSessionServices({ cwd });
|
|
820
|
+
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent, services: incoming }) => {
|
|
821
|
+
const services = incoming ?? (await createAgentSessionServices({ cwd }));
|
|
802
822
|
return {
|
|
803
823
|
...(await createAgentSessionFromServices({
|
|
804
824
|
services,
|
|
@@ -810,10 +830,11 @@ const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionMan
|
|
|
810
830
|
};
|
|
811
831
|
};
|
|
812
832
|
|
|
833
|
+
const runtimeStore = await resolveSessionStore(process.cwd());
|
|
813
834
|
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
814
835
|
cwd: process.cwd(),
|
|
815
836
|
agentDir: getAgentDir(),
|
|
816
|
-
sessionManager: await SessionManager.create(process.cwd()),
|
|
837
|
+
sessionManager: await SessionManager.create(runtimeStore, process.cwd()),
|
|
817
838
|
});
|
|
818
839
|
|
|
819
840
|
// Replace the active session with a fresh one
|
|
@@ -829,6 +850,10 @@ await runtime.fork("entry-id");
|
|
|
829
850
|
await runtime.fork("entry-id", { position: "at" });
|
|
830
851
|
```
|
|
831
852
|
|
|
853
|
+
**Store-closing ownership.** Calling `SessionManager.create(cwd)`, `SessionManager.continueRecent(cwd)`, or `SessionManager.open("/path/to/session.jsonl")` opens a `SessionStore` internally. Passing a caller-created `sessionManager` to `createAgentSession({ sessionManager })` or `createAgentSessionRuntime()` does not transfer store ownership to `dispose()`, so close `sessionManager.getSessionStore().close()` (or the explicit `store` you passed) in `finally` after disposing the session or runtime. When you omit `sessionManager` and pass a selection object such as `sessionStore: { kind: "sqlite", path }` to `createAgentSession()`, `session.dispose()` closes the store it opened automatically.
|
|
854
|
+
|
|
855
|
+
**`SessionManager.listAll()` arguments.** Call `SessionManager.listAll()` with no path to list across the active configured store (SQLite by default), or pass a `SessionStore` (`SessionManager.listAll(store)`). Passing a string path such as `process.cwd()` scans that directory as JSONL files instead of querying SQLite or a configured database.
|
|
856
|
+
|
|
832
857
|
`runtime.switchSession(id, options?)` and `runtime.rehydrate(id, options?)` resume at the current context window, so `getEntries()` and `getTree()` return only the loaded context window.
|
|
833
858
|
|
|
834
859
|
To visit older entries without loading them into memory, iterate `for await (const page of sessionManager.readHistory({ fromSeq, toSeq, signal }))`:
|
|
@@ -856,11 +881,11 @@ const entry = await sessionManager.readEntry("entry-id");
|
|
|
856
881
|
|
|
857
882
|
#### Session stores and claims
|
|
858
883
|
|
|
859
|
-
Construct or open concrete `SessionStore` implementations directly when you manage store lifetimes yourself:
|
|
884
|
+
Construct or open concrete `SessionStore` implementations directly when you manage store lifetimes yourself (see [SDK storage guide](/sdk/storage) and [Storage errors](/storage#storage-errors)):
|
|
860
885
|
|
|
861
|
-
- **`SqlSessionStore.open(database, { prefix?, cwdMatcher? })`:** Opens a SQL-backed session store on a caller-owned `SqliteDatabase` or storage adapter handle.
|
|
862
|
-
- **`JsonlSessionStore.open(directory, { exactDirectory?, scanExisting?, lockFs?, createDirectory? })`:** Opens a JSONL session directory store (creates `directory` unless `createDirectory: false`).
|
|
863
|
-
- **`new MemorySessionStore(cwdMatcher?, historyFiles?)`:** Creates a caller-owned in-memory store that preserves history across `session.release()` and `runtime.rehydrate()`.
|
|
886
|
+
- **`SqlSessionStore.open(database, { prefix?, cwdMatcher? })`:** Opens a SQL-backed session store on a caller-owned `SqliteDatabase` or storage adapter handle. Close the store, then close the database handle.
|
|
887
|
+
- **`JsonlSessionStore.open(directory, { exactDirectory?, scanExisting?, lockFs?, createDirectory? })`:** Opens a JSONL session directory store (creates `directory` unless `createDirectory: false`). `exactDirectory` defaults to `false` and creates per-`cwd` `--<encoded-cwd>--` subdirectories under `directory`. By contrast, `sessionStore: { kind: "jsonl", dir }` opens `JsonlSessionStore.open(dir, { exactDirectory: true })` and writes `.jsonl` files directly in `dir`. Pass `{ exactDirectory: true }` when opening the same flat layout directly.
|
|
888
|
+
- **`new MemorySessionStore(cwdMatcher?, historyFiles?)`:** Creates a caller-owned in-memory store that preserves history in RAM across `session.release()` and `runtime.rehydrate()`. To enable disk spilling of released history under `<agentDir>/released-history/`, open the memory store via `resolveSessionStore(cwd, { agentDir, sessionStore: { kind: "memory" } })`.
|
|
864
889
|
|
|
865
890
|
Coordinate single-writer session ownership across processes with session claims (stored at `<agentDir>/session-claims/<sessionId>.json`, refreshed on a 15-second heartbeat, with a 60-second staleness window for remote hosts and automatic dead-claim takeover):
|
|
866
891
|
|
|
@@ -882,14 +907,15 @@ When managing multiple sessions that share a working directory (or inside `creat
|
|
|
882
907
|
```typescript
|
|
883
908
|
const sm = await SessionManager.open("/path/to/session.jsonl");
|
|
884
909
|
|
|
885
|
-
// Session listing
|
|
910
|
+
// Session listing (pass a SessionStore to listAll(store), or omit arguments for the active resolved store;
|
|
911
|
+
// passing a string scans that directory as JSONL files)
|
|
886
912
|
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
887
|
-
const allSessions = await SessionManager.listAll(
|
|
913
|
+
const allSessions = await SessionManager.listAll();
|
|
888
914
|
|
|
889
915
|
// Tree traversal
|
|
890
916
|
const entries = sm.getEntries(); // Entries in the current window, without the header
|
|
891
917
|
const tree = sm.getTree(); // Tree structure for the current window
|
|
892
|
-
const
|
|
918
|
+
const branch = sm.getBranch(); // Path from root to current leaf
|
|
893
919
|
const leaf = sm.getLeafEntry(); // Current leaf entry
|
|
894
920
|
const entry = sm.getEntry(id); // Get entry by ID
|
|
895
921
|
const children = sm.getChildren(id); // Direct children of entry
|
|
@@ -934,7 +960,7 @@ An unrebuildable snapshot produces a `WorkspaceDriftError` carrying the restore
|
|
|
934
960
|
|
|
935
961
|
| Class | `code` | When | Fields | What to do |
|
|
936
962
|
|---|---|---|---|---|
|
|
937
|
-
| `MissingSessionCwdError` | `session-cwd-missing` | The session's working directory does not exist (`retryable: false`). | `sessionCwd`, `fallbackCwd`, `sessionFile` (JSONL only), `hint` | Retry with `{ cwdOverride }` (`switchSession`) or `importFromJsonl(path, cwdOverride)`, or fork there with `
|
|
963
|
+
| `MissingSessionCwdError` | `session-cwd-missing` | The session's working directory does not exist (`retryable: false`). | `sessionCwd`, `fallbackCwd`, `sessionFile` (JSONL only), `hint` | Retry with `{ cwdOverride }` (`switchSession`) or `importFromJsonl(path, cwdOverride)`, or fork there with `sessionManager.forkTo(cwd, store)`. |
|
|
938
964
|
|
|
939
965
|
Use `isMissingSessionCwdError(error)`, `serializeMissingSessionCwdError(error)`, `isSerializedMissingSessionCwdError(value)`, and `rehydrateMissingSessionCwdError(serialized)` across process boundaries. `RpcClient` rehydrates this error for `switch_session` and `import_session`. Interactive mode prompts to continue in the current directory, fork there, or cancel (see [Sessions](/sessions#resuming-and-deleting-sessions)).
|
|
940
966
|
|
|
@@ -1014,6 +1040,8 @@ import {
|
|
|
1014
1040
|
const loader = new DefaultResourceLoader({
|
|
1015
1041
|
cwd,
|
|
1016
1042
|
agentDir: getAgentDir(),
|
|
1043
|
+
additionalSkillPaths: ["/path/to/extra-skills"],
|
|
1044
|
+
noSkills: false,
|
|
1017
1045
|
});
|
|
1018
1046
|
await loader.reload();
|
|
1019
1047
|
|
|
@@ -1024,7 +1052,14 @@ const themes = loader.getThemes();
|
|
|
1024
1052
|
const contextFiles = loader.getAgentsFiles().agentsFiles;
|
|
1025
1053
|
```
|
|
1026
1054
|
|
|
1027
|
-
|
|
1055
|
+
Key `DefaultResourceLoader` discovery options:
|
|
1056
|
+
|
|
1057
|
+
- `additionalSkillPaths`: extra directories or `SKILL.md` paths loaded in addition to default user, project, and package skill discovery.
|
|
1058
|
+
- `noSkills`: set `true` to disable automatic skill discovery (paths in `additionalSkillPaths` still load).
|
|
1059
|
+
- `additionalExtensionPaths`, `noExtensions`, `disabledBuiltinExtensions`, `extensionFactories`: control extension loading and inline builtin extensions.
|
|
1060
|
+
- `additionalPromptTemplatePaths`, `noPromptTemplates`, `additionalThemePaths`, `noThemes`, `noContextFiles`: add or disable prompt templates, themes, and `AGENTS.md` context files.
|
|
1061
|
+
|
|
1062
|
+
Package MCP servers discovered by `DefaultResourceLoader` connect through the bundled MCP client extension and register their tools as `mcp__<server>__<tool>` (defaulting to `codemode` exposure). Extensions can also register MCP servers dynamically with `atomic.registerMcpServer(name, config)` and inspect the merged package and extension list via `atomic.getMcpServerContributions()` (or subscribe with `atomic.onMcpServerContributionsChanged(listener)`). Custom `ResourceLoader` implementations can provide `getMcpServerContributions()` returning `McpServerContribution[]`; return only contributions allowed by your loader's trust policy. Normal MCP configuration overrides still apply. See [MCP servers](/mcp-servers) for connection and tool invocation.
|
|
1028
1063
|
|
|
1029
1064
|
### Copying extension handlers in `extensionsOverride`
|
|
1030
1065
|
|
|
@@ -1198,7 +1233,7 @@ See [RPC documentation](/rpc) for the JSON protocol.
|
|
|
1198
1233
|
|
|
1199
1234
|
## Session and storage errors
|
|
1200
1235
|
|
|
1201
|
-
SDK callers working with `SessionManager`, `SessionStore`, `AgentSessionRuntime`, `SettingsManager`, or `ModelRuntime.login()` can branch directly on exported error classes
|
|
1236
|
+
SDK callers working with `SessionManager`, `SessionStore`, `AgentSessionRuntime`, `SettingsManager`, or `ModelRuntime.login()` can branch directly on exported error classes. For backend, adapter, lock, payload, spill, and team-profile errors (`StorageError` and its subclasses, exported from both `@bastani/atomic` and `@bastani/atomic/storage`), see [Storage errors](/storage#storage-errors) and the [SDK storage guide](/sdk/storage).
|
|
1202
1237
|
|
|
1203
1238
|
| Class | When | Key fields |
|
|
1204
1239
|
|---|---|---|
|
|
@@ -1347,8 +1382,13 @@ type CreateModelRuntimeOptions
|
|
|
1347
1382
|
type ModelRuntimeAuthOverrides
|
|
1348
1383
|
CredentialSynchronizationError
|
|
1349
1384
|
AuthStorage
|
|
1385
|
+
type AuthStorageBackend
|
|
1386
|
+
FileAuthStorageBackend
|
|
1387
|
+
InMemoryAuthStorageBackend
|
|
1350
1388
|
readStoredCredential
|
|
1351
1389
|
ModelRegistry
|
|
1390
|
+
NoUsableModelError, partitionByCredentials
|
|
1391
|
+
createGatewayBindingFetch
|
|
1352
1392
|
resolveAutoModel
|
|
1353
1393
|
resolveRestoredModelReference
|
|
1354
1394
|
resolveModelScopeFromModels
|
|
@@ -1356,28 +1396,49 @@ resolveModelScopeWithDiagnostics
|
|
|
1356
1396
|
type ResolveModelScopeResult
|
|
1357
1397
|
type ModelScopeDiagnostic
|
|
1358
1398
|
OAuthLoginTransactionError
|
|
1399
|
+
OAuthRefreshRejectedError, isOAuthRefreshRejectedError
|
|
1359
1400
|
GitHubCopilotError, GitHubCopilotAuthenticationError, GitHubCopilotContentFilterError
|
|
1360
1401
|
GitHubCopilotEmptyResponseError, GitHubCopilotInvalidRequestError, GitHubCopilotModelUnavailableError
|
|
1361
1402
|
GitHubCopilotPromptTooLargeError, GitHubCopilotQuotaExhaustedError, GitHubCopilotRateLimitError
|
|
1362
1403
|
GitHubCopilotServiceUnavailableError, GitHubCopilotStreamEndedEarlyError, GitHubCopilotUnrecognizedResponseError
|
|
1363
1404
|
LlamaServerError, LlamaServerRequestError, LlamaServerUnreachableError
|
|
1364
1405
|
|
|
1365
|
-
// Workspaces and Intercom policy
|
|
1406
|
+
// Workspaces and Intercom policy / errors
|
|
1366
1407
|
workspace
|
|
1367
1408
|
bindSessionWorkspace
|
|
1368
1409
|
resolveWorkspace
|
|
1369
1410
|
restoreWorkspace
|
|
1370
1411
|
workspaceChangeSet
|
|
1371
1412
|
publishPullRequest
|
|
1413
|
+
acquireWorkspaceWriterLease
|
|
1414
|
+
inheritWorkspace
|
|
1415
|
+
isWorkspace, isBoundWorkspace, assertWorkspace
|
|
1416
|
+
workspaceSessionCwd, workspaceSessionCwdAsync
|
|
1372
1417
|
WorkspaceError, WorkspaceConfigError, WorkspaceBindingError, WorkspaceGitError
|
|
1373
1418
|
WorkspaceSnapshotError, WorkspaceRestoreError, WorkspaceDriftError, WorkspacePublicationError
|
|
1419
|
+
WorkspaceSandboxError, WorkspaceTimeoutError, WorkspaceCollectionError
|
|
1374
1420
|
isWorkspaceError, findWorkspaceError, isRetryableWorkspaceError, serializeWorkspaceError, rehydrateWorkspaceError
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1421
|
+
isWorkspaceConfigError, isWorkspaceBindingError, isWorkspacePublicationError, isWorkspaceRestoreError
|
|
1422
|
+
isWorkspaceSandboxError, isWorkspaceTimeoutError, isWorkspaceCollectionError
|
|
1423
|
+
isWorkspaceDriftError, isWorkspaceGitError, isWorkspaceSnapshotError
|
|
1424
|
+
IntercomPolicyError, MAX_INTERCOM_REACHABLE_GROUPS
|
|
1425
|
+
confinedIntercomChildGroup, readRuntimeIntercomGroup, RUNTIME_INTERCOM_GROUP_ENV
|
|
1426
|
+
type IntercomSessionOptions, type SessionIntercom
|
|
1427
|
+
IntercomBrokerError, IntercomBrokerProtocolError, IntercomBrokerStopTimeoutError
|
|
1428
|
+
IntercomBrokerSuccessorTimeoutError, IntercomBrokerUpgradeError
|
|
1429
|
+
isIntercomBrokerError, isIntercomBrokerProtocolError, isIntercomBrokerStopTimeoutError
|
|
1430
|
+
isIntercomBrokerSuccessorTimeoutError, isIntercomBrokerUpgradeError, isRetryableIntercomBrokerError
|
|
1431
|
+
serializeIntercomBrokerError, rehydrateIntercomBrokerError, type SerializedIntercomBrokerError
|
|
1432
|
+
IntercomRoutingError, IntercomRoutingChangedError, IntercomRoutingMismatchError
|
|
1433
|
+
IntercomRoutingTimeoutError, IntercomRoutingUnavailableError
|
|
1434
|
+
isIntercomRoutingError, isIntercomRoutingChangedError, isIntercomRoutingMismatchError
|
|
1435
|
+
isIntercomRoutingTimeoutError, isIntercomRoutingUnavailableError, isRetryableIntercomRoutingError
|
|
1436
|
+
ProjectGroupError, isProjectGroupError, type ProjectGroupErrorCode
|
|
1437
|
+
|
|
1438
|
+
// Resource loading and MCP configuration
|
|
1379
1439
|
DefaultResourceLoader
|
|
1380
1440
|
type ResourceLoader
|
|
1441
|
+
type McpServerConfig, type McpServerContribution
|
|
1381
1442
|
createEventBus
|
|
1382
1443
|
|
|
1383
1444
|
// Constants and helpers
|
|
@@ -1434,6 +1495,43 @@ type Transcript
|
|
|
1434
1495
|
type TranscriptOptions
|
|
1435
1496
|
type TranscriptPart
|
|
1436
1497
|
|
|
1498
|
+
// Storage, adapters, team profiles, history, blobs, and StorageError family
|
|
1499
|
+
// (re-exported from @bastani/atomic/storage, plus root process-selection and blob-copy helpers)
|
|
1500
|
+
openNodeSqliteDatabase, wrapNodeSqliteDatabase, sqliteFilePath
|
|
1501
|
+
getWriterQueueStats, getWriterQueueDegradation, DEFAULT_GROUP_COMMIT_HOLD_MS, type WriterQueueStats
|
|
1502
|
+
StorageProvider, type StorageSelection, type StorageOpenContext, type StorageAdapterModule
|
|
1503
|
+
type AdapterOptions, type SecretRef, type SessionStorageOption, type SessionStore
|
|
1504
|
+
loadStorageAdapter, resolveAdapterOptions, adapterOpenContext, storageSelectionKey
|
|
1505
|
+
secretFilePath, secretFilePathAsync
|
|
1506
|
+
LIBSQL_ADAPTER_PACKAGE, POSTGRES_ADAPTER_PACKAGE, LOCAL_SESSIONS_STORAGE, REDACTED_SECRET
|
|
1507
|
+
inMemorySecret, type InMemorySecretRef
|
|
1508
|
+
teamProfileSelection, type TeamProfileSelectionOptions, type TeamStorageSelection
|
|
1509
|
+
joinTeam, leaveTeam, getTeamProfile, isPostgresUrl
|
|
1510
|
+
selectStorage, selectStorageAsync, type StorageInputSelection, type StorageSettingsSelection
|
|
1511
|
+
selectProcessStorage, selectProcessStorageAsync, type ProcessStorageChoice, type StorageDomain
|
|
1512
|
+
processSharedStorageSelection, processSharedStorageSelectionAsync
|
|
1513
|
+
processStorageEnvironment, processStorageEnvironmentAsync
|
|
1514
|
+
createSqliteDatabase, configuredSecretRedactor, redactSecrets, switchToWriteAheadLog
|
|
1515
|
+
validateStoragePrefix, storageMigrationTable, assertStorageSchemaVersion, assertStoredSchemaVersion
|
|
1516
|
+
type SqliteDatabase, type SqliteDriver, type StorageDescriptor
|
|
1517
|
+
readSessionHistory, readSessionHistoryChunks, findInSessionHistory
|
|
1518
|
+
readSessionChildCatalog, readExpandedChildDetails, readSavedChildLaunch
|
|
1519
|
+
copySessionBlobs, assertSessionBlobStore, sessionBlobHashes, toolOutputUrl
|
|
1520
|
+
SqlSnapshotBlobStore, MemorySnapshotBlobStore, type SnapshotBlobStore
|
|
1521
|
+
StorageError, StorageUnavailableError, StoreClosedError, StorageTransactionClosedError
|
|
1522
|
+
StorageRollbackError, StorageInvalidTextError, StorageSchemaVersionError, StoragePrefixError
|
|
1523
|
+
StorageConfigError, StorageAdapterLoadError, StorageOutcomeUnknownError, StoragePayloadTooLargeError
|
|
1524
|
+
StorageWriteLockTimeoutError, StorageUnsupportedOperationError, StorageWriterQueueDegradedError
|
|
1525
|
+
StorageWriterQueueUnusableError, StorageTransientError, SessionBlobError, SessionSpillError
|
|
1526
|
+
TeamProfileError, TeamProfileTimeoutError, TeamProfileConfigError
|
|
1527
|
+
isStorageError, isStorageConfigError, isStorageWriteLockTimeoutError, isStorageUnsupportedOperationError
|
|
1528
|
+
isStorageWriterQueueDegradedError, isStorageWriterQueueUnusableError, isStorageTransientError
|
|
1529
|
+
isSessionBlobError, isSessionSpillError, isStorageResponseRefusal
|
|
1530
|
+
findStorageWriteLockTimeoutError, isRetryableStorageError
|
|
1531
|
+
isTeamProfileError, isTeamProfileTimeoutError, isTeamProfileConfigError, isRetryableTeamProfileError
|
|
1532
|
+
serializeStorageError, rehydrateStorageError, serializeTeamError, rehydrateTeamError
|
|
1533
|
+
describeStorageError, describeStorageFailure, type SerializedStorageError, type SerializedTeamError
|
|
1534
|
+
|
|
1437
1535
|
// Session management and resume
|
|
1438
1536
|
SessionManager
|
|
1439
1537
|
SettingsManager
|
|
@@ -1512,7 +1610,15 @@ type SessionStartConfigReason
|
|
|
1512
1610
|
type SerializedSessionStartError
|
|
1513
1611
|
type SerializedSessionStartCause
|
|
1514
1612
|
|
|
1515
|
-
//
|
|
1613
|
+
// Owner-bound task supervisor, cleanup errors, and finished task retention
|
|
1614
|
+
AgentTaskHost, type AgentTaskHostBinding, type AgentTaskRunnerFactory
|
|
1615
|
+
OwnerTaskStore, bindOwnerTaskStore, getOwnerTaskStore, getOwnerTaskSession
|
|
1616
|
+
scopedBackgroundTasks, sessionTasks, belongsToSession, ownerTaskViewSource, bindTaskResumer, type TaskViewSource
|
|
1617
|
+
heldPrompts, watchHeldPromptAttention, isHeldPromptInput, isPresentationHostInput, routeNamesPrompt
|
|
1618
|
+
type HeldPrompt, type HeldPrompts
|
|
1619
|
+
TaskCleanupError, TaskCleanupAdmissionTimeoutError
|
|
1620
|
+
isTaskCleanupError, isTaskCleanupAdmissionTimeoutError, isRetryableTaskError, rehydrateTaskCleanupError
|
|
1621
|
+
type TaskCleanupErrorCode, type TaskCleanupFailure, type TaskCleanupPhase, type TaskCleanupAdmissionTiming
|
|
1516
1622
|
FINISHED_TASK_RETENTION
|
|
1517
1623
|
TaskEvictedError, isTaskEvictedError, findTaskEvictedError, rehydrateTaskEvictedError
|
|
1518
1624
|
type TaskEvictedErrorCode, type TaskEvictedErrorFields
|