@cortexkit/opencode-magic-context 0.49.19 → 0.49.21

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 (323) hide show
  1. package/dist/auto-search-worker.js +48 -9
  2. package/dist/chunk-embedding-write-worker.js +30 -23
  3. package/dist/{compaction-marker-candidates-n4krhat4.js → compaction-marker-candidates-31h86ph0.js} +3 -3
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/compartment-chunk-embedding-he60aaa2.js +65 -0
  6. package/dist/config/project-security.d.ts.map +1 -1
  7. package/dist/config/schema/magic-context.d.ts +43 -9
  8. package/dist/config/schema/magic-context.d.ts.map +1 -1
  9. package/dist/{conflict-warning-hook-4pmz879v.js → conflict-warning-hook-2r32hyx6.js} +9 -8
  10. package/dist/{context-j31m2dv7.js → context-j7hp43a0.js} +576 -185
  11. package/dist/{derive-budgets-zn7yzd2d.js → derive-budgets-pqybnx09.js} +2 -2
  12. package/dist/embedding-backfill-dtke6tck.js +25 -0
  13. package/dist/embedding-worker-process.js +2 -2
  14. package/dist/embedding-worker.js +6 -6
  15. package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -1
  16. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +44 -1
  17. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +1 -0
  19. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
  24. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  25. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  26. package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
  27. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  28. package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
  29. package/dist/features/magic-context/memory/embedding-worker-client.d.ts +7 -1
  30. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  31. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts +22 -0
  32. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts.map +1 -0
  33. package/dist/features/magic-context/message-index-async.d.ts +7 -2
  34. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  35. package/dist/features/magic-context/message-index.d.ts +2 -0
  36. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  37. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  38. package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
  39. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  40. package/dist/features/magic-context/search-rerank.d.ts +9 -2
  41. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  42. package/dist/features/magic-context/search.d.ts +29 -0
  43. package/dist/features/magic-context/search.d.ts.map +1 -1
  44. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  45. package/dist/features/magic-context/storage-db.d.ts +2 -0
  46. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  47. package/dist/features/magic-context/storage-meta-persisted.d.ts +2 -0
  48. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  49. package/dist/features/magic-context/subagent-token-capture.d.ts +20 -0
  50. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  51. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  52. package/dist/{history-owner-xp3pngv7.js → history-owner-36wp3mkb.js} +2 -2
  53. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/auto-search-hint.d.ts +7 -1
  56. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +33 -6
  59. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/cache-busting-signals.d.ts +6 -2
  61. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  65. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  67. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
  69. package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
  70. package/dist/hooks/magic-context/execute-reclaim.d.ts +35 -0
  71. package/dist/hooks/magic-context/execute-reclaim.d.ts.map +1 -0
  72. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/hook.d.ts +1 -3
  74. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/latest-assistant-turn.d.ts +8 -0
  76. package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +5 -0
  78. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
  80. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
  81. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -0
  83. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/served-shape-repair.d.ts +19 -0
  86. package/dist/hooks/magic-context/served-shape-repair.d.ts.map +1 -0
  87. package/dist/hooks/magic-context/strip-content.d.ts +4 -2
  88. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  89. package/dist/hooks/magic-context/system-date-refresh.d.ts +5 -5
  90. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +10 -0
  92. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
  93. package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
  94. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/tag-messages.d.ts +4 -1
  96. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/text-complete.d.ts +1 -1
  98. package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  100. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +21 -6
  101. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/transform.d.ts +2 -2
  103. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  104. package/dist/{index-3esx8tkf.js → index-11gzxvf4.js} +394 -125
  105. package/dist/{index-jn12fvvh.js → index-1gtfne2c.js} +3 -3
  106. package/dist/{index-jhghdnsm.js → index-1kbznkft.js} +521 -214
  107. package/dist/{index-3h4dp9wb.js → index-3svaejkh.js} +5 -5
  108. package/dist/{index-kee4kn5j.js → index-4pnsgvfk.js} +1 -1
  109. package/dist/{index-bjcnntmz.js → index-51rdvtkz.js} +501 -20
  110. package/dist/{v2/server-8cd2j99z.js → index-5kym00ag.js} +32 -13
  111. package/dist/{index-s74zqahq.js → index-66eby7hx.js} +4 -4
  112. package/dist/{index-63k48rv9.js → index-9q1g3c5q.js} +5 -5
  113. package/dist/{index-jrr131e0.js → index-a9zvn5fe.js} +29 -15
  114. package/dist/{index-c5pytzne.js → index-b88dwwrh.js} +1 -1
  115. package/dist/{index-nj7yykkx.js → index-c7phnbvk.js} +1 -1
  116. package/dist/index-cpjk5jd2.js +82 -0
  117. package/dist/{index-c1p88z1y.js → index-ffzhwfzy.js} +4 -4
  118. package/dist/{v2/server-beht37jy.js → index-gzy5w8ya.js} +194 -5
  119. package/dist/{index-j75v2476.js → index-h7tgn49j.js} +12 -15
  120. package/dist/{index-edmpdxcw.js → index-j32jj2t8.js} +5 -5
  121. package/dist/{index-ke416mdc.js → index-j76ah6d7.js} +2 -2
  122. package/dist/{index-s734jcsr.js → index-jfem3dgz.js} +9 -3
  123. package/dist/{index-n37sebck.js → index-jjvbk92s.js} +1 -1
  124. package/dist/{index-4911rn0b.js → index-jmq8kfe7.js} +6 -6
  125. package/dist/{index-rr2bb45z.js → index-kfyb3k6n.js} +2 -2
  126. package/dist/{index-2vxtcb95.js → index-kq5w68dp.js} +2 -2
  127. package/dist/{index-kq82mtg0.js → index-ksq50rg0.js} +3 -3
  128. package/dist/{index-b5vqckbw.js → index-m32esgmj.js} +314 -127
  129. package/dist/{index-9zcsy3hh.js → index-mnhcdfxg.js} +161 -13
  130. package/dist/{index-se4m2g6w.js → index-mnnkgq0q.js} +111 -19
  131. package/dist/{index-p5y3k4g7.js → index-nda0zgna.js} +2 -1
  132. package/dist/{index-wgypt3cs.js → index-nxrsns5x.js} +2466 -1290
  133. package/dist/{index-4s3t0nd0.js → index-qgh1qwjj.js} +2 -2
  134. package/dist/{index-y9f76s3f.js → index-rrv26qjz.js} +1 -1
  135. package/dist/{index-24fezq97.js → index-rxqr723x.js} +5 -5
  136. package/dist/{index-v10f1rjv.js → index-spwjbkc7.js} +1 -1
  137. package/dist/{index-dxmq29t1.js → index-syaazvy2.js} +182 -47
  138. package/dist/{index-k29z4aqh.js → index-t5pck3ss.js} +1 -1
  139. package/dist/{index-6x57ar45.js → index-wfybj1dw.js} +4 -6
  140. package/dist/{index-cf74k5ak.js → index-whcgcfrv.js} +9 -6
  141. package/dist/{index-a6mc0v4d.js → index-x6cbrv9h.js} +3 -3
  142. package/dist/{index-bp5083x2.js → index-x9k3mqrf.js} +1 -1
  143. package/dist/{index-rpxdjkm0.js → index-y76rhsnr.js} +319 -61
  144. package/dist/{index-ze7mvk54.js → index-zy67whjr.js} +95 -59
  145. package/dist/index.js +58 -54
  146. package/dist/{logger-jm3sqqzr.js → logger-94kew5wm.js} +1 -1
  147. package/dist/{message-fts-rowid-map-17s0dfn4.js → message-fts-rowid-map-e79b7b6x.js} +6 -5
  148. package/dist/{message-index-gtpqnj8w.js → message-index-4q8ek2fc.js} +17 -16
  149. package/dist/{message-index-bounded-zyc8h32y.js → message-index-bounded-rydsg9r5.js} +17 -16
  150. package/dist/{message-time-backfill-73mmm76q.js → message-time-backfill-4qva0b4f.js} +3 -3
  151. package/dist/migration-worker.js +13 -12
  152. package/dist/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  153. package/dist/plugin/embedding-bootstrap.d.ts +4 -1
  154. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  155. package/dist/plugin/hooks/create-session-hooks.d.ts +1 -0
  156. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  157. package/dist/plugin/rpc-handlers.d.ts +8 -0
  158. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  159. package/dist/plugin/subagent-tool-policy.d.ts +9 -0
  160. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
  161. package/dist/plugin/tool-registry.d.ts.map +1 -1
  162. package/dist/{project-embedding-registry-z74mhqkf.js → project-embedding-registry-hn529988.js} +16 -13
  163. package/dist/raw-ordinal-warmup-worker.js +136 -101
  164. package/dist/{read-session-chunk-jjb48bt9.js → read-session-chunk-t039f0m5.js} +12 -11
  165. package/dist/{read-session-raw-rsc8c7qy.js → read-session-raw-aw6jgvwg.js} +4 -3
  166. package/dist/recomp-orchestrator-hbm53jj5.js +62 -0
  167. package/dist/{safe-notification-target-1szv1k5k.js → safe-notification-target-mkr9yzvr.js} +2 -2
  168. package/dist/search-archive-weh164mh.js +26 -0
  169. package/dist/search-hea079d7.js +50 -0
  170. package/dist/{send-session-notification-6ve0e8p4.js → send-session-notification-gqzkz7da.js} +7 -6
  171. package/dist/shared/logger.d.ts.map +1 -1
  172. package/dist/shared/model-resolution.d.ts +2 -0
  173. package/dist/shared/model-resolution.d.ts.map +1 -1
  174. package/dist/shared/prompt-async-transport.d.ts +3 -0
  175. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  176. package/dist/shared/rpc-types.d.ts +7 -0
  177. package/dist/shared/rpc-types.d.ts.map +1 -1
  178. package/dist/shared/sqlite.d.ts +6 -1
  179. package/dist/shared/sqlite.d.ts.map +1 -1
  180. package/dist/shared/subagent-runner.d.ts +2 -0
  181. package/dist/shared/subagent-runner.d.ts.map +1 -1
  182. package/dist/shared/tag-transcript.d.ts +2 -0
  183. package/dist/shared/tag-transcript.d.ts.map +1 -1
  184. package/dist/shared/worker-shutdown.d.ts +68 -0
  185. package/dist/shared/worker-shutdown.d.ts.map +1 -0
  186. package/dist/shared/worker-shutdown.fixture.d.ts +2 -0
  187. package/dist/shared/worker-shutdown.fixture.d.ts.map +1 -0
  188. package/dist/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
  189. package/dist/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
  190. package/dist/{storage-tags-r7k9tjcv.js → storage-tags-a77q4v77.js} +5 -5
  191. package/dist/{task-config-x3qmayd2.js → task-config-t6bpyka7.js} +2 -2
  192. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  193. package/dist/tools/ctx-search/types.d.ts +1 -0
  194. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  195. package/dist/{transform-postprocess-phase-jj99r7z2.js → transform-postprocess-phase-0b04tm1p.js} +35 -32
  196. package/dist/v2/auto-search-worker.js +48 -9
  197. package/dist/v2/chunk-embedding-write-worker.js +30 -23
  198. package/dist/v2/{compaction-marker-candidates-ebx3388k.js → compaction-marker-candidates-m4vmye3w.js} +3 -3
  199. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  200. package/dist/v2/compartment-chunk-embedding-8jjmcgeg.js +64 -0
  201. package/dist/v2/{context-y5yamxak.js → context-ea3x7smm.js} +1797 -810
  202. package/dist/v2/{derive-budgets-2zh4gm2c.js → derive-budgets-knf763tt.js} +3 -3
  203. package/dist/v2/embedding-backfill-5e74ae0m.js +24 -0
  204. package/dist/v2/embedding-worker-process.js +2 -2
  205. package/dist/v2/embedding-worker.js +6 -6
  206. package/dist/v2/hidden-child-record.d.ts +2 -0
  207. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  208. package/dist/v2/hidden-completion.d.ts +2 -0
  209. package/dist/v2/hidden-completion.d.ts.map +1 -1
  210. package/dist/v2/hidden-model-activity.d.ts +7 -0
  211. package/dist/v2/hidden-model-activity.d.ts.map +1 -0
  212. package/dist/v2/{history-owner-42e16w0n.js → history-owner-ad0crnrn.js} +2 -2
  213. package/dist/v2/hooks/context.d.ts.map +1 -1
  214. package/dist/v2/hooks/copied-tag-notation.d.ts +1 -1
  215. package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -1
  216. package/dist/v2/hooks/dream-timer.d.ts +2 -0
  217. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  218. package/dist/v2/hooks/embedding-lifecycle.d.ts +7 -0
  219. package/dist/v2/hooks/embedding-lifecycle.d.ts.map +1 -0
  220. package/dist/v2/hooks/generate.d.ts +36 -1
  221. package/dist/v2/hooks/generate.d.ts.map +1 -1
  222. package/dist/v2/hooks/lkg-system.d.ts +35 -4
  223. package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
  224. package/dist/v2/hooks/payload.d.ts +16 -1
  225. package/dist/v2/hooks/payload.d.ts.map +1 -1
  226. package/dist/v2/hooks/store.d.ts +2 -0
  227. package/dist/v2/hooks/store.d.ts.map +1 -1
  228. package/dist/v2/hooks/tools.d.ts +2 -1
  229. package/dist/v2/hooks/tools.d.ts.map +1 -1
  230. package/dist/v2/hooks/transform-features.d.ts +2 -2
  231. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  232. package/dist/v2/{logger-7qt02bnb.js → logger-p34mjtja.js} +1 -1
  233. package/dist/v2/{message-fts-rowid-map-wfx67gfd.js → message-fts-rowid-map-n8fdg2ja.js} +6 -5
  234. package/dist/v2/{message-index-bounded-spd8r7pj.js → message-index-bounded-8rcd7qq9.js} +17 -16
  235. package/dist/v2/{message-index-8vz2pq76.js → message-index-qz9wdp82.js} +17 -16
  236. package/dist/v2/{message-time-backfill-04t0km1z.js → message-time-backfill-zvthw6xb.js} +3 -3
  237. package/dist/v2/migration-worker.js +13 -12
  238. package/dist/v2/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  239. package/dist/v2/{project-embedding-registry-gnkj56xp.js → project-embedding-registry-v38q4xd5.js} +16 -13
  240. package/dist/v2/raw-ordinal-warmup-worker.js +136 -101
  241. package/dist/v2/{read-session-chunk-cwkxrmns.js → read-session-chunk-wazfyxcg.js} +12 -11
  242. package/dist/v2/{read-session-raw-yaegtjzh.js → read-session-raw-b70cpwzj.js} +4 -3
  243. package/dist/v2/recomp-orchestrator-b12zaptj.js +61 -0
  244. package/dist/v2/{safe-notification-target-qg7n2s77.js → safe-notification-target-khnzg57c.js} +2 -2
  245. package/dist/v2/search-archive-x64rtz1z.js +25 -0
  246. package/dist/v2/search-hza9x72a.js +49 -0
  247. package/dist/v2/{send-session-notification-3pxn658x.js → send-session-notification-8eqe259v.js} +7 -6
  248. package/dist/v2/{server-45q69hkq.js → server-132h8twc.js} +5 -5
  249. package/dist/v2/{server-h0410h0v.js → server-1bw1wcbp.js} +1 -1
  250. package/dist/v2/{server-271qxsf5.js → server-24g8r2d0.js} +2466 -1290
  251. package/dist/v2/{server-tbe1femw.js → server-29qp8nz4.js} +1 -1
  252. package/dist/v2/{server-gsxjv2q2.js → server-33nqbqkw.js} +182 -47
  253. package/dist/v2/{server-tgnbmwah.js → server-3mz2qh5a.js} +1 -1
  254. package/dist/v2/{server-n1prf1g6.js → server-3vhxy2k5.js} +2 -2
  255. package/dist/v2/{server-xj136kt8.js → server-4kjmrjn4.js} +9 -3
  256. package/dist/v2/{server-34kwfsr4.js → server-53eh1r8r.js} +2 -2
  257. package/dist/{index-8cd2j99z.js → v2/server-5kym00ag.js} +32 -13
  258. package/dist/v2/{server-46neh5fa.js → server-62g58aaz.js} +314 -127
  259. package/dist/v2/{server-f2xf5gcb.js → server-6495nmn9.js} +12 -15
  260. package/dist/v2/{server-a9xqj88f.js → server-6v3cdzsx.js} +4 -4
  261. package/dist/v2/{server-d04vrx0j.js → server-806rzhs6.js} +2 -2
  262. package/dist/v2/{server-qd11g795.js → server-92g7d776.js} +2 -1
  263. package/dist/v2/{server-nj659894.js → server-94wk1ey3.js} +14 -3
  264. package/dist/v2/{server-6tmj0s7j.js → server-ab1g0wn9.js} +4 -6
  265. package/dist/v2/{server-8by8qfec.js → server-ad18djzs.js} +95 -59
  266. package/dist/v2/{server-hy3d3vsx.js → server-bsgd4dk1.js} +2 -2
  267. package/dist/v2/server-cpjk5jd2.js +82 -0
  268. package/dist/v2/{server-g3qma5c0.js → server-d1dzgvwd.js} +2 -2
  269. package/dist/v2/{server-hm38q7r0.js → server-d48x3m4x.js} +5 -5
  270. package/dist/v2/{server-1wy7b9de.js → server-dtp8hcjh.js} +3 -3
  271. package/dist/v2/{server-27gq4mfz.js → server-fa7vtp40.js} +9 -6
  272. package/dist/v2/{server-6pmqg9m4.js → server-gyy4k6mf.js} +1 -1
  273. package/dist/{index-beht37jy.js → v2/server-gzy5w8ya.js} +194 -5
  274. package/dist/v2/{server-bmymkx73.js → server-j8h7bsca.js} +29 -15
  275. package/dist/v2/{server-n37sebck.js → server-jjvbk92s.js} +1 -1
  276. package/dist/v2/{server-da07v4xp.js → server-k3t06fxr.js} +1 -1
  277. package/dist/v2/{server-9hx7g5jp.js → server-m4bfaevz.js} +1197 -1049
  278. package/dist/v2/{server-2ar62dyx.js → server-ppcd1qxh.js} +191 -99
  279. package/dist/v2/{server-rmygf5pn.js → server-qjvk4a9t.js} +2 -2
  280. package/dist/v2/{server-zzkj2fch.js → server-qteg2kt9.js} +5 -5
  281. package/dist/v2/{server-pwv4ezb0.js → server-rqebawx1.js} +2 -2
  282. package/dist/v2/{server-h1v0pyxb.js → server-vr4szghm.js} +501 -20
  283. package/dist/v2/{server-xq7dfjke.js → server-wwaw5npa.js} +5 -5
  284. package/dist/v2/{server-6vdzn1td.js → server-zg5y109h.js} +323 -76
  285. package/dist/v2/server.js +8 -8
  286. package/dist/v2/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
  287. package/dist/v2/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
  288. package/dist/v2/{storage-tags-3wdb8zph.js → storage-tags-q71rnr9f.js} +5 -5
  289. package/dist/v2/store-reader.d.ts +10 -0
  290. package/dist/v2/store-reader.d.ts.map +1 -1
  291. package/dist/v2/{task-config-nvz8mapa.js → task-config-7md27rx8.js} +2 -2
  292. package/dist/v2/{wrapup-orchestrator-embdz8gj.js → wrapup-orchestrator-3ssd5yy1.js} +33 -32
  293. package/dist/wrapup-orchestrator-5vpcd1zx.js +49 -0
  294. package/package.json +2 -2
  295. package/src/config/index.test.ts +72 -6
  296. package/src/config/project-security.ts +15 -0
  297. package/src/config/rerank.test.ts +60 -0
  298. package/src/config/schema/magic-context.ts +57 -0
  299. package/src/shared/logger.test.ts +42 -1
  300. package/src/shared/logger.ts +11 -13
  301. package/src/shared/model-resolution.test.ts +67 -12
  302. package/src/shared/model-resolution.ts +43 -16
  303. package/src/shared/model-suggestion-retry.ts +2 -2
  304. package/src/shared/prompt-async-transport.ts +47 -3
  305. package/src/shared/rpc-types.ts +7 -0
  306. package/src/shared/sqlite-busy-budget-review.test.ts +6 -1
  307. package/src/shared/sqlite-turn-deadline.test.ts +270 -0
  308. package/src/shared/sqlite.ts +239 -9
  309. package/src/shared/subagent-runner.ts +2 -0
  310. package/src/shared/tag-transcript.ts +9 -1
  311. package/src/shared/worker-shutdown-fence.test.ts +87 -0
  312. package/src/shared/worker-shutdown.fixture.ts +25 -0
  313. package/src/shared/worker-shutdown.test.ts +127 -0
  314. package/src/shared/worker-shutdown.ts +160 -0
  315. package/dist/embedding-backfill-fmz50tsy.js +0 -24
  316. package/dist/recomp-orchestrator-999jj4bc.js +0 -61
  317. package/dist/search-archive-6vm0e2f5.js +0 -25
  318. package/dist/search-xsqk1bj4.js +0 -49
  319. package/dist/v2/embedding-backfill-7c7yr69y.js +0 -23
  320. package/dist/v2/recomp-orchestrator-f6m9jr7p.js +0 -60
  321. package/dist/v2/search-archive-wve3tq1k.js +0 -24
  322. package/dist/v2/search-hwg7jfbj.js +0 -48
  323. package/dist/wrapup-orchestrator-whhbjmaz.js +0 -48
