@cortexkit/opencode-magic-context 0.49.19 → 0.49.20

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 (271) 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-b2q30cft.js} +3 -3
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/compartment-chunk-embedding-va090as0.js +65 -0
  6. package/dist/config/schema/magic-context.d.ts +6 -6
  7. package/dist/{conflict-warning-hook-4pmz879v.js → conflict-warning-hook-frp3z2wk.js} +9 -8
  8. package/dist/{context-j31m2dv7.js → context-mkece1db.js} +455 -134
  9. package/dist/{derive-budgets-zn7yzd2d.js → derive-budgets-pqybnx09.js} +2 -2
  10. package/dist/embedding-backfill-gy3p78py.js +25 -0
  11. package/dist/embedding-worker-process.js +2 -2
  12. package/dist/embedding-worker.js +5 -5
  13. package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -1
  14. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +44 -1
  15. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
  19. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  20. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  21. package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
  22. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  23. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts +22 -0
  24. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts.map +1 -0
  25. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  26. package/dist/features/magic-context/message-index.d.ts +2 -0
  27. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  28. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  29. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  30. package/dist/features/magic-context/search.d.ts +27 -0
  31. package/dist/features/magic-context/search.d.ts.map +1 -1
  32. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  33. package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
  34. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  35. package/dist/features/magic-context/subagent-token-capture.d.ts +20 -0
  36. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  37. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  38. package/dist/{history-owner-xp3pngv7.js → history-owner-36wp3mkb.js} +2 -2
  39. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/auto-search-hint.d.ts +7 -1
  42. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +33 -6
  45. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/cache-busting-signals.d.ts +5 -2
  47. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  51. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  53. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
  55. package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
  56. package/dist/hooks/magic-context/execute-reclaim.d.ts +35 -0
  57. package/dist/hooks/magic-context/execute-reclaim.d.ts.map +1 -0
  58. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/hook.d.ts +1 -3
  60. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/latest-assistant-turn.d.ts +8 -0
  62. package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +5 -0
  64. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
  66. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
  67. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -0
  69. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/system-date-refresh.d.ts +5 -5
  72. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +10 -0
  74. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
  75. package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
  76. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +21 -6
  79. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  81. package/dist/{index-bjcnntmz.js → index-0wthn7fp.js} +468 -18
  82. package/dist/{index-kq82mtg0.js → index-11zf2wwc.js} +3 -3
  83. package/dist/{index-b5vqckbw.js → index-153r2q6z.js} +314 -127
  84. package/dist/{index-3h4dp9wb.js → index-1pefp8ar.js} +5 -5
  85. package/dist/{index-beht37jy.js → index-1zx2pa5d.js} +1 -1
  86. package/dist/{index-ze7mvk54.js → index-2yhtnfcf.js} +75 -57
  87. package/dist/{index-cf74k5ak.js → index-305y133n.js} +4 -4
  88. package/dist/{index-s734jcsr.js → index-35qc6606.js} +9 -3
  89. package/dist/{index-se4m2g6w.js → index-48stjd56.js} +105 -19
  90. package/dist/{index-4911rn0b.js → index-4n7w9rad.js} +6 -6
  91. package/dist/{index-kee4kn5j.js → index-4pnsgvfk.js} +1 -1
  92. package/dist/{v2/server-8cd2j99z.js → index-5kym00ag.js} +32 -13
  93. package/dist/{index-4s3t0nd0.js → index-616rsjrv.js} +2 -2
  94. package/dist/{index-jhghdnsm.js → index-67nyj0gy.js} +485 -202
  95. package/dist/{index-6x57ar45.js → index-adk2z5d8.js} +3 -3
  96. package/dist/{index-c5pytzne.js → index-b88dwwrh.js} +1 -1
  97. package/dist/{index-rr2bb45z.js → index-c4b76d4t.js} +2 -2
  98. package/dist/{index-nj7yykkx.js → index-c7phnbvk.js} +1 -1
  99. package/dist/index-cpjk5jd2.js +82 -0
  100. package/dist/{index-edmpdxcw.js → index-d6rp4dxh.js} +5 -5
  101. package/dist/{index-dxmq29t1.js → index-dc8hy95c.js} +69 -17
  102. package/dist/{index-j75v2476.js → index-h7tgn49j.js} +12 -15
  103. package/dist/{index-ke416mdc.js → index-j76ah6d7.js} +2 -2
  104. package/dist/{index-c1p88z1y.js → index-jfh3cktr.js} +4 -4
  105. package/dist/{index-a6mc0v4d.js → index-jmycsey7.js} +3 -3
  106. package/dist/{index-24fezq97.js → index-jr5na10t.js} +4 -4
  107. package/dist/{index-s74zqahq.js → index-kc9pn495.js} +4 -4
  108. package/dist/{index-p5y3k4g7.js → index-nda0zgna.js} +2 -1
  109. package/dist/{index-jn12fvvh.js → index-neb2jaed.js} +3 -3
  110. package/dist/{index-63k48rv9.js → index-pnjwa6qa.js} +5 -5
  111. package/dist/{index-jrr131e0.js → index-rmd0069m.js} +11 -11
  112. package/dist/{index-y9f76s3f.js → index-rrv26qjz.js} +1 -1
  113. package/dist/{index-v10f1rjv.js → index-spwjbkc7.js} +1 -1
  114. package/dist/{index-k29z4aqh.js → index-t5pck3ss.js} +1 -1
  115. package/dist/{index-3esx8tkf.js → index-t7hx3qcb.js} +318 -104
  116. package/dist/{index-rpxdjkm0.js → index-v7r4td4c.js} +306 -59
  117. package/dist/{index-2vxtcb95.js → index-vkc1ca9p.js} +2 -2
  118. package/dist/{index-9zcsy3hh.js → index-x4k3f4mf.js} +17 -9
  119. package/dist/{index-bp5083x2.js → index-x9k3mqrf.js} +1 -1
  120. package/dist/{index-n37sebck.js → index-y4a3nhtk.js} +1 -1
  121. package/dist/index.js +52 -49
  122. package/dist/{logger-jm3sqqzr.js → logger-94kew5wm.js} +1 -1
  123. package/dist/{message-fts-rowid-map-17s0dfn4.js → message-fts-rowid-map-22tevnnj.js} +6 -5
  124. package/dist/{message-index-gtpqnj8w.js → message-index-5qxcz6h7.js} +16 -15
  125. package/dist/{message-index-bounded-zyc8h32y.js → message-index-bounded-n0m0t7tv.js} +16 -15
  126. package/dist/{message-time-backfill-73mmm76q.js → message-time-backfill-0myx7fz3.js} +3 -3
  127. package/dist/migration-worker.js +13 -12
  128. package/dist/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  129. package/dist/plugin/embedding-bootstrap.d.ts +3 -1
  130. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  131. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  132. package/dist/plugin/rpc-handlers.d.ts +8 -0
  133. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  134. package/dist/plugin/subagent-tool-policy.d.ts +9 -0
  135. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
  136. package/dist/{project-embedding-registry-z74mhqkf.js → project-embedding-registry-s2pqgec9.js} +13 -12
  137. package/dist/raw-ordinal-warmup-worker.js +136 -101
  138. package/dist/{read-session-chunk-jjb48bt9.js → read-session-chunk-0a8vdyqp.js} +11 -10
  139. package/dist/{read-session-raw-rsc8c7qy.js → read-session-raw-y5cszf0b.js} +4 -3
  140. package/dist/recomp-orchestrator-61vyha9j.js +62 -0
  141. package/dist/{safe-notification-target-1szv1k5k.js → safe-notification-target-mkr9yzvr.js} +2 -2
  142. package/dist/{search-archive-6vm0e2f5.js → search-archive-8q9s49p5.js} +12 -11
  143. package/dist/{search-xsqk1bj4.js → search-v1y9ejws.js} +25 -24
  144. package/dist/{send-session-notification-6ve0e8p4.js → send-session-notification-0k6qzydk.js} +7 -6
  145. package/dist/shared/logger.d.ts.map +1 -1
  146. package/dist/shared/model-resolution.d.ts +2 -0
  147. package/dist/shared/model-resolution.d.ts.map +1 -1
  148. package/dist/shared/prompt-async-transport.d.ts +3 -0
  149. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  150. package/dist/shared/rpc-types.d.ts +7 -0
  151. package/dist/shared/rpc-types.d.ts.map +1 -1
  152. package/dist/shared/sqlite.d.ts +1 -1
  153. package/dist/shared/sqlite.d.ts.map +1 -1
  154. package/dist/shared/subagent-runner.d.ts +2 -0
  155. package/dist/shared/subagent-runner.d.ts.map +1 -1
  156. package/dist/shared/worker-shutdown.d.ts +68 -0
  157. package/dist/shared/worker-shutdown.d.ts.map +1 -0
  158. package/dist/shared/worker-shutdown.fixture.d.ts +2 -0
  159. package/dist/shared/worker-shutdown.fixture.d.ts.map +1 -0
  160. package/dist/{sqlite-zf72c52d.js → sqlite-1rpvw2rj.js} +1 -1
  161. package/dist/{storage-memory-y3qmy00r.js → storage-memory-nm7v82mj.js} +2 -2
  162. package/dist/{storage-tags-r7k9tjcv.js → storage-tags-r6nk29n4.js} +5 -5
  163. package/dist/{task-config-x3qmayd2.js → task-config-t6bpyka7.js} +2 -2
  164. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  165. package/dist/{transform-postprocess-phase-jj99r7z2.js → transform-postprocess-phase-vtrgb7m6.js} +34 -31
  166. package/dist/v2/auto-search-worker.js +48 -9
  167. package/dist/v2/chunk-embedding-write-worker.js +30 -23
  168. package/dist/v2/{compaction-marker-candidates-ebx3388k.js → compaction-marker-candidates-cfab70cs.js} +3 -3
  169. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  170. package/dist/v2/compartment-chunk-embedding-nbdqx1td.js +64 -0
  171. package/dist/v2/{context-y5yamxak.js → context-cc33tv2z.js} +1189 -386
  172. package/dist/v2/{derive-budgets-2zh4gm2c.js → derive-budgets-knf763tt.js} +3 -3
  173. package/dist/v2/embedding-backfill-yxv2h5mc.js +24 -0
  174. package/dist/v2/embedding-worker-process.js +2 -2
  175. package/dist/v2/embedding-worker.js +5 -5
  176. package/dist/v2/hidden-child-record.d.ts +2 -0
  177. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  178. package/dist/v2/hidden-completion.d.ts +2 -0
  179. package/dist/v2/hidden-completion.d.ts.map +1 -1
  180. package/dist/v2/hidden-model-activity.d.ts +7 -0
  181. package/dist/v2/hidden-model-activity.d.ts.map +1 -0
  182. package/dist/v2/{history-owner-42e16w0n.js → history-owner-ad0crnrn.js} +2 -2
  183. package/dist/v2/hooks/context.d.ts.map +1 -1
  184. package/dist/v2/hooks/generate.d.ts +36 -1
  185. package/dist/v2/hooks/generate.d.ts.map +1 -1
  186. package/dist/v2/hooks/lkg-system.d.ts +35 -4
  187. package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
  188. package/dist/v2/hooks/payload.d.ts +16 -1
  189. package/dist/v2/hooks/payload.d.ts.map +1 -1
  190. package/dist/v2/{logger-7qt02bnb.js → logger-p34mjtja.js} +1 -1
  191. package/dist/v2/{message-fts-rowid-map-wfx67gfd.js → message-fts-rowid-map-dg12wymk.js} +6 -5
  192. package/dist/v2/{message-index-bounded-spd8r7pj.js → message-index-bounded-f4e01xk0.js} +16 -15
  193. package/dist/v2/{message-index-8vz2pq76.js → message-index-ydzrp6y6.js} +16 -15
  194. package/dist/v2/{message-time-backfill-04t0km1z.js → message-time-backfill-ddh8n9gy.js} +3 -3
  195. package/dist/v2/migration-worker.js +13 -12
  196. package/dist/v2/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  197. package/dist/v2/{project-embedding-registry-gnkj56xp.js → project-embedding-registry-deza9ksw.js} +13 -12
  198. package/dist/v2/raw-ordinal-warmup-worker.js +136 -101
  199. package/dist/v2/{read-session-chunk-cwkxrmns.js → read-session-chunk-8cxfagky.js} +11 -10
  200. package/dist/v2/{read-session-raw-yaegtjzh.js → read-session-raw-1nrrecvx.js} +4 -3
  201. package/dist/v2/recomp-orchestrator-47m4hv5g.js +61 -0
  202. package/dist/v2/{safe-notification-target-qg7n2s77.js → safe-notification-target-khnzg57c.js} +2 -2
  203. package/dist/v2/{search-archive-wve3tq1k.js → search-archive-e80cvc09.js} +12 -11
  204. package/dist/v2/{search-hwg7jfbj.js → search-fjz746zr.js} +25 -24
  205. package/dist/v2/{send-session-notification-3pxn658x.js → send-session-notification-nwvrv34d.js} +7 -6
  206. package/dist/v2/{server-8by8qfec.js → server-0epqaxhd.js} +75 -57
  207. package/dist/v2/{server-pwv4ezb0.js → server-168pb207.js} +1 -1
  208. package/dist/v2/{server-h0410h0v.js → server-1bw1wcbp.js} +1 -1
  209. package/dist/v2/{server-beht37jy.js → server-1zx2pa5d.js} +1 -1
  210. package/dist/v2/{server-a9xqj88f.js → server-230fnbws.js} +4 -4
  211. package/dist/v2/{server-tbe1femw.js → server-29qp8nz4.js} +1 -1
  212. package/dist/v2/{server-tgnbmwah.js → server-3mz2qh5a.js} +1 -1
  213. package/dist/v2/{server-hy3d3vsx.js → server-4nw4fqhr.js} +2 -2
  214. package/dist/v2/{server-45q69hkq.js → server-4sxjs6hn.js} +5 -5
  215. package/dist/v2/{server-34kwfsr4.js → server-53eh1r8r.js} +2 -2
  216. package/dist/v2/{server-xj136kt8.js → server-55rgxfrw.js} +9 -3
  217. package/dist/v2/{server-nj659894.js → server-5arr9ecn.js} +2 -2
  218. package/dist/{index-8cd2j99z.js → v2/server-5kym00ag.js} +32 -13
  219. package/dist/v2/{server-2ar62dyx.js → server-63fqdghs.js} +106 -20
  220. package/dist/v2/{server-f2xf5gcb.js → server-6495nmn9.js} +12 -15
  221. package/dist/v2/{server-qd11g795.js → server-92g7d776.js} +2 -1
  222. package/dist/v2/{server-xq7dfjke.js → server-9x0kmta4.js} +5 -5
  223. package/dist/v2/{server-27gq4mfz.js → server-a3dwxfgd.js} +4 -4
  224. package/dist/v2/{server-6tmj0s7j.js → server-af2pght7.js} +3 -3
  225. package/dist/v2/{server-1wy7b9de.js → server-br1x0tev.js} +3 -3
  226. package/dist/v2/{server-n1prf1g6.js → server-brj8j2gk.js} +2 -2
  227. package/dist/v2/{server-6vdzn1td.js → server-c7dxxsj7.js} +308 -61
  228. package/dist/v2/server-cpjk5jd2.js +82 -0
  229. package/dist/v2/{server-g3qma5c0.js → server-dj7tz4ph.js} +2 -2
  230. package/dist/v2/{server-9hx7g5jp.js → server-ej96a39v.js} +17 -9
  231. package/dist/v2/{server-6pmqg9m4.js → server-gyy4k6mf.js} +1 -1
  232. package/dist/v2/{server-bmymkx73.js → server-hqzyq8n4.js} +11 -11
  233. package/dist/v2/{server-h1v0pyxb.js → server-j4jnp9b5.js} +468 -18
  234. package/dist/v2/{server-da07v4xp.js → server-k3t06fxr.js} +1 -1
  235. package/dist/v2/{server-gsxjv2q2.js → server-m91f9m5s.js} +69 -17
  236. package/dist/v2/{server-rmygf5pn.js → server-ne8arh8t.js} +2 -2
  237. package/dist/v2/{server-hm38q7r0.js → server-vn2nwcv6.js} +5 -5
  238. package/dist/v2/{server-46neh5fa.js → server-wyawsa88.js} +314 -127
  239. package/dist/v2/{server-zzkj2fch.js → server-xsryvyf6.js} +4 -4
  240. package/dist/v2/{server-n37sebck.js → server-y4a3nhtk.js} +1 -1
  241. package/dist/v2/{server-d04vrx0j.js → server-ygtykank.js} +2 -2
  242. package/dist/v2/server.js +6 -6
  243. package/dist/v2/{sqlite-zf72c52d.js → sqlite-1rpvw2rj.js} +1 -1
  244. package/dist/v2/{storage-memory-y3qmy00r.js → storage-memory-nm7v82mj.js} +2 -2
  245. package/dist/v2/{storage-tags-3wdb8zph.js → storage-tags-ss08kj5r.js} +5 -5
  246. package/dist/v2/store-reader.d.ts +8 -0
  247. package/dist/v2/store-reader.d.ts.map +1 -1
  248. package/dist/v2/{task-config-nvz8mapa.js → task-config-7md27rx8.js} +2 -2
  249. package/dist/v2/{wrapup-orchestrator-embdz8gj.js → wrapup-orchestrator-639whfhq.js} +32 -31
  250. package/dist/wrapup-orchestrator-mnvt2g8m.js +49 -0
  251. package/package.json +1 -1
  252. package/src/config/index.test.ts +28 -6
  253. package/src/shared/logger.test.ts +42 -1
  254. package/src/shared/logger.ts +11 -13
  255. package/src/shared/model-resolution.test.ts +67 -12
  256. package/src/shared/model-resolution.ts +43 -16
  257. package/src/shared/model-suggestion-retry.ts +1 -1
  258. package/src/shared/prompt-async-transport.ts +47 -3
  259. package/src/shared/rpc-types.ts +7 -0
  260. package/src/shared/sqlite-busy-budget-review.test.ts +6 -1
  261. package/src/shared/sqlite.ts +4 -2
  262. package/src/shared/subagent-runner.ts +2 -0
  263. package/src/shared/worker-shutdown-fence.test.ts +87 -0
  264. package/src/shared/worker-shutdown.fixture.ts +25 -0
  265. package/src/shared/worker-shutdown.test.ts +127 -0
  266. package/src/shared/worker-shutdown.ts +160 -0
  267. package/dist/embedding-backfill-fmz50tsy.js +0 -24
  268. package/dist/recomp-orchestrator-999jj4bc.js +0 -61
  269. package/dist/v2/embedding-backfill-7c7yr69y.js +0 -23
  270. package/dist/v2/recomp-orchestrator-f6m9jr7p.js +0 -60
  271. package/dist/wrapup-orchestrator-whhbjmaz.js +0 -48
