@cortexkit/pi-magic-context 0.49.15 → 0.49.16

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 (40) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +8 -6
  3. package/dist/{embedding-backfill-7kj16fh9.js → embedding-backfill-c4bdw8pp.js} +10 -8
  4. package/dist/embedding-worker.js +2 -2
  5. package/dist/index-1cvyaw9a.js +58 -0
  6. package/dist/{index-hshd96pt.js → index-4178cbfw.js} +19 -68
  7. package/dist/{index-75ah9413.js → index-44h64qza.js} +3 -3
  8. package/dist/{index-9jvktm7k.js → index-657xh9w4.js} +1 -1
  9. package/dist/{index-7qc73yk5.js → index-afy3dzf9.js} +3 -3
  10. package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
  11. package/dist/{index-j0n09wtp.js → index-dne4ja7a.js} +7 -5
  12. package/dist/{index-a4pk5yv9.js → index-fhyy4ave.js} +14 -14
  13. package/dist/index-ja1c33qa.js +62 -0
  14. package/dist/{index-1mrvw9en.js → index-mx59cve4.js} +1 -1
  15. package/dist/{index-nwbhe6qv.js → index-n3r2d2pr.js} +5 -5
  16. package/dist/{index-7wagp5jp.js → index-p3evwech.js} +3 -3
  17. package/dist/{index-he9s4qsj.js → index-qqxqwqhp.js} +22 -2
  18. package/dist/{index-djxc8w8c.js → index-s1xn8qfw.js} +21 -25
  19. package/dist/{index-bet4sd3e.js → index-tympym62.js} +1 -1
  20. package/dist/{index-ccsscaap.js → index-v8d4vgam.js} +37 -16
  21. package/dist/index-wrr9rp9a.js +16 -0
  22. package/dist/{index-1vw4f2pe.js → index-x3k1530z.js} +5 -7
  23. package/dist/{index-0awvkeb5.js → index-xmzhrht0.js} +10 -61
  24. package/dist/{index-6ex901g3.js → index-y5c73caa.js} +2 -2
  25. package/dist/index.js +183 -130
  26. package/dist/message-fts-rowid-map-mbanfkt1.js +22 -0
  27. package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-xzerjxmp.js} +7 -7
  28. package/dist/{message-index-dw4z9efj.js → message-index-easvmz22.js} +8 -8
  29. package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-3q4kemfc.js} +4 -4
  30. package/dist/migration-worker.js +6 -4
  31. package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-xwnmqmx8.js} +9 -7
  32. package/dist/raw-ordinal-warmup-worker.js +37 -7
  33. package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-1sb5n7zs.js} +5 -5
  34. package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-jz5e9jz0.js} +1 -1
  35. package/dist/search-archive-3ma5n0wr.js +20 -0
  36. package/dist/{search-ddbz6v60.js → search-x3fa0561.js} +16 -15
  37. package/dist/{storage-tags-3kb5tvgg.js → storage-tags-jtessrec.js} +1 -1
  38. package/dist/subagent-entry.js +19 -17
  39. package/dist/tag-snapshot-worker-pi.js +15 -18
  40. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ import {
2
+ recordMessageFtsRowid2,
3
+ recordIndexedMessageTime2,
4
+ runMessageFtsRowidMapBackfill2,
5
+ startMessageFtsRowidMapBackfill2,
6
+ messageFtsOrdinalRangeIsMapped2,
7
+ deleteUnmappedMessageFtsRows2
8
+ } from "./index-s1xn8qfw.js";
9
+ import"./index-qqxqwqhp.js";
10
+ import"./index-399p688g.js";
11
+ import"./index-d4dt19md.js";
12
+ import"./index-asrxgdt4.js";
13
+ import"./index-7bqrfyny.js";
14
+ import"./index-0h2mkab2.js";
15
+ export {
16
+ deleteUnmappedMessageFtsRows2 as deleteUnmappedMessageFtsRows,
17
+ messageFtsOrdinalRangeIsMapped2 as messageFtsOrdinalRangeIsMapped,
18
+ recordIndexedMessageTime2 as recordIndexedMessageTime,
19
+ recordMessageFtsRowid2 as recordMessageFtsRowid,
20
+ runMessageFtsRowidMapBackfill2 as runMessageFtsRowidMapBackfill,
21
+ startMessageFtsRowidMapBackfill2 as startMessageFtsRowidMapBackfill
22
+ };
@@ -3,16 +3,16 @@ import {
3
3
  withIndexChunk2,
4
4
  yieldIndexChunk2
5
5
  } from "./index-asrxgdt4.js";
