@bastani/atomic 0.9.38-alpha.6 → 0.9.38-alpha.8
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 +41 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/README.md +9 -4
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +143 -134
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +25 -0
- package/dist/builtin/workflows/builtin/{chunk-q7dx7kh7.js → chunk-85mx6wcf.js} +6 -6
- package/dist/builtin/workflows/builtin/{chunk-neszcj53.js → chunk-8kkv04hz.js} +15 -15
- package/dist/builtin/workflows/builtin/{chunk-g1a4hw0s.js → chunk-8x61e0s7.js} +13 -25
- package/dist/builtin/workflows/builtin/{chunk-2qgfyvzs.js → chunk-y45tkftg.js} +7 -7
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +0 -19
- package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +42 -0
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +3 -11
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +15 -9
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +3 -0
- package/dist/builtin/workflows/src/durable/journal/types.d.ts +3 -93
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1137 -748
- package/dist/builtin/workflows/src/index.js +709 -403
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +2 -2
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +6 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +4 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +44 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -4
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +0 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.js +1 -3
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
- package/dist/core/extensions/loader-api.js +1 -1
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +7 -1
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/fast-model-routing.js +1 -1
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/model-config.d.ts +765 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +46 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +1 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +4 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +48 -19
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-work.d.ts +3 -0
- package/dist/core/session-lifecycle-work.d.ts.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -0
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +7 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +149 -41
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +7 -7
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +24 -9
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +1 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-resume-args.d.ts +4 -0
- package/dist/core/session-resume-args.d.ts.map +1 -0
- package/dist/core/session-resume-args.js +9 -0
- package/dist/core/session-resume-args.js.map +1 -0
- package/dist/core/session-storage.d.ts +26 -0
- package/dist/core/session-storage.d.ts.map +1 -0
- package/dist/core/session-storage.js +171 -0
- package/dist/core/session-storage.js.map +1 -0
- package/dist/core/session-store-list.d.ts +4 -0
- package/dist/core/session-store-list.d.ts.map +1 -0
- package/dist/core/session-store-list.js +28 -0
- package/dist/core/session-store-list.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts +0 -1
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +0 -5
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +5 -0
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-schema.d.ts +74 -3
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +28 -14
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/errors.d.ts +1 -0
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/index.d.ts +4 -0
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +3 -0
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/provider.d.ts +58 -0
- package/dist/core/storage/provider.d.ts.map +1 -0
- package/dist/core/storage/provider.js +243 -0
- package/dist/core/storage/provider.js.map +1 -0
- package/dist/core/storage/run-journal.d.ts +93 -0
- package/dist/core/storage/run-journal.d.ts.map +1 -0
- package/dist/core/storage/run-journal.js +15 -0
- package/dist/core/storage/run-journal.js.map +1 -0
- package/dist/core/storage/selection.d.ts +16 -0
- package/dist/core/storage/selection.d.ts.map +1 -0
- package/dist/core/storage/selection.js +87 -0
- package/dist/core/storage/selection.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +9 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +82 -44
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/storage/session/legacy-format.d.ts +20 -0
- package/dist/core/storage/session/legacy-format.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-format.js +89 -0
- package/dist/core/storage/session/legacy-format.js.map +1 -0
- package/dist/core/storage/session/legacy-session-store.d.ts +60 -0
- package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-session-store.js +225 -0
- package/dist/core/storage/session/legacy-session-store.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.d.ts +3 -1
- package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/memory-session-store.js +9 -2
- package/dist/core/storage/session/memory-session-store.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +4 -1
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +25 -6
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/storage/session/types.d.ts +4 -0
- package/dist/core/storage/session/types.d.ts.map +1 -1
- package/dist/core/storage/session/types.js.map +1 -1
- package/dist/core/tools/read-url.d.ts.map +1 -1
- package/dist/core/tools/read-url.js +6 -1
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +13 -0
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +5 -3
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +5 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +106 -45
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +49 -15
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +3 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +15 -7
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +4 -4
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +13 -12
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +16 -5
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +6 -2
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +19 -7
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +3 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +5 -1
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +21 -15
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +3 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +1 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.js +11 -2
- package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
- package/dist/utils/canonical-path.d.ts +5 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +26 -0
- package/dist/utils/canonical-path.js.map +1 -0
- package/dist/utils/paths.d.ts +1 -7
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +1 -15
- package/dist/utils/paths.js.map +1 -1
- package/docs/codemode.md +2 -0
- package/docs/compaction.md +2 -2
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +6 -2
- package/docs/getting-started/installation.md +1 -1
- package/docs/models/reference.md +2 -0
- package/docs/models-configuration.md +206 -0
- package/docs/models.md +11 -1
- package/docs/providers.md +2 -2
- package/docs/reference/cli.md +4 -0
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +40 -3
- package/docs/session-format.md +30 -25
- package/docs/sessions.md +43 -17
- package/docs/settings.md +31 -9
- package/docs/storage.md +85 -2
- package/docs/subagents.md +19 -6
- package/docs/workflows/api-reference.md +23 -15
- package/docs/workflows/operations.md +3 -3
- package/docs/workflows/reliable-design.md +16 -16
- package/npm-shrinkwrap.json +53 -53
- package/package.json +7 -6
- package/schemas/models.schema.json +62 -29
- package/schemas/settings.schema.json +136 -31
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { createJiti } from "jiti";
|
|
5
|
+
import { createSessionCwdMatcher } from "../../utils/canonical-path.js";
|
|
6
|
+
import { StorageAdapterLoadError, StorageConfigError, StorageError, StorageUnavailableError, } from "./errors.js";
|
|
7
|
+
import { openNodeSqliteDatabase } from "./node-sqlite.js";
|
|
8
|
+
import { validateStoragePrefix } from "./prefix.js";
|
|
9
|
+
import { selectStorage } from "./selection.js";
|
|
10
|
+
const databaseIds = new WeakMap();
|
|
11
|
+
let nextDatabaseId = 0;
|
|
12
|
+
function storageOptionKey(value) {
|
|
13
|
+
if (value instanceof Uint8Array)
|
|
14
|
+
return ["bytes", Array.from(value)];
|
|
15
|
+
if (value === null)
|
|
16
|
+
return ["null", null];
|
|
17
|
+
if (typeof value === "number")
|
|
18
|
+
return ["number", Object.is(value, -0) ? "-0" : String(value)];
|
|
19
|
+
if (typeof value === "bigint")
|
|
20
|
+
return ["bigint", String(value)];
|
|
21
|
+
return [typeof value, value];
|
|
22
|
+
}
|
|
23
|
+
export function storageSelectionKey(selection, agentDir) {
|
|
24
|
+
if (selection.kind === "database") {
|
|
25
|
+
let id = databaseIds.get(selection.database);
|
|
26
|
+
if (id === undefined) {
|
|
27
|
+
id = ++nextDatabaseId;
|
|
28
|
+
databaseIds.set(selection.database, id);
|
|
29
|
+
}
|
|
30
|
+
return JSON.stringify(["database", id, selection.prefix ?? ""]);
|
|
31
|
+
}
|
|
32
|
+
if (selection.kind === "sqlite") {
|
|
33
|
+
const path = selection.path === "" || selection.path === ":memory:" ? selection.path : resolve(selection.path);
|
|
34
|
+
return JSON.stringify(["sqlite", path, selection.prefix ?? ""]);
|
|
35
|
+
}
|
|
36
|
+
if (selection.kind === "adapter") {
|
|
37
|
+
const options = Object.entries(selection.options ?? {})
|
|
38
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
39
|
+
.map(([name, value]) => [name, storageOptionKey(value)]);
|
|
40
|
+
const secrets = Object.entries(selection.secrets ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
41
|
+
return JSON.stringify(["adapter", agentDir, selection.module, options, secrets, selection.prefix ?? ""]);
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(selection);
|
|
44
|
+
}
|
|
45
|
+
export async function loadStorageAdapter(module, context) {
|
|
46
|
+
try {
|
|
47
|
+
const loader = createJiti(pathToFileURL(join(context.agentDir, "storage-adapter.js")).href, {
|
|
48
|
+
interopDefault: true,
|
|
49
|
+
});
|
|
50
|
+
const adapter = await loader.import(module, { default: true });
|
|
51
|
+
if (adapter === null ||
|
|
52
|
+
typeof adapter !== "object" ||
|
|
53
|
+
adapter.atomicStorageAdapter !== 1 ||
|
|
54
|
+
[adapter.openDatabase, adapter.openSessionStore, adapter.openRunJournal].some((hook) => hook !== undefined && typeof hook !== "function")) {
|
|
55
|
+
throw new StorageConfigError("sdk", "adapter", "invalid-module-contract");
|
|
56
|
+
}
|
|
57
|
+
return adapter;
|
|
58
|
+
}
|
|
59
|
+
catch (cause) {
|
|
60
|
+
throw new StorageAdapterLoadError(module, cause);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function adapterOptions(selection, context) {
|
|
64
|
+
const options = { ...selection.options };
|
|
65
|
+
for (const [name, ref] of Object.entries(selection.secrets ?? {})) {
|
|
66
|
+
let value;
|
|
67
|
+
if ("env" in ref) {
|
|
68
|
+
const environment = process.env[ref.env];
|
|
69
|
+
if (environment === undefined)
|
|
70
|
+
throw new StorageConfigError("sdk", `secrets.${name}`, "secret-env-missing");
|
|
71
|
+
value = environment;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
try {
|
|
75
|
+
value = await readFile(isAbsolute(ref.file) ? ref.file : join(dirname(context.agentDir), ref.file), "utf8");
|
|
76
|
+
}
|
|
77
|
+
catch (cause) {
|
|
78
|
+
throw new StorageUnavailableError({ adapter: selection.module, location: ref.file }, cause);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
Object.defineProperty(options, name, { value, enumerable: true, writable: true, configurable: true });
|
|
82
|
+
}
|
|
83
|
+
return options;
|
|
84
|
+
}
|
|
85
|
+
function withIdempotentClose(store, release) {
|
|
86
|
+
const close = store.close.bind(store);
|
|
87
|
+
let closing;
|
|
88
|
+
store.close = () => {
|
|
89
|
+
closing ??= (async () => {
|
|
90
|
+
try {
|
|
91
|
+
await close();
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
await release?.();
|
|
95
|
+
}
|
|
96
|
+
})();
|
|
97
|
+
return closing;
|
|
98
|
+
};
|
|
99
|
+
return store;
|
|
100
|
+
}
|
|
101
|
+
const sharedDatabases = new Map();
|
|
102
|
+
export const StorageProvider = class {
|
|
103
|
+
journals;
|
|
104
|
+
databases = sharedDatabases;
|
|
105
|
+
constructor(journals) {
|
|
106
|
+
this.journals = journals;
|
|
107
|
+
}
|
|
108
|
+
async openSessionStore(selection, context) {
|
|
109
|
+
return this.open(selection, context, {
|
|
110
|
+
memory: async () => new (await import("./session/memory-session-store.js")).MemorySessionStore(createSessionCwdMatcher),
|
|
111
|
+
jsonl: async (dir) => (await import("./session/jsonl-session-store.js")).JsonlSessionStore.open(dir, { exactDirectory: true }),
|
|
112
|
+
direct: (adapter, options, storage) => adapter.openSessionStore?.(options, context, storage),
|
|
113
|
+
sql: async (database, options) => (await import("./session/sql-session-store.js")).SqlSessionStore.open(database, {
|
|
114
|
+
...options,
|
|
115
|
+
cwdMatcher: createSessionCwdMatcher,
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async openRunJournal(selection, context) {
|
|
120
|
+
const journals = this.journals;
|
|
121
|
+
if (!journals)
|
|
122
|
+
throw new StorageConfigError("sdk", "journal", "adapter-domain-unsupported");
|
|
123
|
+
return this.open(selection, context, {
|
|
124
|
+
memory: () => journals.memory({ adapter: "memory", location: ":memory:" }),
|
|
125
|
+
direct: (adapter, options, storage) => adapter.openRunJournal?.(options, context, storage),
|
|
126
|
+
sql: async (database, options) => {
|
|
127
|
+
const journal = await journals.sql(database, options);
|
|
128
|
+
const createRun = journal.createRun.bind(journal);
|
|
129
|
+
journal.createRun = (header) => createRun({ ...header, storage: { ...database.descriptor } });
|
|
130
|
+
return journal;
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async open(selection, context, factories) {
|
|
135
|
+
if (selection === null || typeof selection !== "object" || Array.isArray(selection)) {
|
|
136
|
+
throw new StorageConfigError("sdk", "storage", "selection-object-required");
|
|
137
|
+
}
|
|
138
|
+
if (!["memory", "jsonl", "sqlite", "database", "adapter"].includes(selection.kind)) {
|
|
139
|
+
throw new StorageConfigError("sdk", "storage", "invalid-kind");
|
|
140
|
+
}
|
|
141
|
+
const selector = { memory: undefined, jsonl: "dir", sqlite: "path", database: "database", adapter: "module" }[selection.kind];
|
|
142
|
+
if (["path", "dir", "database", "module", "memory", "adapter"].some((key) => key in selection && key !== selector)) {
|
|
143
|
+
throw new StorageConfigError("sdk", "storage", "multiple-selection-forms");
|
|
144
|
+
}
|
|
145
|
+
if (selection.kind === "sqlite" && typeof selection.path !== "string") {
|
|
146
|
+
throw new StorageConfigError("sdk", "storage", "invalid-path");
|
|
147
|
+
}
|
|
148
|
+
if (selection.kind === "adapter" && (typeof selection.module !== "string" || selection.module.length === 0)) {
|
|
149
|
+
throw new StorageConfigError("sdk", "storage", "invalid-adapter");
|
|
150
|
+
}
|
|
151
|
+
if (selection.kind === "database" && !("database" in selection)) {
|
|
152
|
+
throw new StorageConfigError("sdk", "storage", "async-database-required");
|
|
153
|
+
}
|
|
154
|
+
if (selection.kind === "sqlite" || selection.kind === "database" || selection.kind === "adapter") {
|
|
155
|
+
selectStorage(selection.kind === "adapter" ? { ...selection, adapter: selection.module } : selection, "sdk", "storage", "");
|
|
156
|
+
}
|
|
157
|
+
if (selection.kind === "memory")
|
|
158
|
+
return withIdempotentClose(await factories.memory());
|
|
159
|
+
if (selection.kind === "jsonl") {
|
|
160
|
+
if (typeof selection.dir !== "string")
|
|
161
|
+
throw new StorageConfigError("sdk", "dir", "invalid-dir");
|
|
162
|
+
if (factories.jsonl)
|
|
163
|
+
return withIdempotentClose(await factories.jsonl(selection.dir));
|
|
164
|
+
throw new StorageConfigError("sdk", "dir", "adapter-domain-unsupported");
|
|
165
|
+
}
|
|
166
|
+
validateStoragePrefix(selection.prefix);
|
|
167
|
+
let openDatabase;
|
|
168
|
+
if (selection.kind === "adapter") {
|
|
169
|
+
const adapter = await loadStorageAdapter(selection.module, context);
|
|
170
|
+
const options = await adapterOptions(selection, context);
|
|
171
|
+
try {
|
|
172
|
+
const direct = factories.direct(adapter, options, { prefix: selection.prefix });
|
|
173
|
+
if (direct !== undefined)
|
|
174
|
+
return withIdempotentClose(await direct);
|
|
175
|
+
}
|
|
176
|
+
catch (cause) {
|
|
177
|
+
if (cause instanceof StorageError)
|
|
178
|
+
throw cause;
|
|
179
|
+
throw new StorageUnavailableError({ adapter: selection.module, location: selection.module }, cause);
|
|
180
|
+
}
|
|
181
|
+
if (!adapter.openDatabase)
|
|
182
|
+
throw new StorageConfigError("sdk", "adapter", "adapter-domain-unsupported");
|
|
183
|
+
const hook = adapter.openDatabase.bind(adapter);
|
|
184
|
+
openDatabase = async () => {
|
|
185
|
+
try {
|
|
186
|
+
return await hook(options, context);
|
|
187
|
+
}
|
|
188
|
+
catch (cause) {
|
|
189
|
+
if (cause instanceof StorageError)
|
|
190
|
+
throw cause;
|
|
191
|
+
throw new StorageUnavailableError({ adapter: selection.module, location: selection.module }, cause);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
else if (selection.kind === "database") {
|
|
196
|
+
return withIdempotentClose(await factories.sql(selection.database, { prefix: selection.prefix }));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
openDatabase = () => openNodeSqliteDatabase(selection.path);
|
|
200
|
+
}
|
|
201
|
+
const key = storageSelectionKey({ ...selection, prefix: undefined }, context.agentDir);
|
|
202
|
+
let shared = this.databases.get(key);
|
|
203
|
+
if (!shared) {
|
|
204
|
+
shared = { ready: openDatabase(), references: 0 };
|
|
205
|
+
this.databases.set(key, shared);
|
|
206
|
+
}
|
|
207
|
+
shared.references++;
|
|
208
|
+
const entry = shared;
|
|
209
|
+
let database;
|
|
210
|
+
try {
|
|
211
|
+
database = await entry.ready;
|
|
212
|
+
}
|
|
213
|
+
catch (cause) {
|
|
214
|
+
if (this.databases.get(key) === entry)
|
|
215
|
+
this.databases.delete(key);
|
|
216
|
+
throw cause;
|
|
217
|
+
}
|
|
218
|
+
const release = async () => {
|
|
219
|
+
if (--entry.references === 0) {
|
|
220
|
+
if (this.databases.get(key) === entry)
|
|
221
|
+
this.databases.delete(key);
|
|
222
|
+
await database.close();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
try {
|
|
226
|
+
return withIdempotentClose(await factories.sql(database, { prefix: selection.prefix }), release);
|
|
227
|
+
}
|
|
228
|
+
catch (cause) {
|
|
229
|
+
try {
|
|
230
|
+
await release();
|
|
231
|
+
}
|
|
232
|
+
catch (cleanupCause) {
|
|
233
|
+
const openingError = cause instanceof Error
|
|
234
|
+
? cause
|
|
235
|
+
: new StorageUnavailableError(database.descriptor, cause);
|
|
236
|
+
Object.defineProperty(openingError, "cleanupCause", { value: cleanupCause, configurable: true });
|
|
237
|
+
throw openingError;
|
|
238
|
+
}
|
|
239
|
+
throw cause;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/core/storage/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EAEZ,uBAAuB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE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AE,CAAC,EAAE,OAAO,CAAC,CAAC;QAClG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC;gBACJ,MAAM,OAAO,EAAE,CAAC;YACjB,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACvB,MAAM,YAAY,GACjB,KAAK,YAAY,KAAK;oBACrB,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,UAAU,EAAE,KAA4B,CAAC,CAAC;gBACnF,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;gBACjG,MAAM,YAAY,CAAC;YACpB,CAAC;YACD,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { createJiti } from \"jiti\";\nimport { createSessionCwdMatcher } from \"../../utils/canonical-path.ts\";\nimport type { SqliteDatabase, SqliteValue, StorageDescriptor } from \"./database.js\";\nimport {\n\tStorageAdapterLoadError,\n\tStorageConfigError,\n\tStorageError,\n\ttype StorageFailureCause,\n\tStorageUnavailableError,\n} from \"./errors.js\";\nimport { openNodeSqliteDatabase } from \"./node-sqlite.js\";\nimport { validateStoragePrefix } from \"./prefix.js\";\nimport type { RunJournal } from \"./run-journal.js\";\nimport { selectStorage } from \"./selection.js\";\nimport type { SessionStore } from \"./session/types.js\";\n\nexport type SecretRef = { readonly env: string } | { readonly file: string };\nexport type AdapterOptions = Readonly<Record<string, SqliteValue | boolean>>;\nexport type StorageSelection =\n\t| { readonly kind: \"memory\" }\n\t| { readonly kind: \"jsonl\"; readonly dir: string }\n\t| { readonly kind: \"sqlite\"; readonly path: string; readonly prefix?: string }\n\t| { readonly kind: \"database\"; readonly database: SqliteDatabase; readonly prefix?: string }\n\t| {\n\t\t\treadonly kind: \"adapter\";\n\t\t\treadonly module: string;\n\t\t\treadonly options?: AdapterOptions;\n\t\t\treadonly secrets?: Readonly<Record<string, SecretRef>>;\n\t\t\treadonly prefix?: string;\n\t };\nexport interface StorageOpenContext {\n\treadonly agentDir: string;\n\treadonly domain: \"sessions\" | \"journal\";\n\treadonly signal?: AbortSignal;\n}\nexport interface StorageAdapterModule {\n\treadonly atomicStorageAdapter: 1;\n\topenDatabase?(options: AdapterOptions, context: StorageOpenContext): Promise<SqliteDatabase>;\n\topenSessionStore?(\n\t\toptions: AdapterOptions,\n\t\tcontext: StorageOpenContext,\n\t\tstorage: { readonly prefix?: string },\n\t): Promise<SessionStore>;\n\topenRunJournal?(\n\t\toptions: AdapterOptions,\n\t\tcontext: StorageOpenContext,\n\t\tstorage: { readonly prefix?: string },\n\t): Promise<RunJournal>;\n}\nexport interface JournalFactories {\n\tmemory(descriptor: StorageDescriptor): RunJournal;\n\tsql(database: SqliteDatabase, options: { readonly prefix?: string }): Promise<RunJournal>;\n}\n\nconst databaseIds = new WeakMap<SqliteDatabase, number>();\nlet nextDatabaseId = 0;\n\nfunction storageOptionKey(\n\tvalue: SqliteValue | boolean,\n): readonly [string, string | boolean | readonly number[] | null] {\n\tif (value instanceof Uint8Array) return [\"bytes\", Array.from(value)];\n\tif (value === null) return [\"null\", null];\n\tif (typeof value === \"number\") return [\"number\", Object.is(value, -0) ? \"-0\" : String(value)];\n\tif (typeof value === \"bigint\") return [\"bigint\", String(value)];\n\treturn [typeof value, value];\n}\n\nexport function storageSelectionKey(selection: StorageSelection, agentDir?: string): string {\n\tif (selection.kind === \"database\") {\n\t\tlet id = databaseIds.get(selection.database);\n\t\tif (id === undefined) {\n\t\t\tid = ++nextDatabaseId;\n\t\t\tdatabaseIds.set(selection.database, id);\n\t\t}\n\t\treturn JSON.stringify([\"database\", id, selection.prefix ?? \"\"]);\n\t}\n\tif (selection.kind === \"sqlite\") {\n\t\tconst path = selection.path === \"\" || selection.path === \":memory:\" ? selection.path : resolve(selection.path);\n\t\treturn JSON.stringify([\"sqlite\", path, selection.prefix ?? \"\"]);\n\t}\n\tif (selection.kind === \"adapter\") {\n\t\tconst options = Object.entries(selection.options ?? {})\n\t\t\t.sort(([a], [b]) => a.localeCompare(b))\n\t\t\t.map(([name, value]) => [name, storageOptionKey(value)]);\n\t\tconst secrets = Object.entries(selection.secrets ?? {}).sort(([a], [b]) => a.localeCompare(b));\n\t\treturn JSON.stringify([\"adapter\", agentDir, selection.module, options, secrets, selection.prefix ?? \"\"]);\n\t}\n\treturn JSON.stringify(selection);\n}\n\nexport async function loadStorageAdapter(module: string, context: StorageOpenContext): Promise<StorageAdapterModule> {\n\ttry {\n\t\tconst loader = createJiti(pathToFileURL(join(context.agentDir, \"storage-adapter.js\")).href, {\n\t\t\tinteropDefault: true,\n\t\t});\n\t\tconst adapter = await loader.import<StorageAdapterModule>(module, { default: true });\n\t\tif (\n\t\t\tadapter === null ||\n\t\t\ttypeof adapter !== \"object\" ||\n\t\t\tadapter.atomicStorageAdapter !== 1 ||\n\t\t\t[adapter.openDatabase, adapter.openSessionStore, adapter.openRunJournal].some(\n\t\t\t\t(hook) => hook !== undefined && typeof hook !== \"function\",\n\t\t\t)\n\t\t) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"adapter\", \"invalid-module-contract\");\n\t\t}\n\t\treturn adapter;\n\t} catch (cause) {\n\t\tthrow new StorageAdapterLoadError(module, cause as StorageFailureCause);\n\t}\n}\n\nasync function adapterOptions(\n\tselection: Extract<StorageSelection, { kind: \"adapter\" }>,\n\tcontext: StorageOpenContext,\n): Promise<AdapterOptions> {\n\tconst options = { ...selection.options };\n\tfor (const [name, ref] of Object.entries(selection.secrets ?? {})) {\n\t\tlet value: string;\n\t\tif (\"env\" in ref) {\n\t\t\tconst environment = process.env[ref.env];\n\t\t\tif (environment === undefined) throw new StorageConfigError(\"sdk\", `secrets.${name}`, \"secret-env-missing\");\n\t\t\tvalue = environment;\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tvalue = await readFile(isAbsolute(ref.file) ? ref.file : join(dirname(context.agentDir), ref.file), \"utf8\");\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new StorageUnavailableError(\n\t\t\t\t\t{ adapter: selection.module, location: ref.file },\n\t\t\t\t\tcause as StorageFailureCause,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tObject.defineProperty(options, name, { value, enumerable: true, writable: true, configurable: true });\n\t}\n\treturn options;\n}\n\nfunction withIdempotentClose<T extends { close(): Promise<void> }>(store: T, release?: () => Promise<void>): T {\n\tconst close = store.close.bind(store);\n\tlet closing: Promise<void> | undefined;\n\tstore.close = () => {\n\t\tclosing ??= (async () => {\n\t\t\ttry {\n\t\t\t\tawait close();\n\t\t\t} finally {\n\t\t\t\tawait release?.();\n\t\t\t}\n\t\t})();\n\t\treturn closing;\n\t};\n\treturn store;\n}\n\ninterface SharedDatabase {\n\treadonly ready: Promise<SqliteDatabase>;\n\treferences: number;\n}\n\nconst sharedDatabases = new Map<string, SharedDatabase>();\n\nexport interface StorageProvider {\n\topenSessionStore(selection: StorageSelection, context: StorageOpenContext): Promise<SessionStore>;\n\topenRunJournal(selection: StorageSelection, context: StorageOpenContext): Promise<RunJournal>;\n}\n\nexport const StorageProvider: new (journals?: JournalFactories) => StorageProvider = class {\n\tprivate readonly journals?: JournalFactories;\n\tprivate readonly databases = sharedDatabases;\n\n\tconstructor(journals?: JournalFactories) {\n\t\tthis.journals = journals;\n\t}\n\n\tasync openSessionStore(selection: StorageSelection, context: StorageOpenContext): Promise<SessionStore> {\n\t\treturn this.open<SessionStore>(selection, context, {\n\t\t\tmemory: async () =>\n\t\t\t\tnew (await import(\"./session/memory-session-store.js\")).MemorySessionStore(createSessionCwdMatcher),\n\t\t\tjsonl: async (dir) =>\n\t\t\t\t(await import(\"./session/jsonl-session-store.js\")).JsonlSessionStore.open(dir, { exactDirectory: true }),\n\t\t\tdirect: (adapter, options, storage) => adapter.openSessionStore?.(options, context, storage),\n\t\t\tsql: async (database, options) =>\n\t\t\t\t(await import(\"./session/sql-session-store.js\")).SqlSessionStore.open(database, {\n\t\t\t\t\t...options,\n\t\t\t\t\tcwdMatcher: createSessionCwdMatcher,\n\t\t\t\t}),\n\t\t});\n\t}\n\n\tasync openRunJournal(selection: StorageSelection, context: StorageOpenContext): Promise<RunJournal> {\n\t\tconst journals = this.journals;\n\t\tif (!journals) throw new StorageConfigError(\"sdk\", \"journal\", \"adapter-domain-unsupported\");\n\t\treturn this.open<RunJournal>(selection, context, {\n\t\t\tmemory: () => journals.memory({ adapter: \"memory\", location: \":memory:\" }),\n\t\t\tdirect: (adapter, options, storage) => adapter.openRunJournal?.(options, context, storage),\n\t\t\tsql: async (database, options) => {\n\t\t\t\tconst journal = await journals.sql(database, options);\n\t\t\t\tconst createRun = journal.createRun.bind(journal);\n\t\t\t\tjournal.createRun = (header) => createRun({ ...header, storage: { ...database.descriptor } });\n\t\t\t\treturn journal;\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate async open<T extends { close(): Promise<void> }>(\n\t\tselection: StorageSelection,\n\t\tcontext: StorageOpenContext,\n\t\tfactories: {\n\t\t\tmemory(): T | Promise<T>;\n\t\t\tjsonl?(dir: string): Promise<T>;\n\t\t\tdirect(\n\t\t\t\tadapter: StorageAdapterModule,\n\t\t\t\toptions: AdapterOptions,\n\t\t\t\tstorage: { readonly prefix?: string },\n\t\t\t): Promise<T> | undefined;\n\t\t\tsql(database: SqliteDatabase, options: { readonly prefix?: string }): Promise<T>;\n\t\t},\n\t): Promise<T> {\n\t\tif (selection === null || typeof selection !== \"object\" || Array.isArray(selection)) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"selection-object-required\");\n\t\t}\n\t\tif (![\"memory\", \"jsonl\", \"sqlite\", \"database\", \"adapter\"].includes(selection.kind)) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"invalid-kind\");\n\t\t}\n\t\tconst selector = { memory: undefined, jsonl: \"dir\", sqlite: \"path\", database: \"database\", adapter: \"module\" }[\n\t\t\tselection.kind\n\t\t];\n\t\tif (\n\t\t\t[\"path\", \"dir\", \"database\", \"module\", \"memory\", \"adapter\"].some((key) => key in selection && key !== selector)\n\t\t) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"multiple-selection-forms\");\n\t\t}\n\t\tif (selection.kind === \"sqlite\" && typeof selection.path !== \"string\") {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"invalid-path\");\n\t\t}\n\t\tif (selection.kind === \"adapter\" && (typeof selection.module !== \"string\" || selection.module.length === 0)) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"invalid-adapter\");\n\t\t}\n\t\tif (selection.kind === \"database\" && !(\"database\" in selection)) {\n\t\t\tthrow new StorageConfigError(\"sdk\", \"storage\", \"async-database-required\");\n\t\t}\n\t\tif (selection.kind === \"sqlite\" || selection.kind === \"database\" || selection.kind === \"adapter\") {\n\t\t\tselectStorage(\n\t\t\t\tselection.kind === \"adapter\" ? { ...selection, adapter: selection.module } : selection,\n\t\t\t\t\"sdk\",\n\t\t\t\t\"storage\",\n\t\t\t\t\"\",\n\t\t\t);\n\t\t}\n\t\tif (selection.kind === \"memory\") return withIdempotentClose(await factories.memory());\n\t\tif (selection.kind === \"jsonl\") {\n\t\t\tif (typeof selection.dir !== \"string\") throw new StorageConfigError(\"sdk\", \"dir\", \"invalid-dir\");\n\t\t\tif (factories.jsonl) return withIdempotentClose(await factories.jsonl(selection.dir));\n\t\t\tthrow new StorageConfigError(\"sdk\", \"dir\", \"adapter-domain-unsupported\");\n\t\t}\n\t\tvalidateStoragePrefix(selection.prefix);\n\t\tlet openDatabase: () => Promise<SqliteDatabase>;\n\t\tif (selection.kind === \"adapter\") {\n\t\t\tconst adapter = await loadStorageAdapter(selection.module, context);\n\t\t\tconst options = await adapterOptions(selection, context);\n\t\t\ttry {\n\t\t\t\tconst direct = factories.direct(adapter, options, { prefix: selection.prefix });\n\t\t\t\tif (direct !== undefined) return withIdempotentClose(await direct);\n\t\t\t} catch (cause) {\n\t\t\t\tif (cause instanceof StorageError) throw cause;\n\t\t\t\tthrow new StorageUnavailableError(\n\t\t\t\t\t{ adapter: selection.module, location: selection.module },\n\t\t\t\t\tcause as StorageFailureCause,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!adapter.openDatabase) throw new StorageConfigError(\"sdk\", \"adapter\", \"adapter-domain-unsupported\");\n\t\t\tconst hook = adapter.openDatabase.bind(adapter);\n\t\t\topenDatabase = async () => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await hook(options, context);\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tif (cause instanceof StorageError) throw cause;\n\t\t\t\t\tthrow new StorageUnavailableError(\n\t\t\t\t\t\t{ adapter: selection.module, location: selection.module },\n\t\t\t\t\t\tcause as StorageFailureCause,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t} else if (selection.kind === \"database\") {\n\t\t\treturn withIdempotentClose(await factories.sql(selection.database, { prefix: selection.prefix }));\n\t\t} else {\n\t\t\topenDatabase = () => openNodeSqliteDatabase(selection.path);\n\t\t}\n\t\tconst key = storageSelectionKey({ ...selection, prefix: undefined }, context.agentDir);\n\t\tlet shared = this.databases.get(key);\n\t\tif (!shared) {\n\t\t\tshared = { ready: openDatabase(), references: 0 };\n\t\t\tthis.databases.set(key, shared);\n\t\t}\n\t\tshared.references++;\n\t\tconst entry = shared;\n\t\tlet database: SqliteDatabase;\n\t\ttry {\n\t\t\tdatabase = await entry.ready;\n\t\t} catch (cause) {\n\t\t\tif (this.databases.get(key) === entry) this.databases.delete(key);\n\t\t\tthrow cause;\n\t\t}\n\t\tconst release = async () => {\n\t\t\tif (--entry.references === 0) {\n\t\t\t\tif (this.databases.get(key) === entry) this.databases.delete(key);\n\t\t\t\tawait database.close();\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\treturn withIdempotentClose(await factories.sql(database, { prefix: selection.prefix }), release);\n\t\t} catch (cause) {\n\t\t\ttry {\n\t\t\t\tawait release();\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tconst openingError =\n\t\t\t\t\tcause instanceof Error\n\t\t\t\t\t\t? cause\n\t\t\t\t\t\t: new StorageUnavailableError(database.descriptor, cause as StorageFailureCause);\n\t\t\t\tObject.defineProperty(openingError, \"cleanupCause\", { value: cleanupCause, configurable: true });\n\t\t\t\tthrow openingError;\n\t\t\t}\n\t\t\tthrow cause;\n\t\t}\n\t}\n};\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { StorageDescriptor } from "./database.js";
|
|
2
|
+
export declare const RUN_EVENT_TYPES: {
|
|
3
|
+
readonly runStarted: "RunStarted";
|
|
4
|
+
readonly runFinished: "RunFinished";
|
|
5
|
+
readonly statusChanged: "StatusChanged";
|
|
6
|
+
readonly checkpointRecorded: "CheckpointRecorded";
|
|
7
|
+
readonly promptAsked: "PromptAsked";
|
|
8
|
+
readonly promptReleased: "PromptReleased";
|
|
9
|
+
readonly controlRequested: "ControlRequested";
|
|
10
|
+
readonly messageQueued: "MessageQueued";
|
|
11
|
+
readonly messageDelivered: "MessageDelivered";
|
|
12
|
+
readonly messageSettled: "MessageSettled";
|
|
13
|
+
readonly timerScheduled: "TimerScheduled";
|
|
14
|
+
readonly summaryRecorded: "SummaryRecorded";
|
|
15
|
+
};
|
|
16
|
+
export type RunEventType = (typeof RUN_EVENT_TYPES)[keyof typeof RUN_EVENT_TYPES];
|
|
17
|
+
export type JournalSerializableValue = string | number | boolean | null | readonly JournalSerializableValue[] | {
|
|
18
|
+
readonly [key: string]: JournalSerializableValue | undefined;
|
|
19
|
+
};
|
|
20
|
+
export interface RunHeader {
|
|
21
|
+
readonly runId: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly cwd: string;
|
|
24
|
+
readonly createdAt: number;
|
|
25
|
+
readonly status: string;
|
|
26
|
+
readonly inputs?: JournalSerializableValue;
|
|
27
|
+
readonly storage?: StorageDescriptor;
|
|
28
|
+
}
|
|
29
|
+
export type RunSummary = RunHeader;
|
|
30
|
+
type EventOf<Type extends string, Payload = JournalSerializableValue> = {
|
|
31
|
+
readonly type: Type;
|
|
32
|
+
readonly payload: Payload;
|
|
33
|
+
};
|
|
34
|
+
export type RunEvent = EventOf<"RunStarted" | "RunFinished"> | EventOf<"StatusChanged", {
|
|
35
|
+
readonly status: string;
|
|
36
|
+
readonly [key: string]: JournalSerializableValue;
|
|
37
|
+
}> | EventOf<"CheckpointRecorded", {
|
|
38
|
+
readonly kind: "tool" | "ui" | "stage" | "task" | "boundary";
|
|
39
|
+
readonly [key: string]: JournalSerializableValue;
|
|
40
|
+
}> | EventOf<"PromptAsked" | "PromptReleased" | "ControlRequested" | "MessageQueued" | "MessageDelivered" | "MessageSettled" | "TimerScheduled" | "SummaryRecorded">;
|
|
41
|
+
export interface Lease {
|
|
42
|
+
readonly runId: string;
|
|
43
|
+
readonly holderId: string;
|
|
44
|
+
readonly epoch: number;
|
|
45
|
+
}
|
|
46
|
+
export type LeaseState = Lease & {
|
|
47
|
+
readonly renewedAt: number;
|
|
48
|
+
readonly ageMs: number;
|
|
49
|
+
};
|
|
50
|
+
export type LeaseOutcome = {
|
|
51
|
+
readonly status: "acquired";
|
|
52
|
+
readonly lease: Lease;
|
|
53
|
+
} | {
|
|
54
|
+
readonly status: "held";
|
|
55
|
+
readonly holderId: string | null;
|
|
56
|
+
readonly epoch: number;
|
|
57
|
+
};
|
|
58
|
+
export interface JournalEntry {
|
|
59
|
+
readonly runId: string;
|
|
60
|
+
readonly seq: number;
|
|
61
|
+
readonly epoch: number;
|
|
62
|
+
readonly key?: string;
|
|
63
|
+
readonly event: RunEvent;
|
|
64
|
+
readonly at: number;
|
|
65
|
+
}
|
|
66
|
+
export type AppendOutcome = {
|
|
67
|
+
readonly status: "appended" | "exists";
|
|
68
|
+
readonly entry: JournalEntry;
|
|
69
|
+
};
|
|
70
|
+
export interface RunJournal {
|
|
71
|
+
createRun(header: RunHeader): Promise<"created" | "exists">;
|
|
72
|
+
getRun(runId: string): Promise<RunSummary | undefined>;
|
|
73
|
+
listRuns(filter?: {
|
|
74
|
+
cwd?: string;
|
|
75
|
+
}): Promise<readonly RunSummary[]>;
|
|
76
|
+
acquire(runId: string, holderId: string): Promise<LeaseOutcome>;
|
|
77
|
+
takeover(runId: string, holderId: string, expectedHolder: string): Promise<LeaseOutcome>;
|
|
78
|
+
takeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise<LeaseOutcome>;
|
|
79
|
+
leaseState(runId: string): Promise<LeaseState | undefined>;
|
|
80
|
+
renew(lease: Lease): Promise<void>;
|
|
81
|
+
release(lease: Lease): Promise<void>;
|
|
82
|
+
append(lease: Lease, event: RunEvent, options?: {
|
|
83
|
+
key?: string;
|
|
84
|
+
expectSeq?: number;
|
|
85
|
+
}): Promise<AppendOutcome>;
|
|
86
|
+
read(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;
|
|
87
|
+
readKey(runId: string, key: string): Promise<JournalEntry | undefined>;
|
|
88
|
+
deleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;
|
|
89
|
+
deleteRun(runId: string): Promise<void>;
|
|
90
|
+
close(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=run-journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-journal.d.ts","sourceRoot":"","sources":["../../../src/core/storage/run-journal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,eAAO,MAAM,eAAe;aAC3B,UAAU,EAAE,YAAY;aACxB,WAAW,EAAE,aAAa;aAC1B,aAAa,EAAE,eAAe;aAC9B,kBAAkB,EAAE,oBAAoB;aACxC,WAAW,EAAE,aAAa;aAC1B,cAAc,EAAE,gBAAgB;aAChC,gBAAgB,EAAE,kBAAkB;aACpC,aAAa,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GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;IACvE,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const RUN_EVENT_TYPES = {
|
|
2
|
+
runStarted: "RunStarted",
|
|
3
|
+
runFinished: "RunFinished",
|
|
4
|
+
statusChanged: "StatusChanged",
|
|
5
|
+
checkpointRecorded: "CheckpointRecorded",
|
|
6
|
+
promptAsked: "PromptAsked",
|
|
7
|
+
promptReleased: "PromptReleased",
|
|
8
|
+
controlRequested: "ControlRequested",
|
|
9
|
+
messageQueued: "MessageQueued",
|
|
10
|
+
messageDelivered: "MessageDelivered",
|
|
11
|
+
messageSettled: "MessageSettled",
|
|
12
|
+
timerScheduled: "TimerScheduled",
|
|
13
|
+
summaryRecorded: "SummaryRecorded",
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=run-journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-journal.js","sourceRoot":"","sources":["../../../src/core/storage/run-journal.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;CACzB,CAAC","sourcesContent":["import type { StorageDescriptor } from \"./database.js\";\n\nexport const RUN_EVENT_TYPES = {\n\trunStarted: \"RunStarted\",\n\trunFinished: \"RunFinished\",\n\tstatusChanged: \"StatusChanged\",\n\tcheckpointRecorded: \"CheckpointRecorded\",\n\tpromptAsked: \"PromptAsked\",\n\tpromptReleased: \"PromptReleased\",\n\tcontrolRequested: \"ControlRequested\",\n\tmessageQueued: \"MessageQueued\",\n\tmessageDelivered: \"MessageDelivered\",\n\tmessageSettled: \"MessageSettled\",\n\ttimerScheduled: \"TimerScheduled\",\n\tsummaryRecorded: \"SummaryRecorded\",\n} as const;\nexport type RunEventType = (typeof RUN_EVENT_TYPES)[keyof typeof RUN_EVENT_TYPES];\n\nexport type JournalSerializableValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly JournalSerializableValue[]\n\t| { readonly [key: string]: JournalSerializableValue | undefined };\n\nexport interface RunHeader {\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly cwd: string;\n\treadonly createdAt: number;\n\treadonly status: string;\n\treadonly inputs?: JournalSerializableValue;\n\treadonly storage?: StorageDescriptor;\n}\nexport type RunSummary = RunHeader;\n\ntype EventOf<Type extends string, Payload = JournalSerializableValue> = {\n\treadonly type: Type;\n\treadonly payload: Payload;\n};\nexport type RunEvent =\n\t| EventOf<\"RunStarted\" | \"RunFinished\">\n\t| EventOf<\"StatusChanged\", { readonly status: string; readonly [key: string]: JournalSerializableValue }>\n\t| EventOf<\n\t\t\t\"CheckpointRecorded\",\n\t\t\t{\n\t\t\t\treadonly kind: \"tool\" | \"ui\" | \"stage\" | \"task\" | \"boundary\";\n\t\t\t\treadonly [key: string]: JournalSerializableValue;\n\t\t\t}\n\t >\n\t| EventOf<\n\t\t\t| \"PromptAsked\"\n\t\t\t| \"PromptReleased\"\n\t\t\t| \"ControlRequested\"\n\t\t\t| \"MessageQueued\"\n\t\t\t| \"MessageDelivered\"\n\t\t\t| \"MessageSettled\"\n\t\t\t| \"TimerScheduled\"\n\t\t\t| \"SummaryRecorded\"\n\t >;\nexport interface Lease {\n\treadonly runId: string;\n\treadonly holderId: string;\n\treadonly epoch: number;\n}\nexport type LeaseState = Lease & { readonly renewedAt: number; readonly ageMs: number };\nexport type LeaseOutcome =\n\t| { readonly status: \"acquired\"; readonly lease: Lease }\n\t| { readonly status: \"held\"; readonly holderId: string | null; readonly epoch: number };\nexport interface JournalEntry {\n\treadonly runId: string;\n\treadonly seq: number;\n\treadonly epoch: number;\n\treadonly key?: string;\n\treadonly event: RunEvent;\n\treadonly at: number;\n}\nexport type AppendOutcome = { readonly status: \"appended\" | \"exists\"; readonly entry: JournalEntry };\nexport interface RunJournal {\n\tcreateRun(header: RunHeader): Promise<\"created\" | \"exists\">;\n\tgetRun(runId: string): Promise<RunSummary | undefined>;\n\tlistRuns(filter?: { cwd?: string }): Promise<readonly RunSummary[]>;\n\tacquire(runId: string, holderId: string): Promise<LeaseOutcome>;\n\ttakeover(runId: string, holderId: string, expectedHolder: string): Promise<LeaseOutcome>;\n\ttakeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise<LeaseOutcome>;\n\tleaseState(runId: string): Promise<LeaseState | undefined>;\n\trenew(lease: Lease): Promise<void>;\n\trelease(lease: Lease): Promise<void>;\n\tappend(lease: Lease, event: RunEvent, options?: { key?: string; expectSeq?: number }): Promise<AppendOutcome>;\n\tread(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;\n\treadKey(runId: string, key: string): Promise<JournalEntry | undefined>;\n\tdeleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;\n\tdeleteRun(runId: string): Promise<void>;\n\tclose(): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SqliteDatabase } from "./database.js";
|
|
2
|
+
import type { AdapterOptions, SecretRef, StorageSelection } from "./provider.js";
|
|
3
|
+
export interface StorageSettingsSelection {
|
|
4
|
+
readonly path?: string;
|
|
5
|
+
readonly memory?: boolean;
|
|
6
|
+
readonly adapter?: string;
|
|
7
|
+
readonly options?: AdapterOptions;
|
|
8
|
+
readonly secrets?: Readonly<Record<string, SecretRef>>;
|
|
9
|
+
readonly prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
export type StorageInputSelection = StorageSettingsSelection | {
|
|
12
|
+
readonly database: SqliteDatabase;
|
|
13
|
+
readonly prefix?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function selectStorage(value: StorageInputSelection, source: "sdk" | "settings", field: string, defaultPath: string): StorageSelection;
|
|
16
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../src/core/storage/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjF,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,MAAM,qBAAqB,GAC9B,wBAAwB,GACxB;IAAE,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,wBAAgB,aAAa,CAC5B,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,KAAK,GAAG,UAAU,EAC1B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GACjB,gBAAgB,CA0ElB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { StorageConfigError } from "./errors.js";
|
|
2
|
+
export function selectStorage(value, source, field, defaultPath) {
|
|
3
|
+
const invalid = (reason) => {
|
|
4
|
+
throw new StorageConfigError(source, field, reason);
|
|
5
|
+
};
|
|
6
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
7
|
+
return invalid("selection-object-required");
|
|
8
|
+
if ("dir" in value)
|
|
9
|
+
return invalid("adapter-domain-unsupported");
|
|
10
|
+
if ("prefix" in value && value.prefix !== undefined && typeof value.prefix !== "string")
|
|
11
|
+
return invalid("invalid-prefix");
|
|
12
|
+
if (source === "sdk") {
|
|
13
|
+
const forms = ["path", "memory", "adapter", "database"].filter((key) => key in value);
|
|
14
|
+
if (forms.length === 0)
|
|
15
|
+
return invalid("selection-required");
|
|
16
|
+
if (forms.length > 1)
|
|
17
|
+
return invalid("multiple-selection-forms");
|
|
18
|
+
if ("path" in value && typeof value.path !== "string")
|
|
19
|
+
return invalid("invalid-path");
|
|
20
|
+
if ("memory" in value && value.memory !== true)
|
|
21
|
+
return invalid("invalid-memory");
|
|
22
|
+
if ("adapter" in value && (typeof value.adapter !== "string" || value.adapter.length === 0))
|
|
23
|
+
return invalid("invalid-adapter");
|
|
24
|
+
}
|
|
25
|
+
if ("database" in value) {
|
|
26
|
+
if (["path", "memory", "adapter"].some((key) => key in value))
|
|
27
|
+
return invalid("multiple-selection-forms");
|
|
28
|
+
const db = value.database;
|
|
29
|
+
if (db === null ||
|
|
30
|
+
typeof db !== "object" ||
|
|
31
|
+
[db.exec, db.run, db.get, db.all, db.transaction, db.close].some((hook) => typeof hook !== "function") ||
|
|
32
|
+
!db.descriptor ||
|
|
33
|
+
typeof db.descriptor.adapter !== "string" ||
|
|
34
|
+
typeof db.descriptor.location !== "string")
|
|
35
|
+
return invalid("async-database-required");
|
|
36
|
+
return { kind: "database", database: db, ...(value.prefix === undefined ? {} : { prefix: value.prefix }) };
|
|
37
|
+
}
|
|
38
|
+
if (value.path !== undefined && typeof value.path !== "string")
|
|
39
|
+
return invalid("invalid-path");
|
|
40
|
+
if (value.memory !== undefined && typeof value.memory !== "boolean")
|
|
41
|
+
return invalid("invalid-memory");
|
|
42
|
+
if (value.adapter !== undefined) {
|
|
43
|
+
if (typeof value.adapter !== "string" || value.adapter.length === 0)
|
|
44
|
+
return invalid("invalid-adapter");
|
|
45
|
+
if ("path" in value || "memory" in value)
|
|
46
|
+
return invalid("multiple-selection-forms");
|
|
47
|
+
if (value.options !== undefined) {
|
|
48
|
+
if (value.options === null || typeof value.options !== "object" || Array.isArray(value.options))
|
|
49
|
+
return invalid("invalid-options");
|
|
50
|
+
for (const option of Object.values(value.options)) {
|
|
51
|
+
if (option !== null &&
|
|
52
|
+
!["string", "number", "bigint", "boolean"].includes(typeof option) &&
|
|
53
|
+
!(option instanceof Uint8Array))
|
|
54
|
+
return invalid("invalid-options");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (value.secrets !== undefined) {
|
|
58
|
+
if (value.secrets === null || typeof value.secrets !== "object" || Array.isArray(value.secrets))
|
|
59
|
+
return invalid("invalid-secrets");
|
|
60
|
+
for (const ref of Object.values(value.secrets)) {
|
|
61
|
+
if (ref === null || typeof ref !== "object" || Array.isArray(ref) || "env" in ref === "file" in ref)
|
|
62
|
+
return invalid("invalid-secret-ref");
|
|
63
|
+
if ("env" in ref ? typeof ref.env !== "string" : typeof ref.file !== "string")
|
|
64
|
+
return invalid("invalid-secret-ref");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
kind: "adapter",
|
|
69
|
+
module: value.adapter,
|
|
70
|
+
...(value.options === undefined ? {} : { options: value.options }),
|
|
71
|
+
...(value.secrets === undefined ? {} : { secrets: value.secrets }),
|
|
72
|
+
...(value.prefix === undefined ? {} : { prefix: value.prefix }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (value.options !== undefined || value.secrets !== undefined)
|
|
76
|
+
return invalid("adapter-required");
|
|
77
|
+
if (value.path && value.memory === true)
|
|
78
|
+
return invalid("path-and-memory");
|
|
79
|
+
if (value.memory === true)
|
|
80
|
+
return { kind: "memory" };
|
|
81
|
+
return {
|
|
82
|
+
kind: "sqlite",
|
|
83
|
+
path: source === "sdk" && value.path !== undefined ? value.path : value.path || defaultPath,
|
|
84
|
+
...(value.prefix === undefined ? {} : { prefix: value.prefix }),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../../src/core/storage/selection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAejD,MAAM,UAAU,aAAa,CAC5B,KAA4B,EAC5B,MAA0B,EAC1B,KAAa,EACb,WAAmB;IAEnB,MAAM,OAAO,GAAG,CAAC,MAAc,EAAS,EAAE;QACzC,MAAM,IAAI,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACrH,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACjE,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QACtF,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;I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C,OAAO;YACrB,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAClE,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAClE,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAC/D,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnG,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3E,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACrD,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,WAAW;QAC3F,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAC/D,CAAC;AACH,CAAC","sourcesContent":["import type { SqliteDatabase } from \"./database.js\";\nimport { StorageConfigError } from \"./errors.js\";\nimport type { AdapterOptions, SecretRef, StorageSelection } from \"./provider.js\";\n\nexport interface StorageSettingsSelection {\n\treadonly path?: string;\n\treadonly memory?: boolean;\n\treadonly adapter?: string;\n\treadonly options?: AdapterOptions;\n\treadonly secrets?: Readonly<Record<string, SecretRef>>;\n\treadonly prefix?: string;\n}\nexport type StorageInputSelection =\n\t| StorageSettingsSelection\n\t| { readonly database: SqliteDatabase; readonly prefix?: string };\n\nexport function selectStorage(\n\tvalue: StorageInputSelection,\n\tsource: \"sdk\" | \"settings\",\n\tfield: string,\n\tdefaultPath: string,\n): StorageSelection {\n\tconst invalid = (reason: string): never => {\n\t\tthrow new StorageConfigError(source, field, reason);\n\t};\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value)) return invalid(\"selection-object-required\");\n\tif (\"dir\" in value) return invalid(\"adapter-domain-unsupported\");\n\tif (\"prefix\" in value && value.prefix !== undefined && typeof value.prefix !== \"string\")\n\t\treturn invalid(\"invalid-prefix\");\n\tif (source === \"sdk\") {\n\t\tconst forms = [\"path\", \"memory\", \"adapter\", \"database\"].filter((key) => key in value);\n\t\tif (forms.length === 0) return invalid(\"selection-required\");\n\t\tif (forms.length > 1) return invalid(\"multiple-selection-forms\");\n\t\tif (\"path\" in value && typeof value.path !== \"string\") return invalid(\"invalid-path\");\n\t\tif (\"memory\" in value && value.memory !== true) return invalid(\"invalid-memory\");\n\t\tif (\"adapter\" in value && (typeof value.adapter !== \"string\" || value.adapter.length === 0))\n\t\t\treturn invalid(\"invalid-adapter\");\n\t}\n\tif (\"database\" in value) {\n\t\tif ([\"path\", \"memory\", \"adapter\"].some((key) => key in value)) return invalid(\"multiple-selection-forms\");\n\t\tconst db = value.database;\n\t\tif (\n\t\t\tdb === null ||\n\t\t\ttypeof db !== \"object\" ||\n\t\t\t[db.exec, db.run, db.get, db.all, db.transaction, db.close].some((hook) => typeof hook !== \"function\") ||\n\t\t\t!db.descriptor ||\n\t\t\ttypeof db.descriptor.adapter !== \"string\" ||\n\t\t\ttypeof db.descriptor.location !== \"string\"\n\t\t)\n\t\t\treturn invalid(\"async-database-required\");\n\t\treturn { kind: \"database\", database: db, ...(value.prefix === undefined ? {} : { prefix: value.prefix }) };\n\t}\n\tif (value.path !== undefined && typeof value.path !== \"string\") return invalid(\"invalid-path\");\n\tif (value.memory !== undefined && typeof value.memory !== \"boolean\") return invalid(\"invalid-memory\");\n\tif (value.adapter !== undefined) {\n\t\tif (typeof value.adapter !== \"string\" || value.adapter.length === 0) return invalid(\"invalid-adapter\");\n\t\tif (\"path\" in value || \"memory\" in value) return invalid(\"multiple-selection-forms\");\n\t\tif (value.options !== undefined) {\n\t\t\tif (value.options === null || typeof value.options !== \"object\" || Array.isArray(value.options))\n\t\t\t\treturn invalid(\"invalid-options\");\n\t\t\tfor (const option of Object.values(value.options)) {\n\t\t\t\tif (\n\t\t\t\t\toption !== null &&\n\t\t\t\t\t![\"string\", \"number\", \"bigint\", \"boolean\"].includes(typeof option) &&\n\t\t\t\t\t!(option instanceof Uint8Array)\n\t\t\t\t)\n\t\t\t\t\treturn invalid(\"invalid-options\");\n\t\t\t}\n\t\t}\n\t\tif (value.secrets !== undefined) {\n\t\t\tif (value.secrets === null || typeof value.secrets !== \"object\" || Array.isArray(value.secrets))\n\t\t\t\treturn invalid(\"invalid-secrets\");\n\t\t\tfor (const ref of Object.values(value.secrets)) {\n\t\t\t\tif (ref === null || typeof ref !== \"object\" || Array.isArray(ref) || \"env\" in ref === \"file\" in ref)\n\t\t\t\t\treturn invalid(\"invalid-secret-ref\");\n\t\t\t\tif (\"env\" in ref ? typeof ref.env !== \"string\" : typeof ref.file !== \"string\")\n\t\t\t\t\treturn invalid(\"invalid-secret-ref\");\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tkind: \"adapter\",\n\t\t\tmodule: value.adapter,\n\t\t\t...(value.options === undefined ? {} : { options: value.options }),\n\t\t\t...(value.secrets === undefined ? {} : { secrets: value.secrets }),\n\t\t\t...(value.prefix === undefined ? {} : { prefix: value.prefix }),\n\t\t};\n\t}\n\tif (value.options !== undefined || value.secrets !== undefined) return invalid(\"adapter-required\");\n\tif (value.path && value.memory === true) return invalid(\"path-and-memory\");\n\tif (value.memory === true) return { kind: \"memory\" };\n\treturn {\n\t\tkind: \"sqlite\",\n\t\tpath: source === \"sdk\" && value.path !== undefined ? value.path : value.path || defaultPath,\n\t\t...(value.prefix === undefined ? {} : { prefix: value.prefix }),\n\t};\n}\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SessionEntry } from "../../session-manager-types.ts";
|
|
2
|
-
import {
|
|
2
|
+
import type { SessionListQuery, SessionRecordHeader, SessionSnapshot, SessionStore, SessionSummary, SessionWriteOptions, StorageDescriptor } from "./types.js";
|
|
3
|
+
export interface JsonlSessionFile {
|
|
4
|
+
readonly location: string;
|
|
5
|
+
readonly header: SessionRecordHeader;
|
|
6
|
+
read(): Promise<SessionSnapshot>;
|
|
7
|
+
}
|
|
3
8
|
export { SessionFormatVersionError } from "./errors.js";
|
|
4
9
|
export declare class JsonlStoragePoisonedError extends Error {
|
|
5
10
|
readonly location: string;
|
|
@@ -30,12 +35,15 @@ export declare class JsonlSessionStore implements SessionStore {
|
|
|
30
35
|
replace(sessionId: string, header: SessionRecordHeader, entries: readonly SessionEntry[], options: SessionWriteOptions): Promise<{
|
|
31
36
|
readonly lastSeq: number;
|
|
32
37
|
}>;
|
|
38
|
+
private commit;
|
|
33
39
|
load(sessionId: string): Promise<SessionSnapshot>;
|
|
34
40
|
loadFile(path: string): Promise<SessionSnapshot>;
|
|
41
|
+
private readPersisted;
|
|
35
42
|
findFile(sessionId: string): Promise<string | undefined>;
|
|
36
43
|
readHeader(sessionId: string): Promise<SessionRecordHeader | undefined>;
|
|
37
44
|
delete(sessionId: string): Promise<void>;
|
|
38
45
|
list(query: SessionListQuery): AsyncIterable<SessionSummary>;
|
|
46
|
+
scanFiles(): AsyncIterable<JsonlSessionFile>;
|
|
39
47
|
findMostRecent(query: {
|
|
40
48
|
readonly cwd: string;
|
|
41
49
|
readonly includeInternal?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-session-store.d.ts","sourceRoot":"","sources":["../../../../src/core/storage/session/jsonl-session-store.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonl-session-store.d.ts","sourceRoot":"","sources":["../../../../src/core/storage/session/jsonl-session-store.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAqBnE,OAAO,KAAK,EACX,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,YAAY,CAAC;AAmBpB,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CACjC;AAED,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,SAAkB,KAAK,EAAE,KAAK,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC;IAE9B,YAAY,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAM/D;CACD;AAED,qBAAa,iBAAkB,YAAW,YAAY;IACrD,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAkE;IAClF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAElE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,OAAO,eAG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