@cortexkit/pi-magic-context 0.49.34 → 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 (73) hide show
  1. package/dist/auto-search-worker.js +163 -155
  2. package/dist/chunk-embedding-write-worker.js +71 -66
  3. package/dist/{compaction-marker-candidates-p1kqkqhq.js → compaction-marker-candidates-9fzqg6y0.js} +6 -3
  4. package/dist/compaction-marker-candidates-worker.js +24 -23
  5. package/dist/{compartment-chunk-embedding-8c85ebce.js → compartment-chunk-embedding-jpcme6tz.js} +11 -9
  6. package/dist/embedding-backfill-002vyexq.js +27 -0
  7. package/dist/embedding-worker-process.js +2 -1
  8. package/dist/embedding-worker.js +5 -4
  9. package/dist/expand-attachments-8sxeyj26.js +21 -0
  10. package/dist/historian-calibration-extension.js +2 -1
  11. package/dist/{index-hqw0rt9k.js → index-0wtm7g7f.js} +1 -1
  12. package/dist/{index-wqpjhx1p.js → index-2qqsnh1b.js} +2 -2
  13. package/dist/index-3bb24eb6.js +229 -0
  14. package/dist/{index-48twbev2.js → index-6pk49fc3.js} +37 -51
  15. package/dist/{index-399p688g.js → index-8sqebjzk.js} +4 -1
  16. package/dist/{index-np9ryr8y.js → index-a7sj2bam.js} +24 -241
  17. package/dist/index-by1bzjcd.js +24 -0
  18. package/dist/{index-6981g1xv.js → index-c1dqxr10.js} +35 -5
  19. package/dist/index-c6wbq66z.js +168 -0
  20. package/dist/{index-bvpar0bg.js → index-ck8wj35v.js} +2 -2
  21. package/dist/{index-jn44h81p.js → index-cq71g4dk.js} +1 -1
  22. package/dist/{index-pb3ea2tq.js → index-d107f484.js} +5 -5
  23. package/dist/{index-f4fz95fy.js → index-dgqjq8sg.js} +398 -4996
  24. package/dist/index-dnp1jjar.js +222 -0
  25. package/dist/index-ea37qn4x.js +777 -0
  26. package/dist/{index-g2tfayfc.js → index-f6y7mdq9.js} +98 -552
  27. package/dist/{index-0gymvr5j.js → index-f9qet7y8.js} +19 -8
  28. package/dist/index-gxqmh9hq.js +194 -0
  29. package/dist/{index-fgs78jyd.js → index-gymgz20n.js} +5 -222
  30. package/dist/index-hgd00nas.js +113 -0
  31. package/dist/{index-9xd7qveg.js → index-jbkwszd5.js} +4 -4
  32. package/dist/{index-e61zxfts.js → index-kj49vs41.js} +4 -4
  33. package/dist/{index-4zemngt7.js → index-mp0gh04g.js} +2 -2
  34. package/dist/{index-eenxm3t3.js → index-mx757f3g.js} +51 -32
  35. package/dist/{index-23t8ryqw.js → index-n0zjvs3h.js} +1 -168
  36. package/dist/index-nypgv96r.js +58 -0
  37. package/dist/index-p9jfa33t.js +4171 -0
  38. package/dist/{index-eqw9t2ty.js → index-pwp6zyx3.js} +15 -4
  39. package/dist/{index-cj3bkd16.js → index-ry84c8dr.js} +2 -2
  40. package/dist/{index-gwxaz0z5.js → index-rzfr7wdv.js} +2 -2
  41. package/dist/index-w26zvs1q.js +528 -0
  42. package/dist/index-wfqysrwq.js +204 -0
  43. package/dist/index-wrr9rp9a.js +16 -0
  44. package/dist/{index-my0dn413.js → index-wt7vmyj4.js} +1 -1
  45. package/dist/{index-0mc0vv97.js → index-wwsfevck.js} +8 -5
  46. package/dist/{index-54wmg4rj.js → index-x2n261wp.js} +16 -14
  47. package/dist/{index-6wdwv3a6.js → index-y90fxz4t.js} +10 -4
  48. package/dist/{index-c474g0gj.js → index-yacs388s.js} +1 -1
  49. package/dist/{index-xn5yh0pn.js → index-z7dktknj.js} +34 -131
  50. package/dist/index.js +1316 -488
  51. package/dist/{logger-shetp43v.js → logger-2j70hhz4.js} +2 -1
  52. package/dist/{message-fts-rowid-map-3mbvdgn9.js → message-fts-rowid-map-hmgyfxxa.js} +8 -6
  53. package/dist/{message-index-bounded-a6na71rg.js → message-index-bounded-82sergz7.js} +15 -12
  54. package/dist/{message-time-backfill-e3r8ddh1.js → message-time-backfill-x45573rs.js} +3 -2
  55. package/dist/migration-worker.js +56 -48
  56. package/dist/{project-embedding-registry-acqb6be4.js → project-embedding-registry-16pj4vyf.js} +16 -13
  57. package/dist/raw-ordinal-warmup-worker.js +114 -113
  58. package/dist/{read-session-chunk-2xcp6f40.js → read-session-chunk-jxq427v6.js} +17 -10
  59. package/dist/{read-session-raw-g9b1zdn5.js → read-session-raw-a9ntjqap.js} +6 -4
  60. package/dist/render-2wan3bfh.js +42 -0
  61. package/dist/{safe-notification-target-zcpchea6.js → safe-notification-target-jk69jxwp.js} +3 -2
  62. package/dist/search-3p18trsb.js +50 -0
  63. package/dist/search-archive-pgrv04gv.js +25 -0
  64. package/dist/{storage-tags-6409qq18.js → storage-tags-p9y3bnw7.js} +5 -4
  65. package/dist/store-reader-2m80zs5z.js +14 -0
  66. package/dist/store-v60q7dje.js +452 -0
  67. package/dist/subagent-entry.js +34 -25
  68. package/dist/tag-snapshot-worker-pi.js +218 -209
  69. package/dist/v2-archive-reader-5zpj8hrg.js +11 -0
  70. package/package.json +1 -1
  71. package/dist/embedding-backfill-rwfmyvze.js +0 -24
  72. package/dist/search-archive-jate39w5.js +0 -21
  73. package/dist/search-b6hp64hc.js +0 -45