@@ -3,24 +3,24 @@ 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
12
  removeSystemReminders,
13
13
  removeNestedBlocks,
14
14
  hasMeaningfulUserText2,
15
15
  extractTexts2
16
- } from "./server-tgnbmwah.js";
16
+ } from "./server-3mz2qh5a.js";
17
17
  import {
18
18
  Database2,
19
19
  getSqliteDatabasePath2,
20
20
  prepareCachedStatement2,
21
21
  withSqliteBackgroundWriter2,
22
22
  withoutSqliteTransformPass2
23
- } from "./server-beht37jy.js";
23
+ } from "./server-1zx2pa5d.js";
24
24
  import {
25
25
  TAG_TOMBSTONE_OWNER_PREFIX,
26
26
  tagTombstoneOwnerRange,
@@ -28,24 +28,24 @@ import {
28
28
  tagRevisionKey,
29
29
  tagIdentityRevisionKey,
30
30
  deleteTagIdentityRevisions
31
- } from "./server-pwv4ezb0.js";
31
+ } from "./server-168pb207.js";
32
32
  import {
33
33
  resolveOpenCodeDbPath,
34
34
  assertOpenCodeStoreGeneration
35
35
  } from "./server-2ra6pwf3.js";
36
36
  import {
37
37
  cleanUserText2
38
- } from "./server-9hx7g5jp.js";
38
+ } from "./server-ej96a39v.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-br1x0tev.js";
46
46
  import {
47
- deleteChunkEmbedBackoffForSession
48
- } from "./server-46neh5fa.js";
47
+ deleteChunkEmbedBackoffForSession2
48
+ } from "./server-wyawsa88.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,
@@ -136,7 +136,14 @@ import { createHash as createHash4 } from "node:crypto";
136
136
 