@@ -3,24 +3,28 @@ import {
3
3
  } from "./server-pavzsdc6.js";
4
4
  import {
5
5
  getMagicContextStorageDir
6
- } from "./server-f2xf5gcb.js";
6
+ } from "./server-6495nmn9.js";
7
7
  import {
8
8
  isPidAlive,
9
9
  readProcessStartTime
10
- } from "./server-da07v4xp.js";
10
+ } from "./server-k3t06fxr.js";
11
11
  import {
12
- removeSystemReminders,
13
- removeNestedBlocks,
14
- hasMeaningfulUserText2,
15
- extractTexts2
16
- } from "./server-tgnbmwah.js";
12
+ resolveOpenCodeDbPath,
13
+ assertOpenCodeStoreGeneration
14
+ } from "./server-2ra6pwf3.js";
17
15
  import {
18
16
  Database2,
19
17
  getSqliteDatabasePath2,
20
18
  prepareCachedStatement2,
21
19
  withSqliteBackgroundWriter2,
22
20
  withoutSqliteTransformPass2
23
- } from "./server-beht37jy.js";
21
+ } from "./server-gzy5w8ya.js";
22
+ import {
23
+ removeSystemReminders,
24
+ removeNestedBlocks,
25
+ hasMeaningfulUserText2,
26
+ extractTexts2
27
+ } from "./server-3mz2qh5a.js";
24
28
  import {
25
29
  TAG_TOMBSTONE_OWNER_PREFIX,
26
30
  tagTombstoneOwnerRange,
@@ -28,24 +32,20 @@ import {
28
32
  tagRevisionKey,
29
33
  tagIdentityRevisionKey,
30
34
  deleteTagIdentityRevisions
31
- } from "./server-pwv4ezb0.js";
32
- import {
33
- resolveOpenCodeDbPath,
34
- assertOpenCodeStoreGeneration
35
- } from "./server-2ra6pwf3.js";
35
+ } from "./server-rqebawx1.js";
36
36
  import {
37
37
  cleanUserText2
38
- } from "./server-9hx7g5jp.js";
38
+ } from "./server-m4bfaevz.js";
39
39
  import {
40
40
  recordMessageFtsRowid2,
41
41
  recordIndexedMessageTime2,
42
42
  messageFtsOrdinalRangeIsMapped2,
43
43
  getMessageFtsRowidMapBackfillProgress2,
44
44
  deleteUnmappedMessageFtsRows2
45
- } from "./server-1wy7b9de.js";
45
+ } from "./server-dtp8hcjh.js";
46
46
  import {
47
- deleteChunkEmbedBackoffForSession
48
- } from "./server-46neh5fa.js";
47
+ deleteChunkEmbedBackoffForSession2
48
+ } from "./server-62g58aaz.js";
49
49
  import {
50
50
  sameProjectDirectory
51
51
  } from "./server-knvkbfvh.js";