6
- import"./index-j0n09wtp.js";
6
+ import"./index-dne4ja7a.js";
7
7
  import"./index-g4jf772p.js";
8
8
  import"./index-0h2mkab2.js";
9
9
  import"./index-7bqrfyny.js";
10
10
  import"./index-jrap43gc.js";
11
- import"./index-1k729e4f.js";
11
+ import"./index-bxmf4dhr.js";
12
12
  import"./index-399p688g.js";
13
- import"./index-he9s4qsj.js";
13
+ import"./index-qqxqwqhp.js";
14
14
  import"./index-8976mezv.js";
15
- import"./index-75ah9413.js";
15
+ import"./index-44h64qza.js";
16
16
  import"./index-6x556c2q.js";
17
17
  import {
18
18
  MESSAGE_INDEX_MAX_FTS_BYTES2,
@@ -21,11 +21,11 @@ import {
21
21
  markMessageIndexDirty2,
22
22
  getIndexableContent2,
23
23
  indexSingleMessage2
24
- } from "./index-a4pk5yv9.js";
25
- import"./index-djxc8w8c.js";
24
+ } from "./index-fhyy4ave.js";
25
+ import"./index-s1xn8qfw.js";
26
26
  import"./index-apgwdby5.js";
27
27
  import"./index-6dz2ed1v.js";
28
- import"./index-7qc73yk5.js";
28
+ import"./index-afy3dzf9.js";
29
29
  import"./index-d4dt19md.js";
30
30
 
31
31
  // ../plugin/src/features/magic-context/message-index-bounded.ts
@@ -17,19 +17,19 @@ import {
17
17
  indexMessagesAfterOrdinal2,
18
18
  indexSourcesAfterOrdinal2,
19
19
  sweepOrphanedOpenCodeMessageIndexes2
20
- } from "./index-a4pk5yv9.js";
21
- import"./index-7qc73yk5.js";
22
- import"./index-75ah9413.js";
23
- import"./index-he9s4qsj.js";
24
- import"./index-399p688g.js";
25
- import"./index-j0n09wtp.js";
20
+ } from "./index-fhyy4ave.js";
21
+ import"./index-afy3dzf9.js";
22
+ import"./index-44h64qza.js";
23
+ import"./index-dne4ja7a.js";
26
24
  import"./index-6x556c2q.js";
27
25
  import"./index-6dz2ed1v.js";
28
- import"./index-1k729e4f.js";
26
+ import"./index-bxmf4dhr.js";
29
27
  import"./index-apgwdby5.js";
30
- import"./index-djxc8w8c.js";
28
+ import"./index-s1xn8qfw.js";
31
29
  import"./index-8976mezv.js";
32
30
  import"./index-jrap43gc.js";
31
+ import"./index-qqxqwqhp.js";
32
+ import"./index-399p688g.js";
33
33
  import"./index-d4dt19md.js";
34
34
  import"./index-g4jf772p.js";
35
35
  import"./index-asrxgdt4.js";
@@ -95,20 +95,20 @@ function backfillMessageTimesBatch(db, reader, batchSize = MESSAGE_TIME_BACKFILL
95
95
  completed
96
96
  };
97
97
  }
98
- async function runMessageTimeBackfill(db, reader) {
98
+ async function runMessageTimeBackfill(db, reader, signal) {
99
99
  await new Promise((resolve) => setTimeout(resolve, 0));
100
- for (;; ) {
100
+ while (!signal?.aborted) {
101
101
  const progress = backfillMessageTimesBatch(db, reader);
102
102
  if (progress.completed)
103
103
  return;
104
104
  await new Promise((resolve) => setTimeout(resolve, 0));
105
105
  }
106
106
  }
107
- function startMessageTimeBackfill(db, reader) {
107
+ function startMessageTimeBackfill(db, reader, signal) {
108
108
  const active = activeBackfills.get(db);
109
109
  if (active)
110
110
  return active;
111
- const run = withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => runMessageTimeBackfill(db, reader))).finally(() => activeBackfills.delete(db));
111
+ const run = withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => runMessageTimeBackfill(db, reader, signal))).finally(() => activeBackfills.delete(db));
112
112
  activeBackfills.set(db, run);
