@cortexkit/opencode-magic-context 0.49.15 → 0.49.17

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 (235) hide show
  1. package/dist/auto-search-worker.js +76 -63
  2. package/dist/chunk-embedding-write-worker.js +12 -10
  3. package/dist/{compaction-marker-candidates-v5c6997n.js → compaction-marker-candidates-n4krhat4.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/config/schema/magic-context.d.ts +343 -343
  6. package/dist/config/schema/magic-context.d.ts.map +1 -1
  7. package/dist/{conflict-warning-hook-mgq17yr3.js → conflict-warning-hook-4pmz879v.js} +6 -6
  8. package/dist/{context-0m46day0.js → context-yhetp0kn.js} +297 -141
  9. package/dist/embedding-backfill-fmz50tsy.js +24 -0
  10. package/dist/embedding-worker-process.js +1 -1
  11. package/dist/embedding-worker.js +5 -5
  12. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
  13. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  14. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  15. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/project-identity-cache.d.ts +2 -0
  17. package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
  18. package/dist/features/magic-context/message-fts-rowid-map.d.ts +2 -2
  19. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
  20. package/dist/features/magic-context/message-fts-session-filter.d.ts +2 -0
  21. package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
  22. package/dist/features/magic-context/message-index-async.d.ts +1 -1
  23. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  24. package/dist/features/magic-context/message-index.d.ts +5 -0
  25. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  26. package/dist/features/magic-context/message-time-backfill.d.ts +2 -2
  27. package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
  28. package/dist/features/magic-context/search.d.ts +6 -1
  29. package/dist/features/magic-context/search.d.ts.map +1 -1
  30. package/dist/features/magic-context/storage-db.d.ts +2 -1
  31. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  32. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  33. package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
  34. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  35. package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
  36. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/auto-search-deadline.d.ts +2 -1
  39. package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
  41. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
  44. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +4 -2
  46. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -1
  52. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +26 -0
  56. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
  59. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts +8 -0
  61. package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts.map +1 -0
  62. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/tag-messages.d.ts +6 -1
  64. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/todo-view.d.ts +2 -2
  66. package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
  67. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  69. package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
  70. package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/transform.d.ts +1 -0
  72. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  73. package/dist/{index-3kdm78zp.js → index-24fezq97.js} +4 -4
  74. package/dist/{index-a8bvhwqs.js → index-2vxtcb95.js} +32 -3
  75. package/dist/{index-f71thw8j.js → index-4s3t0nd0.js} +1 -1
  76. package/dist/{index-ts1hjk1h.js → index-4yt7dtf4.js} +453 -227
  77. package/dist/{index-mc1cqza6.js → index-5a1ex6x8.js} +5 -5
  78. package/dist/{index-fkx2qnvw.js → index-6x57ar45.js} +2 -2
  79. package/dist/{index-dyvbsvga.js → index-a6mc0v4d.js} +25 -11
  80. package/dist/{index-snp5wbge.js → index-a7c4r5re.js} +160 -749
  81. package/dist/{index-42vcjcwe.js → index-aabzay3h.js} +180 -103
  82. package/dist/{index-3kx0kg0f.js → index-b5vqckbw.js} +14 -8
  83. package/dist/{v2/server-wafzvyhg.js → index-beht37jy.js} +8 -0
  84. package/dist/{index-e20m7284.js → index-bjcnntmz.js} +3 -3
  85. package/dist/{index-hqkczed7.js → index-c5pytzne.js} +22 -2
  86. package/dist/{index-thvnpfsv.js → index-cwzfcbtq.js} +967 -88
  87. package/dist/{index-yxycg7fs.js → index-fb2qxs2y.js} +26 -18
  88. package/dist/{index-mht7bq0z.js → index-hqhm3wke.js} +32 -8
  89. package/dist/{index-e4dsjj1p.js → index-jn12fvvh.js} +1 -1
  90. package/dist/index-kaqs6h31.js +58 -0
  91. package/dist/{index-n6m03s3n.js → index-ke416mdc.js} +1 -1
  92. package/dist/index-kmdj7dsq.js +96 -0
  93. package/dist/{index-1d289pq2.js → index-kq82mtg0.js} +2 -2
  94. package/dist/{index-n78avt2p.js → index-n37sebck.js} +1 -1
  95. package/dist/{index-1vc7jrkg.js → index-nkpmm9q8.js} +3 -3
  96. package/dist/{index-944w16m0.js → index-p7m7j0cp.js} +25 -17
  97. package/dist/{index-wk0n1cgt.js → index-qn7xstt2.js} +2 -2
  98. package/dist/{index-saews2s3.js → index-rr2bb45z.js} +1 -1
  99. package/dist/{index-mmfa86mt.js → index-s734jcsr.js} +169 -149
  100. package/dist/{index-dgs16axy.js → index-s74zqahq.js} +1 -1
  101. package/dist/{index-bxdg2nbt.js → index-v8awdgvd.js} +4 -4
  102. package/dist/{index-xn6q9pg6.js → index-vrzjhftj.js} +36 -76
  103. package/dist/{index-1sarmj9z.js → index-wgypt3cs.js} +6 -6
  104. package/dist/{index-y1qysm3q.js → index-ze7mvk54.js} +11 -8
  105. package/dist/index.js +47 -45
  106. package/dist/message-fts-rowid-map-17s0dfn4.js +25 -0
  107. package/dist/{message-index-bounded-vtgpq6b4.js → message-index-bounded-1633vc7f.js} +17 -17
  108. package/dist/{message-index-a6gztaqx.js → message-index-dprebmtt.js} +15 -15
  109. package/dist/{message-time-backfill-qjge9044.js → message-time-backfill-73mmm76q.js} +5 -5
  110. package/dist/migration-worker.js +9 -7
  111. package/dist/plugin/dream-timer.d.ts +11 -0
  112. package/dist/plugin/dream-timer.d.ts.map +1 -1
  113. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  114. package/dist/{project-embedding-registry-x45bv3qr.js → project-embedding-registry-z74mhqkf.js} +12 -10
  115. package/dist/raw-ordinal-warmup-worker.js +40 -10
  116. package/dist/{read-session-chunk-3ae3nfdn.js → read-session-chunk-4zp09ejb.js} +9 -9
  117. package/dist/{read-session-raw-m56hc7v2.js → read-session-raw-rsc8c7qy.js} +2 -2
  118. package/dist/{recomp-orchestrator-nwzcfhx4.js → recomp-orchestrator-z3ecszx6.js} +26 -26
  119. package/dist/{search-deajrd90.js → search-6mee3vty.js} +23 -22
  120. package/dist/search-archive-znyy44ve.js +25 -0
  121. package/dist/{send-session-notification-24r4esbh.js → send-session-notification-6ve0e8p4.js} +5 -5
  122. package/dist/shared/historian-cache.d.ts +8 -0
  123. package/dist/shared/historian-cache.d.ts.map +1 -0
  124. package/dist/shared/model-suggestion-retry.d.ts +4 -0
  125. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  126. package/dist/shared/resolve-fallbacks.d.ts +3 -3
  127. package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
  128. package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
  129. package/dist/shared/rpc-server.d.ts +2 -0
  130. package/dist/shared/rpc-server.d.ts.map +1 -1
  131. package/dist/shared/search-text.d.ts +8 -0
  132. package/dist/shared/search-text.d.ts.map +1 -0
  133. package/dist/shared/sqlite.d.ts +4 -2
  134. package/dist/shared/sqlite.d.ts.map +1 -1
  135. package/dist/shared/storage-file-mutex.d.ts.map +1 -1
  136. package/dist/shared/subagent-runner.d.ts +2 -0
  137. package/dist/shared/subagent-runner.d.ts.map +1 -1
  138. package/dist/shared/system-directive.d.ts +2 -0
  139. package/dist/shared/system-directive.d.ts.map +1 -1
  140. package/dist/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
  141. package/dist/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
  142. package/dist/{storage-tags-s5bg1ahx.js → storage-tags-8qns3012.js} +8 -4
  143. package/dist/tools/ctx-expand/search-archive.d.ts +5 -1
  144. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
  145. package/dist/{transform-postprocess-phase-ne3z1zmt.js → transform-postprocess-phase-3ydzxa62.js} +26 -26
  146. package/dist/v2/auto-search-worker.js +76 -63
  147. package/dist/v2/chunk-embedding-write-worker.js +12 -10
  148. package/dist/v2/{compaction-marker-candidates-1vqwr3s5.js → compaction-marker-candidates-ebx3388k.js} +2 -2
  149. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  150. package/dist/v2/{context-4qczzck7.js → context-jn3zpeqh.js} +909 -454
  151. package/dist/v2/embedding-backfill-7c7yr69y.js +23 -0
  152. package/dist/v2/embedding-worker-process.js +1 -1
  153. package/dist/v2/embedding-worker.js +5 -5
  154. package/dist/v2/fold/native-replay.d.ts +11 -2
  155. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  156. package/dist/v2/fold/policy.d.ts.map +1 -1
  157. package/dist/v2/fold/restore.d.ts.map +1 -1
  158. package/dist/v2/hooks/context.d.ts.map +1 -1
  159. package/dist/v2/hooks/hidden-child.d.ts +8 -0
  160. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  161. package/dist/v2/hooks/types.d.ts +17 -0
  162. package/dist/v2/hooks/types.d.ts.map +1 -1
  163. package/dist/v2/message-fts-rowid-map-wfx67gfd.js +24 -0
  164. package/dist/v2/{message-index-bounded-rxxznd34.js → message-index-bounded-hpejqyd8.js} +17 -17
  165. package/dist/v2/{message-index-f947qtbz.js → message-index-pxehjpzx.js} +15 -15
  166. package/dist/v2/{message-time-backfill-bsteyc4d.js → message-time-backfill-04t0km1z.js} +5 -5
  167. package/dist/v2/migration-worker.js +9 -7
  168. package/dist/v2/{project-embedding-registry-0msp56p8.js → project-embedding-registry-gnkj56xp.js} +12 -10
  169. package/dist/v2/raw-ordinal-warmup-worker.js +40 -10
  170. package/dist/v2/{read-session-chunk-rq9nx1nn.js → read-session-chunk-zdppn4bj.js} +9 -9
  171. package/dist/v2/{read-session-raw-b3tf6ra1.js → read-session-raw-yaegtjzh.js} +2 -2
  172. package/dist/v2/{recomp-orchestrator-5zhxtwha.js → recomp-orchestrator-cmqnfpp3.js} +26 -26
  173. package/dist/v2/{search-n8wqxb1j.js → search-66842dya.js} +23 -22
  174. package/dist/v2/search-archive-gfh11vs0.js +24 -0
  175. package/dist/v2/{send-session-notification-8ghn9tnv.js → send-session-notification-3pxn658x.js} +5 -5
  176. package/dist/v2/{server-yrvqaswb.js → server-1wy7b9de.js} +25 -11
  177. package/dist/v2/{server-th4y11y7.js → server-271qxsf5.js} +6 -6
  178. package/dist/v2/{server-e298hswg.js → server-3rhpvy84.js} +967 -88
  179. package/dist/v2/{server-qhfvvfxj.js → server-46neh5fa.js} +14 -8
  180. package/dist/v2/{server-rrqpvwqd.js → server-6tmj0s7j.js} +2 -2
  181. package/dist/v2/{server-hek6z3w6.js → server-8by8qfec.js} +11 -8
  182. package/dist/v2/{server-vbe4se57.js → server-a9xqj88f.js} +1 -1
  183. package/dist/{index-wafzvyhg.js → v2/server-beht37jy.js} +8 -0
  184. package/dist/v2/{server-05xjtq6c.js → server-d04vrx0j.js} +1 -1
  185. package/dist/v2/server-ec4ca92p.js +96 -0
  186. package/dist/v2/{server-dd0tz6cn.js → server-fw7wrk01.js} +160 -750
  187. package/dist/v2/{server-zs8d0s3b.js → server-g3qma5c0.js} +1 -1
  188. package/dist/v2/{server-k2bzedxk.js → server-gpvay0xz.js} +2 -2
  189. package/dist/v2/{server-kmbarfmn.js → server-gtfhttbr.js} +26 -18
  190. package/dist/v2/{server-g10mdym6.js → server-h1v0pyxb.js} +3 -3
  191. package/dist/v2/{server-4gn3z5an.js → server-hy3d3vsx.js} +1 -1
  192. package/dist/v2/server-kaqs6h31.js +58 -0
  193. package/dist/v2/{server-ehyava47.js → server-kh7dpa1a.js} +25 -17
  194. package/dist/v2/{server-6cdy4rc0.js → server-my7k4eds.js} +4 -4
  195. package/dist/v2/{server-d8tj10db.js → server-n1prf1g6.js} +1 -1
  196. package/dist/v2/{server-n78avt2p.js → server-n37sebck.js} +1 -1
  197. package/dist/v2/{server-zc3e54vy.js → server-nj659894.js} +6 -6
  198. package/dist/v2/{server-gvkm8xaj.js → server-rmygf5pn.js} +32 -3
  199. package/dist/v2/{server-0ppsweh6.js → server-tgnbmwah.js} +22 -2
  200. package/dist/v2/{server-cfbr1s2x.js → server-vsw8tmm6.js} +36 -76
  201. package/dist/v2/{server-prg55b7k.js → server-xj136kt8.js} +23 -3
  202. package/dist/v2/{server-atbc19ab.js → server-zyzawhdw.js} +32 -8
  203. package/dist/v2/{server-ef89gdsx.js → server-zzkj2fch.js} +4 -4
  204. package/dist/v2/server.js +5 -5
  205. package/dist/v2/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
  206. package/dist/v2/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
  207. package/dist/v2/{storage-tags-hcc2adpf.js → storage-tags-1h8k6ra9.js} +8 -4
  208. package/dist/v2/store-reader.d.ts +2 -0
  209. package/dist/v2/store-reader.d.ts.map +1 -1
  210. package/dist/v2/{wrapup-orchestrator-65pwye0d.js → wrapup-orchestrator-xs8redz9.js} +26 -26
  211. package/dist/wrapup-orchestrator-j7d7ry5b.js +48 -0
  212. package/package.json +1 -1
  213. package/src/config/latch-permanence-guard.test.ts +4 -0
  214. package/src/config/schema/magic-context.ts +14 -6
  215. package/src/shared/historian-cache.test.ts +69 -0
  216. package/src/shared/historian-cache.ts +55 -0
  217. package/src/shared/model-resolution.test.ts +22 -0
  218. package/src/shared/model-suggestion-retry.ts +11 -3
  219. package/src/shared/resolve-fallbacks.test.ts +2 -3
  220. package/src/shared/resolve-fallbacks.ts +3 -3
  221. package/src/shared/rpc-discovery-cleanup.test.ts +57 -0
  222. package/src/shared/rpc-discovery-cleanup.ts +57 -0
  223. package/src/shared/rpc-server.ts +36 -13
  224. package/src/shared/search-text.test.ts +47 -0
  225. package/src/shared/search-text.ts +63 -0
  226. package/src/shared/sqlite.test.ts +56 -0
  227. package/src/shared/sqlite.ts +51 -2
  228. package/src/shared/storage-file-mutex-review.test.ts +22 -2
  229. package/src/shared/storage-file-mutex.ts +11 -1
  230. package/src/shared/subagent-runner.ts +2 -0
  231. package/src/shared/system-directive.ts +19 -1
  232. package/src/shared/tag-transcript.ts +12 -4
  233. package/dist/embedding-backfill-5e1t5wha.js +0 -22
  234. package/dist/v2/embedding-backfill-jmaf8zrr.js +0 -21
  235. package/dist/wrapup-orchestrator-28xzsj5q.js +0 -48
@@ -1,9 +1,10 @@
1
1
  // src/hooks/magic-context/auto-search-worker.ts
2
2
  import { parentPort, workerData } from "node:worker_threads";
3
- var port = parentPort;
4
- if (!port)
3
+ if (!parentPort)
5
4
  throw new Error("auto-search worker requires a parent port");
5
+ var port = parentPort;
6
6
  var input = workerData;
7
+ var persistent = input.persistent === true;
7
8
  if (input.job === "messages") {
8
9
  port.postMessage({ kind: "accepted" });
9
10
  }
@@ -18,19 +19,18 @@ var [
18
19
  { Database, registerSqliteDiagnosticSink },
19
20
  { log }
20
21
  ] = await Promise.all([
21
- import("./embedding-backfill-5e1t5wha.js"),
22
+ import("./embedding-backfill-fmz50tsy.js"),
22
23
  import("./embedding-cache-mgyr73ef.js"),
23
- import("./storage-memory-j3v3hc83.js"),
24
- import("./project-embedding-registry-x45bv3qr.js"),
25
- import("./search-deajrd90.js"),
24
+ import("./storage-memory-y3qmy00r.js"),
25
+ import("./project-embedding-registry-z74mhqkf.js"),
26
+ import("./search-6mee3vty.js"),
26
27
  import("./embedding-activity-g1dhes6g.js"),
27
28
  import("./harness-e4avh192.js"),
28
- import("./sqlite-4pqyynrs.js"),
29
+ import("./sqlite-zf72c52d.js"),
29
30
  import("./logger-jm3sqqzr.js")
30
31
  ]);
31
32
  setHarness(input.harness);
32
33
  registerSqliteDiagnosticSink(log, getHarness);
33
- setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
34
34
  var nextId = 0;
35
35
  var pending = new Map;
36
36
  var queryDimensions = null;
@@ -51,65 +51,78 @@ function request(message) {
51
51
  port?.postMessage({ ...message, id });
52
52
  });