137
137
  // src/hooks/magic-context/lkg-recovery-fence.ts
138
138
  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";
139
+ import {
140
+ lstatSync,
141
+ opendirSync,
142
+ readdirSync as readdirSync2,
143
+ readFileSync as readFileSync2,
144
+ rmdirSync,
145
+ rmSync as rmSync2
146
+ } from "node:fs";
140
147
  import { basename, dirname, join as join2 } from "node:path";
141
148
 
142
149
  // src/shared/storage-file-mutex.ts
@@ -279,6 +286,58 @@ var lkgServedArrayDigest = hash;
279
286
  function lkgRecoveryFencePath(sessionId) {
280
287
  return join2(getMagicContextStorageDir(), "lkg-recovery-fences", `${hash(sessionId)}.json`);
281
288
  }
289
+ var lockSweepDirectory;
290
+ function closeLkgLockSweepDirectory() {
291
+ lockSweepDirectory?.dir.closeSync();
292
+ lockSweepDirectory = undefined;
293
+ }
294
+ function takeLkgRecoveryLockSweepPage(maxEntries = 200) {
295
+ const path = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
296
+ if (lockSweepDirectory?.path !== path)
297
+ closeLkgLockSweepDirectory();
298
+ const names = [];
299
+ try {
300
+ lockSweepDirectory ??= { path, dir: opendirSync(path) };
301
+ for (let i = 0;i < Math.min(200, Math.max(1, maxEntries)); i++) {
302
+ const entry = lockSweepDirectory.dir.readSync();
303
+ if (!entry) {
304
+ closeLkgLockSweepDirectory();
305
+ break;
306
+ }
307
+ if (entry.isDirectory() && /^[a-f0-9]{64}\.json\.locks$/.test(entry.name))
308
+ names.push(entry.name);
309
+ }
310
+ } catch {
311
+ closeLkgLockSweepDirectory();
312
+ }
313
+ return names;
314
+ }
315
+ function sweepEmptyLkgRecoveryLockDirectories(names, retainedSessionIds) {
316
+ if (!durableFencesSupported())
317
+ return 0;
318
+ const retainedHashes = new Set(Array.from(retainedSessionIds, hash));
319
+ const root = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
320
+ let removed = 0;
321
+ for (const name of names.slice(0, 200)) {
322
+ if (!/^[a-f0-9]{64}\.json\.locks$/.test(name) || retainedHashes.has(name.slice(0, 64)))
323
+ continue;
324
+ const path = join2(root, name);
325
+ try {
326
+ try {
327
+ lstatSync(path.slice(0, -".locks".length));
328
+ continue;
329
+ } catch (error) {
330
+ if (error.code !== "ENOENT")
331
+ continue;
332
+ }
333
+ if (!lstatSync(path).isDirectory())
334
+ continue;
335
+ rmdirSync(path);
336
+ removed++;
337
+ } catch {}
338
+ }
339
+ return removed;
340
+ }
282
341
  function metadata(slot) {
283
342
  return [
284
343
  slot.inputIdSeq,
@@ -856,6 +915,11 @@ class V2StoreReaderPool {
856
915
  this.idleWaiters.clear();
857
916
  }
858
917
  }
918
+ function messageTimesQuery(count) {
919
+ return `SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
920
+ json_extract(data, '$.time.completed') AS completed
921
+ FROM session_message WHERE +session_id = ? AND id IN (${Array.from({ length: count }, () => "?").join(",")})`;
922
+ }
859
923
 
860
924
  class V2StoreReader {
861
925
  path;
@@ -1079,9 +1143,7 @@ class V2StoreReader {
1079
1143
  const times = new Map;
1080
1144
  for (let offset = 0;offset < ids.length; offset += 500) {
1081
1145
  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);
1146
+ const rows = this.prepare(messageTimesQuery(batch.length)).all(sessionID, ...batch);
1085
1147
  for (const row of rows)
1086
1148
  times.set(row.id, {
1087
1149
  created: typeof row.created === "number" ? row.created : undefined,
@@ -1438,7 +1500,7 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
1438
1500
  fallback.run(tagTombstoneOwnerKey(id, getHarness2()), getHarness2(), ...tagTombstoneOwnerRange(id));
1439
1501
  }
1440
1502
  for (const sessionId of deletableSessionIds)
1441
- deleteChunkEmbedBackoffForSession(db, sessionId);
1503
+ deleteChunkEmbedBackoffForSession2(db, sessionId);
1442
1504
  for (const definition of SESSION_SCOPED_TABLES) {
1443
1505
  if (definition.table === "message_history_fts") {
1444
1506
  cleanupStatement(db, `DELETE FROM message_history_fts
@@ -1489,7 +1551,7 @@ function deleteSessionScopedRowsSlice(db, sessionId, harness) {
1489
1551
  cleanupStatement(db, "INSERT OR IGNORE INTO schema_migrations_meta(key,value) VALUES (?,?)").run(tagTombstoneOwnerKey(sessionId, harness), harness);
1490
1552
  let remaining = SESSION_CLEANUP_SLICE_ROWS;
1491
1553
  const started = performance.now();
1492
- remaining -= deleteChunkEmbedBackoffForSession(db, sessionId, remaining);
1554
+ remaining -= deleteChunkEmbedBackoffForSession2(db, sessionId, remaining);
1493
1555
  if (remaining <= 0)
1494
1556
  return { complete: false, deleted: 0 };
1495
1557
  for (const definition of SESSION_SCOPED_TABLES) {
@@ -2003,14 +2065,20 @@ function harnessSupportsOpenCodeOrphanSweep(harness) {
2003
2065
  return harness === "opencode" || harness === "opencode2";
2004
2066
  }
2005
2067
  function getMessageHistoryOrphanSweepState(db, harness) {
2006
- return db.prepare("SELECT cursor_session_id, last_swept_at FROM message_history_orphan_sweep WHERE harness = ?").get(harness) ?? {};
2068
+ const state = db.prepare("SELECT cursor_session_id, last_swept_at FROM message_history_orphan_sweep WHERE harness = ?").get(harness) ?? {};
2069
+ if (harness === "opencode2") {
2070
+ if (!state.cursor_session_id?.startsWith("session_v2:"))
2071
+ return {};
2072
+ return { ...state, cursor_session_id: state.cursor_session_id.slice("session_v2:".length) };
2073
+ }
2074
+ return state;
2007
2075
  }
2008
2076
  function persistMessageHistoryOrphanSweepState(db, cursor, lastSweptAt, harness) {
2009
2077
  db.prepare(`INSERT INTO message_history_orphan_sweep (harness, cursor_session_id, last_swept_at)
2010
2078
  VALUES (?, ?, ?)
2011
2079
  ON CONFLICT(harness) DO UPDATE SET
2012
2080
  cursor_session_id = excluded.cursor_session_id,
2013
- last_swept_at = excluded.last_swept_at`).run(harness, cursor, lastSweptAt);
2081
+ last_swept_at = excluded.last_swept_at`).run(harness, harness === "opencode2" ? `session_v2:${cursor}` : cursor, lastSweptAt);
2014
2082
  }
2015
2083
  function getOpenCodeSessionScopedCandidateSourceSql(harness) {
2016
2084
  const sources = SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped === true).map((definition) => {
@@ -2058,13 +2126,14 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
2058
2126
  let v2Reader;
2059
2127
  try {
2060
2128
  let sessionExists;
2129
+ let liveIds;
2061
2130
  if (harness === "opencode2") {
2062
2131
  try {
2063
2132
  const path = getSqliteDatabasePath2(openCodeDb);
2064
2133
  if (!path)
2065
2134
  throw new Error("OpenCode 2 source has no durable path");
2066
2135
  v2Reader = new V2StoreReader(path);
2067
- const liveIds = new Set(v2Reader.sessionIds());
2136
+ liveIds = new Set(v2Reader.sessionIds());
2068
2137
  if (liveIds.size === 0)
2069
2138
  throw new Error("OpenCode 2 source has no sessions");
2070
2139
  sessionExists = (id) => liveIds.has(id);
@@ -2073,9 +2142,26 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
2073
2142
  return { status: "source_unavailable", scanned: 0, deleted: 0, cursor };
2074
2143
  }
2075
2144
  } else {
2145
+ liveIds = new Set(openCodeDb.prepare("SELECT id FROM session").all().map((row) => row.id));
2076
2146
  const query = openCodeDb.prepare("SELECT 1 FROM session WHERE id = ? LIMIT 1");
2077
2147
  sessionExists = (id) => !!query.get(id);
2078
2148
  }
2149
+ if (options.fenceLockNames?.length) {
2150
+ const retainedIds = new Set(liveIds);
2151
+ const sources = SESSION_SCOPED_TABLES.map((def) => `SELECT session_id FROM ${def.table}${def.extraPredicate ? ` WHERE ${def.extraPredicate}` : ""}`);
2152
+ for (const row of db.prepare(sources.join(" UNION ")).all()) {
2153
+ if (typeof row.session_id === "string")
2154
+ retainedIds.add(row.session_id);
2155
+ }
2156
+ for (const row of db.prepare("SELECT key FROM schema_migrations_meta WHERE key >= ? AND key < ?").all(TAG_TOMBSTONE_OWNER_PREFIX, "tag_revision_owner;")) {
2157
+ try {
2158
+ const id = JSON.parse(row.key.slice(TAG_TOMBSTONE_OWNER_PREFIX.length, row.key.lastIndexOf(":")));
2159
+ if (typeof id === "string")
2160
+ retainedIds.add(id);
2161
+ } catch {}
2162
+ }
2163
+ sweepEmptyLkgRecoveryLockDirectories(options.fenceLockNames, retainedIds);
2164
+ }
2079
2165
  const cutoff = now - safetyAgeMs;
2080
2166
  const candidateSourceSql = getOpenCodeSessionScopedCandidateSourceSql(harness);
2081
2167
  const candidates = db.prepare(`SELECT session_id
@@ -2167,4 +2253,4 @@ async function sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource,
2167
2253
  }));
2168
2254
  }
2169
2255
 
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 };
2256
+ export { BoundedSessionMap, clearCompressionDepth, clearCompressionDepthRange, LkgRecoveryFenceError, clearLkgFenceProcessState, lkgServedArrayDigest, takeLkgRecoveryLockSweepPage, 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 };
@@ -486,6 +486,7 @@ async function importPluginModule(load) {
486
486
 
487
487
  // src/shared/logger.ts
488
488
  var isTestEnv = false;
489
+ var syncLogWrites = process.env.MAGIC_CONTEXT_LOG_SYNC === "1";
489
490
  var buffer = [];
490
491
  var flushTimer = null;
491
492
  var FLUSH_INTERVAL_MS = 500;
@@ -630,6 +631,15 @@ function scheduleFlush() {
630
631
  flush();
631
632
  }, FLUSH_INTERVAL_MS);
632
633
  }
634
+ function appendLine(line) {
635
+ buffer.push(line);
636
+ bufferedBytes += Buffer.byteLength(line);
637
+ boundBuffer();
638
+ if (syncLogWrites || buffer.length >= BUFFER_SIZE_LIMIT)
639
+ flush();
640
+ else
641
+ scheduleFlush();
642
+ }
633
643
  var lineForwarder = null;
634
644
  function setLogLineForwarder2(forward) {
635
645
  lineForwarder = forward;
@@ -638,13 +648,7 @@ function writeForwardedLogLine2(line) {
638
648
  if (isTestEnv)
639
649
  return;
640
650
  try {
641
- buffer.push(line);
642
- bufferedBytes += Buffer.byteLength(line);
643
- boundBuffer();
644
- if (buffer.length >= BUFFER_SIZE_LIMIT)
645
- flush();
646
- else
647
- scheduleFlush();
651
+ appendLine(line);
648
652
  } catch {}
649
653
  }
650
654
  function log2(message, data) {
@@ -669,14 +673,7 @@ ${data.stack}` : ""}`)}` : ` ${JSON.stringify(sanitizeConfigValue(data))}`;
669
673
  lineForwarder(line);
670
674
  return;
671
675
  }
672
- buffer.push(line);
673
- bufferedBytes += Buffer.byteLength(line);
674
- boundBuffer();
675
- if (buffer.length >= BUFFER_SIZE_LIMIT) {
676
- flush();
677
- } else {
678
- scheduleFlush();
679
- }
676
+ appendLine(line);
680
677
  } catch {}
681
678
  }
682
679
  function sessionLog2(sessionId, message, data) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveDreamerTaskModel2
3
- } from "./server-8cd2j99z.js";
3
+ } from "./server-5kym00ag.js";
4
4
  import {
5
5
  isDreamerRunnable
6
6
  } from "./server-0s95v3en.js";
@@ -169,6 +169,7 @@ function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, smartNotesEna
169
169
  schedule: resolved.schedule ?? "",
170
170
  model: resolved.primary,
171
171
  fallbackModels: resolved.fallbacks,
172
+ modelConfigKey: resolved.primary?.sourceConfigKey ?? resolved.fallbacks[0]?.sourceConfigKey,
172
173
  thinkingLevel: harness === "pi" ? resolved.primary?.qualifier : undefined,
173
174
  language,
174
175
  timeoutMinutes: resolved.timeoutMinutes ?? 20,
@@ -3,12 +3,12 @@ import {
3
3
  } from "./server-fr0wbhdn.js";
4
4
  import {
5
5
  log2
6
- } from "./server-f2xf5gcb.js";
6
+ } from "./server-6495nmn9.js";
7
7
  import {
8
8
  ensureColumn,
9
9
  healAllNullColumns,
10
10
  installV95PerfSchema
11
- } from "./server-pwv4ezb0.js";
11
+ } from "./server-168pb207.js";
12
12
  import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
@@ -16,14 +16,14 @@ import {
16
16
  } from "./server-2ra6pwf3.js";
17
17
  import {
18
18
  Database2
19
- } from "./server-beht37jy.js";
19
+ } from "./server-1zx2pa5d.js";
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./server-rmygf5pn.js";
23
+ } from "./server-ne8arh8t.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
- } from "./server-6pmqg9m4.js";
26
+ } from "./server-gyy4k6mf.js";
27
27
 