113
113
  return run;
114
114
  }
@@ -9,19 +9,21 @@ import {
9
9
  import"./index-135e8hvg.js";
10
10
  import {
11
11
  runMigrationsWithRetry
12
- } from "./index-bet4sd3e.js";
12
+ } from "./index-tympym62.js";
13
13
  import {
14
14
  closeQuietly
15
15
  } from "./index-jrap43gc.js";
16
16
  import"./index-8976mezv.js";
17
- import"./index-6ex901g3.js";
17
+ import"./index-y5c73caa.js";
18
18
  import"./index-apgwdby5.js";
19
19
  import"./index-fapenpch.js";
20
20
  import {
21
21
  setSqlitePragmaConfig,
22
22
  initializeDatabase
23
- } from "./index-ccsscaap.js";
24
- import"./index-djxc8w8c.js";
23
+ } from "./index-v8d4vgam.js";
24
+ import"./index-399p688g.js";
25
+ import"./index-qqxqwqhp.js";
26
+ import"./index-s1xn8qfw.js";
25
27
  import"./index-g4jf772p.js";
26
28
  import"./index-d4dt19md.js";
27
29
 
@@ -33,16 +33,18 @@ import {
33
33
  sweepAllRegisteredProjects2,
34
34
  _setTestProviderFactoryForProject2,
35
35
  _resetProjectEmbeddingRegistryForTests2
36
- } from "./index-nwbhe6qv.js";
36
+ } from "./index-n3r2d2pr.js";
37
37
  import"./index-9p40dgkm.js";
38
38
  import"./index-yhzhdp3m.js";
39
- import"./index-1mrvw9en.js";
40
- import"./index-7qc73yk5.js";
41
- import"./index-9jvktm7k.js";
39
+ import"./index-mx59cve4.js";
40
+ import"./index-afy3dzf9.js";
41
+ import"./index-657xh9w4.js";
42
42
  import"./index-6dz2ed1v.js";
43
- import"./index-1k729e4f.js";
44
- import"./index-6ex901g3.js";
45
- import"./index-djxc8w8c.js";
43
+ import"./index-bxmf4dhr.js";
44
+ import"./index-y5c73caa.js";
45
+ import"./index-s1xn8qfw.js";
46
+ import"./index-qqxqwqhp.js";
47
+ import"./index-399p688g.js";
46
48
  import"./index-d4dt19md.js";
47
49
  import"./index-g4jf772p.js";
48
50
  import"./index-asrxgdt4.js";
@@ -12,7 +12,7 @@ var [
12
12
  { log }
13
13
  ] = await Promise.all([
14
14
  import("./sqlite-adjpy399.js"),
15
- import("./read-session-raw-azkqjgzg.js"),
15
+ import("./read-session-raw-jz5e9jz0.js"),
16
16
  import("./harness-9872e0ym.js"),
17
17
  import("./logger-dygt96rn.js")
18
18
  ]);
@@ -21,9 +21,36 @@ registerSqliteDiagnosticSink(log, getHarness);
21
21
  var db;
22
22
  var reply;