53
53
  }
54
- if (input.snapshot) {
55
- installProjectEmbeddingSearchBridge(input.snapshot, {
56
- modelId: input.snapshot.modelId,
57
- initialize: async () => true,
58
- isLoaded: () => true,
59
- dispose: async () => {},
60
- embed: async (text) => {
61
- const result = (await request({ kind: "query", text })).result;
62
- return result instanceof Float32Array ? result : result?.vector ?? null;
63
- },
64
- embedBatch: async (texts, _signal, purpose = "passage") => {
65
- const passage = (await request({ kind: "batch", texts, purpose })).passage;
66
- const captured = input.snapshot;
67
- 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)
68
- return texts.map(() => null);
69
- return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
70
- }
71
- });
72
- }
73
54
  db = new Database(input.path, input.job === "backfill" ? undefined : { readonly: true });
74
55
  db.exec("PRAGMA busy_timeout = 250");
75
- try {
76
- if (input.job === "backfill") {
77
- if (input.snapshot?.enabled && input.snapshot.features.memoryEnabled) {
78
- await request({ kind: "query", text: input.query });
79
- if (queryDimensions) {
80
- const existingEmbeddings = getProjectEmbeddings(db, input.projectPath, input.snapshot.modelId);
81
- const memories = getMemoriesByProject(db, input.projectPath).filter((memory) => !existingEmbeddings.has(memory.id)).slice(0, 50);
82
- await ensureMemoryEmbeddings({
83
- db,
84
- projectIdentity: input.projectPath,
85
- memories,
86
- existingEmbeddings
87
- });
56
+ async function run(jobInput) {
57
+ input = jobInput;
58
+ queryDimensions = null;
59
+ setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
60
+ if (input.snapshot) {
61
+ installProjectEmbeddingSearchBridge(input.snapshot, {
62
+ modelId: input.snapshot.modelId,
63
+ initialize: async () => true,
64
+ isLoaded: () => true,
65
+ dispose: async () => {},
66
+ embed: async (text) => {
67
+ const result = (await request({ kind: "query", text })).result;
68
+ return result instanceof Float32Array ? result : result?.vector ?? null;
69
+ },
70
+ embedBatch: async (texts, _signal, purpose = "passage") => {
71
+ const passage = (await request({ kind: "batch", texts, purpose })).passage;
72
+ const captured = input.snapshot;
73
+ 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)
74
+ return texts.map(() => null);
75
+ return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
88
76
  }
77
+ });
78
+ }
79
+ try {
80
+ if (input.job === "backfill") {
81
+ if (input.snapshot?.enabled && input.snapshot.features.memoryEnabled) {
82
+ await request({ kind: "query", text: input.query });
83
+ if (queryDimensions) {
84
+ const existingEmbeddings = getProjectEmbeddings(db, input.projectPath, input.snapshot.modelId);
85
+ const memories = getMemoriesByProject(db, input.projectPath).filter((memory) => !existingEmbeddings.has(memory.id)).slice(0, 50);
86
+ await ensureMemoryEmbeddings({
87
+ db,
88
+ projectIdentity: input.projectPath,
89
+ memories,
90
+ existingEmbeddings
91
+ });
92
+ }
93
+ }
94
+ port.postMessage({ kind: "result", results: [] });
95
+ } else if (input.job === "messages") {
96
+ if (!input.messageRequest)
97
+ throw new Error("message search job carries no request");
98
+ const outcome = searchMessageHistory(db, input.messageRequest);
99
+ port.postMessage({ kind: "messages", outcome });
100
+ } else {
101
+ const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
102
+ ...input.options,
103
+ backfillMemoryEmbeddings: false,
104
+ countRetrievals: false,
105
+ measurementDisabled: true,
106
+ embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
107
+ isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled
108
+ });
109
+ port.postMessage({ kind: "result", results });
89
110
  }
90
- port.postMessage({ kind: "result", results: [] });
91
- } else if (input.job === "messages") {
92
- if (!input.messageRequest)
93
- throw new Error("message search job carries no request");
94
- const outcome = searchMessageHistory(db, input.messageRequest);
95
- port.postMessage({ kind: "messages", outcome });
96
- } else {
97
- const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
98
- ...input.options,
99
- backfillMemoryEmbeddings: false,
100
- countRetrievals: false,
101
- measurementDisabled: true,
102
- embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
103
- isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled
111
+ } catch (error) {
112
+ port.postMessage({
113
+ kind: "error",
114
+ error: error instanceof Error ? error.message : String(error)
104
115
  });
105
- port.postMessage({ kind: "result", results });
116
+ } finally {
117
+ setEmbeddingSessionBusy(input.sessionId, false);
118
+ if (!persistent) {
119
+ db.close();
120
+ port?.close();
121
+ }
106
122
  }
107
- } catch (error) {
108
- port.postMessage({
109
- kind: "error",
110
- error: error instanceof Error ? error.message : String(error)
111
- });
112
- } finally {
113
- db.close();
114
- port.close();
115
123
  }
124
+ port.on("message", (message) => {
125
+ if (message.kind === "run" && message.input)
126
+ run(message.input);
127
+ });
128
+ await run(input);
@@ -3,38 +3,40 @@ import {
3
3
  } from "./index-pavzsdc6.js";
4
4
  import {
5
5
  Database2
6
- } from "./index-wafzvyhg.js";
6
+ } from "./index-beht37jy.js";
7
7
  import {
8
8
  configureContextDatabasePragmas2
9
9
  } from "./index-fb3zxn06.js";
