@bastani/atomic 0.9.38-alpha.3 → 0.9.38-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +24 -0
- package/dist/builtin/workflows/README.md +5 -10
- package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
- package/dist/builtin/workflows/builtin/{chunk-94f8zfz1.js → chunk-454hz1qt.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-wf876n16.js → chunk-4bwtzyjq.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-kb7s3gx2.js → chunk-5eh0brtd.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-r97ndfvt.js → chunk-bjva9j5k.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-x6az1sxp.js → chunk-h5fn47y5.js} +1 -1
- package/dist/builtin/workflows/builtin/chunk-na3wpwzh.js +3115 -0
- package/dist/builtin/workflows/builtin/{chunk-nkj4qhj6.js → chunk-q7dx7kh7.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-a1ar035d.js → chunk-qdd897wm.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-gyjck9z8.js → chunk-qjqn389g.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-ad83gc5p.js → chunk-qrrkfg9v.js} +5 -12
- package/dist/builtin/workflows/builtin/{chunk-632fxeb8.js → chunk-x0vvjyzg.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-3n2bnz64.js → chunk-xg7kkgf8.js} +2 -2
- package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
- package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +11 -11
- package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
- package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/tournament.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +8 -6
- package/dist/builtin/workflows/src/durable/journal/conformance.d.ts +4 -0
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +27 -0
- package/dist/builtin/workflows/src/durable/journal/node-sqlite.d.ts +20 -0
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +21 -0
- package/dist/builtin/workflows/src/durable/journal/sqlite-run-journal.d.ts +49 -0
- package/dist/builtin/workflows/src/durable/journal/types.d.ts +200 -0
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +3 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +51800 -88088
- package/dist/builtin/workflows/src/index.js +9393 -45371
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -6
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +4 -6
- package/dist/bun/split-loader.js +0 -13
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +1 -0
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +1 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +6 -6
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +1 -0
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +4 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.d.ts +2 -1
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.js +5 -5
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +32 -7
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +3 -3
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js +4 -4
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +4 -4
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +3 -8
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +14 -20
- 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 +4 -13
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +1 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +49 -24
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +2 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js +2 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager-validation.d.ts +3 -0
- package/dist/core/session-manager-validation.d.ts.map +1 -1
- package/dist/core/session-manager-validation.js +16 -0
- package/dist/core/session-manager-validation.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +4 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +9 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/database.d.ts +21 -0
- package/dist/core/storage/database.d.ts.map +1 -0
- package/dist/core/storage/database.js +2 -0
- package/dist/core/storage/database.js.map +1 -0
- package/dist/core/storage/errors.d.ts +63 -0
- package/dist/core/storage/errors.d.ts.map +1 -0
- package/dist/core/storage/errors.js +103 -0
- package/dist/core/storage/errors.js.map +1 -0
- package/dist/core/storage/index.d.ts +6 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +5 -0
- package/dist/core/storage/index.js.map +1 -0
- package/dist/core/storage/node-sqlite.d.ts +5 -0
- package/dist/core/storage/node-sqlite.d.ts.map +1 -0
- package/dist/core/storage/node-sqlite.js +161 -0
- package/dist/core/storage/node-sqlite.js.map +1 -0
- package/dist/core/storage/prefix.d.ts +5 -0
- package/dist/core/storage/prefix.d.ts.map +1 -0
- package/dist/core/storage/prefix.js +15 -0
- package/dist/core/storage/prefix.js.map +1 -0
- package/dist/core/storage/schema.d.ts +3 -0
- package/dist/core/storage/schema.d.ts.map +1 -0
- package/dist/core/storage/schema.js +6 -0
- package/dist/core/storage/schema.js.map +1 -0
- package/dist/core/storage/session/conformance.d.ts +12 -0
- package/dist/core/storage/session/conformance.d.ts.map +1 -0
- package/dist/core/storage/session/conformance.js +674 -0
- package/dist/core/storage/session/conformance.js.map +1 -0
- package/dist/core/storage/session/entry-structure.d.ts +4 -0
- package/dist/core/storage/session/entry-structure.d.ts.map +1 -0
- package/dist/core/storage/session/entry-structure.js +83 -0
- package/dist/core/storage/session/entry-structure.js.map +1 -0
- package/dist/core/storage/session/errors.d.ts +54 -0
- package/dist/core/storage/session/errors.d.ts.map +1 -0
- package/dist/core/storage/session/errors.js +95 -0
- package/dist/core/storage/session/errors.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +57 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.js +482 -0
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.d.ts +31 -0
- package/dist/core/storage/session/memory-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/memory-session-store.js +113 -0
- package/dist/core/storage/session/memory-session-store.js.map +1 -0
- package/dist/core/storage/session/scratch-directory.d.ts +2 -0
- package/dist/core/storage/session/scratch-directory.d.ts.map +1 -0
- package/dist/core/storage/session/scratch-directory.js +5 -0
- package/dist/core/storage/session/scratch-directory.js.map +1 -0
- package/dist/core/storage/session/session-summary.d.ts +24 -0
- package/dist/core/storage/session/session-summary.d.ts.map +1 -0
- package/dist/core/storage/session/session-summary.js +79 -0
- package/dist/core/storage/session/session-summary.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.d.ts +46 -0
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/sql-session-store.js +227 -0
- package/dist/core/storage/session/sql-session-store.js.map +1 -0
- package/dist/core/storage/session/types.d.ts +68 -0
- package/dist/core/storage/session/types.d.ts.map +1 -0
- package/dist/core/storage/session/types.js +2 -0
- package/dist/core/storage/session/types.js.map +1 -0
- package/dist/core/storage/session/validation.d.ts +7 -0
- package/dist/core/storage/session/validation.d.ts.map +1 -0
- package/dist/core/storage/session/validation.js +47 -0
- package/dist/core/storage/session/validation.js.map +1 -0
- package/dist/core/storage/testing.d.ts +13 -0
- package/dist/core/storage/testing.d.ts.map +1 -0
- package/dist/core/storage/testing.js +264 -0
- package/dist/core/storage/testing.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +8 -4
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +5 -4
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +8 -5
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/docs/docs.json +1 -0
- package/docs/getting-started/installation.md +1 -2
- package/docs/json.md +1 -1
- package/docs/packages/authoring.md +1 -1
- package/docs/sdk/reference.md +1 -1
- package/docs/sdk/web-server.md +5 -5
- package/docs/sdk.md +11 -25
- package/docs/session-format.md +4 -10
- package/docs/settings.md +5 -29
- package/docs/storage.md +43 -0
- package/docs/workflows/api-reference.md +17 -55
- package/docs/workflows/authoring.md +2 -1
- package/docs/workflows/operations.md +31 -175
- package/docs/workflows/reliable-design.md +1 -1
- package/npm-shrinkwrap.json +32 -448
- package/package.json +13 -6
- package/schemas/settings.schema.json +27 -0
- package/dist/builtin/workflows/builtin/chunk-ymwq372z.js +0 -11609
- package/dist/core/session-manager-migrations.d.ts +0 -11
- package/dist/core/session-manager-migrations.d.ts.map +0 -1
- package/dist/core/session-manager-migrations.js +0 -80
- package/dist/core/session-manager-migrations.js.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { StorageAdapterLoadError, StorageInvalidTextError, StorageRollbackError, StorageTransactionClosedError, StorageUnavailableError, StoreClosedError, } from "./errors.js";
|
|
4
|
+
/** Copies binary parameters so queued work binds the bytes the caller passed, not later buffer contents. */
|
|
5
|
+
function snapshotParams(params) {
|
|
6
|
+
return params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Bun's `DatabaseSync.close()` defers closing the file until garbage collection finalizes every statement the
|
|
10
|
+
* connection prepared, so the database, WAL and shared-memory files stay open (and locked on Windows). The adapter
|
|
11
|
+
* keeps no statement references, so a synchronous collection finalizes them and releases the files. Node finalizes
|
|
12
|
+
* statements inside `close()` and has no `Bun` global.
|
|
13
|
+
*/
|
|
14
|
+
function finalizeReleasedStatements() {
|
|
15
|
+
globalThis.Bun?.gc(true);
|
|
16
|
+
}
|
|
17
|
+
function normalizeRow(row) {
|
|
18
|
+
return Object.fromEntries(Object.entries(row).map(([key, value]) => [
|
|
19
|
+
key,
|
|
20
|
+
typeof value === "bigint" &&
|
|
21
|
+
value >= -BigInt(Number.MAX_SAFE_INTEGER) &&
|
|
22
|
+
value <= BigInt(Number.MAX_SAFE_INTEGER)
|
|
23
|
+
? Number(value)
|
|
24
|
+
: value instanceof Uint8Array
|
|
25
|
+
? new Uint8Array(value)
|
|
26
|
+
: value,
|
|
27
|
+
]));
|
|
28
|
+
}
|
|
29
|
+
class NodeSqliteDatabase {
|
|
30
|
+
descriptor;
|
|
31
|
+
connection;
|
|
32
|
+
tail = Promise.resolve();
|
|
33
|
+
closing = false;
|
|
34
|
+
closePromise;
|
|
35
|
+
executor;
|
|
36
|
+
constructor(connection, descriptor) {
|
|
37
|
+
this.connection = connection;
|
|
38
|
+
this.descriptor = descriptor;
|
|
39
|
+
this.executor = this.createExecutor(() => true);
|
|
40
|
+
}
|
|
41
|
+
driver(operation) {
|
|
42
|
+
try {
|
|
43
|
+
return operation();
|
|
44
|
+
}
|
|
45
|
+
catch (cause) {
|
|
46
|
+
throw new StorageUnavailableError(this.descriptor, cause);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
createExecutor(active) {
|
|
50
|
+
const execute = async (operation, params = []) => {
|
|
51
|
+
if (!active())
|
|
52
|
+
throw new StorageTransactionClosedError();
|
|
53
|
+
const invalidIndex = params.findIndex((value) => typeof value === "string" && value.includes("\0"));
|
|
54
|
+
if (invalidIndex !== -1)
|
|
55
|
+
throw new StorageInvalidTextError(invalidIndex);
|
|
56
|
+
return this.driver(operation);
|
|
57
|
+
};
|
|
58
|
+
const statement = (sql) => {
|
|
59
|
+
const prepared = this.connection.prepare(sql);
|
|
60
|
+
prepared.setReadBigInts(true);
|
|
61
|
+
return prepared;
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
exec: (sql) => execute(() => this.connection.exec(sql)),
|
|
65
|
+
run: (sql, ...params) => execute(() => ({ changes: Number(statement(sql).run(...params).changes) }), params),
|
|
66
|
+
get: (sql, ...params) => execute(() => {
|
|
67
|
+
const row = statement(sql).get(...params);
|
|
68
|
+
return row === undefined ? undefined : normalizeRow(row);
|
|
69
|
+
}, params),
|
|
70
|
+
all: (sql, ...params) => execute(() => statement(sql)
|
|
71
|
+
.all(...params)
|
|
72
|
+
.map((row) => normalizeRow(row)), params),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
enqueue(operation) {
|
|
76
|
+
if (this.closing)
|
|
77
|
+
return Promise.reject(new StoreClosedError(this.descriptor));
|
|
78
|
+
const result = this.tail.then(operation);
|
|
79
|
+
this.tail = result.then(() => { }, () => { });
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
exec(sql) {
|
|
83
|
+
return this.enqueue(() => this.executor.exec(sql));
|
|
84
|
+
}
|
|
85
|
+
run(sql, ...params) {
|
|
86
|
+
const bound = snapshotParams(params);
|
|
87
|
+
return this.enqueue(() => this.executor.run(sql, ...bound));
|
|
88
|
+
}
|
|
89
|
+
get(sql, ...params) {
|
|
90
|
+
const bound = snapshotParams(params);
|
|
91
|
+
return this.enqueue(() => this.executor.get(sql, ...bound));
|
|
92
|
+
}
|
|
93
|
+
all(sql, ...params) {
|
|
94
|
+
const bound = snapshotParams(params);
|
|
95
|
+
return this.enqueue(() => this.executor.all(sql, ...bound));
|
|
96
|
+
}
|
|
97
|
+
transaction(callback) {
|
|
98
|
+
return this.enqueue(async () => {
|
|
99
|
+
await this.executor.exec("BEGIN IMMEDIATE");
|
|
100
|
+
let active = true;
|
|
101
|
+
const transaction = this.createExecutor(() => active);
|
|
102
|
+
try {
|
|
103
|
+
const result = await callback(transaction);
|
|
104
|
+
active = false;
|
|
105
|
+
await this.executor.exec("COMMIT");
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
catch (cause) {
|
|
109
|
+
active = false;
|
|
110
|
+
try {
|
|
111
|
+
await this.executor.exec("ROLLBACK");
|
|
112
|
+
}
|
|
113
|
+
catch (rollbackCause) {
|
|
114
|
+
throw new StorageRollbackError(cause, rollbackCause);
|
|
115
|
+
}
|
|
116
|
+
throw cause;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
close() {
|
|
121
|
+
if (!this.closePromise) {
|
|
122
|
+
this.closing = true;
|
|
123
|
+
this.closePromise = this.tail.then(() => this.driver(() => {
|
|
124
|
+
this.connection.close();
|
|
125
|
+
finalizeReleasedStatements();
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
return this.closePromise;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export async function openNodeSqliteDatabase(path, { busyTimeoutMs = 5000 } = {}) {
|
|
132
|
+
const descriptor = { adapter: "node-sqlite", location: path };
|
|
133
|
+
// Load node:sqlite on first open: importing it prints Node's experimental warning, which every importer of the
|
|
134
|
+
// package entry point would otherwise see.
|
|
135
|
+
let Database;
|
|
136
|
+
try {
|
|
137
|
+
({ DatabaseSync: Database } = await import("node:sqlite"));
|
|
138
|
+
}
|
|
139
|
+
catch (cause) {
|
|
140
|
+
throw new StorageAdapterLoadError("node:sqlite", cause);
|
|
141
|
+
}
|
|
142
|
+
let connection;
|
|
143
|
+
try {
|
|
144
|
+
if (path !== ":memory:")
|
|
145
|
+
await mkdir(dirname(path), { recursive: true });
|
|
146
|
+
connection = new Database(path);
|
|
147
|
+
connection.exec(`PRAGMA busy_timeout=${busyTimeoutMs}`);
|
|
148
|
+
connection.exec("PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON");
|
|
149
|
+
return new NodeSqliteDatabase(connection, descriptor);
|
|
150
|
+
}
|
|
151
|
+
catch (cause) {
|
|
152
|
+
try {
|
|
153
|
+
connection?.close();
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Preserve the opening failure if cleanup also fails.
|
|
157
|
+
}
|
|
158
|
+
throw new StorageUnavailableError(descriptor, cause);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=node-sqlite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-sqlite.js","sourceRoot":"","sources":["../../../src/core/storage/node-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACN,uBAAuB,EAEvB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,aAAa,CAAC;AAErB,4GAA4G;AAC5G,SAAS,cAAc,CAAC,MAA8B;IACrD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;;;GAKG;AACH,SAAS,0BAA0B;IACjC,UAAqD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,GAAgC;IACrD,OAA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AC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC;YACJ,UAAU,EAAE,KAAK,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,sDAAsD;QACvD,CAAC;QACD,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,KAA4B,CAAC,CAAC;IAC7E,CAAC;AACF,CAAC","sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { DatabaseSync } from \"node:sqlite\";\nimport type { SqliteDatabase, SqliteExecutor, SqliteRow, SqliteValue, StorageDescriptor } from \"./database.js\";\nimport {\n\tStorageAdapterLoadError,\n\ttype StorageFailureCause,\n\tStorageInvalidTextError,\n\tStorageRollbackError,\n\tStorageTransactionClosedError,\n\tStorageUnavailableError,\n\tStoreClosedError,\n} from \"./errors.js\";\n\n/** Copies binary parameters so queued work binds the bytes the caller passed, not later buffer contents. */\nfunction snapshotParams(params: readonly SqliteValue[]): SqliteValue[] {\n\treturn params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));\n}\n\n/**\n * Bun's `DatabaseSync.close()` defers closing the file until garbage collection finalizes every statement the\n * connection prepared, so the database, WAL and shared-memory files stay open (and locked on Windows). The adapter\n * keeps no statement references, so a synchronous collection finalizes them and releases the files. Node finalizes\n * statements inside `close()` and has no `Bun` global.\n */\nfunction finalizeReleasedStatements(): void {\n\t(globalThis as { Bun?: { gc(force: boolean): void } }).Bun?.gc(true);\n}\n\nfunction normalizeRow(row: Record<string, SqliteValue>): SqliteRow {\n\treturn Object.fromEntries(\n\t\tObject.entries(row).map(([key, value]) => [\n\t\t\tkey,\n\t\t\ttypeof value === \"bigint\" &&\n\t\t\tvalue >= -BigInt(Number.MAX_SAFE_INTEGER) &&\n\t\t\tvalue <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t\t? Number(value)\n\t\t\t\t: value instanceof Uint8Array\n\t\t\t\t\t? new Uint8Array(value)\n\t\t\t\t\t: value,\n\t\t]),\n\t);\n}\n\nclass NodeSqliteDatabase implements SqliteDatabase {\n\treadonly descriptor: StorageDescriptor;\n\tprivate readonly connection: DatabaseSync;\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate closing = false;\n\tprivate closePromise?: Promise<void>;\n\tprivate readonly executor: SqliteExecutor;\n\n\tconstructor(connection: DatabaseSync, descriptor: StorageDescriptor) {\n\t\tthis.connection = connection;\n\t\tthis.descriptor = descriptor;\n\t\tthis.executor = this.createExecutor(() => true);\n\t}\n\n\tprivate driver<T>(operation: () => T): T {\n\t\ttry {\n\t\t\treturn operation();\n\t\t} catch (cause) {\n\t\t\tthrow new StorageUnavailableError(this.descriptor, cause as StorageFailureCause);\n\t\t}\n\t}\n\n\tprivate createExecutor(active: () => boolean): SqliteExecutor {\n\t\tconst execute = async <T>(operation: () => T, params: readonly SqliteValue[] = []): Promise<T> => {\n\t\t\tif (!active()) throw new StorageTransactionClosedError();\n\t\t\tconst invalidIndex = params.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\treturn this.driver(operation);\n\t\t};\n\t\tconst statement = (sql: string) => {\n\t\t\tconst prepared = this.connection.prepare(sql);\n\t\t\tprepared.setReadBigInts(true);\n\t\t\treturn prepared;\n\t\t};\n\t\treturn {\n\t\t\texec: (sql) => execute(() => this.connection.exec(sql)),\n\t\t\trun: (sql, ...params) => execute(() => ({ changes: Number(statement(sql).run(...params).changes) }), params),\n\t\t\tget: <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) =>\n\t\t\t\texecute(() => {\n\t\t\t\t\tconst row = statement(sql).get(...params);\n\t\t\t\t\treturn row === undefined ? undefined : (normalizeRow(row) as T);\n\t\t\t\t}, params),\n\t\t\tall: <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) =>\n\t\t\t\texecute(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tstatement(sql)\n\t\t\t\t\t\t\t.all(...params)\n\t\t\t\t\t\t\t.map((row) => normalizeRow(row) as T),\n\t\t\t\t\tparams,\n\t\t\t\t),\n\t\t};\n\t}\n\n\tprivate enqueue<T>(operation: () => Promise<T>): Promise<T> {\n\t\tif (this.closing) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\texec(sql: string): Promise<void> {\n\t\treturn this.enqueue(() => this.executor.exec(sql));\n\t}\n\n\trun(sql: string, ...params: readonly SqliteValue[]) {\n\t\tconst bound = snapshotParams(params);\n\t\treturn this.enqueue(() => this.executor.run(sql, ...bound));\n\t}\n\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {\n\t\tconst bound = snapshotParams(params);\n\t\treturn this.enqueue(() => this.executor.get<T>(sql, ...bound));\n\t}\n\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {\n\t\tconst bound = snapshotParams(params);\n\t\treturn this.enqueue(() => this.executor.all<T>(sql, ...bound));\n\t}\n\n\ttransaction<T>(callback: (transaction: SqliteExecutor) => Promise<T>): Promise<T> {\n\t\treturn this.enqueue(async () => {\n\t\t\tawait this.executor.exec(\"BEGIN IMMEDIATE\");\n\t\t\tlet active = true;\n\t\t\tconst transaction = this.createExecutor(() => active);\n\t\t\ttry {\n\t\t\t\tconst result = await callback(transaction);\n\t\t\t\tactive = false;\n\t\t\t\tawait this.executor.exec(\"COMMIT\");\n\t\t\t\treturn result;\n\t\t\t} catch (cause) {\n\t\t\t\tactive = false;\n\t\t\t\ttry {\n\t\t\t\t\tawait this.executor.exec(\"ROLLBACK\");\n\t\t\t\t} catch (rollbackCause) {\n\t\t\t\t\tthrow new StorageRollbackError(cause as StorageFailureCause, rollbackCause as StorageFailureCause);\n\t\t\t\t}\n\t\t\t\tthrow cause;\n\t\t\t}\n\t\t});\n\t}\n\n\tclose(): Promise<void> {\n\t\tif (!this.closePromise) {\n\t\t\tthis.closing = true;\n\t\t\tthis.closePromise = this.tail.then(() =>\n\t\t\t\tthis.driver(() => {\n\t\t\t\t\tthis.connection.close();\n\t\t\t\t\tfinalizeReleasedStatements();\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\treturn this.closePromise;\n\t}\n}\n\nexport async function openNodeSqliteDatabase(\n\tpath: string,\n\t{ busyTimeoutMs = 5000 }: { busyTimeoutMs?: number } = {},\n): Promise<SqliteDatabase> {\n\tconst descriptor = { adapter: \"node-sqlite\", location: path };\n\t// Load node:sqlite on first open: importing it prints Node's experimental warning, which every importer of the\n\t// package entry point would otherwise see.\n\tlet Database: typeof DatabaseSync;\n\ttry {\n\t\t({ DatabaseSync: Database } = await import(\"node:sqlite\"));\n\t} catch (cause) {\n\t\tthrow new StorageAdapterLoadError(\"node:sqlite\", cause as StorageFailureCause);\n\t}\n\tlet connection: DatabaseSync | undefined;\n\ttry {\n\t\tif (path !== \":memory:\") await mkdir(dirname(path), { recursive: true });\n\t\tconnection = new Database(path);\n\t\tconnection.exec(`PRAGMA busy_timeout=${busyTimeoutMs}`);\n\t\tconnection.exec(\"PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; PRAGMA foreign_keys=ON\");\n\t\treturn new NodeSqliteDatabase(connection, descriptor);\n\t} catch (cause) {\n\t\ttry {\n\t\t\tconnection?.close();\n\t\t} catch {\n\t\t\t// Preserve the opening failure if cleanup also fails.\n\t\t}\n\t\tthrow new StorageUnavailableError(descriptor, cause as StorageFailureCause);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function validateStoragePrefix(prefix?: string): string;
|
|
2
|
+
export declare function renderStorageIdentifiers<T extends Readonly<Record<string, string>>>(domain: "journal" | "sessions", names: T, prefix?: string): Readonly<{
|
|
3
|
+
[K in keyof T]: string;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../../../src/core/storage/prefix.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,MAAM,SAAK,GAAG,MAAM,CAMzD;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAClF,MAAM,EAAE,SAAS,GAAG,UAAU,EAC9B,KAAK,EAAE,CAAC,EACR,MAAM,SAAK,GACT,QAAQ,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC,CAMtC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StoragePrefixError } from "./errors.js";
|
|
2
|
+
export function validateStoragePrefix(prefix = "") {
|
|
3
|
+
if (prefix !== "" && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(prefix)) {
|
|
4
|
+
throw new StoragePrefixError(prefix, "pattern");
|
|
5
|
+
}
|
|
6
|
+
if (/^sqlite_/i.test(prefix))
|
|
7
|
+
throw new StoragePrefixError(prefix, "reserved");
|
|
8
|
+
return prefix;
|
|
9
|
+
}
|
|
10
|
+
export function renderStorageIdentifiers(domain, names, prefix = "") {
|
|
11
|
+
const validated = validateStoragePrefix(prefix);
|
|
12
|
+
const domainPrefix = domain === "journal" ? "wf_" : "session_";
|
|
13
|
+
return Object.freeze(Object.fromEntries(Object.entries(names).map(([key, name]) => [key, `${validated}${domainPrefix}${name}`])));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.js","sourceRoot":"","sources":["../../../src/core/storage/prefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,UAAU,qBAAqB,CAAC,MAAM,GAAG,EAAE;IAChD,IAAI,MAAM,KAAK,EAAE,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/E,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,MAA8B,EAC9B,KAAQ,EACR,MAAM,GAAG,EAAE;IAEX,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CACnE,CAAC;AAC3C,CAAC","sourcesContent":["import { StoragePrefixError } from \"./errors.js\";\n\nexport function validateStoragePrefix(prefix = \"\"): string {\n\tif (prefix !== \"\" && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(prefix)) {\n\t\tthrow new StoragePrefixError(prefix, \"pattern\");\n\t}\n\tif (/^sqlite_/i.test(prefix)) throw new StoragePrefixError(prefix, \"reserved\");\n\treturn prefix;\n}\n\nexport function renderStorageIdentifiers<T extends Readonly<Record<string, string>>>(\n\tdomain: \"journal\" | \"sessions\",\n\tnames: T,\n\tprefix = \"\",\n): Readonly<{ [K in keyof T]: string }> {\n\tconst validated = validateStoragePrefix(prefix);\n\tconst domainPrefix = domain === \"journal\" ? \"wf_\" : \"session_\";\n\treturn Object.freeze(\n\t\tObject.fromEntries(Object.entries(names).map(([key, name]) => [key, `${validated}${domainPrefix}${name}`])),\n\t) as Readonly<{ [K in keyof T]: string }>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/core/storage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAEtG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/storage/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,UAAU,0BAA0B,CAAC,MAAc,EAAE,KAAkB,EAAE,SAAiB;IAC/F,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { SqliteValue } from \"./database.js\";\nimport { StorageSchemaVersionError } from \"./errors.js\";\n\nexport function assertStorageSchemaVersion(domain: string, found: SqliteValue, supported: number): void {\n\tif (found !== supported) throw new StorageSchemaVersionError(domain, found, supported);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SessionStore } from "./types.js";
|
|
2
|
+
export interface SessionStoreConformanceRunner {
|
|
3
|
+
describe(name: string, body: () => void): void;
|
|
4
|
+
it(name: string, body: () => Promise<void>): void;
|
|
5
|
+
}
|
|
6
|
+
export interface SessionStoreConformanceSubject {
|
|
7
|
+
store: SessionStore;
|
|
8
|
+
reopen(): Promise<SessionStore>;
|
|
9
|
+
}
|
|
10
|
+
export type WithSessionStore = (body: (subject: SessionStoreConformanceSubject) => Promise<void>) => Promise<void>;
|
|
11
|
+
export declare function registerSessionStoreConformance(runner: SessionStoreConformanceRunner, name: string, withSubject: WithSessionStore): void;
|
|
12
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../../src/core/storage/session/conformance.ts"],"names":[],"mappings":"AAYA,OAAO,EAAoD,KAAK,YAAY,EAAuB,MAAM,YAAY,CAAC;AAEtH,MAAM,WAAW,6BAA6B;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC/C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,8BAA8B,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAwDnH,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,6BAA6B,EACrC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,gBAAgB,GAC3B,IAAI,CAysBN"}
|