23
23
  try {
24
- db = input.indexMessage || input.orphanSweep ? new Database(input.path) : new Database(input.path, { readonly: true });
24
+ if (input.openCancellation && Atomics.load(new Int32Array(input.openCancellation), 0) !== 0) {
25
+ throw new Error("warm-up owner closed before database open");
26
+ }
27
+ db = input.indexMessage || input.orphanSweep || input.ftsRowidBackfill ? new Database(input.path) : new Database(input.path, { readonly: true });
25
28
  db.exec("PRAGMA busy_timeout = 250");
26
- if (input.exactOrdinalIds) {
29
+ if (input.ftsRowidBackfill) {
30
+ const { runMessageFtsRowidMapBackfill } = await import("./message-fts-rowid-map-mbanfkt1.js");
31
+ db.exec("PRAGMA busy_timeout = 0");
32
+ await runMessageFtsRowidMapBackfill(db);
33
+ reply = { kind: "fts-rowid-backfill" };
34
+ } else if (input.searchArchive) {
35
+ const { renderSearchArchive } = await import("./search-archive-3ma5n0wr.js");
36
+ const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-jz5e9jz0.js");
37
+ const archive = input.searchArchive;
38
+ let raw;
39
+ try {
40
+ reply = {
41
+ kind: "search-archive",
42
+ text: renderSearchArchive(db, input.sessionId, archive.start, archive.end, archive.tokenBudget, archive.archiveOnly, () => {
43
+ if (!archive.rawPath)
44
+ return new Map(archive.rawIds);
45
+ raw = new Database(archive.rawPath, { readonly: true });
46
+ raw.exec("PRAGMA busy_timeout = 250");
47
+ return readRawSessionMessageIdOrdinalsForRangeFromDb(raw, input.sessionId, archive.start, archive.end);
48
+ })
49
+ };
50
+ } finally {
51
+ raw?.close();
52
+ }
53
+ } else if (input.exactOrdinalIds) {
27
54
  reply = {
28
55
  kind: "exact-ordinal-ids",
29
56
  ids: readRawSessionMessageIdsAtOrdinalsFromDb(db, input.sessionId, input.exactOrdinalIds)
@@ -35,7 +62,7 @@ try {
35
62
  { configureContextDatabasePragmas }
36
63
  ] = await Promise.all([
37
64
  import("./harness-9872e0ym.js"),
38
- import("./message-index-dw4z9efj.js"),
65
+ import("./message-index-easvmz22.js"),
39
66
  import("./sqlite-context-pragmas-gcgch6qz.js")
40
67
  ]);
41
68
  setHarness(input.harness ?? "opencode");
@@ -49,7 +76,7 @@ try {
49
76
  const { setHarness } = await import("./harness-9872e0ym.js");
50
77
  setHarness(input.harness ?? "opencode");
51
78
  const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
52
- import("./message-index-bounded-z4d3x9ty.js"),
79
+ import("./message-index-bounded-xzerjxmp.js"),
53
80
  import("./sqlite-context-pragmas-gcgch6qz.js")
54
81
  ]);
55
82
  configureContextDatabasePragmas(db);
@@ -59,7 +86,7 @@ try {
59
86
  const result = await indexMessageInShortChunks(writer, input.sessionId, message, input, () => !cancellation || Atomics.load(cancellation, 0) === 0);
60
87
  reply = { kind: "indexed", inserted: result.inserted, measurements: result.measurements };
61
88
  } else if (input.tagRatio !== undefined) {
62
- const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-3kb5tvgg.js");
89
+ const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-jtessrec.js");
63
90
  const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
64
91
  if (delta)
65
92
  reply = { kind: "tag-delta", delta };
@@ -73,9 +100,12 @@ try {
73
100
  reply = { kind: "scan", scan };
74
101
  }
75
102
  } catch (error) {
103
+ const sqliteError = error;
76
104
  reply = {
77
105
  kind: "error",
78
- error: error instanceof Error ? error.stack ?? error.message : String(error)
106
+ error: error instanceof Error ? error.stack ?? error.message : String(error),
107
+ code: typeof sqliteError?.code === "string" ? sqliteError.code : undefined,
108
+ errcode: typeof sqliteError?.errcode === "number" ? sqliteError.errcode : undefined
79
109
  };
80
110
  } finally {
81
111
  db?.close();
@@ -35,14 +35,14 @@ import {
35
35
  readSessionChunk2,
36
36
  getRawSessionMessageIdsThrough2,
37
37
  readRawSessionSeedTail2
38
- } from "./index-75ah9413.js";
39
- import"./index-he9s4qsj.js";
40
- import"./index-399p688g.js";
41
- import"./index-j0n09wtp.js";
38
+ } from "./index-44h64qza.js";
39
+ import"./index-dne4ja7a.js";
42
40
  import"./index-6x556c2q.js";
43
- import"./index-1k729e4f.js";
41
+ import"./index-bxmf4dhr.js";
44
42
  import"./index-8976mezv.js";
45
43
  import"./index-jrap43gc.js";
44
+ import"./index-qqxqwqhp.js";
45
+ import"./index-399p688g.js";
46
46
  import"./index-d4dt19md.js";
47
47
  import {
48
48
  hasMeaningfulUserText2,
@@ -26,7 +26,7 @@ import {
26
26
  hasRawSessionMessageByIdFromDb2,
27
27
  readRawSeedTailFromDb2,
28
28
  readRawSessionBoundaryEndpointsFromDb2
29
- } from "./index-he9s4qsj.js";
29
+ } from "./index-qqxqwqhp.js";
30
30
  import"./index-399p688g.js";
31
31
  import"./index-asrxgdt4.js";
32
32
  import"./index-7bqrfyny.js";
@@ -0,0 +1,20 @@
1
+ import {
2
+ renderSearchArchive2
3
+ } from "./index-ja1c33qa.js";
4
+ import"./index-1cvyaw9a.js";
5
+ import"./index-44h64qza.js";
6
+ import"./index-dne4ja7a.js";
7
+ import"./index-6x556c2q.js";
8
+ import"./index-bxmf4dhr.js";
9
+ import"./index-8976mezv.js";
10
+ import"./index-jrap43gc.js";
11
+ import"./index-qqxqwqhp.js";
12
+ import"./index-399p688g.js";
13
+ import"./index-d4dt19md.js";
14
+ import"./index-g4jf772p.js";
15
+ import"./index-asrxgdt4.js";
16
+ import"./index-7bqrfyny.js";
17
+ import"./index-0h2mkab2.js";
18
+ export {
19
+ renderSearchArchive2 as renderSearchArchive
20
+ };
@@ -5,30 +5,31 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./index-0awvkeb5.js";
9
- import"./index-a4pk5yv9.js";
10
- import"./index-7wagp5jp.js";
11
- import"./index-nwbhe6qv.js";
8
+ } from "./index-xmzhrht0.js";
9
+ import"./index-1cvyaw9a.js";
10
+ import"./index-fhyy4ave.js";
11
+ import"./index-p3evwech.js";
12
+ import"./index-n3r2d2pr.js";
12
13
  import"./index-9p40dgkm.js";
13
14
  import"./index-hy44m6jc.js";
14
15
  import"./index-yhzhdp3m.js";
15
- import"./index-1mrvw9en.js";
16
- import"./index-7qc73yk5.js";
17
- import"./index-75ah9413.js";
18
- import"./index-he9s4qsj.js";
19
- import"./index-399p688g.js";
20
- import"./index-j0n09wtp.js";
16
+ import"./index-mx59cve4.js";
17
+ import"./index-afy3dzf9.js";
18
+ import"./index-44h64qza.js";
19
+ import"./index-dne4ja7a.js";
21
20
  import"./index-6x556c2q.js";
22
- import"./index-9jvktm7k.js";
21
+ import"./index-657xh9w4.js";
23
22
  import"./index-6dz2ed1v.js";
24
- import"./index-1k729e4f.js";
25
- import"./index-bet4sd3e.js";
23
+ import"./index-bxmf4dhr.js";
24
+ import"./index-tympym62.js";
26
25
  import"./index-apgwdby5.js";
27
- import"./index-6ex901g3.js";
28
- import"./index-djxc8w8c.js";
26
+ import"./index-y5c73caa.js";
27
+ import"./index-s1xn8qfw.js";
29
28
  import"./index-135e8hvg.js";
30
29
  import"./index-8976mezv.js";
31
30
  import"./index-jrap43gc.js";
31
+ import"./index-qqxqwqhp.js";
32
+ import"./index-399p688g.js";
32
33
  import"./index-d4dt19md.js";
33
34
  import"./index-g4jf772p.js";
34
35
  import"./index-asrxgdt4.js";
@@ -60,7 +60,7 @@ import {
60
60
  adoptNullOwnerToolTag2,
61
61
  getCandidateToolOwners2,
62
62
  pickNearestPriorOwner2
63
- } from "./index-j0n09wtp.js";
63
+ } from "./index-dne4ja7a.js";
64
64
  import"./index-jrap43gc.js";
65
65
  import"./index-g4jf772p.js";
66
66
  import"./index-asrxgdt4.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TOKEN_BUDGET_TOOL_REFUSAL
3
- } from "./index-75ah9413.js";
3
+ } from "./index-44h64qza.js";
4
4
  import {
5
5
  setHarness2
6
6
  } from "./index-0h2mkab2.js";