@@ -1,171 +1,179 @@
1
1
  import {
2
2
  exitOnWorkerClose
3
- } from "./index-54wmg4rj.js";
3
+ } from "./index-x2n261wp.js";
4
+ import {
5
+ serveWorkerJobs
6
+ } from "./index-nypgv96r.js";
4
7
 
5
8
  // ../plugin/src/hooks/magic-context/auto-search-worker.ts
6
- import { parentPort, workerData } from "node:worker_threads";
7
- if (!parentPort)
8
- throw new Error("auto-search worker requires a parent port");
9
- var port = parentPort;
10
- var input = workerData;
11
- var persistent = input.persistent === true;
12
- if (input.job === "messages") {
13
- port.postMessage({ kind: "accepted" });
14
- }
15
- var [
16
- { ensureMemoryEmbeddings },
17
- { getProjectEmbeddings },
18
- { getMemoriesByProject },
19
- { installProjectEmbeddingSearchBridge },
20
- { searchMessageHistory, unifiedSearch },
21
- { getLastCompartmentChunkPoolWarm, maintainCompartmentChunkSearchPools },
22
- { setEmbeddingSessionBusy },
23
- { getHarness, setHarness },
24
- { Database, registerSqliteDiagnosticSink },
25
- { log }
26
- ] = await Promise.all([
27
- import("./embedding-backfill-rwfmyvze.js"),
28
- import("./embedding-cache-7rp4gqzr.js"),
29
- import("./storage-memory-0ndn65fm.js"),
30
- import("./project-embedding-registry-acqb6be4.js"),
31
- import("./search-b6hp64hc.js"),
32
- import("./compartment-chunk-embedding-8c85ebce.js"),
33
- import("./embedding-activity-ew6dshfd.js"),
34
- import("./harness-9872e0ym.js"),
35
- import("./sqlite-v89bj0yy.js"),
36
- import("./logger-shetp43v.js")
37
- ]);
38
- setHarness(input.harness);
39
- registerSqliteDiagnosticSink(log, getHarness);
40
- var nextId = 0;
41
- var pending = new Map;
42
- var queryDimensions = null;
43
- var db;
44
- port.on("message", (reply) => {
45
- if (reply.embeddingHostBusy !== undefined)
46
- setEmbeddingSessionBusy(input.sessionId, reply.embeddingHostBusy);
47
- const vector = reply.result instanceof Float32Array ? reply.result : reply.result?.vector;
48
- if (vector)
49
- queryDimensions = vector.length;
50
- pending.get(reply.id)?.(reply);
51
- pending.delete(reply.id);
52
- });
53
- function request(message) {
54
- return new Promise((resolve, reject) => {
55
- const id = ++nextId;
56
- pending.set(id, (reply) => reply.error ? reject(new Error(reply.error)) : resolve(reply));
57
- port?.postMessage({ ...message, id });
58
- });
59
- }
60
- db = new Database(input.path, input.job === "backfill" ? undefined : { readonly: true });
61
- db.exec("PRAGMA busy_timeout = 250");
62
- var { closePort } = exitOnWorkerClose(port, () => db.close());
63
- var CHUNK_POOL_MAINTENANCE_INTERVAL_MS = 5000;
64
- var maintenanceTimer;
65
- var maintaining = false;
66
- function maintainChunkPools() {
67
- if (maintaining)
68
- return;
69
- maintaining = true;
70
- maintainCompartmentChunkSearchPools(db).catch(() => {}).finally(() => {
71
- maintaining = false;
9
+ serveWorkerJobs(async (initial, port) => {
10
+ let input = initial;
11
+ function post(reply) {
12
+ port.postMessage({ ...reply, jobId: input.jobId });
13
+ }
14
+ const persistent = input.persistent === true;
15
+ if (input.job === "messages") {
16
+ post({ kind: "accepted" });
17
+ }
18
+ const [
19
+ { ensureMemoryEmbeddings },
20
+ { getProjectEmbeddings },
21
+ { getMemoriesByProject },
22
+ { installProjectEmbeddingSearchBridge },
23
+ { searchMessageHistory, unifiedSearch },
24
+ { getLastCompartmentChunkPoolWarm, maintainCompartmentChunkSearchPools },
25
+ { setEmbeddingSessionBusy },
26
+ { getHarness, setHarness },
27
+ { Database, registerSqliteDiagnosticSink },
28
+ { log }
29
+ ] = await Promise.all([
30
+ import("./embedding-backfill-002vyexq.js"),
31
+ import("./embedding-cache-7rp4gqzr.js"),
32
+ import("./storage-memory-0ndn65fm.js"),
33
+ import("./project-embedding-registry-16pj4vyf.js"),
34
+ import("./search-3p18trsb.js"),
35
+ import("./compartment-chunk-embedding-jpcme6tz.js"),
36
+ import("./embedding-activity-ew6dshfd.js"),
37
+ import("./harness-9872e0ym.js"),
38
+ import("./sqlite-v89bj0yy.js"),
39
+ import("./logger-2j70hhz4.js")
40
+ ]);
41
+ setHarness(input.harness);
42
+ registerSqliteDiagnosticSink(log, getHarness);
43
+ let nextId = 0;
44
+ const pending = new Map;
45
+ let queryDimensions = null;
46
+ let db;
47
+ port.on("message", (reply) => {
48
+ if (reply.jobId !== input.jobId)
49
+ return;
50
+ if (reply.embeddingHostBusy !== undefined)
51
+ setEmbeddingSessionBusy(input.sessionId, reply.embeddingHostBusy);
52
+ const vector = reply.result instanceof Float32Array ? reply.result : reply.result?.vector;
53
+ if (vector)
54
+ queryDimensions = vector.length;
55
+ pending.get(reply.id)?.(reply);
56
+ pending.delete(reply.id);
72
57
  });
73
- }
74
- function scheduleChunkPoolMaintenance() {
75
- if (!persistent)
76
- return;
77
- if (!maintenanceTimer) {
78
- maintenanceTimer = setInterval(maintainChunkPools, CHUNK_POOL_MAINTENANCE_INTERVAL_MS);
79
- maintenanceTimer.unref?.();
58
+ function request(message) {
59
+ return new Promise((resolve, reject) => {
60
+ const id = ++nextId;
61
+ pending.set(id, (reply) => reply.error ? reject(new Error(reply.error)) : resolve(reply));
62
+ post({ ...message, id });
63
+ });
80
64
  }
81
- setTimeout(maintainChunkPools, 0);
82
- }
83
- async function run(jobInput) {
84
- input = jobInput;
85
- queryDimensions = null;
86
- setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
87
- if (input.snapshot) {
88
- installProjectEmbeddingSearchBridge(input.snapshot, {
89
- modelId: input.snapshot.modelId,
90
- initialize: async () => true,
91
- isLoaded: () => true,
92
- dispose: async () => {},
93
- embed: async (text) => {
94
- const result = (await request({ kind: "query", text })).result;
95
- return result instanceof Float32Array ? result : result?.vector ?? null;
96
- },
97
- embedBatch: async (texts, _signal, purpose = "passage") => {
98
- const passage = (await request({ kind: "batch", texts, purpose })).passage;
99
- const captured = input.snapshot;
100
- if (!passage || !captured || passage.generation !== captured.generation || passage.modelId !== captured.modelId || passage.providerIdentity !== captured.providerIdentity || passage.runtimeFingerprint !== captured.runtimeFingerprint || !queryDimensions || passage.dimensions !== queryDimensions || passage.vectors.length !== texts.length)
101
- return texts.map(() => null);
102
- return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
103
- }
65
+ db = new Database(input.path, input.job === "backfill" ? undefined : { readonly: true });
66
+ db.exec("PRAGMA busy_timeout = 250");
67
+ const { closePort } = exitOnWorkerClose(port, () => db.close());
68
+ const CHUNK_POOL_MAINTENANCE_INTERVAL_MS = 5000;
69
+ let maintenanceTimer;
70
+ let maintaining = false;
71
+ function maintainChunkPools() {
72
+ if (maintaining)
73
+ return;
74
+ maintaining = true;
75
+ maintainCompartmentChunkSearchPools(db).catch(() => {}).finally(() => {
76
+ maintaining = false;
104
77
  });
105
78
  }
106
- try {
107
- if (input.job === "backfill") {
108
- if (input.snapshot?.enabled && input.snapshot.features.memoryEnabled) {
109
- await request({ kind: "query", text: input.query });
110
- if (queryDimensions) {
111
- const existingEmbeddings = getProjectEmbeddings(db, input.projectPath, input.snapshot.modelId);
112
- const memories = getMemoriesByProject(db, input.projectPath).filter((memory) => !existingEmbeddings.has(memory.id)).slice(0, 50);
113
- await ensureMemoryEmbeddings({
114
- db,
115
- projectIdentity: input.projectPath,
116
- memories,
117
- existingEmbeddings
118
- });
79
+ function scheduleChunkPoolMaintenance() {
80
+ if (!persistent)
81
+ return;
82
+ if (!maintenanceTimer) {
83
+ maintenanceTimer = setInterval(maintainChunkPools, CHUNK_POOL_MAINTENANCE_INTERVAL_MS);
84
+ maintenanceTimer.unref?.();
85
+ }
86
+ setTimeout(maintainChunkPools, 0);
87
+ }
88
+ async function run(jobInput) {
89
+ input = jobInput;
90
+ queryDimensions = null;
91
+ setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
92
+ if (input.snapshot) {
93
+ installProjectEmbeddingSearchBridge(input.snapshot, {
94
+ modelId: input.snapshot.modelId,
95
+ initialize: async () => true,
96
+ isLoaded: () => true,
97
+ dispose: async () => {},
98
+ embed: async (text) => {
99
+ const result = (await request({ kind: "query", text })).result;
100
+ return result instanceof Float32Array ? result : result?.vector ?? null;
101
+ },
102
+ embedBatch: async (texts, _signal, purpose = "passage") => {
103
+ const passage = (await request({ kind: "batch", texts, purpose })).passage;
104
+ const captured = input.snapshot;
105
+ if (!passage || !captured || passage.generation !== captured.generation || passage.modelId !== captured.modelId || passage.providerIdentity !== captured.providerIdentity || passage.runtimeFingerprint !== captured.runtimeFingerprint || !queryDimensions || passage.dimensions !== queryDimensions || passage.vectors.length !== texts.length)
106
+ return texts.map(() => null);
107
+ return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
119
108
  }
120
- }
121
- port.postMessage({ kind: "result", results: [] });
122
- } else if (input.job === "messages") {
123
- if (!input.messageRequest)
124
- throw new Error("message search job carries no request");
125
- const outcome = searchMessageHistory(db, input.messageRequest);
126
- port.postMessage({ kind: "messages", outcome });
127
- } else {
128
- const jobStarted = performance.now();
129
- const steps = {};
130
- const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
131
- ...input.options,
132
- backfillMemoryEmbeddings: false,
133
- countRetrievals: false,
134
- measurementDisabled: true,
135
- embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
136
- isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled,
137
- stepTimings: steps
138
109
  });
139
- port.postMessage({
140
- kind: "result",
141
- results,
142
- timings: {
143
- steps,
144
- jobMs: performance.now() - jobStarted,
145
- lastPoolWarm: getLastCompartmentChunkPoolWarm()
110
+ }
111
+ try {
112
+ if (input.job === "backfill") {
113
+ if (input.snapshot?.enabled && input.snapshot.features.memoryEnabled) {
114
+ await request({ kind: "query", text: input.query });
115
+ if (queryDimensions) {
116
+ const existingEmbeddings = getProjectEmbeddings(db, input.projectPath, input.snapshot.modelId);
117
+ const memories = getMemoriesByProject(db, input.projectPath).filter((memory) => !existingEmbeddings.has(memory.id)).slice(0, 50);
118
+ await ensureMemoryEmbeddings({
119
+ db,
120
+ projectIdentity: input.projectPath,
121
+ memories,
122
+ existingEmbeddings
123
+ });
124
+ }
146
125
  }
126
+ post({ kind: "result", results: [] });
127
+ } else if (input.job === "messages") {
128
+ if (!input.messageRequest)
129
+ throw new Error("message search job carries no request");
130
+ const outcome = searchMessageHistory(db, input.messageRequest);
131
+ post({ kind: "messages", outcome });
132
+ } else {
133
+ const jobStarted = performance.now();
134
+ const steps = {};
135
+ const diagnostics = input.options.autoSearchDiagnostics;
136
+ const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
137
+ ...input.options,
138
+ backfillMemoryEmbeddings: false,
139
+ countRetrievals: false,
140
+ measurementDisabled: true,
141
+ embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
142
+ isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled,
143
+ stepTimings: steps,
144
+ onAutoSearchDiagnostics: diagnostics ? () => port.postMessage({
145
+ kind: "diagnostics",
146
+ diagnostics,
147
+ jobId: jobInput.jobId
148
+ }) : undefined
149
+ });
150
+ post({
151
+ kind: "result",
152
+ results,
153
+ timings: {
154
+ steps,
155
+ jobMs: performance.now() - jobStarted,
156
+ lastPoolWarm: getLastCompartmentChunkPoolWarm()
157
+ }
158
+ });
159
+ scheduleChunkPoolMaintenance();
160
+ }
161
+ } catch (error) {
162
+ post({
163
+ kind: "error",
164
+ error: error instanceof Error ? error.message : String(error)
147
165
  });
148
- scheduleChunkPoolMaintenance();
149
- }
150
- } catch (error) {
151
- port.postMessage({
152
- kind: "error",
153
- error: error instanceof Error ? error.message : String(error)
154
- });
155
- } finally {
156
- setEmbeddingSessionBusy(input.sessionId, false);
157
- if (!persistent) {
158
- db.close();
159
- closePort();
166
+ } finally {
167
+ setEmbeddingSessionBusy(input.sessionId, false);
168
+ if (!persistent) {
169
+ db.close();
170
+ closePort();
171
+ }
160
172
  }
161
173
  }
162
- }
163
- port.on("message", (message) => {
164
- if (message.kind === "run" && message.input)
165
- run(message.input);
166
- });
167
- run(input).catch((error) => {
168
- setTimeout(() => {
169
- throw error;
174
+ port.on("message", (message) => {
175
+ if (message.kind === "run" && message.input)
176
+ run(message.input);
170
177
  });
178
+ await run(input);
171
179
  });
@@ -10,86 +10,91 @@ import {
10
10
  import {
11
11
  isWorkerCloseMessage,
12
12
  exitOnWorkerClose
13
- } from "./index-54wmg4rj.js";
14
- import"./index-my0dn413.js";
15
- import"./index-fgs78jyd.js";
16
- import"./index-gwxaz0z5.js";
17
- import"./index-399p688g.js";
18
- import"./index-6981g1xv.js";
19
- import"./index-bvpar0bg.js";
13
+ } from "./index-x2n261wp.js";
14
+ import"./index-wt7vmyj4.js";
15
+ import"./index-gymgz20n.js";
16
+ import"./index-dnp1jjar.js";
17
+ import"./index-rzfr7wdv.js";
18
+ import"./index-8sqebjzk.js";
19
+ import"./index-wfqysrwq.js";
20
+ import"./index-c1dqxr10.js";
21
+ import"./index-ck8wj35v.js";
20
22
  import {
21
23
  replaceCompartmentChunkEmbeddings2,
22
24
  recordChunkEmbedBackoff2,
23
25
  loadUnembeddedSessionChunkCandidates2,
24
26
  countUnembeddedSessionCompartments2
25
- } from "./index-0gymvr5j.js";
27
+ } from "./index-f9qet7y8.js";
26
28
  import {
27
29
  recordSessionProjectIdentity,
28
30
  acquireGitSweepLease,
29
31
  renewGitSweepLease,
30
32
  releaseGitSweepLease
31
- } from "./index-4zemngt7.js";
32
- import"./index-48twbev2.js";
33
+ } from "./index-mp0gh04g.js";
34
+ import"./index-6pk49fc3.js";
33
35
  import {
34
36
  LATEST_SUPPORTED_VERSION,
35
37
  enforceSchemaFence
36
- } from "./index-np9ryr8y.js";
37
- import"./index-pb3ea2tq.js";
38
- import"./index-c474g0gj.js";
38
+ } from "./index-a7sj2bam.js";
39
+ import"./index-3bb24eb6.js";
40
+ import"./index-d107f484.js";
41
+ import"./index-yacs388s.js";
39
42
  import"./index-135e8hvg.js";
40
- import"./index-23t8ryqw.js";
41
- import"./index-hqw0rt9k.js";
43
+ import"./index-n0zjvs3h.js";
44
+ import"./index-c6wbq66z.js";
45
+ import"./index-0wtm7g7f.js";
46
+ import {
47
+ serveWorkerJobs
48
+ } from "./index-nypgv96r.js";
42
49
 
43
50
  // ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts
44
- import { parentPort, workerData } from "node:worker_threads";
45
- var port = parentPort;
46
- if (!port)
47
- throw new Error("chunk embedding writer requires a parent port");
48
- setHarness2(workerData.harness);
49
- var db = new Database2(workerData.path);
50
- if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
51
- db.close();
52
- throw new Error("chunk embedding writer rejected an unsupported store schema");
53
- }
54
- var timeout = Math.max(0, Math.floor(workerData.timeout));
55
- db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
56
- configureContextDatabasePragmas2(db);
57
- exitOnWorkerClose(port, () => db.close());
58
- port.on("message", (input) => {
59
- if (isWorkerCloseMessage(input))
60
- return;
61
- try {
62
- let value;
63
- switch (input.kind) {
64
- case "replace":
65
- replaceCompartmentChunkEmbeddings2(db, input.rows, input.sourceKey);
66
- break;
67
- case "project":
68
- recordSessionProjectIdentity(db, input.session, input.project);
69
- break;
70
- case "count":
71
- value = countUnembeddedSessionCompartments2(db, input.project, input.session, input.model, input.tokens);
72
- break;
73
- case "candidates":
74
- value = loadUnembeddedSessionChunkCandidates2(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
75
- break;
76
- case "backoff":
77
- recordChunkEmbedBackoff2(db, input.candidate, input.project, input.model);
78
- break;
79
- case "acquire":
80
- value = acquireGitSweepLease(db, input.project, input.holder, {
81
- ignoreCooldown: true
82
- });
83
- break;
84
- case "renew":
85
- value = renewGitSweepLease(db, input.project, input.holder);
86
- break;
87
- case "release":
88
- releaseGitSweepLease(db, input.project, input.holder);
89
- break;
90
- }
91
- port.postMessage({ value });
92
- } catch (error) {
93
- port.postMessage({ error: error instanceof Error ? error.message : String(error) });
51
+ serveWorkerJobs((workerData, port) => {
52
+ setHarness2(workerData.harness);
53
+ const db = new Database2(workerData.path);
54
+ if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
55
+ db.close();
56
+ throw new Error("chunk embedding writer rejected an unsupported store schema");
94
57
  }
95
- });
58
+ const timeout = Math.max(0, Math.floor(workerData.timeout));
59
+ db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
60
+ configureContextDatabasePragmas2(db);
61
+ exitOnWorkerClose(port, () => db.close(), false);
62
+ port.on("message", (input) => {
63
+ if (isWorkerCloseMessage(input))
64
+ return;
65
+ try {
66
+ let value;
67
+ switch (input.kind) {
68
+ case "replace":
69
+ replaceCompartmentChunkEmbeddings2(db, input.rows, input.sourceKey);
70
+ break;
71
+ case "project":
72
+ recordSessionProjectIdentity(db, input.session, input.project);
73
+ break;
74
+ case "count":
75
+ value = countUnembeddedSessionCompartments2(db, input.project, input.session, input.model, input.tokens);
76
+ break;
77
+ case "candidates":
78
+ value = loadUnembeddedSessionChunkCandidates2(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
79
+ break;
80
+ case "backoff":
81
+ recordChunkEmbedBackoff2(db, input.candidate, input.project, input.model);
82
+ break;
83
+ case "acquire":
84
+ value = acquireGitSweepLease(db, input.project, input.holder, {
85
+ ignoreCooldown: true
86
+ });
87
+ break;
88
+ case "renew":
89
+ value = renewGitSweepLease(db, input.project, input.holder);
90
+ break;
91
+ case "release":
92
+ releaseGitSweepLease(db, input.project, input.holder);
93
+ break;
94
+ }
95
+ port.postMessage({ value });
96
+ } catch (error) {
97
+ port.postMessage({ error: error instanceof Error ? error.message : String(error) });
98
+ }
99
+ });
100
+ }, false);
@@ -4,11 +4,14 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-6wdwv3a6.js";
8
- import"./index-399p688g.js";
7
+ } from "./index-y90fxz4t.js";
8
+ import"./index-wfqysrwq.js";
9
+ import"./index-8sqebjzk.js";
9
10
  import"./index-2qtx0q6h.js";
10
- import"./index-fgs78jyd.js";
11
+ import"./index-gymgz20n.js";
11
12
  import"./index-0h2mkab2.js";
13
+ import"./index-dnp1jjar.js";
14
+ import"./index-x2n261wp.js";
12
15
  export {
13
16
  invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
14
17
  isMarkerCandidateBasisCurrent2 as isMarkerCandidateBasisCurrent,
@@ -1,24 +1,25 @@
1
+ import {
2
+ serveWorkerJobs
3
+ } from "./index-nypgv96r.js";
4
+
1
5
  // ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts
2
- import { parentPort, workerData } from "node:worker_threads";
3
- var port = parentPort;
4
- if (!port)
5
- throw new Error("marker candidate worker requires a parent port");
6
- port.postMessage({ kind: "accepted" });
7
- var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
- import("./sqlite-v89bj0yy.js"),
9
- import("./compaction-marker-candidates-p1kqkqhq.js")
10
- ]);
11
- var input = workerData;
12
- var db;
13
- var reply;
14
- try {
15
- db = new Database(input.path, { readonly: true });
16
- db.exec("PRAGMA busy_timeout=250");
17
- reply = { kind: "candidates", snapshot: scanMarkerCandidateSnapshot(db, input.sessionId) };
18
- } catch (error) {
19
- reply = { kind: "error", error: error instanceof Error ? error.message : String(error) };
20
- } finally {
21
- db?.close();
22
- }
23
- port.postMessage(reply);
24
- port.close();
6
+ serveWorkerJobs(async (input, port) => {
7
+ port.postMessage({ kind: "accepted" });
8
+ const [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
9
+ import("./sqlite-v89bj0yy.js"),
10
+ import("./compaction-marker-candidates-9fzqg6y0.js")
11
+ ]);
12
+ let db;
13
+ let reply;
14
+ try {
15
+ db = new Database(input.path, { readonly: true });
16
+ db.exec("PRAGMA busy_timeout=250");
17
+ reply = { kind: "candidates", snapshot: scanMarkerCandidateSnapshot(db, input.sessionId) };
18
+ } catch (error) {
19
+ reply = { kind: "error", error: error instanceof Error ? error.message : String(error) };
20
+ } finally {
21
+ db?.close();
22
+ }
23
+ port.postMessage(reply);
24
+ port.close();
25
+ });
@@ -24,17 +24,19 @@ import {
24
24
  countSessionCompartmentEmbedCoverage2,
25
25
  countSessionCompartmentEmbedCoveragePolite2,
26
26
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-0gymvr5j.js";
28
- import"./index-gwxaz0z5.js";
29
- import"./index-bvpar0bg.js";
30
- import"./index-6981g1xv.js";
31
- import"./index-399p688g.js";
32
- import"./index-hqw0rt9k.js";
33
- import"./index-my0dn413.js";
27
+ } from "./index-f9qet7y8.js";
28
+ import"./index-rzfr7wdv.js";
29
+ import"./index-ck8wj35v.js";
30
+ import"./index-c1dqxr10.js";
31
+ import"./index-wfqysrwq.js";
32
+ import"./index-8sqebjzk.js";
33
+ import"./index-0wtm7g7f.js";
34
+ import"./index-wt7vmyj4.js";
34
35
  import"./index-2qtx0q6h.js";
35
- import"./index-fgs78jyd.js";
36
+ import"./index-gymgz20n.js";
36
37
  import"./index-0h2mkab2.js";
37
- import"./index-54wmg4rj.js";
38
+ import"./index-dnp1jjar.js";
39
+ import"./index-x2n261wp.js";
38
40
  export {
39
41
  CHUNK_WINDOW_SAFETY_RATIO2 as CHUNK_WINDOW_SAFETY_RATIO,
40
42
  DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2 as DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS,
@@ -0,0 +1,27 @@
1
+ import {
2
+ ensureMemoryEmbeddings2
3
+ } from "./index-jbkwszd5.js";
4
+ import"./index-z7dktknj.js";
5
+ import"./index-9p40dgkm.js";
6
+ import"./index-hgd00nas.js";
7
+ import"./index-yhzhdp3m.js";
8
+ import"./index-mp0gh04g.js";
9
+ import"./index-f9qet7y8.js";
10
+ import"./index-2qqsnh1b.js";
11
+ import"./index-rzfr7wdv.js";
12
+ import"./index-ccanzg8p.js";
13
+ import"./index-6pk49fc3.js";
14
+ import"./index-ck8wj35v.js";
15
+ import"./index-c1dqxr10.js";
16
+ import"./index-wfqysrwq.js";
17
+ import"./index-8sqebjzk.js";
18
+ import"./index-0wtm7g7f.js";
19
+ import"./index-wt7vmyj4.js";
20
+ import"./index-2qtx0q6h.js";
21
+ import"./index-gymgz20n.js";
22
+ import"./index-0h2mkab2.js";
23
+ import"./index-dnp1jjar.js";
24
+ import"./index-x2n261wp.js";
25
+ export {
26
+ ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
27
+ };
@@ -1,7 +1,8 @@
1
1
  import"./index-0h2mkab2.js";
2
2
  import {
3
3
  log2
4
- } from "./index-fgs78jyd.js";
4
+ } from "./index-gymgz20n.js";
5
+ import"./index-dnp1jjar.js";
5
6
  import {
6
7
  inRootAsyncContext2
7
8
  } from "./index-2qtx0q6h.js";
@@ -3,16 +3,17 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-fgs78jyd.js";
6
+ } from "./index-gymgz20n.js";
7
+ import"./index-dnp1jjar.js";
7
8
  import"./index-ccanzg8p.js";
8
- import"./index-gwxaz0z5.js";
9
- import"./index-my0dn413.js";
9
+ import"./index-rzfr7wdv.js";
10
+ import"./index-wt7vmyj4.js";
10
11
  import"./index-2qtx0q6h.js";
11
12
  import {
12
13
  resolveLocalEmbeddingWorkerRuntime,
13
14
  getLocalEmbeddingNativeMemoryStats,
14
15
  LocalEmbeddingProvider
15
- } from "./index-wqpjhx1p.js";
16
+ } from "./index-2qqsnh1b.js";
16
17
  import {
17
18
  setStoragePrivatePermissionEnforcement
18
19
  } from "./index-81nthk8j.js";