@cortexkit/pi-magic-context 0.49.35 → 0.49.37

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,176 +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-jt459ady.js"),
28
- import("./embedding-cache-7rp4gqzr.js"),
29
- import("./storage-memory-0ndn65fm.js"),
30
- import("./project-embedding-registry-davzvsz9.js"),
31
- import("./search-atp7g95j.js"),
32
- import("./compartment-chunk-embedding-5j1d1e3v.js"),
33
- import("./embedding-activity-ew6dshfd.js"),
34
- import("./harness-9872e0ym.js"),
35
- import("./sqlite-v89bj0yy.js"),
36
- import("./logger-2j70hhz4.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 diagnostics = input.options.autoSearchDiagnostics;
131
- const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
132
- ...input.options,
133
- backfillMemoryEmbeddings: false,
134
- countRetrievals: false,
135
- measurementDisabled: true,
136
- embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
137
- isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled,
138
- stepTimings: steps,
139
- onAutoSearchDiagnostics: diagnostics ? () => port.postMessage({
140
- kind: "diagnostics",
141
- diagnostics
142
- }) : undefined
143
109
  });
144
- port.postMessage({
145
- kind: "result",
146
- results,
147
- timings: {
148
- steps,
149
- jobMs: performance.now() - jobStarted,
150
- 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
+ }
151
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)
152
165
  });
153
- scheduleChunkPoolMaintenance();
154
- }
155
- } catch (error) {
156
- port.postMessage({
157
- kind: "error",
158
- error: error instanceof Error ? error.message : String(error)
159
- });
160
- } finally {
161
- setEmbeddingSessionBusy(input.sessionId, false);
162
- if (!persistent) {
163
- db.close();
164
- closePort();
166
+ } finally {
167
+ setEmbeddingSessionBusy(input.sessionId, false);
168
+ if (!persistent) {
169
+ db.close();
170
+ closePort();
171
+ }
165
172
  }
166
173
  }
