@cortexkit/opencode-magic-context 0.49.35 → 0.49.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +1 -1
  2. package/dist/auto-search-worker.js +163 -160
  3. package/dist/chunk-embedding-write-worker.js +58 -56
  4. package/dist/{compaction-marker-candidates-g0p67ced.js → compaction-marker-candidates-5p1qkve9.js} +3 -1
  5. package/dist/compaction-marker-candidates-worker.js +24 -23
  6. package/dist/{compartment-chunk-embedding-y4136are.js → compartment-chunk-embedding-ypktm0tk.js} +5 -4
  7. package/dist/{conflict-warning-hook-hhw8z5ak.js → conflict-warning-hook-b75jn458.js} +6 -5
  8. package/dist/{context-fk8e3h9p.js → context-969z683s.js} +485 -91
  9. package/dist/{embedding-backfill-q6n72sy0.js → embedding-backfill-rma0v2ct.js} +9 -8
  10. package/dist/embedding-worker.js +2 -2
  11. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
  12. package/dist/features/magic-context/compaction-marker.d.ts +5 -3
  13. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/verify-gate.d.ts +2 -0
  16. package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/verify-state.d.ts +9 -0
  18. package/dist/features/magic-context/dreamer/verify-state.d.ts.map +1 -0
  19. package/dist/features/magic-context/dreamer/verify.d.ts +2 -1
  20. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  21. package/dist/features/magic-context/migration-worker-client.d.ts +3 -0
  22. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  23. package/dist/features/magic-context/migration-worker.d.ts +15 -0
  24. package/dist/features/magic-context/migration-worker.d.ts.map +1 -1
  25. package/dist/features/magic-context/overflow-detection.d.ts +2 -2
  26. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  27. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  28. package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
  29. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  30. package/dist/features/magic-context/storage-tags.d.ts +4 -0
  31. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  32. package/dist/features/magic-context/work-metrics-carry-storage.d.ts +10 -0
  33. package/dist/features/magic-context/work-metrics-carry-storage.d.ts.map +1 -0
  34. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +5 -1
  35. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/issue-423-fixture.d.ts +1 -1
  39. package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/issue-424-fixture.d.ts +1 -1
  41. package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/project-structural-sentinels.d.ts +25 -0
  43. package/dist/hooks/magic-context/project-structural-sentinels.d.ts.map +1 -0
  44. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -1
  45. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +2 -0
  48. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/release-recovery-prefix.d.ts +9 -0
  50. package/dist/hooks/magic-context/release-recovery-prefix.d.ts.map +1 -0
  51. package/dist/hooks/magic-context/strip-structural-noise.d.ts +6 -3
  52. package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/transform-context-state.d.ts +3 -0
  54. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +3 -0
  56. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  58. package/dist/{index-cpjk5jd2.js → index-1d042x6w.js} +16 -14
  59. package/dist/{index-jn0ddrhp.js → index-21fgrfrf.js} +8 -6
  60. package/dist/{index-pq0dpwrc.js → index-2rs7912w.js} +2 -2
  61. package/dist/{index-ezv6dz3y.js → index-4ks89h5a.js} +4 -4
  62. package/dist/{index-vzhhr1ht.js → index-4y35msh5.js} +1 -2
  63. package/dist/{index-f297z1n8.js → index-72czy45z.js} +5 -5
  64. package/dist/index-7v05d9b7.js +58 -0
  65. package/dist/{index-f9b3vtt1.js → index-850vthn3.js} +8 -2
  66. package/dist/{index-ksv0a31x.js → index-8jjjmhab.js} +12 -1
  67. package/dist/index-96ztjvkn.js +204 -0
  68. package/dist/{index-gyaa159j.js → index-9fgmkfaf.js} +6 -3
  69. package/dist/{index-4bgk5ztz.js → index-9tdvbdv1.js} +187 -90
  70. package/dist/{index-2v6nvy3k.js → index-ae1ar4v1.js} +1 -1
  71. package/dist/{index-faxb7mck.js → index-b1ydbp95.js} +1 -1
  72. package/dist/{index-nxrsns5x.js → index-c5dzns43.js} +75 -75
  73. package/dist/{index-zhqwda72.js → index-dcjkw41m.js} +1 -1
  74. package/dist/{index-x2mrq5xv.js → index-dfdg2cgg.js} +179 -49
  75. package/dist/{index-87ctnzz9.js → index-dz48h1wx.js} +2 -2
  76. package/dist/{index-b6xz3qbe.js → index-gnmhbyyc.js} +366 -83
  77. package/dist/{index-qx8j6kds.js → index-j105mf16.js} +2 -2
  78. package/dist/{index-p56dszfp.js → index-jggt5gf2.js} +1 -1
  79. package/dist/{index-xwwsbsd3.js → index-pp8vdn01.js} +5 -5
  80. package/dist/{index-dy7w6wm4.js → index-prw8apnc.js} +5 -5
  81. package/dist/{index-qncw9hey.js → index-r2epb000.js} +33 -3
  82. package/dist/{index-brg2w6qc.js → index-tn9drm1a.js} +16 -14
  83. package/dist/{index-pswsyf1w.js → index-ty4vhe4n.js} +3 -3
  84. package/dist/{index-pztqab6k.js → index-vd2ywmfe.js} +1 -1
  85. package/dist/{index-3j9t1v4n.js → index-wcwhhtdh.js} +10 -9
  86. package/dist/{index-1rhgxqs8.js → index-xd2p95m7.js} +1 -1
  87. package/dist/{index-0c7p8mq5.js → index-xnm0wq1r.js} +1 -1
  88. package/dist/{index-3d3872c6.js → index-ys7j6679.js} +4 -4
  89. package/dist/index.js +38 -37
  90. package/dist/{message-fts-rowid-map-xg7hr0mk.js → message-fts-rowid-map-t6qsyg9s.js} +4 -3
  91. package/dist/{message-index-bounded-narw7bnz.js → message-index-bounded-wfk6aqxk.js} +9 -8
  92. package/dist/migration-worker.js +45 -40
  93. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  94. package/dist/{project-embedding-registry-tdz7985n.js → project-embedding-registry-3yyegjma.js} +8 -7
  95. package/dist/raw-ordinal-warmup-worker.js +114 -118
  96. package/dist/{read-session-chunk-vmg1zjg0.js → read-session-chunk-26yrrhyz.js} +7 -6
  97. package/dist/{read-session-raw-mncmzbm9.js → read-session-raw-j7c9w57v.js} +3 -2
  98. package/dist/{recomp-orchestrator-qyyhnc9b.js → recomp-orchestrator-wk509qkp.js} +20 -19
  99. package/dist/{render-c5p0k846.js → render-h1qarr8a.js} +13 -12
  100. package/dist/{search-f6hwvcxk.js → search-5h9fydyq.js} +16 -15
  101. package/dist/{search-archive-0ny7p3bw.js → search-archive-q79hyqxs.js} +9 -8
  102. package/dist/{send-session-notification-0gwcz3fw.js → send-session-notification-14p3yje4.js} +5 -4
  103. package/dist/shared/model-suggestion-retry.d.ts +7 -0
  104. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  105. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  106. package/dist/shared/reusable-worker-entry.d.ts +4 -0
  107. package/dist/shared/reusable-worker-entry.d.ts.map +1 -0
  108. package/dist/shared/reusable-worker.d.ts +6 -0
  109. package/dist/shared/reusable-worker.d.ts.map +1 -0
  110. package/dist/shared/reusable-worker.fixture.d.ts +2 -0
  111. package/dist/shared/reusable-worker.fixture.d.ts.map +1 -0
  112. package/dist/shared/worker-shutdown.d.ts +1 -1
  113. package/dist/shared/worker-shutdown.d.ts.map +1 -1
  114. package/dist/{storage-tags-zx1023km.js → storage-tags-vj0yj7ed.js} +1 -1
  115. package/dist/{store-620rjzt9.js → store-s3eykdjt.js} +1 -1
  116. package/dist/{transform-postprocess-phase-807ff6t2.js → transform-postprocess-phase-4gj0mtcg.js} +21 -20
  117. package/dist/v2/auto-search-worker.js +163 -160
  118. package/dist/v2/chunk-embedding-write-worker.js +59 -57
  119. package/dist/v2/compaction-marker-candidates-worker.js +24 -23
  120. package/dist/v2/{compaction-marker-candidates-t1aq6gsj.js → compaction-marker-candidates-yeb2ky46.js} +4 -2
  121. package/dist/v2/{compartment-chunk-embedding-ncsk0r9e.js → compartment-chunk-embedding-qfk791bd.js} +6 -5
  122. package/dist/v2/{context-znqfkap4.js → context-bxr039be.js} +1011 -209
  123. package/dist/v2/{embedding-backfill-11j425e0.js → embedding-backfill-00tw59rx.js} +10 -9
  124. package/dist/v2/embedding-worker.js +2 -2
  125. package/dist/v2/fold/code-mode-catalog.d.ts +3 -0
  126. package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -0
  127. package/dist/v2/fold/idle.d.ts +1 -0
  128. package/dist/v2/fold/idle.d.ts.map +1 -1
  129. package/dist/v2/fold/manual-baseline.d.ts +8 -0
  130. package/dist/v2/fold/manual-baseline.d.ts.map +1 -0
  131. package/dist/v2/fold/native-replay-v3.d.ts +7 -0
  132. package/dist/v2/fold/native-replay-v3.d.ts.map +1 -1
  133. package/dist/v2/fold/native-replay.d.ts +24 -7
  134. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  135. package/dist/v2/fold/restore.d.ts.map +1 -1
  136. package/dist/v2/fold/summary.d.ts +4 -0
  137. package/dist/v2/fold/summary.d.ts.map +1 -0
  138. package/dist/v2/hidden-completion.d.ts.map +1 -1
  139. package/dist/v2/hooks/channel2.d.ts +6 -0
  140. package/dist/v2/hooks/channel2.d.ts.map +1 -1
  141. package/dist/v2/hooks/context.d.ts.map +1 -1
  142. package/dist/v2/hooks/restore-rows.d.ts +12 -2
  143. package/dist/v2/hooks/restore-rows.d.ts.map +1 -1
  144. package/dist/v2/hooks/synthetic-admission.d.ts +7 -0
  145. package/dist/v2/hooks/synthetic-admission.d.ts.map +1 -0
  146. package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
  147. package/dist/v2/{message-fts-rowid-map-rmk571mb.js → message-fts-rowid-map-z86avy0n.js} +5 -4
  148. package/dist/v2/{message-index-bounded-620bppw7.js → message-index-bounded-w14496s9.js} +9 -8
  149. package/dist/v2/migration-worker.js +46 -41
  150. package/dist/v2/{project-embedding-registry-bm5fe1a8.js → project-embedding-registry-jqq2qeqb.js} +9 -8
  151. package/dist/v2/raw-ordinal-warmup-worker.js +114 -118
  152. package/dist/v2/{read-session-chunk-qfwv1k71.js → read-session-chunk-tqnh1ret.js} +7 -6
  153. package/dist/v2/{read-session-raw-q294t8xs.js → read-session-raw-qpp6x9kg.js} +4 -3
  154. package/dist/v2/{recomp-orchestrator-fcnjref7.js → recomp-orchestrator-9cjk6aej.js} +19 -18
  155. package/dist/v2/{render-98a1qv0b.js → render-5dz1knf2.js} +13 -12
  156. package/dist/v2/{search-z1zqzsmh.js → search-8yfet25y.js} +15 -14
  157. package/dist/v2/{search-archive-r0y1bafr.js → search-archive-z6z9jqwf.js} +9 -8
  158. package/dist/v2/{send-session-notification-fst6hkg7.js → send-session-notification-kxp47tsw.js} +4 -3
  159. package/dist/v2/{server-cpjk5jd2.js → server-1d042x6w.js} +16 -14
  160. package/dist/v2/{server-fqj6ddpr.js → server-5by3vdzs.js} +186 -89
  161. package/dist/v2/{server-5jp38p98.js → server-6emy0v9a.js} +1 -2
  162. package/dist/v2/{server-rktnzs89.js → server-6vzh6wej.js} +1 -1
  163. package/dist/v2/{server-qa74bj91.js → server-7094pk3w.js} +9 -8
  164. package/dist/v2/{server-bxpz2dcn.js → server-7acq7815.js} +8 -6
  165. package/dist/v2/server-7v05d9b7.js +58 -0
  166. package/dist/v2/{server-24g8r2d0.js → server-7zacmty5.js} +75 -75
  167. package/dist/v2/server-96ztjvkn.js +204 -0
  168. package/dist/v2/{server-hnknwaz8.js → server-a9w5f0yw.js} +3 -3
  169. package/dist/v2/{server-9k0mjef7.js → server-avdveykk.js} +1 -1
  170. package/dist/v2/{server-hsf0qsn5.js → server-cp1a03vc.js} +1 -1
  171. package/dist/v2/{server-r3chnxs5.js → server-dfq5vb8j.js} +2 -2
  172. package/dist/v2/{server-x4m6xcn4.js → server-e51xmr4d.js} +6 -6
  173. package/dist/v2/{server-7ccxt4nq.js → server-g3gqq4ac.js} +6 -3
  174. package/dist/v2/{server-kkxzwa6w.js → server-gkse1wyz.js} +3 -3
  175. package/dist/v2/{server-1xesqm5h.js → server-jd7vzwn4.js} +15 -13
  176. package/dist/v2/{server-ws5exe6q.js → server-nmyganc8.js} +1 -1
  177. package/dist/v2/{server-q0z2q2dx.js → server-nq3cb7be.js} +1 -1
  178. package/dist/v2/{server-55v5hpth.js → server-qjyp27vf.js} +2 -2
  179. package/dist/v2/{server-xbtw0p9t.js → server-r4430x9m.js} +9 -3
  180. package/dist/v2/{server-qf2kzsh2.js → server-t8y64xj7.js} +4 -4
  181. package/dist/v2/{server-s9xgyyj9.js → server-tnzbk64q.js} +34 -4
  182. package/dist/v2/{server-51779zs2.js → server-v0p37hm2.js} +4 -1
  183. package/dist/v2/{server-bpvsvtph.js → server-xfjjbrkt.js} +12 -1
  184. package/dist/v2/server.js +4 -4
  185. package/dist/v2/{storage-tags-19s0ebf0.js → storage-tags-cw07ky67.js} +1 -1
  186. package/dist/v2/{store-vdm8v3jd.js → store-z3qe67cg.js} +1 -1
  187. package/dist/v2/{v2-archive-reader-t2c0eypn.js → v2-archive-reader-z7wr42ry.js} +3 -3
  188. package/dist/v2/{wrapup-orchestrator-aqpqsveg.js → wrapup-orchestrator-j1v62bkj.js} +19 -18
  189. package/dist/{v2-archive-reader-tm2eayp2.js → v2-archive-reader-028z6kck.js} +2 -2
  190. package/dist/{wrapup-orchestrator-k5yp19a6.js → wrapup-orchestrator-xg9avt2p.js} +21 -20
  191. package/package.json +1 -1
  192. package/src/shared/model-suggestion-retry.ts +1 -1
  193. package/src/shared/prompt-async-transport.test.ts +64 -3
  194. package/src/shared/prompt-async-transport.ts +61 -16
  195. package/src/shared/reusable-worker-entry.ts +58 -0
  196. package/src/shared/reusable-worker-reset.test.ts +108 -0
  197. package/src/shared/reusable-worker.fixture.ts +35 -0
  198. package/src/shared/reusable-worker.test.ts +253 -0
  199. package/src/shared/reusable-worker.ts +240 -0
  200. package/src/shared/worker-shutdown.ts +21 -17
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- **English** · [简体中文](docs/i18n/README.zh-CN.md) · [繁體中文](docs/i18n/README.zh-TW.md) · [한국어](docs/i18n/README.ko.md) · [Deutsch](docs/i18n/README.de.md) · [Español](docs/i18n/README.es.md) · [Français](docs/i18n/README.fr.md) · [Italiano](docs/i18n/README.it.md) · [Dansk](docs/i18n/README.da.md) · [日本語](docs/i18n/README.ja.md) · [Polski](docs/i18n/README.pl.md) · [Русский](docs/i18n/README.ru.md) · [Bosanski](docs/i18n/README.bs.md) · [العربية](docs/i18n/README.ar.md) · [Norsk](docs/i18n/README.nb.md) · [Português (Brasil)](docs/i18n/README.pt-BR.md) · [ไทย](docs/i18n/README.th.md) · [Türkçe](docs/i18n/README.tr.md) · [Українська](docs/i18n/README.uk.md) · [বাংলা](docs/i18n/README.bn.md) · [Ελληνικά](docs/i18n/README.el.md) · [Tiếng Việt](docs/i18n/README.vi.md)
1
+ **English** · [简体中文](docs/i18n/README.zh-CN.md) · [繁體中文](docs/i18n/README.zh-TW.md) · [한국어](docs/i18n/README.ko.md) · [Deutsch](docs/i18n/README.de.md) · [Español](docs/i18n/README.es.md) · [Français](docs/i18n/README.fr.md) · [Italiano](docs/i18n/README.it.md) · [Dansk](docs/i18n/README.da.md) · [日本語](docs/i18n/README.ja.md) · [Polski](docs/i18n/README.pl.md) · [Русский](docs/i18n/README.ru.md) · [Bosanski](docs/i18n/README.bs.md) · [العربية](docs/i18n/README.ar.md) · [فارسی](docs/i18n/README.fa.md) · [Norsk](docs/i18n/README.nb.md) · [Português (Brasil)](docs/i18n/README.pt-BR.md) · [ไทย](docs/i18n/README.th.md) · [Türkçe](docs/i18n/README.tr.md) · [Українська](docs/i18n/README.uk.md) · [বাংলা](docs/i18n/README.bn.md) · [Ελληνικά](docs/i18n/README.el.md) · [Tiếng Việt](docs/i18n/README.vi.md)
2
2
 
