@cortexkit/opencode-magic-context 0.49.34 → 0.49.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/README.md +1 -1
  2. package/dist/auto-search-worker.js +163 -155
  3. package/dist/chunk-embedding-write-worker.js +70 -66
  4. package/dist/{compaction-marker-candidates-31h86ph0.js → compaction-marker-candidates-5p1qkve9.js} +5 -2
  5. package/dist/compaction-marker-candidates-worker.js +24 -23
  6. package/dist/{compartment-chunk-embedding-5q5gj67r.js → compartment-chunk-embedding-ypktm0tk.js} +10 -8
  7. package/dist/{conflict-warning-hook-xgskea1v.js → conflict-warning-hook-b75jn458.js} +11 -9
  8. package/dist/{context-p3xrarzt.js → context-969z683s.js} +1839 -746
  9. package/dist/{derive-budgets-pqybnx09.js → derive-budgets-htj16n4x.js} +3 -2
  10. package/dist/embedding-backfill-rma0v2ct.js +28 -0
  11. package/dist/embedding-worker-process.js +2 -1
  12. package/dist/embedding-worker.js +6 -5
  13. package/dist/expand-attachments-h33jbgyz.js +21 -0
  14. package/dist/features/magic-context/auto-search-diagnostics.d.ts +21 -0
  15. package/dist/features/magic-context/auto-search-diagnostics.d.ts.map +1 -0
  16. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
  17. package/dist/features/magic-context/compaction-marker.d.ts +5 -3
  18. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  19. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
  20. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/verify-gate.d.ts +2 -0
  23. package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/verify-state.d.ts +9 -0
  25. package/dist/features/magic-context/dreamer/verify-state.d.ts.map +1 -0
  26. package/dist/features/magic-context/dreamer/verify.d.ts +2 -1
  27. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  28. package/dist/features/magic-context/migration-worker-client.d.ts +3 -0
  29. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  30. package/dist/features/magic-context/migration-worker.d.ts +15 -0
  31. package/dist/features/magic-context/migration-worker.d.ts.map +1 -1
  32. package/dist/features/magic-context/overflow-detection.d.ts +2 -2
  33. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  34. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  35. package/dist/features/magic-context/search.d.ts +4 -0
  36. package/dist/features/magic-context/search.d.ts.map +1 -1
  37. package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
  38. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  39. package/dist/features/magic-context/storage-tags.d.ts +4 -0
  40. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  41. package/dist/features/magic-context/store-generation-rebase-labels.d.ts +6 -0
  42. package/dist/features/magic-context/store-generation-rebase-labels.d.ts.map +1 -0
  43. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  44. package/dist/features/magic-context/work-metrics-carry-storage.d.ts +10 -0
  45. package/dist/features/magic-context/work-metrics-carry-storage.d.ts.map +1 -0
  46. package/dist/{history-owner-36wp3mkb.js → history-owner-0z620wgz.js} +3 -2
  47. package/dist/hooks/magic-context/apply-operations.d.ts +20 -3
  48. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/auto-search-observation.d.ts +13 -0
  50. package/dist/hooks/magic-context/auto-search-observation.d.ts.map +1 -0
  51. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
  53. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/compartment-commit-hashes.d.ts +4 -0
  56. package/dist/hooks/magic-context/compartment-commit-hashes.d.ts.map +1 -0
  57. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -0
  59. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/final-wire-completeness.d.ts +15 -0
  62. package/dist/hooks/magic-context/final-wire-completeness.d.ts.map +1 -0
  63. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/issue-423-fixture.d.ts +1 -1
  65. package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/issue-424-fixture.d.ts +1 -1
  67. package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/project-structural-sentinels.d.ts +25 -0
  69. package/dist/hooks/magic-context/project-structural-sentinels.d.ts.map +1 -0
  70. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -1
  71. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  72. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +1 -0
  73. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/read-session-chunk.d.ts +11 -0
  75. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/read-session-formatting.d.ts +2 -0
  77. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +2 -0
  79. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/release-recovery-prefix.d.ts +9 -0
  81. package/dist/hooks/magic-context/release-recovery-prefix.d.ts.map +1 -0
  82. package/dist/hooks/magic-context/strip-structural-noise.d.ts +6 -3
  83. package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/transform-context-state.d.ts +3 -0
  85. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +3 -0
  87. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  88. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  89. package/dist/{index-cpjk5jd2.js → index-1d042x6w.js} +16 -14
  90. package/dist/{index-2743x98y.js → index-21fgrfrf.js} +35 -142
  91. package/dist/index-2amn2s73.js +123 -0
  92. package/dist/{index-c7phnbvk.js → index-2p37txes.js} +1 -1
  93. package/dist/index-2qbtqg1w.js +529 -0
  94. package/dist/{index-9gpw8hrm.js → index-2rs7912w.js} +4 -4
  95. package/dist/{index-m1x9ghk5.js → index-4ks89h5a.js} +37 -7
  96. package/dist/{index-b88dwwrh.js → index-4xyjr62e.js} +1 -1
  97. package/dist/index-4y35msh5.js +531 -0
  98. package/dist/index-66a50f3e.js +777 -0
  99. package/dist/index-72czy45z.js +4557 -0
  100. package/dist/index-7v05d9b7.js +58 -0
  101. package/dist/{index-qgh1qwjj.js → index-850vthn3.js} +9 -3
  102. package/dist/{index-np3rgfw4.js → index-8jjjmhab.js} +15 -4
  103. package/dist/index-96ztjvkn.js +204 -0
  104. package/dist/{index-fm36bjv4.js → index-9fgmkfaf.js} +22 -277
  105. package/dist/{index-atekmqef.js → index-9tdvbdv1.js} +508 -5547
  106. package/dist/{index-xrnsygfq.js → index-9wnbnx8f.js} +1 -1
  107. package/dist/{index-waktfbjy.js → index-ae1ar4v1.js} +4 -4
  108. package/dist/{index-v15ne3a3.js → index-b1ydbp95.js} +2 -2
  109. package/dist/{index-nxrsns5x.js → index-c5dzns43.js} +75 -75
  110. package/dist/{index-v7287tzq.js → index-dcjkw41m.js} +19 -8
  111. package/dist/{index-hbx7m8he.js → index-dfdg2cgg.js} +338 -86
  112. package/dist/{index-spwjbkc7.js → index-dnqqqc5f.js} +1 -1
  113. package/dist/{index-04z754rd.js → index-dz48h1wx.js} +33 -5
  114. package/dist/{index-rrv26qjz.js → index-fw42ms3m.js} +1 -1
  115. package/dist/{index-t5pck3ss.js → index-fxbk7gk3.js} +1 -1
  116. package/dist/{index-wfybj1dw.js → index-g4t7850m.js} +2 -2
  117. package/dist/{index-97spytxq.js → index-gnmhbyyc.js} +583 -474
  118. package/dist/{index-4pnsgvfk.js → index-hacf2tyx.js} +1 -1
  119. package/dist/index-j105mf16.js +270 -0
  120. package/dist/{index-gkee6p4g.js → index-jggt5gf2.js} +3 -3
  121. package/dist/{index-s1n8dd2n.js → index-jkanybgq.js} +2 -2
  122. package/dist/{index-h7tgn49j.js → index-jrfre9ah.js} +5 -222
  123. package/dist/{index-kfyb3k6n.js → index-jz5bk7xd.js} +2 -2
  124. package/dist/{index-7kkphb6c.js → index-nj360hcs.js} +4 -4
  125. package/dist/{index-07vskjn8.js → index-pp8vdn01.js} +15 -13
  126. package/dist/index-prw8apnc.js +194 -0
  127. package/dist/{index-rverk2vz.js → index-r2epb000.js} +34 -4
  128. package/dist/{index-7g9dr8gy.js → index-tn9drm1a.js} +125 -143
  129. package/dist/{index-kq5w68dp.js → index-txs8tce6.js} +1 -1
  130. package/dist/{index-rfxzazzy.js → index-ty4vhe4n.js} +5 -5
  131. package/dist/{index-y1qwzvxn.js → index-vd2ywmfe.js} +2 -2
  132. package/dist/{index-0677w9sd.js → index-wcwhhtdh.js} +58 -23
  133. package/dist/index-wh9fxds5.js +265 -0
  134. package/dist/{index-51rdvtkz.js → index-xd2p95m7.js} +3 -3
  135. package/dist/{index-as2amvn3.js → index-xnm0wq1r.js} +6 -531
  136. package/dist/{index-ftr84kkv.js → index-ys7j6679.js} +7 -5
  137. package/dist/index-z4p0ry94.js +222 -0
  138. package/dist/index-z9zygwse.js +89 -0
  139. package/dist/index.js +86 -74
  140. package/dist/{logger-94kew5wm.js → logger-qwnbcfj9.js} +2 -1
  141. package/dist/{message-fts-rowid-map-va36knh4.js → message-fts-rowid-map-t6qsyg9s.js} +7 -5
  142. package/dist/{message-index-bounded-qh91fdr3.js → message-index-bounded-wfk6aqxk.js} +15 -13
  143. package/dist/{message-time-backfill-4qva0b4f.js → message-time-backfill-39bm498k.js} +3 -2
  144. package/dist/migration-worker.js +55 -48
  145. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  146. package/dist/{project-embedding-registry-6yex0r9f.js → project-embedding-registry-3yyegjma.js} +16 -13
  147. package/dist/raw-ordinal-warmup-worker.js +114 -113
  148. package/dist/{read-session-chunk-kaghtr75.js → read-session-chunk-26yrrhyz.js} +18 -12
  149. package/dist/{read-session-raw-b2sd67v4.js → read-session-raw-j7c9w57v.js} +5 -3
  150. package/dist/recomp-orchestrator-wk509qkp.js +69 -0
  151. package/dist/render-h1qarr8a.js +44 -0
  152. package/dist/{safe-notification-target-mkr9yzvr.js → safe-notification-target-wztd7bgk.js} +3 -2
  153. package/dist/search-5h9fydyq.js +54 -0
  154. package/dist/search-archive-q79hyqxs.js +29 -0
  155. package/dist/{send-session-notification-vz86nt79.js → send-session-notification-14p3yje4.js} +9 -7
  156. package/dist/shared/model-suggestion-retry.d.ts +7 -0
  157. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  158. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  159. package/dist/shared/reusable-worker-entry.d.ts +4 -0
  160. package/dist/shared/reusable-worker-entry.d.ts.map +1 -0
  161. package/dist/shared/reusable-worker.d.ts +6 -0
  162. package/dist/shared/reusable-worker.d.ts.map +1 -0
  163. package/dist/shared/reusable-worker.fixture.d.ts +2 -0
  164. package/dist/shared/reusable-worker.fixture.d.ts.map +1 -0
  165. package/dist/shared/worker-shutdown.d.ts +1 -1
  166. package/dist/shared/worker-shutdown.d.ts.map +1 -1
  167. package/dist/{storage-tags-6hvkk01c.js → storage-tags-vj0yj7ed.js} +5 -4
  168. package/dist/store-reader-yh19h38c.js +14 -0
  169. package/dist/store-s3eykdjt.js +21 -0
  170. package/dist/tools/ctx-expand/render.d.ts +5 -3
  171. package/dist/tools/ctx-expand/render.d.ts.map +1 -1
  172. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
  173. package/dist/tools/ctx-expand/tools.d.ts +2 -0
  174. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  175. package/dist/tools/ctx-expand/v2-archive-reader.d.ts +33 -0
  176. package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -0
  177. package/dist/{transform-postprocess-phase-ph38mhrs.js → transform-postprocess-phase-4gj0mtcg.js} +39 -32
  178. package/dist/v2/auto-search-worker.js +163 -155
  179. package/dist/v2/chunk-embedding-write-worker.js +71 -67
  180. package/dist/v2/compaction-marker-candidates-worker.js +24 -23
  181. package/dist/v2/{compaction-marker-candidates-m4vmye3w.js → compaction-marker-candidates-yeb2ky46.js} +6 -3
  182. package/dist/v2/{compartment-chunk-embedding-rc31e6md.js → compartment-chunk-embedding-qfk791bd.js} +11 -9
  183. package/dist/v2/{context-s60hcatx.js → context-bxr039be.js} +2678 -1246
  184. package/dist/v2/{derive-budgets-knf763tt.js → derive-budgets-sa0v7bz0.js} +4 -3
  185. package/dist/v2/embedding-backfill-00tw59rx.js +27 -0
  186. package/dist/v2/embedding-worker-process.js +2 -1
  187. package/dist/v2/embedding-worker.js +6 -5
  188. package/dist/v2/expand-attachments-h33jbgyz.js +21 -0
  189. package/dist/v2/fold/code-mode-catalog.d.ts +3 -0
  190. package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -0
  191. package/dist/v2/fold/idle.d.ts +16 -0
  192. package/dist/v2/fold/idle.d.ts.map +1 -0
  193. package/dist/v2/fold/manual-baseline.d.ts +8 -0
  194. package/dist/v2/fold/manual-baseline.d.ts.map +1 -0
  195. package/dist/v2/fold/native-replay-v3.d.ts +75 -0
  196. package/dist/v2/fold/native-replay-v3.d.ts.map +1 -0
  197. package/dist/v2/fold/native-replay.d.ts +81 -8
  198. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  199. package/dist/v2/fold/policy.d.ts +2 -1
  200. package/dist/v2/fold/policy.d.ts.map +1 -1
  201. package/dist/v2/fold/restore.d.ts.map +1 -1
  202. package/dist/v2/fold/summary.d.ts +4 -0
  203. package/dist/v2/fold/summary.d.ts.map +1 -0
  204. package/dist/v2/hidden-completion.d.ts.map +1 -1
  205. package/dist/v2/{history-owner-ad0crnrn.js → history-owner-fpka43cn.js} +3 -2
  206. package/dist/v2/hooks/channel2.d.ts +6 -0
  207. package/dist/v2/hooks/channel2.d.ts.map +1 -1
  208. package/dist/v2/hooks/context.d.ts.map +1 -1
  209. package/dist/v2/hooks/expand-attachments.d.ts +8 -0
  210. package/dist/v2/hooks/expand-attachments.d.ts.map +1 -0
  211. package/dist/v2/hooks/overflow-recovery.d.ts +45 -0
  212. package/dist/v2/hooks/overflow-recovery.d.ts.map +1 -0
  213. package/dist/v2/hooks/restore-rows.d.ts +12 -2
  214. package/dist/v2/hooks/restore-rows.d.ts.map +1 -1
  215. package/dist/v2/hooks/store.d.ts +7 -2
  216. package/dist/v2/hooks/store.d.ts.map +1 -1
  217. package/dist/v2/hooks/synthetic-admission.d.ts +7 -0
  218. package/dist/v2/hooks/synthetic-admission.d.ts.map +1 -0
  219. package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
  220. package/dist/v2/{logger-p34mjtja.js → logger-4cj6d03m.js} +2 -1
  221. package/dist/v2/{message-fts-rowid-map-78awh03v.js → message-fts-rowid-map-z86avy0n.js} +8 -6
  222. package/dist/v2/{message-index-bounded-4htdr1j6.js → message-index-bounded-w14496s9.js} +16 -14
  223. package/dist/v2/{message-time-backfill-zvthw6xb.js → message-time-backfill-0c4h7sg6.js} +3 -2
  224. package/dist/v2/migration-worker.js +56 -49
  225. package/dist/v2/ordinal-range.fixture.d.ts +7 -0
  226. package/dist/v2/ordinal-range.fixture.d.ts.map +1 -0
  227. package/dist/v2/{project-embedding-registry-1x5qe2fy.js → project-embedding-registry-jqq2qeqb.js} +17 -14
  228. package/dist/v2/raw-ordinal-warmup-worker.js +114 -113
  229. package/dist/v2/{read-session-chunk-1fa9qzwb.js → read-session-chunk-tqnh1ret.js} +18 -12
  230. package/dist/v2/{read-session-raw-5x088amc.js → read-session-raw-qpp6x9kg.js} +6 -4
  231. package/dist/v2/recomp-orchestrator-9cjk6aej.js +68 -0
  232. package/dist/v2/render-5dz1knf2.js +43 -0
  233. package/dist/v2/{safe-notification-target-khnzg57c.js → safe-notification-target-gphhast7.js} +3 -2
  234. package/dist/v2/search-8yfet25y.js +52 -0
  235. package/dist/v2/search-archive-z6z9jqwf.js +28 -0
  236. package/dist/v2/{send-session-notification-x5nzy34v.js → send-session-notification-kxp47tsw.js} +9 -7
  237. package/dist/v2/{server-cpjk5jd2.js → server-1d042x6w.js} +16 -14
  238. package/dist/v2/server-2amn2s73.js +123 -0
  239. package/dist/v2/{server-6g98c227.js → server-3schkz95.js} +4 -4
  240. package/dist/v2/server-468mya5v.js +209 -0
  241. package/dist/v2/{server-z2wft9zv.js → server-5by3vdzs.js} +562 -5560
  242. package/dist/v2/{server-qjvk4a9t.js → server-69m30b21.js} +1 -1
  243. package/dist/v2/server-6emy0v9a.js +531 -0
  244. package/dist/v2/{server-vr4szghm.js → server-6vzh6wej.js} +3 -3
  245. package/dist/v2/{server-ajxhrgjv.js → server-7094pk3w.js} +80 -19
  246. package/dist/v2/{server-ab8017gw.js → server-7acq7815.js} +34 -141
  247. package/dist/v2/server-7v05d9b7.js +58 -0
  248. package/dist/v2/{server-24g8r2d0.js → server-7zacmty5.js} +75 -75
  249. package/dist/v2/{server-3mz2qh5a.js → server-969cdpmg.js} +1 -1
  250. package/dist/v2/server-96ztjvkn.js +204 -0
  251. package/dist/v2/{server-grakwy1v.js → server-a9w5f0yw.js} +37 -7
  252. package/dist/v2/{server-835q39kd.js → server-avdveykk.js} +3 -3
  253. package/dist/v2/{server-qc915kw2.js → server-bez34e60.js} +4 -4
  254. package/dist/v2/{server-h1byrhwx.js → server-cp1a03vc.js} +19 -8
  255. package/dist/v2/{server-bsgd4dk1.js → server-dcws5831.js} +2 -2
  256. package/dist/v2/{server-m1pfg2d4.js → server-dfq5vb8j.js} +4 -4
  257. package/dist/v2/server-e51xmr4d.js +194 -0
  258. package/dist/v2/server-ef1mskas.js +777 -0
  259. package/dist/v2/{server-1bw1wcbp.js → server-f0j864ma.js} +1 -1
  260. package/dist/v2/{server-jw5qe9y8.js → server-g3gqq4ac.js} +18 -217
  261. package/dist/v2/{server-2aasmpsp.js → server-gkse1wyz.js} +5 -5
  262. package/dist/v2/{server-6495nmn9.js → server-jb6tjyeb.js} +5 -222
  263. package/dist/v2/{server-qvy4qavp.js → server-jd7vzwn4.js} +125 -143
  264. package/dist/v2/{server-a7x00tw8.js → server-mfn1yf9d.js} +1 -1
  265. package/dist/v2/{server-awr8qa4c.js → server-nmyganc8.js} +2 -2
  266. package/dist/v2/{server-tkdabx8q.js → server-nq3cb7be.js} +5 -530
  267. package/dist/v2/server-qjyp27vf.js +270 -0
  268. package/dist/v2/{server-gyy4k6mf.js → server-qmmkhz2z.js} +1 -1
  269. package/dist/v2/{server-29qp8nz4.js → server-qxzbmtqt.js} +1 -1
  270. package/dist/v2/{server-806rzhs6.js → server-r4430x9m.js} +10 -4
  271. package/dist/v2/{server-53eh1r8r.js → server-sd8hvzte.js} +2 -2
  272. package/dist/v2/{server-k3t06fxr.js → server-sefxj8k1.js} +1 -1
  273. package/dist/v2/server-t8y64xj7.js +4513 -0
  274. package/dist/v2/{server-6vd2n183.js → server-tnzbk64q.js} +35 -5
  275. package/dist/v2/{server-v77xa5wj.js → server-tpt7bwq8.js} +1 -1
  276. package/dist/v2/{server-51779zs2.js → server-v0p37hm2.js} +4 -1
  277. package/dist/v2/{server-nxas8v1d.js → server-xfjjbrkt.js} +15 -4
  278. package/dist/v2/{server-cqjvxyrp.js → server-xy7w7hrd.js} +2 -2
  279. package/dist/v2/server-ypf1ap0v.js +529 -0
  280. package/dist/v2/server-z4p0ry94.js +222 -0
  281. package/dist/v2/server-z9zygwse.js +89 -0
  282. package/dist/v2/{server-ab1g0wn9.js → server-zzgtgqmd.js} +2 -2
  283. package/dist/v2/server.js +7 -6
  284. package/dist/v2/{storage-tags-18nbaanf.js → storage-tags-cw07ky67.js} +5 -4
  285. package/dist/v2/store-reader-cgx47zkp.js +14 -0
  286. package/dist/v2/store-reader.d.ts +9 -2
  287. package/dist/v2/store-reader.d.ts.map +1 -1
  288. package/dist/v2/store-z3qe67cg.js +21 -0
  289. package/dist/v2/v2-archive-reader-z7wr42ry.js +11 -0
  290. package/dist/v2/{wrapup-orchestrator-wxf7n5k6.js → wrapup-orchestrator-j1v62bkj.js} +50 -42
  291. package/dist/v2-archive-reader-028z6kck.js +11 -0
  292. package/dist/wrapup-orchestrator-xg9avt2p.js +56 -0
  293. package/package.json +1 -1
  294. package/src/shared/model-suggestion-retry.ts +1 -1
  295. package/src/shared/prompt-async-transport.test.ts +64 -3
  296. package/src/shared/prompt-async-transport.ts +61 -16
  297. package/src/shared/reusable-worker-entry.ts +58 -0
  298. package/src/shared/reusable-worker-reset.test.ts +108 -0
  299. package/src/shared/reusable-worker.fixture.ts +35 -0
  300. package/src/shared/reusable-worker.test.ts +253 -0
  301. package/src/shared/reusable-worker.ts +240 -0
  302. package/src/shared/sqlite-transaction-mode-guard.test.ts +2 -0
  303. package/src/shared/worker-shutdown.ts +21 -17
  304. package/dist/embedding-backfill-0jgtqxen.js +0 -25
  305. package/dist/recomp-orchestrator-0y983w7h.js +0 -62
  306. package/dist/search-archive-1kw2rp19.js +0 -26
  307. package/dist/search-p684j8ww.js +0 -50
  308. package/dist/v2/embedding-backfill-f43hd8y6.js +0 -24
  309. package/dist/v2/recomp-orchestrator-7q9nvxte.js +0 -61
  310. package/dist/v2/search-archive-xfp51s0g.js +0 -25
  311. package/dist/v2/search-wf8rqxhm.js +0 -48
  312. package/dist/wrapup-orchestrator-ys2nrkkb.js +0 -49