@@ -9,15 +9,17 @@ import {
9
9
  } from "./index-7bqrfyny.js";
10
10
  import {
11
11
  resolveProjectIdentityForSession
12
- } from "./index-6ex901g3.js";
12
+ } from "./index-y5c73caa.js";
13
13
  import"./index-asrxgdt4.js";
14
14
  import"./index-apgwdby5.js";
15
15
  import"./index-fapenpch.js";
16
16
  import {
17
17
  openDatabase
18
- } from "./index-ccsscaap.js";
19
- import"./index-djxc8w8c.js";
20
- import"./index-bet4sd3e.js";
18
+ } from "./index-v8d4vgam.js";
19
+ import"./index-399p688g.js";
20
+ import"./index-qqxqwqhp.js";
21
+ import"./index-s1xn8qfw.js";
22
+ import"./index-tympym62.js";
21
23
  import"./index-jrap43gc.js";
22
24
  import"./index-135e8hvg.js";
23
25
  import"./index-8976mezv.js";
@@ -27,22 +29,22 @@ import {
27
29
  ensureProjectRegisteredFromPiDirectory,
28
30
  resolvePiHarnessKind,
29
31
  registerMagicContextTools
30
- } from "./index-hshd96pt.js";
31
- import"./index-1k729e4f.js";
32
+ } from "./index-4178cbfw.js";
33
+ import"./index-bxmf4dhr.js";
32
34
  import"./index-6dz2ed1v.js";
33
- import"./index-7qc73yk5.js";
34
- import"./index-9jvktm7k.js";
35
- import"./index-nwbhe6qv.js";
35
+ import"./index-afy3dzf9.js";
36
+ import"./index-657xh9w4.js";
37
+ import"./index-n3r2d2pr.js";
36
38
  import"./index-9p40dgkm.js";
37
- import"./index-1mrvw9en.js";
39
+ import"./index-mx59cve4.js";
38
40
  import"./index-yhzhdp3m.js";
39
- import"./index-7wagp5jp.js";
40
- import"./index-a4pk5yv9.js";
41
- import"./index-j0n09wtp.js";
42
- import"./index-399p688g.js";
43
- import"./index-he9s4qsj.js";
41
+ import"./index-p3evwech.js";
42
+ import"./index-fhyy4ave.js";
43
+ import"./index-dne4ja7a.js";
44
44
  import"./index-6x556c2q.js";
45
- import"./index-0awvkeb5.js";
45
+ import"./index-xmzhrht0.js";
46
+ import"./index-1cvyaw9a.js";
47
+ import"./index-ja1c33qa.js";
46
48
  import"./index-hy44m6jc.js";
47
49
  import"./index-46q4e104.js";
48
50
  import"./index-d4dt19md.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Database2
3
3
  } from "./index-asrxgdt4.js";
4
- import"./index-6ex901g3.js";
4
+ import"./index-y5c73caa.js";
5
5
  import"./index-0h2mkab2.js";
6
6
  import"./index-7bqrfyny.js";
7
7
  import"./index-apgwdby5.js";
@@ -9,9 +9,11 @@ import"./index-fapenpch.js";
9
9
  import {
10
10
  LATEST_SUPPORTED_VERSION,
11
11
  getPersistedSchemaVersion
12
- } from "./index-ccsscaap.js";
13
- import"./index-djxc8w8c.js";
14
- import"./index-bet4sd3e.js";
12
+ } from "./index-v8d4vgam.js";
13
+ import"./index-399p688g.js";
14
+ import"./index-qqxqwqhp.js";
15
+ import"./index-s1xn8qfw.js";
16
+ import"./index-tympym62.js";
15
17
  import {
16
18
  tagRevisionKey
17
19
  } from "./index-jrap43gc.js";