@@ -54,7 +54,7 @@ import {
54
54
  } from "./server-8ajstryz.js";
55
55
  import {
56
56
  logSlowWriteTransaction
57
- } from "./server-6pmqg9m4.js";
57
+ } from "./server-gyy4k6mf.js";
58
58
  import {
59
59
  ensurePrivateStorageDirectorySync,
60
60
  writeStorageFileSync,
@@ -108,35 +108,16 @@ class BoundedSessionMap {
108
108
  }
109
109
  }
110
110
 
111
- // src/features/magic-context/compression-depth-storage.ts
112
- var incrementDepthStatements = new WeakMap;
113
- var totalDepthStatements = new WeakMap;
114
- var maxDepthStatements = new WeakMap;
115
- var clearDepthStatements = new WeakMap;
116
- function getClearDepthStatement(db) {
117
- let stmt = clearDepthStatements.get(db);
118
- if (!stmt) {
119
- stmt = db.prepare("DELETE FROM compression_depth WHERE session_id = ?");
120
- clearDepthStatements.set(db, stmt);
121
- }
122
- return stmt;
123
- }
124
- function clearCompressionDepth(db, sessionId) {
125
- getClearDepthStatement(db).run(sessionId);
126
- }
127
- function clearCompressionDepthRange(db, sessionId, startOrdinal, endOrdinal) {
128
- if (endOrdinal < startOrdinal) {
129
- return;
130
- }
131
- db.prepare("DELETE FROM compression_depth WHERE session_id = ? AND message_ordinal BETWEEN ? AND ?").run(sessionId, startOrdinal, endOrdinal);
132
- }
133
-
134
- // src/features/magic-context/message-index.ts
135
- import { createHash as createHash4 } from "node:crypto";
136
-
137
111
  // src/hooks/magic-context/lkg-recovery-fence.ts