10
- import"./index-hqkczed7.js";
10
+ import"./index-c5pytzne.js";
11
11
  import"./index-g2q4htwp.js";
12
12
  import"./index-j75v2476.js";
13
- import"./index-fkx2qnvw.js";
14
- import"./index-dyvbsvga.js";
13
+ import"./index-6x57ar45.js";
14
+ import"./index-v0p37hm2.js";
15
+ import"./index-s734jcsr.js";
16
+ import"./index-a6mc0v4d.js";
15
17
  import {
16
18
  replaceCompartmentChunkEmbeddings,
17
19
  recordChunkEmbedBackoff,
18
20
  loadUnembeddedSessionChunkCandidates,
19
21
  countUnembeddedSessionCompartments
20
- } from "./index-3kx0kg0f.js";
22
+ } from "./index-b5vqckbw.js";
21
23
  import {
22
24
  recordSessionProjectIdentity,
23
25
  acquireGitSweepLease,
24
26
  renewGitSweepLease,
25
27
  releaseGitSweepLease
26
- } from "./index-saews2s3.js";
27
- import"./index-a8bvhwqs.js";
28
+ } from "./index-rr2bb45z.js";
29
+ import"./index-2vxtcb95.js";
28
30
  import"./index-nj7yykkx.js";
29
31
  import {
30
32
  LATEST_SUPPORTED_VERSION,
31
33
  enforceSchemaFence
32
- } from "./index-yxycg7fs.js";
33
- import"./index-wk0n1cgt.js";
34
+ } from "./index-fb2qxs2y.js";
35
+ import"./index-qn7xstt2.js";
34
36
  import"./index-bp5083x2.js";