167
- }
168
- port.on("message", (message) => {
169
- if (message.kind === "run" && message.input)
170
- run(message.input);
171
- });
172
- run(input).catch((error) => {
173
- setTimeout(() => {
174
- throw error;
174
+ port.on("message", (message) => {
175
+ if (message.kind === "run" && message.input)
176
+ run(message.input);
175
177
  });
178
+ await run(input);
176
179
  });
@@ -10,20 +10,21 @@ import {
10
10
  import {
11
11
  isWorkerCloseMessage,
12
12
  exitOnWorkerClose
13
- } from "./index-54wmg4rj.js";
13
+ } from "./index-x2n261wp.js";
14
14
  import"./index-wt7vmyj4.js";
15
15
  import"./index-gymgz20n.js";
16
16
  import"./index-dnp1jjar.js";
17
17
  import"./index-rzfr7wdv.js";
18
- import"./index-399p688g.js";
19
- import"./index-mkh1cm5k.js";
20
- import"./index-rgvqh5x7.js";
18
+ import"./index-8sqebjzk.js";
19
+ import"./index-wfqysrwq.js";
20
+ import"./index-c1dqxr10.js";
21
+ import"./index-ck8wj35v.js";
21
22
  import {
22
23
  replaceCompartmentChunkEmbeddings2,
23
24
  recordChunkEmbedBackoff2,
24
25
  loadUnembeddedSessionChunkCandidates2,
25
26
  countUnembeddedSessionCompartments2
26
- } from "./index-2p691ayw.js";
27
+ } from "./index-f9qet7y8.js";
27
28
  import {
28
29
  recordSessionProjectIdentity,
29
30
  acquireGitSweepLease,
@@ -34,7 +35,7 @@ import"./index-6pk49fc3.js";
34
35
  import {
35
36
  LATEST_SUPPORTED_VERSION,
36
37
  enforceSchemaFence
37
- } from "./index-11knwv2h.js";
38
+ } from "./index-a7sj2bam.js";
38
39
  import"./index-3bb24eb6.js";
39
40
  import"./index-d107f484.js";
40
41
  import"./index-yacs388s.js";
@@ -42,57 +43,58 @@ import"./index-135e8hvg.js";
42
43
  import"./index-n0zjvs3h.js";
43
44
  import"./index-c6wbq66z.js";
44
45
  import"./index-0wtm7g7f.js";
46
+ import {
47
+ serveWorkerJobs
48
+ } from "./index-nypgv96r.js";
45
49
 
46
50
  // ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts
47
- import { parentPort, workerData } from "node:worker_threads";
48
- var port = parentPort;
49
- if (!port)
50
- throw new Error("chunk embedding writer requires a parent port");
51
- setHarness2(workerData.harness);
52
- var db = new Database2(workerData.path);
53
- if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
54
- db.close();
55
- throw new Error("chunk embedding writer rejected an unsupported store schema");
56
- }
57
- var timeout = Math.max(0, Math.floor(workerData.timeout));
58
- db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
59
- configureContextDatabasePragmas2(db);
60
- exitOnWorkerClose(port, () => db.close());
61
- port.on("message", (input) => {
62
- if (isWorkerCloseMessage(input))
63
- return;
64
- try {
65
- let value;
66
- switch (input.kind) {
67
- case "replace":
68
- replaceCompartmentChunkEmbeddings2(db, input.rows, input.sourceKey);
69
- break;
70
- case "project":
71
- recordSessionProjectIdentity(db, input.session, input.project);
72
- break;
73
- case "count":
74
- value = countUnembeddedSessionCompartments2(db, input.project, input.session, input.model, input.tokens);
75
- break;
76
- case "candidates":
77
- value = loadUnembeddedSessionChunkCandidates2(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
78
- break;
79
- case "backoff":
80
- recordChunkEmbedBackoff2(db, input.candidate, input.project, input.model);
81
- break;
82
- case "acquire":
83
- value = acquireGitSweepLease(db, input.project, input.holder, {
84
- ignoreCooldown: true
85
- });
86
- break;
87
- case "renew":
88
- value = renewGitSweepLease(db, input.project, input.holder);
89
- break;
90
- case "release":
91
- releaseGitSweepLease(db, input.project, input.holder);
92
- break;
93
- }
94
- port.postMessage({ value });
95
- } catch (error) {
96
- 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");
97
57
  }
98
- });
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,12 +4,14 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-d0w84hy5.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
11
  import"./index-gymgz20n.js";
11
12
  import"./index-0h2mkab2.js";
12
13
  import"./index-dnp1jjar.js";
14
+ import"./index-x2n261wp.js";
13
15
  export {
14
16
  invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
15
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-hk2frhac.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,18 +24,19 @@ import {
24
24
  countSessionCompartmentEmbedCoverage2,
25
25
  countSessionCompartmentEmbedCoveragePolite2,
26
26
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-2p691ayw.js";
27
+ } from "./index-f9qet7y8.js";
28
28
  import"./index-rzfr7wdv.js";
29
- import"./index-rgvqh5x7.js";
30
- import"./index-mkh1cm5k.js";
31
- import"./index-399p688g.js";
29
+ import"./index-ck8wj35v.js";
30
+ import"./index-c1dqxr10.js";
31
+ import"./index-wfqysrwq.js";
32
+ import"./index-8sqebjzk.js";
32
33
  import"./index-0wtm7g7f.js";
33
34
  import"./index-wt7vmyj4.js";
34
35
  import"./index-2qtx0q6h.js";
35
36
  import"./index-gymgz20n.js";
36
37
  import"./index-0h2mkab2.js";
37
38
  import"./index-dnp1jjar.js";
38
- import"./index-54wmg4rj.js";
39
+ import"./index-x2n261wp.js";
39
40
  export {
40
41
  CHUNK_WINDOW_SAFETY_RATIO2 as CHUNK_WINDOW_SAFETY_RATIO,
41
42
  DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2 as DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS,
@@ -1,26 +1,27 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-vgfk2xa5.js";
4
- import"./index-a11nmw5t.js";
3
+ } from "./index-jbkwszd5.js";
4
+ import"./index-z7dktknj.js";
5
5
  import"./index-9p40dgkm.js";
6
6
  import"./index-hgd00nas.js";
7
7
  import"./index-yhzhdp3m.js";
8
8
  import"./index-mp0gh04g.js";
9
- import"./index-2p691ayw.js";
9
+ import"./index-f9qet7y8.js";
10
10
  import"./index-2qqsnh1b.js";
11
11
  import"./index-rzfr7wdv.js";
12
12
  import"./index-ccanzg8p.js";
13
13
  import"./index-6pk49fc3.js";
14
- import"./index-rgvqh5x7.js";
15
- import"./index-mkh1cm5k.js";
16
- import"./index-399p688g.js";
14
+ import"./index-ck8wj35v.js";
15
+ import"./index-c1dqxr10.js";
16
+ import"./index-wfqysrwq.js";
17
+ import"./index-8sqebjzk.js";
17
18
  import"./index-0wtm7g7f.js";
18
19
  import"./index-wt7vmyj4.js";
19
20
  import"./index-2qtx0q6h.js";
20
21
  import"./index-gymgz20n.js";
21
22
  import"./index-0h2mkab2.js";
22
23
  import"./index-dnp1jjar.js";
23
- import"./index-54wmg4rj.js";
24
+ import"./index-x2n261wp.js";
24
25
  export {
25
26
  ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
26
27
  };
@@ -15,5 +15,8 @@ function registerExitAbort(controller) {
15
15
  listenerRegistered = true;
16
16
  process.once("exit", abortAll);
17
17
  }
18
+ function unregisterExitAbort(controller) {
19
+ controllers.delete(controller);
20
+ }
18
21
 
19
- export { registerExitAbort };
22
+ export { registerExitAbort, unregisterExitAbort };
@@ -31,9 +31,12 @@ import {
31
31
  import {
32
32
  attachFailClosedBlockingProcessEvidence
33
33
  } from "./index-3bb24eb6.js";
34
+ import {
35
+ reuseWorker
36
+ } from "./index-wfqysrwq.js";
34
37
  import {
35
38
  startMessageFtsRowidMapBackfill2
36
- } from "./index-rgvqh5x7.js";
39
+ } from "./index-ck8wj35v.js";
37
40
  import {
38
41
  LKG_SLOT_CHUNKS_DDL,
39
42
  SESSION_REPLAY_DECISIONS_DDL,
@@ -991,7 +994,7 @@ function runMigrationsOffThread(data) {
991
994
  return new Promise((resolve, reject) => {
992
995
  let worker;
993
996
  try {
994
- worker = inRootAsyncContext2(() => new Worker(workerEntryOverride ?? defaultWorkerEntry(), { workerData: data }));
997
+ worker = inRootAsyncContext2(() => workerEntryOverride ? new Worker(workerEntryOverride, { workerData: data }) : reuseWorker(defaultWorkerEntry(), { workerData: data }));
995
998
  } catch (error) {
996
999
  reject(workerStartError(error instanceof Error ? error.message : String(error)));
997
1000
  return;
@@ -1785,7 +1788,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1785
1788
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1786
1789
  if (signal.aborted || !readsOpenCodeStore)
1787
1790
  return;
1788
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-nbcznexm.js"));
1791
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-jxq427v6.js"));
1789
1792
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-x45573rs.js"));
1790
1793
  if (signal.aborted)
1791
1794
  return;