138
112
  import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
139
- import { lstatSync, readdirSync as readdirSync2, readFileSync as readFileSync2, rmdirSync, rmSync as rmSync2 } from "node:fs";
113
+ import {
114
+ lstatSync,
115
+ opendirSync,
116
+ readdirSync as readdirSync2,
117
+ readFileSync as readFileSync2,
118
+ rmdirSync,
119
+ rmSync as rmSync2
120
+ } from "node:fs";
140
121
  import { basename, dirname, join as join2 } from "node:path";
141
122
 
142
123
  // src/shared/storage-file-mutex.ts
@@ -279,6 +260,58 @@ var lkgServedArrayDigest = hash;
279
260
  function lkgRecoveryFencePath(sessionId) {
280
261
  return join2(getMagicContextStorageDir(), "lkg-recovery-fences", `${hash(sessionId)}.json`);
281
262
  }
263
+ var lockSweepDirectory;
264
+ function closeLkgLockSweepDirectory() {
265
+ lockSweepDirectory?.dir.closeSync();
266
+ lockSweepDirectory = undefined;
267
+ }
268
+ function takeLkgRecoveryLockSweepPage(maxEntries = 200) {
269
+ const path = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
270
+ if (lockSweepDirectory?.path !== path)
271
+ closeLkgLockSweepDirectory();
272
+ const names = [];
273
+ try {
274
+ lockSweepDirectory ??= { path, dir: opendirSync(path) };
275
+ for (let i = 0;i < Math.min(200, Math.max(1, maxEntries)); i++) {
276
+ const entry = lockSweepDirectory.dir.readSync();
277
+ if (!entry) {
278
+ closeLkgLockSweepDirectory();
279
+ break;
280
+ }
281
+ if (entry.isDirectory() && /^[a-f0-9]{64}\.json\.locks$/.test(entry.name))
282
+ names.push(entry.name);
283
+ }
284
+ } catch {
285
+ closeLkgLockSweepDirectory();
286
+ }
287
+ return names;
288
+ }
289
+ function sweepEmptyLkgRecoveryLockDirectories(names, retainedSessionIds) {
290
+ if (!durableFencesSupported())
291
+ return 0;
292
+ const retainedHashes = new Set(Array.from(retainedSessionIds, hash));
293
+ const root = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
294
+ let removed = 0;
295
+ for (const name of names.slice(0, 200)) {
296
+ if (!/^[a-f0-9]{64}\.json\.locks$/.test(name) || retainedHashes.has(name.slice(0, 64)))
297
+ continue;
298
+ const path = join2(root, name);
299
+ try {
300
+ try {
301
+ lstatSync(path.slice(0, -".locks".length));
302
+ continue;
303
+ } catch (error) {
304
+ if (error.code !== "ENOENT")
305
+ continue;
306
+ }
307
+ if (!lstatSync(path).isDirectory())
308
+ continue;
309
+ rmdirSync(path);
310
+ removed++;
311
+ } catch {}
312
+ }
313
+ return removed;
314
+ }
282
315
  function metadata(slot) {
283
316
  return [
284
317
  slot.inputIdSeq,
@@ -558,51 +591,6 @@ function clearLkgRecoveryFence(sessionId, remove, shouldClear) {
558
591
  }
559
592
  }
560
593
 
561
- // src/shared/search-text.ts
562
- function removeTaskNotifications(text) {
563
- return removeNestedBlocks(text, ["task", "task_cohort"]);
564
- }
565
- function cleanSearchText(text) {
566
- return removeNestedBlocks(text, ["system-reminder", "task", "task_cohort"]).replace(/\s+/g, " ").trim();
567
- }
568
- var QUERY_STOP_WORDS = new Set("a an and are as at be been by can could did do does for from how i in is it me my of on or our please should that the their them there these they this to us was we were what when where which who why will with would you your".split(" "));
569
- function terms(text) {
570
- return [
571
- ...new Set((text.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? []).filter((term) => !QUERY_STOP_WORDS.has(term)))
572
- ];
573
- }
574
- function keywordRelevance(query, content) {
575
- const needles = terms(query);
576
- if (needles.length === 0)
577
- return 0;
578
- const words = new Set(terms(cleanSearchText(content)));
579
- return 0.8 * needles.filter((term) => words.has(term)).length / needles.length;
580
- }
581
- function matchedSearchSnippet(content, query, cap = 220) {
582
- const text = cleanSearchText(content);
583
- const needles = new Set(terms(query));
584
- const matches = [...text.matchAll(/[\p{L}\p{N}_]+/gu)].filter((match) => needles.has(match[0].toLowerCase()));
585
- if (matches.length === 0)
586
- return "";
587
- let bestStart = matches[0].index;
588
- let bestCoverage = -1;
589
- for (const match of matches) {
590
- const start = Math.max(0, match.index - Math.floor(cap / 5));
591
- const coverage = keywordRelevance(query, text.slice(start, start + cap));
592
- if (coverage > bestCoverage) {
593
- bestStart = start;
594
- bestCoverage = coverage;
595
- }
596
- }
597
- if (bestStart > 0) {
598
- const boundary = text.indexOf(" ", bestStart);
599
- if (boundary >= 0 && boundary < matches[matches.length - 1].index)
600
- bestStart = boundary + 1;
601
- }
602
- const passage = text.slice(bestStart, bestStart + cap).trim();
603
- return `${bestStart > 0 ? "…" : ""}${passage}${bestStart + cap < text.length ? "…" : ""}`;
604
- }
605
-
606
594
  // src/v2/store-reader.ts
607
595
  import { createHash as createHash3 } from "node:crypto";
608
596
  import { statSync } from "node:fs";
@@ -856,6 +844,11 @@ class V2StoreReaderPool {
856
844
  this.idleWaiters.clear();
857
845
  }
858
846
  }