35
37
  import"./index-fr0wbhdn.js";
36
38
  import"./index-58e3y90n.js";
37
- import"./index-n6m03s3n.js";
39
+ import"./index-ke416mdc.js";
38
40
  import"./index-k29z4aqh.js";
39
41
 
40
42
  // src/features/magic-context/chunk-embedding-write-worker.ts
@@ -4,9 +4,9 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-f71thw8j.js";
7
+ } from "./index-4s3t0nd0.js";
8
8
  import"./index-v0p37hm2.js";
9
- import"./index-wafzvyhg.js";
9
+ import"./index-beht37jy.js";
10
10
  import"./index-j75v2476.js";
11
11
  import"./index-g2q4htwp.js";
12
12
  import"./index-pavzsdc6.js";
@@ -5,8 +5,8 @@ if (!port)
5
5
  throw new Error("marker candidate worker requires a parent port");
6
6
  port.postMessage({ kind: "accepted" });
7
7
  var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
- import("./sqlite-4pqyynrs.js"),
9
- import("./compaction-marker-candidates-v5c6997n.js")
8
+ import("./sqlite-zf72c52d.js"),
9
+ import("./compaction-marker-candidates-n4krhat4.js")
10
10
  ]);
11
11
  var input = workerData;
12
12
  var db;