28
28
  // src/features/magic-context/migrations.ts
29
29
  import { isMainThread } from "node:worker_threads";
@@ -4,23 +4,23 @@ import {
4
4
  } from "./server-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./server-tgnbmwah.js";
7
+ } from "./server-3mz2qh5a.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./server-pavzsdc6.js";
11
11
  import {
12
12
  sessionLog2
13
- } from "./server-f2xf5gcb.js";
13
+ } from "./server-6495nmn9.js";
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
17
- } from "./server-beht37jy.js";
17
+ } from "./server-1zx2pa5d.js";
18
18
  import {
19
19
  stableStringify,
20
20
  stableStringifyHash,
21
21
  tagOrderConstraintIndex,
22
22
  tagIdentityRevisionKey
23
- } from "./server-pwv4ezb0.js";
23
+ } from "./server-168pb207.js";
24
24
  import {
25
25
  DEFAULT_PROTECTED_TOOLS,
26
26
  normalizeProtectedToolName,
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./server-tgnbmwah.js";
3
+ } from "./server-3mz2qh5a.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./server-pavzsdc6.js";
7
7
  import {
8
8
  log2
9
- } from "./server-f2xf5gcb.js";
9
+ } from "./server-6495nmn9.js";
10
10
  import {
11
11
  inRootAsyncContext2
12
- } from "./server-beht37jy.js";
12
+ } from "./server-1zx2pa5d.js";
13
13
 
