@cortexkit/pi-magic-context 0.49.35 → 0.49.36

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.
Files changed (43) hide show
  1. package/dist/auto-search-worker.js +163 -160
  2. package/dist/chunk-embedding-write-worker.js +59 -57
  3. package/dist/{compaction-marker-candidates-hk2frhac.js → compaction-marker-candidates-9fzqg6y0.js} +4 -2
  4. package/dist/compaction-marker-candidates-worker.js +24 -23
  5. package/dist/{compartment-chunk-embedding-5j1d1e3v.js → compartment-chunk-embedding-jpcme6tz.js} +6 -5
  6. package/dist/{embedding-backfill-jt459ady.js → embedding-backfill-002vyexq.js} +8 -7
  7. package/dist/{index-399p688g.js → index-8sqebjzk.js} +4 -1
  8. package/dist/{index-11knwv2h.js → index-a7sj2bam.js} +6 -3
  9. package/dist/{index-mkh1cm5k.js → index-c1dqxr10.js} +34 -4
  10. package/dist/{index-rgvqh5x7.js → index-ck8wj35v.js} +1 -1
  11. package/dist/{index-fzm8fm4z.js → index-dgqjq8sg.js} +143 -64
  12. package/dist/{index-yg42q9bc.js → index-f6y7mdq9.js} +8 -7
  13. package/dist/{index-2p691ayw.js → index-f9qet7y8.js} +1 -1
  14. package/dist/{index-6y6v2wvn.js → index-gxqmh9hq.js} +6 -6
  15. package/dist/{index-vgfk2xa5.js → index-jbkwszd5.js} +1 -1
  16. package/dist/{index-8m82cez2.js → index-kj49vs41.js} +2 -2
  17. package/dist/{index-svqk0701.js → index-mx757f3g.js} +13 -5
  18. package/dist/index-nypgv96r.js +58 -0
  19. package/dist/{index-d21rhpbd.js → index-p9jfa33t.js} +5 -5
  20. package/dist/{index-yhsmjvqa.js → index-pwp6zyx3.js} +12 -1
  21. package/dist/{index-m68qfjte.js → index-ry84c8dr.js} +1 -1
  22. package/dist/index-wfqysrwq.js +204 -0
  23. package/dist/{index-0rvn6vhq.js → index-wwsfevck.js} +6 -3
  24. package/dist/{index-54wmg4rj.js → index-x2n261wp.js} +16 -14
  25. package/dist/{index-d0w84hy5.js → index-y90fxz4t.js} +9 -3
  26. package/dist/{index-a11nmw5t.js → index-z7dktknj.js} +6 -4
  27. package/dist/index.js +846 -305
  28. package/dist/{message-fts-rowid-map-aw4xa05a.js → message-fts-rowid-map-hmgyfxxa.js} +5 -4
  29. package/dist/{message-index-bounded-da34vhs4.js → message-index-bounded-82sergz7.js} +8 -7
  30. package/dist/migration-worker.js +46 -41
  31. package/dist/{project-embedding-registry-davzvsz9.js → project-embedding-registry-16pj4vyf.js} +7 -6
  32. package/dist/raw-ordinal-warmup-worker.js +114 -118
  33. package/dist/{read-session-chunk-nbcznexm.js → read-session-chunk-jxq427v6.js} +6 -5
  34. package/dist/{read-session-raw-zb8kpa2y.js → read-session-raw-a9ntjqap.js} +4 -3
  35. package/dist/{render-d931g2vv.js → render-2wan3bfh.js} +11 -10
  36. package/dist/{search-atp7g95j.js → search-3p18trsb.js} +12 -11
  37. package/dist/{search-archive-a76pp30g.js → search-archive-pgrv04gv.js} +8 -7
  38. package/dist/{storage-tags-jy8b0xsy.js → storage-tags-p9y3bnw7.js} +1 -1
  39. package/dist/{store-kabezr25.js → store-v60q7dje.js} +1 -2
  40. package/dist/subagent-entry.js +18 -17
  41. package/dist/tag-snapshot-worker-pi.js +208 -202
  42. package/dist/{v2-archive-reader-wcjcfdzq.js → v2-archive-reader-5zpj8hrg.js} +3 -3
  43. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TOKEN_BUDGET_TOOL_REFUSAL