3
3
  <h1 align="center">Magic Context</h1>
4
4
 
@@ -1,176 +1,179 @@
1
1
  import {
2
2
  exitOnWorkerClose
3
- } from "./index-cpjk5jd2.js";
3
+ } from "./index-1d042x6w.js";
4
+ import {
5
+ serveWorkerJobs
6
+ } from "./index-7v05d9b7.js";
4
7
 
5
8
  // 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-q6n72sy0.js"),
28
- import("./embedding-cache-mgyr73ef.js"),
29
- import("./storage-memory-e6a7mb0k.js"),
30
- import("./project-embedding-registry-tdz7985n.js"),
31
- import("./search-f6hwvcxk.js"),
32
- import("./compartment-chunk-embedding-y4136are.js"),
33
- import("./embedding-activity-g1dhes6g.js"),
34
- import("./harness-e4avh192.js"),
35
- import("./sqlite-zdgm52sv.js"),
36
- import("./logger-qwnbcfj9.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-rma0v2ct.js"),
31
+ import("./embedding-cache-mgyr73ef.js"),
32
+ import("./storage-memory-e6a7mb0k.js"),
33
+ import("./project-embedding-registry-3yyegjma.js"),
34
+ import("./search-5h9fydyq.js"),
35
+ import("./compartment-chunk-embedding-ypktm0tk.js"),
36
+ import("./embedding-activity-g1dhes6g.js"),
37
+ import("./harness-e4avh192.js"),
38
+ import("./sqlite-zdgm52sv.js"),
39
+ import("./logger-qwnbcfj9.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,21 +10,22 @@ import {
10
10
  import {
11
11
  isWorkerCloseMessage,
12
12
  exitOnWorkerClose
13
- } from "./index-cpjk5jd2.js";
13
+ } from "./index-1d042x6w.js";
14
14
  import"./index-4xyjr62e.js";