@@ -21,12 +23,12 @@ import"./index-g4jf772p.js";
21
23
  import {
22
24
  normalizeTagSnapshotRow2,
23
25
  TAG_SELECT_COLUMNS2
24
- } from "./index-j0n09wtp.js";
26
+ } from "./index-dne4ja7a.js";
25
27
  import {
26
28
  encodePiHydrationOperation,
27
29
  PI_FALLBACK_ROW_COLUMNS,
28
30
  PI_FALLBACK_ROW_PREDICATE
29
- } from "./index-1vw4f2pe.js";
31
+ } from "./index-x3k1530z.js";
30
32
  import"./index-d4dt19md.js";
31
33
 
32
34
  // src/tag-snapshot-worker-pi.ts
@@ -42,8 +44,7 @@ var generation = { revision: "0", durable: 0 };
42
44
  var maxReadTransactionMs = 0;
43
45
  var packetCount = 0;
44
46
  var packetBytes = 0;
45
- var workerDataVersion;
46
- var dataVersionStatement;
47
+ var sampledGeneration = false;
47
48
  var generationStatement;
48
49
  var opened = false;
49
50
  var persistedVersion = 0;
@@ -53,9 +54,6 @@ class StaleGeneration extends Error {
53
54
 
54
55
  class UnsupportedSchema extends Error {
55
56
  }
56
- function dataVersion(_connection) {
57
- return dataVersionStatement.get().data_version;
58
- }
59
57
  function sample(_connection) {
60
58
  return generationStatement.get(tagRevisionKey(request.sessionId), request.sessionId);
61
59
  }
@@ -128,11 +126,11 @@ async function stream(kind) {
128
126
  connection.exec("BEGIN");
129
127
  try {
130
128
  const stamp = sample(connection);
131
- if (workerDataVersion === undefined) {
132
- workerDataVersion = dataVersion(connection);
129
+ if (!sampledGeneration) {
130
+ sampledGeneration = true;
133
131
  generation = stamp;
134
- } else if (stamp.revision !== generation.revision || stamp.durable !== generation.durable || dataVersion(connection) !== workerDataVersion)
135
- throw new StaleGeneration("database changed between pages");
132
+ } else if (stamp.revision !== generation.revision || stamp.durable !== generation.durable)
133
+ throw new StaleGeneration("session tags changed between pages");
136
134
  rows = cursor ? nextPage.all(request.sessionId, cursor.tag_number, cursor.tag_number, cursor.tag_number, cursor.id) : firstPage.all(request.sessionId);
137
135
  connection.exec("COMMIT");
138
136
  } catch (error) {
@@ -194,7 +192,6 @@ try {
194
192
  db = new Database2(request.path, { readonly: true });
195
193
  opened = true;
196
194
  db.exec("PRAGMA query_only = ON; PRAGMA busy_timeout = 50; PRAGMA cache_size = -1024");
197
- dataVersionStatement = db.prepare("PRAGMA data_version");
198
195
  generationStatement = db.prepare(`SELECT
199
196
  COALESCE((SELECT value FROM schema_migrations_meta WHERE key = ?), '0') AS revision,
200
197
  COALESCE((SELECT tags_version FROM session_meta WHERE session_id = ?), 0) AS durable`);
@@ -207,8 +204,8 @@ try {
207
204
  if (request.test?.crash === "before-end")
208
205
  throw new Error("injected worker crash before completion");
209
206
  const final = sample(db);
210
- if (dataVersion(db) !== workerDataVersion || final.revision !== generation.revision || final.durable !== generation.durable)
211
- throw new StaleGeneration("database changed after final page");
207
+ if (final.revision !== generation.revision || final.durable !== generation.durable)
208
+ throw new StaleGeneration("session tags changed after final page");
212
209
  db.close();
213
210
  db = undefined;
214
211
  port.postMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.15",
3
+ "version": "0.49.16",
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",