3
- } from "./index-svqk0701.js";
3
+ } from "./index-mx757f3g.js";
4
4
  import {
5
5
  setHarness2
6
6
  } from "./index-0h2mkab2.js";
@@ -14,13 +14,14 @@ import {
14
14
  import"./index-2qtx0q6h.js";
15
15
  import {
16
16
  openDatabase
17
- } from "./index-11knwv2h.js";
17
+ } from "./index-a7sj2bam.js";
18
18
  import"./index-fapenpch.js";
19
19
  import"./index-3bb24eb6.js";
20
- import"./index-399p688g.js";
21
- import"./index-54wmg4rj.js";
22
- import"./index-mkh1cm5k.js";
23
- import"./index-rgvqh5x7.js";
20
+ import"./index-8sqebjzk.js";
21
+ import"./index-wfqysrwq.js";
22
+ import"./index-x2n261wp.js";
23
+ import"./index-c1dqxr10.js";
24
+ import"./index-ck8wj35v.js";
24
25
  import"./index-d107f484.js";
25
26
  import"./index-yacs388s.js";
26
27
  import"./index-135e8hvg.js";
@@ -33,29 +34,29 @@ import {
33
34
  ensureProjectRegisteredFromPiDirectory,
34
35
  resolvePiHarnessKind,
35
36
  registerMagicContextTools
36
- } from "./index-fzm8fm4z.js";
37
+ } from "./index-dgqjq8sg.js";
37
38
  import"./index-ccanzg8p.js";
38
39
  import"./index-rzfr7wdv.js";
39
- import"./index-2p691ayw.js";
40
+ import"./index-f9qet7y8.js";
40
41
  import"./index-2qqsnh1b.js";
41
- import"./index-a11nmw5t.js";
42
+ import"./index-z7dktknj.js";
42
43
  import"./index-hgd00nas.js";
43
44
  import"./index-9p40dgkm.js";
44
45
  import"./index-mp0gh04g.js";
45
46
  import"./index-yhzhdp3m.js";
46
- import"./index-vgfk2xa5.js";
47
- import"./index-d21rhpbd.js";
48
- import"./index-8m82cez2.js";
49
- import"./index-yhsmjvqa.js";
47
+ import"./index-jbkwszd5.js";
48
+ import"./index-p9jfa33t.js";
49
+ import"./index-kj49vs41.js";
50
+ import"./index-pwp6zyx3.js";
50
51
  import"./index-6x556c2q.js";
51
52
  import"./index-ea37qn4x.js";
52
53
  import"./index-w26zvs1q.js";
53
54
  import"./index-1cvyaw9a.js";
54
- import"./index-6y6v2wvn.js";
55
- import"./index-m68qfjte.js";
55
+ import"./index-gxqmh9hq.js";
56
+ import"./index-ry84c8dr.js";
56
57
  import"./index-29nw7n1r.js";
57
- import"./index-yg42q9bc.js";
58
- import"./index-d0w84hy5.js";
58
+ import"./index-f6y7mdq9.js";
59
+ import"./index-y90fxz4t.js";
59
60
  import"./index-0wtm7g7f.js";
60
61
  import {
61
62
  setStoragePrivatePermissionEnforcement
@@ -8,15 +8,16 @@ import"./index-dnp1jjar.js";
8
8
  import {
9
9
  LATEST_SUPPORTED_VERSION,
10
10
  getPersistedSchemaVersion
11
- } from "./index-11knwv2h.js";
11
+ } from "./index-a7sj2bam.js";
12
12
  import"./index-fapenpch.js";
13
13
  import"./index-3bb24eb6.js";
14
- import"./index-399p688g.js";
14
+ import"./index-8sqebjzk.js";
15
+ import"./index-wfqysrwq.js";
15
16
  import {
16
17
  exitOnWorkerClose
17
- } from "./index-54wmg4rj.js";
18
- import"./index-mkh1cm5k.js";
19
- import"./index-rgvqh5x7.js";
18
+ } from "./index-x2n261wp.js";
19
+ import"./index-c1dqxr10.js";
20
+ import"./index-ck8wj35v.js";
20
21
  import"./index-d107f484.js";
21
22
  import {
22
23
  tagRevisionKey
@@ -28,221 +29,226 @@ import"./index-c6wbq66z.js";
28
29
  import {
29
30
  normalizeTagSnapshotRow2,
30
31
  TAG_SELECT_COLUMNS2
31
- } from "./index-yhsmjvqa.js";
32
+ } from "./index-pwp6zyx3.js";
32
33
  import {
33
34
  encodePiHydrationOperation,
34
35
  projectPiPassTag,
35
36
  PI_FALLBACK_ROW_COLUMNS,
36
37
  PI_FALLBACK_ROW_PREDICATE
37
- } from "./index-0rvn6vhq.js";
38
+ } from "./index-wwsfevck.js";
38
39
  import"./index-0wtm7g7f.js";
40
+ import {
41
+ serveWorkerJobs
42
+ } from "./index-nypgv96r.js";
39
43
 
40
44
  // src/tag-snapshot-worker-pi.ts
41
45
  import { setTimeout as delay } from "node:timers/promises";
42
- import { parentPort, workerData } from "node:worker_threads";
43
- var port = parentPort;
44
- if (!port)
45
- throw new Error("Pi tag hydration requires a worker port");
46
- var request = workerData;
47
- var db;
48
- var sequence = 0;
49
- var generation = { revision: "0", durable: 0 };
50
- var maxReadTransactionMs = 0;
51
- var packetCount = 0;
52
- var packetBytes = 0;
53
- var sampledGeneration = false;
54
- var generationStatement;
55
- var opened = false;
56
- var persistedVersion = 0;
57
- var { closePort } = exitOnWorkerClose(port, () => {
58
- const connection = db;
59
- db = undefined;
60
- connection?.close();
61
- });
46
+ serveWorkerJobs(async (request, port) => {
47
+ let db;
48
+ let sequence = 0;
49
+ let generation = { revision: "0", durable: 0 };
50
+ let maxReadTransactionMs = 0;
51
+ let packetCount = 0;
52
+ let packetBytes = 0;
53
+ let sampledGeneration = false;
54
+ let generationStatement;
55
+ let opened = false;
56
+ let persistedVersion = 0;
57
+ const { closePort } = exitOnWorkerClose(port, () => {
58
+ const connection = db;
59
+ db = undefined;
60
+ connection?.close();
61
+ });
62
62
 
63
- class StaleGeneration extends Error {
64
- }
63
+ class StaleGeneration extends Error {
64
+ }
65
65
 
66
- class UnsupportedSchema extends Error {
67
- }
68
- function sample(_connection) {
69
- return generationStatement.get(tagRevisionKey(request.sessionId), request.sessionId);
70
- }
71
- function envelope() {
72
- return {
73
- jobId: request.jobId,
74
- sessionId: request.sessionId,
75
- connectionEpoch: request.connectionEpoch,
76
- sessionEpoch: request.sessionEpoch,
77
- sequence: sequence++,
78
- generation
79
- };
80
- }
81
- async function send(message) {
82
- const ack = new Promise((resolve, reject) => {
83
- port?.once("message", (value) => {
84
- if (value.type !== "ack" || value.sequence !== message.sequence)
85
- reject(new Error("invalid packet credit"));
86
- else if (message.type === "packet" && (!(value.bytes instanceof ArrayBuffer) || value.bytes.byteLength !== 65536))
87
- reject(new Error("invalid returned packet buffer"));
88
- else
89
- resolve(value.bytes);
66
+ class UnsupportedSchema extends Error {
67
+ }
68
+ function sample(_connection) {
69
+ return generationStatement.get(tagRevisionKey(request.sessionId), request.sessionId);
70
+ }
71
+ function envelope() {
72
+ return {
73
+ jobId: request.jobId,
74
+ sessionId: request.sessionId,
75
+ connectionEpoch: request.connectionEpoch,
76
+ sessionEpoch: request.sessionEpoch,
77
+ sequence: sequence++,
78
+ generation
79
+ };
80
+ }
81
+ async function send(message) {
82
+ const ack = new Promise((resolve, reject) => {
83
+ port?.once("message", (value) => {
84
+ if (value.type !== "ack" || value.sequence !== message.sequence)
85
+ reject(new Error("invalid packet credit"));
86
+ else if (message.type === "packet" && (!(value.bytes instanceof ArrayBuffer) || value.bytes.byteLength !== 65536))
87
+ reject(new Error("invalid returned packet buffer"));
88
+ else
89
+ resolve(value.bytes);
90
+ });
90
91
  });
91
- });
92
- if (message.type === "packet")
93
- port?.postMessage(message, [message.bytes]);
94
- else
95
- port?.postMessage(message);
96
- return await ack;
97
- }
98
- function* operations(row) {
99
- if (Object.values(row).every((value) => !(typeof value === "string" && value.length > 2048) && !(value instanceof Uint8Array && value.length > 2048))) {
100
- yield { type: "row", value: row };
101
- return;
92
+ if (message.type === "packet")
93
+ port?.postMessage(message, [message.bytes]);
94
+ else
95
+ port?.postMessage(message);
96
+ return await ack;
102
97
  }
103
- for (const [key, value] of Object.entries(row)) {
104
- if (typeof value === "string" || value instanceof Uint8Array) {
105
- if (value.length === 0)
98
+ function* operations(row) {
99
+ if (Object.values(row).every((value) => !(typeof value === "string" && value.length > 2048) && !(value instanceof Uint8Array && value.length > 2048))) {
100
+ yield { type: "row", value: row };
101
+ return;
102
+ }
103
+ for (const [key, value] of Object.entries(row)) {
104
+ if (typeof value === "string" || value instanceof Uint8Array) {
105
+ if (value.length === 0)
106
+ yield { type: "field", key, value, append: false };
107
+ for (let start = 0;start < value.length; start += 2048)
108
+ yield {
109
+ type: "field",
110
+ key,
111
+ value: value.slice(start, start + 2048),
112
+ append: start !== 0,
113
+ totalLength: value instanceof Uint8Array ? value.length : undefined
114
+ };
115
+ } else
106
116
  yield { type: "field", key, value, append: false };
107
- for (let start = 0;start < value.length; start += 2048)
108
- yield {
109
- type: "field",
110
- key,
111
- value: value.slice(start, start + 2048),
112
- append: start !== 0,
113
- totalLength: value instanceof Uint8Array ? value.length : undefined
114
- };
115
- } else
116
- yield { type: "field", key, value, append: false };
117
- }
118
- yield { type: "row-end" };
119
- }
120
- async function stream(kind) {
121
- const connection = db;
122
- if (!connection)
123
- throw new Error("closed worker connection");
124
- let cursor;
125
- let rowsSent = 0;
126
- const columns = kind === "tags" ? TAG_SELECT_COLUMNS2 : PI_FALLBACK_ROW_COLUMNS;
127
- const fallback = kind === "fallback" ? `AND ${PI_FALLBACK_ROW_PREDICATE}` : "";
128
- const query = `SELECT ${columns} FROM tags WHERE session_id = ? ${fallback}`;
129
- const firstPage = connection.prepare(`${query} ORDER BY tag_number ASC, id ASC LIMIT 256`);
130
- const nextPage = connection.prepare(`${query} AND (tag_number, id) > (?, ?) ORDER BY tag_number ASC, id ASC LIMIT 256`);
131
- const nextNullPage = connection.prepare(`${query} AND ((tag_number IS NULL AND id > ?) OR tag_number IS NOT NULL) ORDER BY tag_number ASC, id ASC LIMIT 256`);
132
- let buffer = new Uint8Array(65536);
133
- for (;; ) {
134
- if (request.test?.pageDelayMs)
135
- await delay(request.test.pageDelayMs);
136
- const started = performance.now();
137
- let rows;
138
- connection.exec("BEGIN");
139
- try {
140
- const stamp = sample(connection);
141
- if (!sampledGeneration) {
142
- sampledGeneration = true;
143
- generation = stamp;
144
- } else if (stamp.revision !== generation.revision || stamp.durable !== generation.durable)
145
- throw new StaleGeneration("session tags changed between pages");
146
- rows = cursor ? cursor.tag_number === null ? nextNullPage.all(request.sessionId, cursor.id) : nextPage.all(request.sessionId, cursor.tag_number, cursor.id) : firstPage.all(request.sessionId);
147
- connection.exec("COMMIT");
148
- } catch (error) {
149
- connection.exec("ROLLBACK");
150
- throw error;
151
- } finally {
152
- maxReadTransactionMs = Math.max(maxReadTransactionMs, performance.now() - started);
153
117
  }
154
- let used = 0;
155
- let packetRows = 0;
156
- const flush = async () => {
157
- if (used === 0)
158
- return;
159
- const bytes = buffer.buffer;
160
- packetCount++;
161
- packetBytes += used;
162
- const returned = await send({
163
- ...envelope(),
164
- type: "packet",
165
- stream: kind,
166
- bytes,
167
- byteLength: used,
168
- rows: packetRows
169
- });
170
- buffer = new Uint8Array(returned);
171
- used = 0;
172
- packetRows = 0;
173
- };
174
- for (const raw of rows) {
175
- cursor = { tag_number: raw.tag_number, id: raw.id };
176
- const normalized = kind === "tags" ? normalizeTagSnapshotRow2(raw) : raw;
177
- const row = kind === "tags" && normalized && request.projection === "pass" ? projectPiPassTag(normalized) : normalized;
178
- if (!row)
179
- continue;
180
- for (const operation of operations(row)) {
181
- const encoded = encodePiHydrationOperation(operation);
182
- if (encoded.length + 4 > 65536)
183
- throw new Error("field fragment exceeds packet limit");
184
- if (used + encoded.length + 4 > buffer.length || packetRows === 256)
185
- await flush();
186
- new DataView(buffer.buffer).setUint32(used, encoded.length);
187
- used += 4;
188
- buffer.set(encoded, used);
189
- used += encoded.length;
190
- if (operation.type === "row" || operation.type === "row-end") {
191
- packetRows++;
192
- rowsSent++;
118
+ yield { type: "row-end" };
119
+ }
120
+ async function stream(kind) {
121
+ const connection = db;
122
+ if (!connection)
123
+ throw new Error("closed worker connection");
124
+ let cursor;
125
+ let rowsSent = 0;
126
+ const columns = kind === "tags" ? TAG_SELECT_COLUMNS2 : PI_FALLBACK_ROW_COLUMNS;
127
+ const fallback = kind === "fallback" ? `AND ${PI_FALLBACK_ROW_PREDICATE}` : "";
128
+ const query = `SELECT ${columns} FROM tags WHERE session_id = ? ${fallback}`;
129
+ const firstPage = connection.prepare(`${query} ORDER BY tag_number ASC, id ASC LIMIT 256`);
130
+ const nextPage = connection.prepare(`${query} AND (tag_number, id) > (?, ?) ORDER BY tag_number ASC, id ASC LIMIT 256`);
131
+ const nextNullPage = connection.prepare(`${query} AND ((tag_number IS NULL AND id > ?) OR tag_number IS NOT NULL) ORDER BY tag_number ASC, id ASC LIMIT 256`);
132
+ let buffer = new Uint8Array(65536);
133
+ for (;; ) {
134
+ if (request.test?.pageDelayMs)
135
+ await delay(request.test.pageDelayMs);
136
+ const started = performance.now();
137
+ let rows;
138
+ connection.exec("BEGIN");
139
+ try {
140
+ const stamp = sample(connection);
141
+ if (!sampledGeneration) {
142
+ sampledGeneration = true;
143
+ generation = stamp;
144
+ } else if (stamp.revision !== generation.revision || stamp.durable !== generation.durable)
145
+ throw new StaleGeneration("session tags changed between pages");
146
+ rows = cursor ? cursor.tag_number === null ? nextNullPage.all(request.sessionId, cursor.id) : nextPage.all(request.sessionId, cursor.tag_number, cursor.id) : firstPage.all(request.sessionId);
147
+ connection.exec("COMMIT");
148
+ } catch (error) {
149
+ connection.exec("ROLLBACK");
150
+ throw error;
151
+ } finally {
152
+ maxReadTransactionMs = Math.max(maxReadTransactionMs, performance.now() - started);
153
+ }
154
+ let used = 0;
155
+ let packetRows = 0;
156
+ const flush = async () => {
157
+ if (used === 0)
158
+ return;
159
+ const bytes = buffer.buffer;
160
+ packetCount++;
161
+ packetBytes += used;
162
+ const returned = await send({
163
+ ...envelope(),
164
+ type: "packet",
165
+ stream: kind,
166
+ bytes,
167
+ byteLength: used,
168
+ rows: packetRows
169
+ });
170
+ buffer = new Uint8Array(returned);
171
+ used = 0;
172
+ packetRows = 0;
173
+ };
174
+ for (const raw of rows) {
175
+ cursor = { tag_number: raw.tag_number, id: raw.id };
176
+ const normalized = kind === "tags" ? normalizeTagSnapshotRow2(raw) : raw;
177
+ const row = kind === "tags" && normalized && request.projection === "pass" ? projectPiPassTag(normalized) : normalized;
178
+ if (!row)
179
+ continue;
180
+ for (const operation of operations(row)) {
181
+ const encoded = encodePiHydrationOperation(operation);
182
+ if (encoded.length + 4 > 65536)
183
+ throw new Error("field fragment exceeds packet limit");
184
+ if (used + encoded.length + 4 > buffer.length || packetRows === 256)
185
+ await flush();
186
+ new DataView(buffer.buffer).setUint32(used, encoded.length);
187
+ used += 4;
188
+ buffer.set(encoded, used);
189
+ used += encoded.length;
190
+ if (operation.type === "row" || operation.type === "row-end") {
191
+ packetRows++;
192
+ rowsSent++;
193
+ }
193
194
  }
194
195
  }
196
+ await flush();
197
+ if (rows.length < 256)
198
+ break;
195
199
  }
196
- await flush();
197
- if (rows.length < 256)
198
- break;
200
+ await send({ ...envelope(), type: "end", stream: kind, rows: rowsSent });
199
201
  }
200
- await send({ ...envelope(), type: "end", stream: kind, rows: rowsSent });
201
- }
202
- var run = async () => {
203
- try {
204
- if (request.test?.openDelayMs)
205
- await delay(request.test.openDelayMs);
206
- db = new Database2(request.path, { readonly: true });
207
- opened = true;
208
- db.exec("PRAGMA query_only = ON; PRAGMA busy_timeout = 50; PRAGMA cache_size = -1024");
209
- generationStatement = db.prepare(`SELECT
202
+ const run = async () => {
203
+ try {
204
+ if (request.test?.openDelayMs)
205
+ await delay(request.test.openDelayMs);
206
+ db = new Database2(request.path, { readonly: true });
207
+ opened = true;
208
+ db.exec("PRAGMA query_only = ON; PRAGMA busy_timeout = 50; PRAGMA cache_size = -1024");
209
+ generationStatement = db.prepare(`SELECT
210
210
  COALESCE((SELECT value FROM schema_migrations_meta WHERE key = ?), '0') AS revision,
211
211
  COALESCE((SELECT tags_version FROM session_meta WHERE session_id = ?), 0) AS durable`);
212
- const version = getPersistedSchemaVersion(db);
213
- persistedVersion = version;
214
- if (version > LATEST_SUPPORTED_VERSION)
215
- throw new UnsupportedSchema(`shared database schema v${version} is newer than this build supports (v${LATEST_SUPPORTED_VERSION}); update and restart this host`);
216
- await stream("tags");
217
- await stream("fallback");
218
- if (request.test?.crash === "before-end")
219
- throw new Error("injected worker crash before completion");
220
- const final = sample(db);
221
- if (final.revision !== generation.revision || final.durable !== generation.durable)
222
- throw new StaleGeneration("session tags changed after final page");
223
- db.close();
224
- db = undefined;
225
- port.postMessage({
226
- ...envelope(),
227
- type: "done",
228
- maxReadTransactionMs,
229
- packetCount,
230
- packetBytes
231
- });
232
- if (request.test?.crash === "after-end")
233
- process.exitCode = 1;
234
- } catch (error) {
235
- port.postMessage({
236
- ...envelope(),
237
- type: "failed",
238
- code: error instanceof StaleGeneration ? "stale" : error instanceof UnsupportedSchema ? "schema" : opened ? "failed" : "open",
239
- persistedVersion,
240
- supportedVersion: LATEST_SUPPORTED_VERSION,
241
- reason: error instanceof Error ? error.message : String(error)
242
- });
243
- } finally {
244
- db?.close();
245
- closePort();
246
- }
247
- };
248
- run();
212
+ const version = getPersistedSchemaVersion(db);
213
+ persistedVersion = version;
214
+ if (version > LATEST_SUPPORTED_VERSION)
215
+ throw new UnsupportedSchema(`shared database schema v${version} is newer than this build supports (v${LATEST_SUPPORTED_VERSION}); update and restart this host`);
216
+ await stream("tags");
217
+ await stream("fallback");
218
+ if (request.test?.crash === "before-end")
219
+ throw new Error("injected worker crash before completion");
220
+ const final = sample(db);
221
+ if (final.revision !== generation.revision || final.durable !== generation.durable)
222
+ throw new StaleGeneration("session tags changed after final page");
223
+ db.close();
224
+ db = undefined;
225
+ port.postMessage({
226
+ ...envelope(),
227
+ type: "done",
228
+ maxReadTransactionMs,
229
+ packetCount,
230
+ packetBytes
231
+ });
232
+ if (request.test?.crash === "after-end")
233
+ process.exit(1);
234
+ } catch (error) {
235
+ port.postMessage({
236
+ ...envelope(),
237
+ type: "failed",
238
+ code: error instanceof StaleGeneration ? "stale" : error instanceof UnsupportedSchema ? "schema" : opened ? "failed" : "open",
239
+ persistedVersion,
240
+ supportedVersion: LATEST_SUPPORTED_VERSION,
241
+ reason: error instanceof Error ? error.message : String(error)
242
+ });
243
+ if (request.test?.crash === "before-end") {
244
+ db?.close();
245
+ db = undefined;
246
+ process.exit(1);
247
+ }
248
+ } finally {
249
+ db?.close();
250
+ closePort();
251
+ }
252
+ };
253
+ await run();
254
+ });
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-6y6v2wvn.js";
5
- import"./index-399p688g.js";
4
+ } from "./index-gxqmh9hq.js";
5
+ import"./index-8sqebjzk.js";
6
6
  import"./index-2qtx0q6h.js";
7
- import"./index-54wmg4rj.js";
7
+ import"./index-x2n261wp.js";
8
8
  export {
9
9
  readV2ArchiveOffThread2 as readV2ArchiveOffThread,
10
10
  serveV2ArchiveReads2 as serveV2ArchiveReads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.35",
3
+ "version": "0.49.36",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",