15
15
  import"./index-g2q4htwp.js";
16
16
  import"./index-z4p0ry94.js";
17
17
  import"./index-jrfre9ah.js";
18
18
  import"./index-g4t7850m.js";
19
19
  import"./index-v0p37hm2.js";
20
- import"./index-qncw9hey.js";
21
- import"./index-faxb7mck.js";
20
+ import"./index-96ztjvkn.js";
21
+ import"./index-r2epb000.js";
22
+ import"./index-b1ydbp95.js";
22
23
  import {
23
24
  replaceCompartmentChunkEmbeddings2,
24
25
  recordChunkEmbedBackoff2,
25
26
  loadUnembeddedSessionChunkCandidates2,
26
27
  countUnembeddedSessionCompartments2
27
- } from "./index-zhqwda72.js";
28
+ } from "./index-dcjkw41m.js";
28
29
  import {
29
30
  recordSessionProjectIdentity,
30
31
  acquireGitSweepLease,
@@ -36,7 +37,7 @@ import"./index-2p37txes.js";
36
37
  import {
37
38
  LATEST_SUPPORTED_VERSION,
38
39
  enforceSchemaFence
39
- } from "./index-gyaa159j.js";
40
+ } from "./index-9fgmkfaf.js";
40
41
  import"./index-wh9fxds5.js";
41
42
  import"./index-nj360hcs.js";
42
43
  import"./index-9wnbnx8f.js";
@@ -44,57 +45,58 @@ import"./index-fr0wbhdn.js";
44
45
  import"./index-58e3y90n.js";
45
46
  import"./index-jkanybgq.js";
46
47
  import"./index-fxbk7gk3.js";
48
+ import {
49
+ serveWorkerJobs
50
+ } from "./index-7v05d9b7.js";
47
51
 
48
52
  // src/features/magic-context/chunk-embedding-write-worker.ts
49
- import { parentPort, workerData } from "node:worker_threads";
50
- var port = parentPort;
51
- if (!port)
52
- throw new Error("chunk embedding writer requires a parent port");
53
- setHarness2(workerData.harness);
54
- var db = new Database2(workerData.path);
55
- if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
56
- db.close();
57
- throw new Error("chunk embedding writer rejected an unsupported store schema");
58
- }
59
- var timeout = Math.max(0, Math.floor(workerData.timeout));
60
- db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
61
- configureContextDatabasePragmas2(db);
62
- exitOnWorkerClose(port, () => db.close());
63
- port.on("message", (input) => {
64
- if (isWorkerCloseMessage(input))
65
- return;
66
- try {
67
- let value;
68
- switch (input.kind) {
69
- case "replace":
70
- replaceCompartmentChunkEmbeddings2(db, input.rows, input.sourceKey);
71
- break;
72
- case "project":
73
- recordSessionProjectIdentity(db, input.session, input.project);
74
- break;
75
- case "count":
76
- value = countUnembeddedSessionCompartments2(db, input.project, input.session, input.model, input.tokens);
77
- break;
78
- case "candidates":
79
- value = loadUnembeddedSessionChunkCandidates2(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
80
- break;
81
- case "backoff":
82
- recordChunkEmbedBackoff2(db, input.candidate, input.project, input.model);
83
- break;
84
- case "acquire":
85
- value = acquireGitSweepLease(db, input.project, input.holder, {
86
- ignoreCooldown: true
87
- });
88
- break;
89
- case "renew":
90
- value = renewGitSweepLease(db, input.project, input.holder);
91
- break;
92
- case "release":
93
- releaseGitSweepLease(db, input.project, input.holder);
94
- break;
95
- }
96
- port.postMessage({ value });
97
- } catch (error) {
98
- port.postMessage({ error: error instanceof Error ? error.message : String(error) });
53
+ serveWorkerJobs((workerData, port) => {
54
+ setHarness2(workerData.harness);
55
+ const db = new Database2(workerData.path);
56
+ if (!enforceSchemaFence(db, workerData.path, LATEST_SUPPORTED_VERSION)) {
57
+ db.close();
58
+ throw new Error("chunk embedding writer rejected an unsupported store schema");
99
59
  }
100
- });
60
+ const timeout = Math.max(0, Math.floor(workerData.timeout));
61
+ db.exec(`PRAGMA busy_timeout=${timeout}; PRAGMA foreign_keys=ON`);
62
+ configureContextDatabasePragmas2(db);
63
+ exitOnWorkerClose(port, () => db.close(), false);
64
+ port.on("message", (input) => {
65
+ if (isWorkerCloseMessage(input))
66
+ return;
67
+ try {
68
+ let value;
69
+ switch (input.kind) {
70
+ case "replace":
71
+ replaceCompartmentChunkEmbeddings2(db, input.rows, input.sourceKey);
72
+ break;
73
+ case "project":
74
+ recordSessionProjectIdentity(db, input.session, input.project);
75
+ break;
76
+ case "count":
77
+ value = countUnembeddedSessionCompartments2(db, input.project, input.session, input.model, input.tokens);
78
+ break;
79
+ case "candidates":
80
+ value = loadUnembeddedSessionChunkCandidates2(db, input.project, input.session, input.model, input.limit, input.excluded, input.tokens, true);
81
+ break;
82
+ case "backoff":
83
+ recordChunkEmbedBackoff2(db, input.candidate, input.project, input.model);
84
+ break;
85
+ case "acquire":
86
+ value = acquireGitSweepLease(db, input.project, input.holder, {
87
+ ignoreCooldown: true
88
+ });
89
+ break;
90
+ case "renew":
91
+ value = renewGitSweepLease(db, input.project, input.holder);
92
+ break;
93
+ case "release":
94
+ releaseGitSweepLease(db, input.project, input.holder);
95
+ break;
96
+ }
97
+ port.postMessage({ value });
98
+ } catch (error) {
99
+ port.postMessage({ error: error instanceof Error ? error.message : String(error) });
100
+ }
101
+ });
102
+ }, false);
@@ -4,13 +4,15 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-f9b3vtt1.js";
7
+ } from "./index-850vthn3.js";
8
+ import"./index-96ztjvkn.js";
8
9
  import"./index-v0p37hm2.js";
9
10
  import"./index-gzy5w8ya.js";
10
11
  import"./index-jrfre9ah.js";
11
12
  import"./index-g2q4htwp.js";
12
13
  import"./index-pavzsdc6.js";
13
14
  import"./index-z4p0ry94.js";
15
+ import"./index-1d042x6w.js";
14
16
  export {
15
17
  invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
16
18
  isMarkerCandidateBasisCurrent2 as isMarkerCandidateBasisCurrent,
@@ -1,24 +1,25 @@
1
+ import {
2
+ serveWorkerJobs
3
+ } from "./index-7v05d9b7.js";
4
+
1
5
  // 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-zdgm52sv.js"),
9
- import("./compaction-marker-candidates-g0p67ced.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-zdgm52sv.js"),
10
+ import("./compaction-marker-candidates-5p1qkve9.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,10 +24,11 @@ import {
24
24
  countSessionCompartmentEmbedCoverage2,
25
25
  countSessionCompartmentEmbedCoveragePolite2,
26
26
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-zhqwda72.js";
27
+ } from "./index-dcjkw41m.js";
28
28
  import"./index-g4t7850m.js";
29
- import"./index-faxb7mck.js";
30
- import"./index-qncw9hey.js";
29
+ import"./index-b1ydbp95.js";
30
+ import"./index-r2epb000.js";
31
+ import"./index-96ztjvkn.js";
31
32
  import"./index-v0p37hm2.js";
32
33
  import"./index-fxbk7gk3.js";
33
34
  import"./index-4xyjr62e.js";
@@ -36,7 +37,7 @@ import"./index-jrfre9ah.js";
36
37
  import"./index-g2q4htwp.js";
37
38
  import"./index-pavzsdc6.js";
38
39
  import"./index-z4p0ry94.js";
39
- import"./index-cpjk5jd2.js";
40
+ import"./index-1d042x6w.js";
40
41
  export {
41
42
  CHUNK_WINDOW_SAFETY_RATIO2 as CHUNK_WINDOW_SAFETY_RATIO,
42
43
  DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2 as DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS,
@@ -4,14 +4,15 @@ import {
4
4
  cleanupConflictWarnings2,
5
5
  sendSchemaFenceWarning2,
6
6
  sendStartupAnnouncement2
7
- } from "./index-p56dszfp.js";
7
+ } from "./index-jggt5gf2.js";
8
8
  import"./index-hacf2tyx.js";
9
9
  import"./index-sd3egckz.js";
10
- import"./index-2v6nvy3k.js";
10
+ import"./index-ae1ar4v1.js";
11
11
  import"./index-qt1qqasc.js";
12
- import"./index-pztqab6k.js";
12
+ import"./index-vd2ywmfe.js";
13
13
  import"./index-fw42ms3m.js";
14
- import"./index-qncw9hey.js";
14
+ import"./index-r2epb000.js";
15
+ import"./index-96ztjvkn.js";
15
16
  import"./index-v0p37hm2.js";
16
17
  import"./index-58e3y90n.js";
17
18
  import"./index-gzy5w8ya.js";
@@ -19,7 +20,7 @@ import"./index-jrfre9ah.js";
19
20
  import"./index-g2q4htwp.js";
20
21
  import"./index-pavzsdc6.js";
21
22
  import"./index-z4p0ry94.js";
22
- import"./index-cpjk5jd2.js";
23
+ import"./index-1d042x6w.js";
23
24
  export {
24
25
  __conflictWarningTest2 as __conflictWarningTest,
25
26
  cleanupConflictWarnings2 as cleanupConflictWarnings,