@@ -0,0 +1,58 @@
1
+ // src/shared/reusable-worker-entry.ts
2
+ import { EventEmitter } from "node:events";
3
+ import { parentPort, workerData } from "node:worker_threads";
4
+ function serveWorkerJobs(run, autoClose = true) {
5
+ if (!parentPort)
6
+ throw new Error("worker requires a parent port");
7
+ const parent = parentPort;
8
+ if (!workerData?.reusableWorker) {
9
+ Promise.resolve(run(workerData, parent)).catch(rethrow);
10
+ return;
11
+ }
12
+ let active;
13
+ parent.on("message", (message) => {
14
+ if (!("start" in message)) {
15
+ if (active?.id === message.jobId)
16
+ active.port.emit("message", message.value);
17
+ return;
18
+ }
19
+ if (active)
20
+ throw new Error("reusable worker received overlapping jobs");
21
+ const id = message.jobId;
22
+ let closed = false;
23
+ const port = Object.assign(new EventEmitter, {
24
+ postMessage(value, transferList) {
25
+ if (!closed)
26
+ parent.postMessage({ jobId: id, value }, transferList);
27
+ },
28
+ close() {
29
+ if (closed)
30
+ return;
31
+ closed = true;
32
+ port.removeAllListeners();
33
+ active = undefined;
34
+ parent.postMessage({
35
+ jobId: id,
36
+ finished: true,
37
+ code: Number(process.exitCode) || 0
38
+ });
39
+ }
40
+ });
41
+ active = { id, port };
42
+ try {
43
+ Promise.resolve(run(message.start, port)).then(() => {
44
+ if (autoClose)
45
+ port.close();
46
+ }).catch(rethrow);
47
+ } catch (error) {
48
+ rethrow(error);
49
+ }
50
+ });
51
+ }
52
+ function rethrow(error) {
53
+ setTimeout(() => {
54
+ throw error;
55
+ });
56
+ }
57
+
58
+ export { serveWorkerJobs };
@@ -3,11 +3,17 @@ import {
3
3
  } from "./index-v0p37hm2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-h7tgn49j.js";
6
+ } from "./index-jrfre9ah.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2
10
10
  } from "./index-gzy5w8ya.js";
11
+ import {
12
+ reuseWorker
13
+ } from "./index-96ztjvkn.js";
14
+ import {
15
+ createWorkerShutdown
16
+ } from "./index-1d042x6w.js";
11
17
 
12
18
  // src/features/magic-context/compaction-marker-candidates.ts
13
19
  import { existsSync, realpathSync } from "node:fs";
@@ -140,7 +146,7 @@ function runCandidateWorker(path, sessionId, options) {
140
146
  return;
141
147
  }
142
148
  workers.delete(worker);
143
- const stopped = worker.terminate();
149
+ const stopped = snapshot ? createWorkerShutdown(worker, "marker-candidates", 1000).close() : worker.terminate();
144
150
  worker.unref();
145
151
  stopped.then(() => resolve(snapshot), () => resolve(snapshot));
146
152
  };
@@ -153,7 +159,7 @@ function runCandidateWorker(path, sessionId, options) {
153
159
  timer.unref?.();
154
160
  };
155
161
  try {
156
- worker = inRootAsyncContext2(() => new Worker(entry, { workerData: { path, sessionId } }));
162
+ worker = inRootAsyncContext2(() => options.entry ? new Worker(entry, { workerData: { path, sessionId } }) : reuseWorker(entry, { workerData: { path, sessionId } }));
157
163
  workers.add(worker);
158
164
  worker.unref();
159
165
  deadline(options.acceptMs ?? 2000);
@@ -4,13 +4,13 @@ import {
4
4
  } from "./index-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./index-b88dwwrh.js";
7
+ } from "./index-4xyjr62e.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./index-pavzsdc6.js";
11
11
  import {
12
12
  sessionLog2
13
- } from "./index-h7tgn49j.js";
13
+ } from "./index-jrfre9ah.js";
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
@@ -20,7 +20,7 @@ import {
20
20
  tagOrderConstraintIndex,
21
21
  stableStringify,
22
22
  stableStringifyHash
23
- } from "./index-xrnsygfq.js";
23
+ } from "./index-9wnbnx8f.js";
24
24
  import {
25
25
  DEFAULT_PROTECTED_TOOLS,
26
26
  normalizeProtectedToolName,
@@ -2554,7 +2554,9 @@ function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration =
2554
2554
  FROM tags
2555
2555
  WHERE session_id = ?`).all(sessionId);
2556
2556
  const totals = new Map;
2557
+ const summaryRemovedTotals = new Map;
2557
2558
  const nullMessageIds = new Set;
2559
+ const nullSummaryRemovedMessageIds = new Set;
2558
2560
  for (const row of rows) {
2559
2561
  if (row.type === "tool" && row.tool_owner_message_id === null)
2560
2562
  continue;
@@ -2564,6 +2566,7 @@ function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration =
2564
2566
  if (row.token_count === null) {
2565
2567
  nullMessageIds.add(owner);
2566
2568
  totals.delete(owner);
2569
+ summaryRemovedTotals.delete(owner);
2567
2570
  continue;
2568
2571
  }
2569
2572
  if (nullMessageIds.has(owner))
@@ -2571,8 +2574,16 @@ function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration =
2571
2574
  const ratio = row.type === "tool" ? calibration.toolsRatio : calibration.proseRatio;
2572
2575
  const weight = ((row.token_count ?? 0) + (row.input_token_count ?? 0)) * ratio + (row.reasoning_token_count ?? 0) * calibration.proseRatio;
2573
2576
  totals.set(owner, (totals.get(owner) ?? 0) + weight);
2577
+ if (row.type === "tool" && row.input_token_count === null) {
2578
+ nullSummaryRemovedMessageIds.add(owner);
2579
+ summaryRemovedTotals.delete(owner);
2580
+ }
2581
+ if (!nullSummaryRemovedMessageIds.has(owner)) {
2582
+ const removedWeight = row.type === "tool" ? (row.input_token_count ?? 0) * calibration.toolsRatio : row.type === "message" ? row.token_count * calibration.proseRatio : 0;
2583
+ summaryRemovedTotals.set(owner, (summaryRemovedTotals.get(owner) ?? 0) + removedWeight);
2584
+ }
2574
2585
  }
2575
- return { totals, nullMessageIds };
2586
+ return { totals, summaryRemovedTotals, nullMessageIds };
2576
2587
  }
2577
2588
  function getReasoningTokenEstimatesByMessage2(db, sessionId, proseRatio) {
2578
2589
  const summary = readTagOwnerSummary(db, sessionId, proseRatio);
@@ -0,0 +1,204 @@
1
+ import {
2
+ registerExitAbort,
3
+ unregisterExitAbort
4
+ } from "./index-v0p37hm2.js";
5
+ import {
6
+ inRootAsyncContext2
7
+ } from "./index-gzy5w8ya.js";
8
+
9
+ // src/shared/reusable-worker.ts
10
+ import { EventEmitter } from "node:events";
11
+ import * as timers from "node:timers";
12
+ import {
13
+ MessageChannel,
14
+ receiveMessageOnPort,
15
+ Worker
16
+ } from "node:worker_threads";
17
+ var pools = new Map;
18
+ var liveSlots = new Set;
19
+ var nextId = 0;
20
+ var IDLE_MS = 60000;
21
+ var sharedCloneWorks = (() => {
22
+ const source = new SharedArrayBuffer(1);
23
+ const clone = structuredClone(source);
24
+ new Uint8Array(source)[0] = 1;
25
+ return new Uint8Array(clone)[0] === 1;
26
+ })();
27
+ var cloneChannel;
28
+ function cloneJobValue(value, transferList) {
29
+ if (sharedCloneWorks)
30
+ return structuredClone(value, { transfer: transferList });
31
+ if (!cloneChannel) {
32
+ cloneChannel = inRootAsyncContext2(() => new MessageChannel);
33
+ cloneChannel.port1.unref();
34
+ cloneChannel.port2.unref();
35
+ }
36
+ cloneChannel.port1.postMessage(value, transferList);
37
+ const packet = receiveMessageOnPort(cloneChannel.port2);
38
+ if (!packet)
39
+ throw new Error("worker input clone did not arrive synchronously");
40
+ return packet.message;
41
+ }
42
+
43
+ class Lease extends EventEmitter {
44
+ slot;
45
+ data;
46
+ id = ++nextId;
47
+ ended = false;
48
+ referenced = true;
49
+ outbox = [];
50
+ constructor(slot, data) {
51
+ super();
52
+ this.slot = slot;
53
+ this.data = data;
54
+ }
55
+ postMessage(value, transferList) {
56
+ if (this.ended)
57
+ return;
58
+ if (this.slot.active === this)
59
+ this.slot.worker.postMessage({ jobId: this.id, value }, transferList);
60
+ else
61
+ this.outbox.push(cloneJobValue({ value, transferList }, transferList));
62
+ }
63
+ start() {
64
+ if (this.referenced)
65
+ this.slot.worker.ref();
66
+ else
67
+ this.slot.worker.unref();
68
+ this.emit("online");
69
+ this.slot.worker.postMessage({ jobId: this.id, start: this.data });
70
+ for (const { value, transferList } of this.outbox.splice(0))
71
+ this.postMessage(value, transferList);
72
+ }
73
+ ref() {
74
+ this.referenced = true;
75
+ if (this.slot.active === this)
76
+ this.slot.worker.ref();
77
+ return this;
78
+ }
79
+ unref() {
80
+ this.referenced = false;
81
+ if (this.slot.active === this)
82
+ this.slot.worker.unref();
83
+ return this;
84
+ }
85
+ async terminate() {
86
+ if (this.ended)
87
+ return 0;
88
+ if (this.slot.active === this)
89
+ return await this.slot.worker.terminate();
90
+ this.ended = true;
91
+ this.slot.queue.splice(this.slot.queue.indexOf(this), 1);
92
+ this.emit("exit", 0);
93
+ return 0;
94
+ }
95
+ }
96
+ function reuseWorker(entry, options, idleMs = IDLE_MS) {
97
+ const data = cloneJobValue(options.workerData);
98
+ const slot = acquireSlot(entry, options, idleMs);
99
+ const lease = new Lease(slot, data);
100
+ enqueue(slot, lease);
101
+ return lease;
102
+ }
103
+ function enqueue(slot, lease) {
104
+ timers.clearTimeout(slot.idle);
105
+ lease.slot = slot;
106
+ slot.queue.push(lease);
107
+ queueMicrotask(() => slot.advance());
108
+ }
109
+ function acquireSlot(entry, options, idleMs) {
110
+ const data = options.workerData;
111
+ const key = JSON.stringify([
112
+ String(entry),
113
+ data?.path ?? data?.dbPath,
114
+ data?.harness,
115
+ data?.job
116
+ ]);
117
+ let slot = pools.get(key);
118
+ if (!slot) {
119
+ const worker = inRootAsyncContext2(() => new Worker(entry, { ...options, workerData: { reusableWorker: true } }));
120
+ const controller = new AbortController;
121
+ slot = { worker, controller, queue: [], advance: () => {} };
122
+ pools.set(key, slot);
123
+ liveSlots.add(slot);
124
+ const owned = slot;
125
+ const advance = () => {
126
+ if (controller.signal.aborted || owned.active)
127
+ return;
128
+ timers.clearTimeout(owned.idle);
129
+ const lease = owned.queue.shift();
130
+ owned.active = lease;
131
+ if (!lease) {
132
+ worker.unref();
133
+ owned.idle = timers.setTimeout(() => {
134
+ if (pools.get(key) === owned)
135
+ pools.delete(key);
136
+ worker.terminate();
137
+ }, idleMs);
138
+ owned.idle.unref();
139
+ return;
140
+ }
141
+ lease.start();
142
+ };
143
+ owned.advance = advance;
144
+ worker.on("message", (message) => {
145
+ const lease = owned.active;
146
+ if (!lease || message.jobId !== lease.id)
147
+ return;
148
+ if (!message.finished) {
149
+ lease.emit("message", message.value);
150
+ return;
151
+ }
152
+ lease.ended = true;
153
+ owned.active = undefined;
154
+ if (message.code) {
155
+ if (pools.get(key) === owned)
156
+ pools.delete(key);
157
+ lease.emit("exit", message.code);
158
+ worker.terminate();
159
+ return;
160
+ }
161
+ lease.emit("exit", 0);
162
+ advance();
163
+ });
164
+ worker.on("error", (error) => {
165
+ if (pools.get(key) === owned)
166
+ pools.delete(key);
167
+ owned.active?.emit("error", error);
168
+ });
169
+ worker.on("exit", (code) => {
170
+ liveSlots.delete(owned);
171
+ timers.clearTimeout(owned.idle);
172
+ if (pools.get(key) === owned)
173
+ pools.delete(key);
174
+ const active = owned.active;
175
+ owned.active = undefined;
176
+ if (active && !active.ended) {
177
+ active.ended = true;
178
+ active.emit("exit", code);
179
+ }
180
+ for (const lease of owned.queue.splice(0)) {
181
+ if (controller.signal.aborted) {
182
+ lease.ended = true;
183
+ lease.emit("exit", code);
184
+ } else {
185
+ try {
186
+ enqueue(acquireSlot(entry, options, idleMs), lease);
187
+ } catch (error) {
188
+ lease.ended = true;
189
+ lease.emit("error", error);
190
+ lease.emit("exit", 1);
191
+ }
192
+ }
193
+ }
194
+ });
195
+ controller.signal.addEventListener("abort", () => {
196
+ worker.terminate();
197
+ }, { once: true });
198
+ registerExitAbort(controller);
199
+ worker.once("exit", () => unregisterExitAbort(controller));
200
+ }
201
+ return slot;
202
+ }
203
+
204
+ export { reuseWorker };