14
14
  // src/features/magic-context/memory/embedding-synapse.ts
15
15
  import { createHash } from "node:crypto";
@@ -2,13 +2,13 @@ import {
2
2
  getSqliteDatabasePath2,
3
3
  withSqliteBackgroundWriter2,
4
4
  withoutSqliteTransformPass2
5
- } from "./server-beht37jy.js";
5
+ } from "./server-1zx2pa5d.js";
6
6
  import {
7
7
  runSessionWarmupWorker
8
- } from "./server-xj136kt8.js";
8
+ } from "./server-55rgxfrw.js";
9
9
  import {
10
10
  logSlowWriteTransaction
11
- } from "./server-6pmqg9m4.js";
11
+ } from "./server-gyy4k6mf.js";
12
12
 
13
13
  // src/features/magic-context/message-fts-rowid-map.ts
14
14
  import { createHash } from "node:crypto";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./server-pavzsdc6.js";
5
5
  import {
6
6
  log2
7
- } from "./server-f2xf5gcb.js";
7
+ } from "./server-6495nmn9.js";
8
8
  import {
9
9
  resolveOpenCodeDbPath,
10
10
  assertOpenCodeStoreGeneration,
@@ -15,7 +15,7 @@ import {
15
15
  } from "./server-2ra6pwf3.js";
16
16
  import {
17
17
  Database2
18
- } from "./server-beht37jy.js";
18
+ } from "./server-1zx2pa5d.js";
19
19
  import {
20
20
  closeQuietly
21
21
  } from "./server-8ajstryz.js";