847
+ function messageTimesQuery(count) {
848
+ return `SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
849
+ json_extract(data, '$.time.completed') AS completed
850
+ FROM session_message WHERE +session_id = ? AND id IN (${Array.from({ length: count }, () => "?").join(",")})`;
851
+ }
859
852
 
860
853
  class V2StoreReader {
861
854
  path;
@@ -952,6 +945,12 @@ class V2StoreReader {
952
945
  return typeof row?.count === "number" ? row.count : 0;
953
946
  });
954
947
  }
948
+ messageCountAfterSequence(sessionID, after, through) {
949
+ const rawTypes = RAW_MESSAGE_TYPES.map(() => "?").join(", ");
950
+ const row = this.prepare(`SELECT COUNT(*) AS count FROM session_message
951
+ WHERE session_id = ? AND seq > ? AND seq <= ? AND type IN (${rawTypes})`).get(sessionID, after, through, ...RAW_MESSAGE_TYPES);
952
+ return typeof row?.count === "number" ? row.count : 0;
953
+ }
955
954
  sessionDirectoryPage(afterSessionID, limit) {
956
955
  const rows = this.prepare(`SELECT id, COALESCE(directory, '') AS directory FROM session_v2
957
956
  WHERE id > ? ORDER BY id ASC LIMIT ?`).all(afterSessionID ?? "", limit);
@@ -1079,9 +1078,7 @@ class V2StoreReader {
1079
1078
  const times = new Map;
1080
1079
  for (let offset = 0;offset < ids.length; offset += 500) {
1081
1080
  const batch = ids.slice(offset, offset + 500);
1082
- const rows = this.prepare(`SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
1083
- json_extract(data, '$.time.completed') AS completed
1084
- FROM session_message WHERE session_id = ? AND id IN (${batch.map(() => "?").join(",")})`).all(sessionID, ...batch);
1081
+ const rows = this.prepare(messageTimesQuery(batch.length)).all(sessionID, ...batch);
1085
1082
  for (const row of rows)
1086
1083
  times.set(row.id, {
1087
1084
  created: typeof row.created === "number" ? row.created : undefined,
@@ -1300,6 +1297,77 @@ class V2StoreReader {
1300
1297
  }
1301
1298
  }
1302
1299
 
1300
+ // src/features/magic-context/message-index.ts
1301
+ import { createHash as createHash4 } from "node:crypto";
1302
+
1303
+ // src/shared/search-text.ts
1304
+ function removeTaskNotifications(text) {
1305
+ return removeNestedBlocks(text, ["task", "task_cohort"]);
1306
+ }
1307
+ function cleanSearchText(text) {
1308
+ return removeNestedBlocks(text, ["system-reminder", "task", "task_cohort"]).replace(/\s+/g, " ").trim();
1309
+ }
1310
+ var QUERY_STOP_WORDS = new Set("a an and are as at be been by can could did do does for from how i in is it me my of on or our please should that the their them there these they this to us was we were what when where which who why will with would you your".split(" "));
1311
+ function terms(text) {
1312
+ return [
1313
+ ...new Set((text.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? []).filter((term) => !QUERY_STOP_WORDS.has(term)))
1314
+ ];
1315
+ }
1316
+ function keywordRelevance(query, content) {
1317
+ const needles = terms(query);
1318
+ if (needles.length === 0)
1319
+ return 0;
1320
+ const words = new Set(terms(cleanSearchText(content)));
1321
+ return 0.8 * needles.filter((term) => words.has(term)).length / needles.length;
1322
+ }
1323
+ function matchedSearchSnippet(content, query, cap = 220) {
1324
+ const text = cleanSearchText(content);
1325
+ const needles = new Set(terms(query));
1326
+ const matches = [...text.matchAll(/[\p{L}\p{N}_]+/gu)].filter((match) => needles.has(match[0].toLowerCase()));
1327
+ if (matches.length === 0)
1328
+ return "";
1329
+ let bestStart = matches[0].index;
1330
+ let bestCoverage = -1;
1331
+ for (const match of matches) {
1332
+ const start = Math.max(0, match.index - Math.floor(cap / 5));
1333
+ const coverage = keywordRelevance(query, text.slice(start, start + cap));
1334
+ if (coverage > bestCoverage) {
1335
+ bestStart = start;
1336
+ bestCoverage = coverage;
1337
+ }
1338
+ }
1339
+ if (bestStart > 0) {
1340
+ const boundary = text.indexOf(" ", bestStart);
1341
+ if (boundary >= 0 && boundary < matches[matches.length - 1].index)
1342
+ bestStart = boundary + 1;
1343
+ }
1344
+ const passage = text.slice(bestStart, bestStart + cap).trim();
1345
+ return `${bestStart > 0 ? "…" : ""}${passage}${bestStart + cap < text.length ? "…" : ""}`;
1346
+ }
1347
+
1348
+ // src/features/magic-context/compression-depth-storage.ts
1349
+ var incrementDepthStatements = new WeakMap;
1350
+ var totalDepthStatements = new WeakMap;
1351
+ var maxDepthStatements = new WeakMap;
1352
+ var clearDepthStatements = new WeakMap;
1353
+ function getClearDepthStatement(db) {
1354
+ let stmt = clearDepthStatements.get(db);
1355
+ if (!stmt) {
1356
+ stmt = db.prepare("DELETE FROM compression_depth WHERE session_id = ?");
1357
+ clearDepthStatements.set(db, stmt);
1358
+ }
1359
+ return stmt;
1360
+ }
1361
+ function clearCompressionDepth(db, sessionId) {
1362
+ getClearDepthStatement(db).run(sessionId);
1363
+ }
1364
+ function clearCompressionDepthRange(db, sessionId, startOrdinal, endOrdinal) {
1365
+ if (endOrdinal < startOrdinal) {
1366
+ return;
1367
+ }
1368
+ db.prepare("DELETE FROM compression_depth WHERE session_id = ? AND message_ordinal BETWEEN ? AND ?").run(sessionId, startOrdinal, endOrdinal);
1369
+ }
1370
+
1303
1371
  // src/features/magic-context/session-activity.ts
1304
1372
  var PREFIX = "retrospective_activity:";
1305
1373
  var pending = new WeakMap;
@@ -1438,7 +1506,7 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
1438
1506
  fallback.run(tagTombstoneOwnerKey(id, getHarness2()), getHarness2(), ...tagTombstoneOwnerRange(id));
1439
1507
  }
1440
1508
  for (const sessionId of deletableSessionIds)
1441
- deleteChunkEmbedBackoffForSession(db, sessionId);
1509
+ deleteChunkEmbedBackoffForSession2(db, sessionId);
1442
1510
  for (const definition of SESSION_SCOPED_TABLES) {
1443
1511
  if (definition.table === "message_history_fts") {
1444
1512
  cleanupStatement(db, `DELETE FROM message_history_fts
@@ -1489,7 +1557,7 @@ function deleteSessionScopedRowsSlice(db, sessionId, harness) {
1489
1557
  cleanupStatement(db, "INSERT OR IGNORE INTO schema_migrations_meta(key,value) VALUES (?,?)").run(tagTombstoneOwnerKey(sessionId, harness), harness);
1490
1558
  let remaining = SESSION_CLEANUP_SLICE_ROWS;
1491
1559
  const started = performance.now();
1492
- remaining -= deleteChunkEmbedBackoffForSession(db, sessionId, remaining);
1560
+ remaining -= deleteChunkEmbedBackoffForSession2(db, sessionId, remaining);
1493
1561
  if (remaining <= 0)
1494
1562
  return { complete: false, deleted: 0 };
1495
1563
  for (const definition of SESSION_SCOPED_TABLES) {
@@ -2003,14 +2071,20 @@ function harnessSupportsOpenCodeOrphanSweep(harness) {
2003
2071
  return harness === "opencode" || harness === "opencode2";
2004
2072
  }
2005
2073
  function getMessageHistoryOrphanSweepState(db, harness) {
2006
- return db.prepare("SELECT cursor_session_id, last_swept_at FROM message_history_orphan_sweep WHERE harness = ?").get(harness) ?? {};
2074
+ const state = db.prepare("SELECT cursor_session_id, last_swept_at FROM message_history_orphan_sweep WHERE harness = ?").get(harness) ?? {};
2075
+ if (harness === "opencode2") {
2076
+ if (!state.cursor_session_id?.startsWith("session_v2:"))
2077
+ return {};
2078
+ return { ...state, cursor_session_id: state.cursor_session_id.slice("session_v2:".length) };
2079
+ }
2080
+ return state;
2007
2081
  }
2008
2082
  function persistMessageHistoryOrphanSweepState(db, cursor, lastSweptAt, harness) {
2009
2083
  db.prepare(`INSERT INTO message_history_orphan_sweep (harness, cursor_session_id, last_swept_at)
2010
2084
  VALUES (?, ?, ?)
2011
2085
  ON CONFLICT(harness) DO UPDATE SET
2012
2086
  cursor_session_id = excluded.cursor_session_id,
2013
- last_swept_at = excluded.last_swept_at`).run(harness, cursor, lastSweptAt);
2087
+ last_swept_at = excluded.last_swept_at`).run(harness, harness === "opencode2" ? `session_v2:${cursor}` : cursor, lastSweptAt);
2014
2088
  }
2015
2089
  function getOpenCodeSessionScopedCandidateSourceSql(harness) {
2016
2090
  const sources = SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped === true).map((definition) => {
@@ -2058,13 +2132,14 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
2058
2132
  let v2Reader;
2059
2133
  try {
2060
2134
  let sessionExists;
2135
+ let liveIds;
2061
2136
  if (harness === "opencode2") {
2062
2137
  try {
2063
2138
  const path = getSqliteDatabasePath2(openCodeDb);
2064
2139
  if (!path)
2065
2140
  throw new Error("OpenCode 2 source has no durable path");
2066
2141
  v2Reader = new V2StoreReader(path);
2067
- const liveIds = new Set(v2Reader.sessionIds());
2142
+ liveIds = new Set(v2Reader.sessionIds());
2068
2143
  if (liveIds.size === 0)
2069
2144
  throw new Error("OpenCode 2 source has no sessions");
2070
2145
  sessionExists = (id) => liveIds.has(id);
@@ -2073,9 +2148,26 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
2073
2148
  return { status: "source_unavailable", scanned: 0, deleted: 0, cursor };
2074
2149
  }
2075
2150
  } else {
2151
+ liveIds = new Set(openCodeDb.prepare("SELECT id FROM session").all().map((row) => row.id));
2076
2152
  const query = openCodeDb.prepare("SELECT 1 FROM session WHERE id = ? LIMIT 1");
2077
2153
  sessionExists = (id) => !!query.get(id);
2078
2154
  }
2155
+ if (options.fenceLockNames?.length) {
2156
+ const retainedIds = new Set(liveIds);
2157
+ const sources = SESSION_SCOPED_TABLES.map((def) => `SELECT session_id FROM ${def.table}${def.extraPredicate ? ` WHERE ${def.extraPredicate}` : ""}`);
2158
+ for (const row of db.prepare(sources.join(" UNION ")).all()) {
2159
+ if (typeof row.session_id === "string")
2160
+ retainedIds.add(row.session_id);
2161
+ }
2162
+ for (const row of db.prepare("SELECT key FROM schema_migrations_meta WHERE key >= ? AND key < ?").all(TAG_TOMBSTONE_OWNER_PREFIX, "tag_revision_owner;")) {
2163
+ try {
2164
+ const id = JSON.parse(row.key.slice(TAG_TOMBSTONE_OWNER_PREFIX.length, row.key.lastIndexOf(":")));
2165
+ if (typeof id === "string")
2166
+ retainedIds.add(id);
2167
+ } catch {}
2168
+ }
2169
+ sweepEmptyLkgRecoveryLockDirectories(options.fenceLockNames, retainedIds);
2170
+ }
2079
2171
  const cutoff = now - safetyAgeMs;
2080
2172
  const candidateSourceSql = getOpenCodeSessionScopedCandidateSourceSql(harness);
2081
2173
  const candidates = db.prepare(`SELECT session_id
@@ -2167,4 +2259,4 @@ async function sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource,
2167
2259
  }));
2168
2260
  }
2169
2261
 
2170
- export { BoundedSessionMap, clearCompressionDepth, clearCompressionDepthRange, LkgRecoveryFenceError, clearLkgFenceProcessState, lkgServedArrayDigest, hasCleanLkgRecoveryFence, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, cleanSearchText, keywordRelevance, matchedSearchSnippet, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, advanceSessionActivity, backfillSessionActivity, deleteSessionScopedRows, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
2262
+ export { BoundedSessionMap, LkgRecoveryFenceError, clearLkgFenceProcessState, lkgServedArrayDigest, takeLkgRecoveryLockSweepPage, hasCleanLkgRecoveryFence, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, cleanSearchText, keywordRelevance, matchedSearchSnippet, clearCompressionDepth, clearCompressionDepthRange, advanceSessionActivity, backfillSessionActivity, deleteSessionScopedRows, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getMagicContextStorageDir,
3
3
  log2
4
- } from "./server-f2xf5gcb.js";
4
+ } from "./server-6495nmn9.js";
5
5
  import {
6
6
  inRootAsyncContext2
7
- } from "./server-beht37jy.js";
7
+ } from "./server-gzy5w8ya.js";
8
8
  import {
9
9
  projectDirectoryKey
10
10
  } from "./server-knvkbfvh.js";
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./server-271qxsf5.js";
3
+ } from "./server-24g8r2d0.js";
4
4
  import {
5
5
  log2
6
- } from "./server-f2xf5gcb.js";
6
+ } from "./server-6495nmn9.js";
7
7
  import {
8
8
  isSynapseEmbeddingTruncated,
9
9
  SynapseEmbeddingProvider
10
- } from "./server-6tmj0s7j.js";
10
+ } from "./server-ab1g0wn9.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./server-h1v0pyxb.js";
13
+ } from "./server-vr4szghm.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./server-8by8qfec.js";
18
+ } from "./server-ad18djzs.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./server-qt1qqasc.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./server-f2xf5gcb.js";
3
+ } from "./server-6495nmn9.js";
4
4
  import {
5
5
  isKnownAutocommit
6
6
  } from "./server-8ajstryz.js";
@@ -530,4 +530,4 @@ function jsonHashSink(prefix = "") {
530
530
  return { write, digest: () => (hash >>> 0).toString(16).padStart(8, "0") };
531
531
  }
532
532
 
533
- export { getTableColumnNames, ensureColumn, healAllNullColumns, stableStringify, stableStringifyHash, getTemporalDecisions, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, TAG_TOMBSTONE_OWNER_PREFIX, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };
533
+ export { stableStringify, stableStringifyHash, getTableColumnNames, ensureColumn, healAllNullColumns, getTemporalDecisions, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, TAG_TOMBSTONE_OWNER_PREFIX, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };