@cortexkit/opencode-magic-context 0.49.93 → 0.49.96

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 (256) hide show
  1. package/dist/{announcement-4ynkaf0d.js → announcement-8nj2jd87.js} +5 -5
  2. package/dist/auto-search-worker.js +5 -5
  3. package/dist/chunk-embedding-write-worker.js +16 -16
  4. package/dist/{compaction-marker-candidates-1ndjqh9k.js → compaction-marker-candidates-a4b0anvv.js} +3 -3
  5. package/dist/compaction-marker-candidates-worker.js +1 -1
  6. package/dist/{compartment-chunk-embedding-rp4asvk0.js → compartment-chunk-embedding-re2cw7y3.js} +8 -8
  7. package/dist/config/removed-agent-config.d.ts +1 -1
  8. package/dist/config/removed-agent-config.d.ts.map +1 -1
  9. package/dist/config/schema/magic-context.d.ts +0 -75
  10. package/dist/config/schema/magic-context.d.ts.map +1 -1
  11. package/dist/{conflict-warning-hook-exf96bpt.js → conflict-warning-hook-wcq55y61.js} +8 -8
  12. package/dist/{context-jpxthqxg.js → context-gtjdrp8f.js} +237 -140
  13. package/dist/{derive-budgets-hzzq71rm.js → derive-budgets-g1sy72e8.js} +5 -5
  14. package/dist/embedding-backfill-pdymqbnh.js +29 -0
  15. package/dist/embedding-worker-process.js +2 -2
  16. package/dist/embedding-worker.js +8 -8
  17. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +5 -2
  19. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/token-budget.d.ts +2 -2
  21. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
  22. package/dist/features/magic-context/history-gap-recovery.d.ts +42 -0
  23. package/dist/features/magic-context/history-gap-recovery.d.ts.map +1 -0
  24. package/dist/features/magic-context/memory/embedding-synapse.d.ts +18 -5
  25. package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
  26. package/dist/features/magic-context/message-visibility.d.ts +10 -0
  27. package/dist/features/magic-context/message-visibility.d.ts.map +1 -0
  28. package/dist/features/magic-context/search-rerank.d.ts +2 -2
  29. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  30. package/dist/features/magic-context/search.d.ts +4 -0
  31. package/dist/features/magic-context/search.d.ts.map +1 -1
  32. package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
  33. package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
  34. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  35. package/dist/{history-owner-xqfsvf9k.js → history-owner-74826t4n.js} +3 -3
  36. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  38. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/history-boundary-repair.d.ts +2 -2
  40. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/inject-compartments.d.ts +6 -1
  43. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/lkg-persist.d.ts +3 -1
  45. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +1 -0
  47. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/lkg-replay.d.ts +3 -0
  49. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +1 -0
  51. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +4 -0
  53. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +2 -0
  55. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -1
  57. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
  59. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/transform-stage-logger.d.ts +6 -0
  61. package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/transform.d.ts +2 -0
  63. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  64. package/dist/{index-5zrzg8r1.js → index-0bjj9yf3.js} +2 -2
  65. package/dist/{index-g9qtxv87.js → index-0sqhg9nf.js} +132 -64
  66. package/dist/{index-nxxzeq4y.js → index-0ve29s6f.js} +1 -1
  67. package/dist/{index-g6y2wk32.js → index-2afrmgy3.js} +6 -6
  68. package/dist/{index-ywrz4wy2.js → index-3fhb0j32.js} +1 -1
  69. package/dist/{index-gqf8r04r.js → index-3n4j5rqc.js} +1 -1
  70. package/dist/{index-xsqw8kbd.js → index-45qgkg8j.js} +2 -2
  71. package/dist/{index-5df2fw5b.js → index-6mryx739.js} +1 -1
  72. package/dist/{index-n9kd68vc.js → index-7m2tnk8q.js} +10 -10
  73. package/dist/{index-r4y0dczp.js → index-7sdns2ww.js} +2 -2
  74. package/dist/{index-mjy2k9jr.js → index-880a24vd.js} +1 -1
  75. package/dist/{index-pnawfv4e.js → index-89bkkgcn.js} +4 -4
  76. package/dist/{index-s32f8y67.js → index-89xg64wb.js} +2 -2
  77. package/dist/{index-hee64h6k.js → index-8sgv96kq.js} +7 -7
  78. package/dist/{index-ttdk2w0z.js → index-910gahfb.js} +6 -6
  79. package/dist/{index-kty5k23y.js → index-9jvxq5rt.js} +4 -4
  80. package/dist/{index-832w615x.js → index-azkfw78y.js} +1 -1
  81. package/dist/{index-wh9fxds5.js → index-c205x7xd.js} +1 -1
  82. package/dist/{index-mg9s2rc3.js → index-cpbr0xvk.js} +2 -2
  83. package/dist/{index-g5c67kay.js → index-cq8znmyw.js} +17 -17
  84. package/dist/{index-cr483vx6.js → index-dj64gzg5.js} +2 -2
  85. package/dist/{index-jba6ny4m.js → index-dnpcv1rg.js} +4 -4
  86. package/dist/{index-z4p0ry94.js → index-dt7cyqfe.js} +2 -1
  87. package/dist/{index-j2w79s9r.js → index-e6ay1gez.js} +2 -2
  88. package/dist/{index-y2vshk67.js → index-f154w8m4.js} +229 -84
  89. package/dist/{index-6r99v53h.js → index-fgw241hh.js} +164 -62
  90. package/dist/{index-rz47hf2m.js → index-fvfnq8n6.js} +30 -14
  91. package/dist/{index-yqha238s.js → index-gnrwgvn7.js} +127 -17
  92. package/dist/{index-fpjnjxyx.js → index-h7kta6cn.js} +3 -3
  93. package/dist/{index-q7q6qp1f.js → index-hedgz8an.js} +1 -1
  94. package/dist/{index-5pgyqgmx.js → index-hj78hvhm.js} +2 -2
  95. package/dist/{index-dr6bd4c8.js → index-hp46xe93.js} +7 -7
  96. package/dist/{index-0twg41mh.js → index-j4dcjb8t.js} +4 -4
  97. package/dist/{index-e6ncz7a6.js → index-jzrvdqb8.js} +1 -1
  98. package/dist/{index-sp5pvs95.js → index-k34hc455.js} +2 -2
  99. package/dist/{index-9ffntwyr.js → index-kj4bprep.js} +4 -4
  100. package/dist/index-mgy7g740.js +119 -0
  101. package/dist/{index-za1yx1m4.js → index-nqdwpdje.js} +154 -32
  102. package/dist/{index-hes3k87g.js → index-r1d45dsr.js} +4 -4
  103. package/dist/{index-y915t3ey.js → index-r3f85n7y.js} +5 -1
  104. package/dist/{index-1kem0xxx.js → index-t2e10rag.js} +5 -5
  105. package/dist/{index-m0pwswv9.js → index-tqtpgnhr.js} +1 -1
  106. package/dist/{index-01h7tqe3.js → index-tr4ep2ej.js} +21 -6
  107. package/dist/{index-xr1t0fxb.js → index-w7n7qkpf.js} +49 -13
  108. package/dist/{index-s7460efs.js → index-zfx7mtqa.js} +1 -1
  109. package/dist/{index-gqfy38m9.js → index-zkjx8gq3.js} +11 -11
  110. package/dist/{index-et39x9k3.js → index-zmgp0tr6.js} +3 -3
  111. package/dist/index.js +59 -56
  112. package/dist/{logger-d7c8akh9.js → logger-nmb2508f.js} +2 -2
  113. package/dist/{message-fts-rowid-map-0xx8ge09.js → message-fts-rowid-map-vcatdan0.js} +5 -5
  114. package/dist/{message-index-bounded-vjrnptar.js → message-index-bounded-abhwe610.js} +12 -12
  115. package/dist/{message-time-backfill-pz5981mf.js → message-time-backfill-zc5rsvhv.js} +3 -3
  116. package/dist/migration-worker.js +13 -13
  117. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  118. package/dist/{project-embedding-registry-m8zcmrsg.js → project-embedding-registry-e566q4bg.js} +15 -15
  119. package/dist/raw-ordinal-warmup-worker.js +9 -9
  120. package/dist/{read-session-chunk-zkzdc0e5.js → read-session-chunk-sde0wym3.js} +10 -10
  121. package/dist/{read-session-raw-3sc9231y.js → read-session-raw-trhdgc9z.js} +3 -3
  122. package/dist/recomp-orchestrator-d3rbpa59.js +69 -0
  123. package/dist/render-6cf1dgc4.js +43 -0
  124. package/dist/{safe-notification-target-d21swr3n.js → safe-notification-target-54ns7dv9.js} +3 -3
  125. package/dist/{search-e9bb9hpx.js → search-11aw8wpq.js} +27 -27
  126. package/dist/search-archive-s9m5szf0.js +29 -0
  127. package/dist/{send-session-notification-0779tyd9.js → send-session-notification-gxrj4w1r.js} +6 -6
  128. package/dist/shared/host-sqlite-runtime.d.ts +3 -0
  129. package/dist/shared/host-sqlite-runtime.d.ts.map +1 -0
  130. package/dist/shared/redaction.d.ts.map +1 -1
  131. package/dist/shared/storage-file-mutex.d.ts.map +1 -1
  132. package/dist/{storage-tags-gk7gjkqt.js → storage-tags-jq0c0zsn.js} +7 -7
  133. package/dist/{store-yr443ye8.js → store-29ksp6vy.js} +4 -4
  134. package/dist/{store-reader-qbq6q4v0.js → store-reader-dgh3ssxx.js} +1 -1
  135. package/dist/tools/ctx-expand/search-archive.d.ts +3 -2
  136. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
  137. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  138. package/dist/tools/ctx-expand/v2-archive-reader.d.ts +2 -0
  139. package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -1
  140. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  141. package/dist/{transform-postprocess-phase-neds90e3.js → transform-postprocess-phase-376xn40x.js} +35 -35
  142. package/dist/v2/auto-search-worker.js +5 -5
  143. package/dist/v2/chunk-embedding-write-worker.js +16 -16
  144. package/dist/v2/{compaction-marker-candidates-bp1bn579.js → compaction-marker-candidates-6nypmsr3.js} +3 -3
  145. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  146. package/dist/v2/{compartment-chunk-embedding-w7ht0t9v.js → compartment-chunk-embedding-jthtfhcd.js} +8 -8
  147. package/dist/v2/{context-ctsd80vc.js → context-vm09agrs.js} +426 -185
  148. package/dist/v2/{derive-budgets-hr4qqrnv.js → derive-budgets-wj0q7s7d.js} +6 -6
  149. package/dist/v2/embedding-backfill-16b16m38.js +29 -0
  150. package/dist/v2/embedding-worker-process.js +2 -2
  151. package/dist/v2/embedding-worker.js +8 -8
  152. package/dist/v2/fold/memory-cache.d.ts +2 -0
  153. package/dist/v2/fold/memory-cache.d.ts.map +1 -1
  154. package/dist/v2/fold/native-replay.d.ts +23 -5
  155. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  156. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  157. package/dist/v2/hidden-child-record.d.ts +8 -0
  158. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  159. package/dist/v2/hidden-completion.d.ts.map +1 -1
  160. package/dist/v2/hidden-run-holder.d.ts +8 -2
  161. package/dist/v2/hidden-run-holder.d.ts.map +1 -1
  162. package/dist/v2/{history-owner-260djmv5.js → history-owner-8pd5ax3n.js} +3 -3
  163. package/dist/v2/hooks/context.d.ts.map +1 -1
  164. package/dist/v2/hooks/hidden-child.d.ts +3 -0
  165. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  166. package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
  167. package/dist/v2/hooks/session-project-backfill.d.ts +2 -1
  168. package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
  169. package/dist/v2/{logger-zyf43np1.js → logger-58jfese9.js} +2 -2
  170. package/dist/v2/{message-fts-rowid-map-n8mcvcpz.js → message-fts-rowid-map-ax4vk78j.js} +5 -5
  171. package/dist/v2/{message-index-bounded-1vew9c37.js → message-index-bounded-qh794qxx.js} +12 -12
  172. package/dist/v2/{message-time-backfill-ynb3vg6r.js → message-time-backfill-yj773saf.js} +3 -3
  173. package/dist/v2/migration-worker.js +13 -13
  174. package/dist/v2/{project-embedding-registry-je5jam7y.js → project-embedding-registry-z05xvckg.js} +15 -15
  175. package/dist/v2/raw-ordinal-warmup-worker.js +9 -9
  176. package/dist/v2/{read-session-chunk-09sre4xv.js → read-session-chunk-8tn2dbn1.js} +10 -10
  177. package/dist/v2/{read-session-raw-wg5zc29f.js → read-session-raw-ywebck9q.js} +3 -3
  178. package/dist/v2/recomp-orchestrator-pfjpzdrb.js +69 -0
  179. package/dist/v2/render-7t5d7hkv.js +43 -0
  180. package/dist/v2/{safe-notification-target-y55z2zat.js → safe-notification-target-zrwbh6k7.js} +3 -3
  181. package/dist/v2/{search-gmye6n25.js → search-35cz80x0.js} +26 -26
  182. package/dist/v2/search-archive-5dpxv0ck.js +29 -0
  183. package/dist/v2/{send-session-notification-v69y04f5.js → send-session-notification-8x146x5y.js} +6 -6
  184. package/dist/v2/{server-z9czv2vb.js → server-11ra1pmx.js} +49 -13
  185. package/dist/v2/{server-gs2251jr.js → server-2cq3e1c1.js} +4 -4
  186. package/dist/v2/{server-39bcszk4.js → server-2qvnr3t7.js} +1 -1
  187. package/dist/v2/{server-jkj1dq6j.js → server-2sare4qg.js} +4 -4
  188. package/dist/v2/{server-jdfe07mp.js → server-2wz6y46g.js} +1 -1
  189. package/dist/v2/{server-at0v0z4t.js → server-379fd3n7.js} +1 -1
  190. package/dist/v2/{server-ds8vpfkr.js → server-40vdz8sf.js} +2 -2
  191. package/dist/v2/{server-qntmqaca.js → server-4yrvbnnm.js} +2 -2
  192. package/dist/v2/{server-x69fqsvz.js → server-5t4nzfpt.js} +1 -1
  193. package/dist/v2/{server-npdey91q.js → server-63ree5ns.js} +1 -1
  194. package/dist/v2/{server-gqkdfdvw.js → server-6qax5pds.js} +2 -2
  195. package/dist/v2/{server-qb3s0mnc.js → server-73bqw5c0.js} +1 -1
  196. package/dist/v2/{server-6chcnnhq.js → server-7h4gwphm.js} +4 -4
  197. package/dist/v2/{server-rkj44mez.js → server-7tj8yzrv.js} +2 -2
  198. package/dist/v2/{server-e6xneh68.js → server-arfzfxe8.js} +5 -1
  199. package/dist/v2/{server-6ash6z8z.js → server-av3p9c8k.js} +1 -1
  200. package/dist/v2/{server-5hwf5c7r.js → server-bx5k66qc.js} +1 -1
  201. package/dist/v2/{server-dgsjamm4.js → server-db91dxwc.js} +7 -7
  202. package/dist/v2/{server-z4p0ry94.js → server-dt7cyqfe.js} +2 -1
  203. package/dist/v2/{server-k1xc2bw1.js → server-ganavh75.js} +2 -2
  204. package/dist/v2/{server-6x40bnb7.js → server-gh2w75fn.js} +3 -3
  205. package/dist/v2/server-j1gxs1gj.js +119 -0
  206. package/dist/v2/{server-ps6zrzwj.js → server-k3ntgf6n.js} +164 -62
  207. package/dist/v2/{server-j8376q08.js → server-kzrrdjp5.js} +1 -1
  208. package/dist/v2/{server-1rrmxhd1.js → server-n33hyq9t.js} +2 -2
  209. package/dist/v2/{server-0tv6kytx.js → server-n34vzyfm.js} +1 -1
  210. package/dist/v2/{server-vc5fta6s.js → server-nnh81jqy.js} +6 -6
  211. package/dist/v2/{server-g53asaqt.js → server-pcq2d1wh.js} +30 -14
  212. package/dist/v2/{server-bnkc9kph.js → server-ppy2dj7g.js} +6 -6
  213. package/dist/v2/{server-96nm9vk4.js → server-rr5c0xcg.js} +2 -2
  214. package/dist/v2/{server-j4jjtdc5.js → server-rt8t6s2a.js} +2 -2
  215. package/dist/v2/{server-2xm0gxke.js → server-svccj9rd.js} +4 -4
  216. package/dist/v2/{server-5sbsnpkn.js → server-tq523gj6.js} +1 -1
  217. package/dist/v2/{server-00adcfjd.js → server-vj0xbbrc.js} +17 -3
  218. package/dist/v2/{server-4ecpanyn.js → server-vntc961c.js} +127 -17
  219. package/dist/v2/{server-btgnkr9z.js → server-vsx9tsks.js} +11 -11
  220. package/dist/v2/{server-vtgeyhq6.js → server-vtkbxzw1.js} +21 -6
  221. package/dist/v2/{server-cvp9w5gs.js → server-w35ep6wn.js} +192 -84
  222. package/dist/v2/{server-myp4pc6x.js → server-z2nv8jdv.js} +132 -64
  223. package/dist/v2/{server-pcarsvj2.js → server-z5cv5wm5.js} +10 -10
  224. package/dist/v2/{server-barj0mjz.js → server-zemnpv92.js} +4 -4
  225. package/dist/v2/server.js +9 -9
  226. package/dist/v2/{storage-tags-nccqr0kr.js → storage-tags-pcenytad.js} +7 -7
  227. package/dist/v2/{store-enef5jcn.js → store-gx19qc3a.js} +4 -4
  228. package/dist/v2/{store-reader-jbaqv1yp.js → store-reader-qt2msa8z.js} +1 -1
  229. package/dist/v2/store-reader.d.ts +1 -1
  230. package/dist/v2/store-reader.d.ts.map +1 -1
  231. package/dist/v2/{v2-archive-reader-7vmng8q7.js → v2-archive-reader-jqrwz7b8.js} +1 -1
  232. package/dist/v2/{wrapup-orchestrator-7r4y0bf6.js → wrapup-orchestrator-kcq3cv7y.js} +35 -35
  233. package/dist/{v2-archive-reader-7s90gfax.js → v2-archive-reader-64h2gtam.js} +1 -1
  234. package/dist/wrapup-orchestrator-knyac7jp.js +56 -0
  235. package/package.json +1 -1
  236. package/src/config/index.test.ts +23 -5
  237. package/src/config/live-run-config.test.ts +7 -7
  238. package/src/config/removed-agent-config.ts +14 -1
  239. package/src/config/schema/magic-context.ts +5 -1
  240. package/src/shared/host-sqlite-runtime.test.ts +21 -0
  241. package/src/shared/host-sqlite-runtime.ts +32 -0
  242. package/src/shared/redaction.test.ts +11 -8
  243. package/src/shared/redaction.ts +5 -1
  244. package/src/shared/storage-file-mutex-review.test.ts +110 -0
  245. package/src/shared/storage-file-mutex.ts +12 -0
  246. package/dist/embedding-backfill-6wzc4p2n.js +0 -29
  247. package/dist/index-52x68mj4.js +0 -58
  248. package/dist/recomp-orchestrator-qb2hymj5.js +0 -69
  249. package/dist/render-34p0kek8.js +0 -43
  250. package/dist/search-archive-08ppk0q5.js +0 -27
  251. package/dist/v2/embedding-backfill-40g0anxh.js +0 -29
  252. package/dist/v2/recomp-orchestrator-mgcty3we.js +0 -69
  253. package/dist/v2/render-ygcmyn9x.js +0 -43
  254. package/dist/v2/search-archive-nrsqqmk5.js +0 -27
  255. package/dist/v2/server-52x68mj4.js +0 -58
  256. package/dist/wrapup-orchestrator-m2p89973.js +0 -56
@@ -7,7 +7,7 @@ import {
7
7
  deleteTagIdentityRevisions,
8
8
  getTableColumnNames,
9
9
  getMeasuredToolDefinitionTokens
10
- } from "./index-mg9s2rc3.js";
10
+ } from "./index-cpbr0xvk.js";
11
11
  import {
12
12
  invalidateAutoEmbedSession,
13
13
  drainBackgroundBatches
@@ -20,7 +20,7 @@ import {
20
20
  getMagicContextStorageDir,
21
21
  log2,
22
22
  sessionLog2
23
- } from "./index-ywrz4wy2.js";
23
+ } from "./index-3fhb0j32.js";
24
24
  import {
25
25
  prepareCachedStatement2,
26
26
  withSqliteBackgroundWriter2,
@@ -28,14 +28,14 @@ import {
28
28
  } from "./index-gzy5w8ya.js";
29
29
  import {
30
30
  deleteUnmappedMessageFtsRows2
31
- } from "./index-s32f8y67.js";
31
+ } from "./index-89xg64wb.js";
32
32
  import {
33
33
  deleteChunkEmbedBackoffForSession2
34
- } from "./index-0twg41mh.js";
34
+ } from "./index-j4dcjb8t.js";
35
35
  import {
36
36
  isPidAlive,
37
37
  readProcessStartTime
38
- } from "./index-gqf8r04r.js";
38
+ } from "./index-3n4j5rqc.js";
39
39
  import {
40
40
  stripTagPrefix,
41
41
  isRecord,
@@ -68,25 +68,25 @@ import {
68
68
  getPendingPiCompactionMarkerState,
69
69
  logPiCompactionMarkerClear,
70
70
  isPrefixBoundThinkingModel
71
- } from "./index-xr1t0fxb.js";
71
+ } from "./index-w7n7qkpf.js";
72
72
  import {
73
73
  withReadOnlySessionDb
74
- } from "./index-sp5pvs95.js";
74
+ } from "./index-k34hc455.js";
75
75
  import {
76
76
  layoutLkgPrefix,
77
77
  assembleLkgPrefix
78
- } from "./index-jba6ny4m.js";
78
+ } from "./index-dnpcv1rg.js";
79
79
  import {
80
80
  ensurePrivateStorageDirectorySync,
81
81
  writeStorageFileSync,
82
82
  writeStorageFileAtomicSync,
83
83
  syncStorageDirectorySync,
84
84
  writeStorageFileDurableAtomicSync
85
- } from "./index-5df2fw5b.js";
85
+ } from "./index-6mryx739.js";
86
86
  import {
87
87
  gaDatabasePath2,
88
88
  V2StoreReader2
89
- } from "./index-01h7tqe3.js";
89
+ } from "./index-tr4ep2ej.js";
90
90
  import {
91
91
  markHostInstructionRow,
92
92
  hostInstructionRowID,
@@ -99,7 +99,7 @@ import {
99
99
  } from "./index-avwt563y.js";
100
100
  import {
101
101
  logSlowWriteTransaction
102
- } from "./index-m0pwswv9.js";
102
+ } from "./index-tqtpgnhr.js";
103
103
 
104
104
  // src/features/magic-context/session-activity.ts
105
105
  var PREFIX = "retrospective_activity:";
@@ -240,6 +240,86 @@ function isCompartmentLeaseHeld(db, sessionId, holderId) {
240
240
  return row != null;
241
241
  }
242
242
 
243
+ // src/features/magic-context/history-gap-recovery.ts
244
+ var STATE = `CASE WHEN json_valid(deferred_execute_state)
245
+ AND json_type(deferred_execute_state) = 'object' THEN deferred_execute_state ELSE '{}' END`;
246
+ var PATH = "$.historyGapRecovery";
247
+ var MARK = `json_extract(${STATE}, '${PATH}')`;
248
+ var MARK_ID = `json_extract(${STATE}, '${PATH}.id')`;
249
+ var CHECKED_AT = `json_extract(${STATE}, '${PATH}.checkedAt')`;
250
+ function readSummaryCoverage(db, sessionId) {
251
+ return db.prepare(`SELECT id, sequence, end_message AS endOrdinal, end_message_id AS messageId
252
+ FROM compartments WHERE session_id = ? AND rebase_status != 'unresolved'
253
+ ORDER BY end_message DESC, sequence DESC LIMIT 1`).get(sessionId) ?? null;
254
+ }
255
+ function markHistoryGapAfterCoverageChange(db, sessionId, before, projectionChanged = false) {
256
+ if (!before)
257
+ return false;
258
+ const after = readSummaryCoverage(db, sessionId);
259
+ if (projectionChanged && after && before.messageId && before.messageId === after.messageId) {
260
+ if (before.endOrdinal !== after.endOrdinal) {
261
+ const pending = readHistoryGapMark(db, sessionId);
262
+ if (pending && pending.endOrdinal < before.endOrdinal) {
263
+ clearHistoryGapMark(db, sessionId, pending.id);
264
+ } else if (pending && pending.endOrdinal === before.endOrdinal) {
265
+ db.prepare(`UPDATE session_meta SET deferred_execute_state = json_set(${STATE}, '${PATH}.endOrdinal', ?)
266
+ WHERE session_id = ? AND ${MARK_ID} = ?`).run(after.endOrdinal, sessionId, pending.id);
267
+ }
268
+ }
269
+ return false;
270
+ }
271
+ if (db.prepare("SELECT 1 FROM compartments WHERE id = ?").get(before.id))
272
+ return false;
273
+ if (after) {
274
+ if (before.messageId && before.messageId === after.messageId)
275
+ return false;
276
+ if (projectionChanged) {
277
+ if (after.sequence > before.sequence)
278
+ return false;
279
+ } else if (after.endOrdinal >= before.endOrdinal)
280
+ return false;
281
+ }
282
+ ensureSessionMetaRow(db, sessionId);
283
+ const mark = { id: crypto.randomUUID(), endOrdinal: after?.endOrdinal ?? -1 };
284
+ db.prepare(`UPDATE session_meta SET deferred_execute_state = json_set(${STATE}, '${PATH}', json(?))
285
+ WHERE session_id = ?`).run(JSON.stringify(mark), sessionId);
286
+ return true;
287
+ }
288
+ function settleHistoryGapAfterReplacement(db, sessionId, before, published) {
289
+ if (!markHistoryGapAfterCoverageChange(db, sessionId, before) && published) {
290
+ clearPublishedHistoryGapMark(db, sessionId);
291
+ }
292
+ }
293
+ function readHistoryGapMark(db, sessionId) {
294
+ const row = db.prepare(`SELECT ${MARK} AS mark FROM session_meta WHERE session_id = ?`).get(sessionId);
295
+ if (typeof row?.mark !== "string" || !row.mark.startsWith("{"))
296
+ return null;
297
+ const mark = JSON.parse(row.mark);
298
+ return typeof mark.id === "string" && Number.isInteger(mark.endOrdinal) ? mark : null;
299
+ }
300
+ function clearHistoryGapMark(db, sessionId, expected) {
301
+ db.prepare(`UPDATE session_meta SET deferred_execute_state = json_remove(${STATE}, '${PATH}')
302
+ WHERE session_id = ? AND ${MARK_ID} = ?`).run(sessionId, expected);
303
+ }
304
+ function clearPublishedHistoryGapMark(db, sessionId) {
305
+ const mark = readHistoryGapMark(db, sessionId);
306
+ if (!mark)
307
+ return;
308
+ const coverage = readSummaryCoverage(db, sessionId);
309
+ if (coverage && coverage.endOrdinal > mark.endOrdinal)
310
+ clearHistoryGapMark(db, sessionId, mark.id);
311
+ }
312
+ function claimHistoryGapCheck(db, sessionId, mark, now, inspectedCount) {
313
+ return db.prepare(`UPDATE session_meta SET deferred_execute_state = json_set(${STATE},
314
+ '${PATH}.checkedAt', ?, '${PATH}.inspectedCount', ?)
315
+ WHERE session_id = ? AND ${MARK_ID} = ? AND ${CHECKED_AT} IS ?`).run(now, inspectedCount, sessionId, mark.id, mark.checkedAt ?? null).changes > 0;
316
+ }
317
+ function recordHistoryGapAdmission(db, sessionId, admission) {
318
+ return db.prepare(`UPDATE session_meta SET deferred_execute_state = json_set(${STATE},
319
+ '${PATH}.admittedRuns', ?, '${PATH}.failureCountAtAdmission', ?)
320
+ WHERE session_id = ? AND ${MARK_ID} = ? AND ${CHECKED_AT} = ?`).run(admission.admittedRuns, admission.failureCount, sessionId, admission.id, admission.checkedAt).changes > 0;
321
+ }
322
+
243
323
  // src/features/magic-context/no-content-compartment.ts
244
324
  function isNoContentCompartment(row) {
245
325
  return [row.title, row.content, row.p1, row.p2, row.p3, row.p4].every((value) => !value);
@@ -400,6 +480,8 @@ function appendCompartments(db, sessionId, compartments) {
400
480
  const now = Date.now();
401
481
  db.transaction(() => {
402
482
  insertCompartmentRows(db, sessionId, compartments, now);
483
+ if (compartments.some((row) => !isNoContentCompartment(row)))
484
+ clearPublishedHistoryGapMark(db, sessionId);
403
485
  }).immediate();
404
486
  }
405
487
  function buildCompartmentBlock(compartments, facts, memoryBlock, dateRanges) {
@@ -793,6 +875,11 @@ function withStorageFileMutex(directory, work, timeoutMs = 1000) {
793
875
  writeStorageFileSync(ownPath, encodedTicket(), { flag: "wx", forcePrivate: true });
794
876
  break;
795
877
  } catch (error) {
878
+ try {
879
+ rmSync(ownPath, { force: true });
880
+ } catch (cleanupError) {
881
+ log2(`[magic-context] storage mutex could not remove its unwritten ticket ${ownPath}: ${String(cleanupError)}`);
882
+ }
796
883
  const code = error.code;
797
884
  if (code !== "ENOENT" && code !== "EEXIST" && code !== "EINVAL" || performance.now() >= deadline)
798
885
  throw error;
@@ -1093,14 +1180,19 @@ function markLkgRecoveryDirty(args) {
1093
1180
  });
1094
1181
  }
1095
1182
  function commitLkgWithRecoveryFence(args) {
1096
- if (!durableFencesSupported())
1097
- return args.commit();
1183
+ if (!durableFencesSupported()) {
1184
+ const committed = args.commit();
1185
+ if (committed)
1186
+ args.onCommitted?.();
1187
+ return committed;
1188
+ }
1098
1189
  const state = known(args.sessionId);
1099
1190
  if (state.state === "clean" && !args.requiredRevision && !args.retainDirtyRevision) {
1100
1191
  const committed = args.commit();
1101
1192
  if (committed) {
1102
1193
  observer?.("committed");
1103
1194
  remember(args.sessionId, { state: "clean", record: null });
1195
+ args.onCommitted?.();
1104
1196
  }
1105
1197
  return committed;
1106
1198
  }
@@ -1118,6 +1210,7 @@ function commitLkgWithRecoveryFence(args) {
1118
1210
  if (!args.commit())
1119
1211
  return false;
1120
1212
  observer?.("committed");
1213
+ args.onCommitted?.();
1121
1214
  const saved = args.load();
1122
1215
  if (!saved || representationKey(saved) !== representationKey(args.slot))
1123
1216
  throw new LkgRecoveryFenceError("Last-good commit did not match its certificate");
@@ -2074,11 +2167,12 @@ function persistLkgSlot(db, sessionId, slot, publishMetadata) {
2074
2167
  }
2075
2168
  }
2076
2169
  function saveLkgSlotToDb(db, sessionId, slot, publishMetadata, fence = {}) {
2170
+ const { isLoadDeadline, ...publicationFence } = fence;
2077
2171
  return commitLkgWithRecoveryFence({
2078
2172
  sessionId,
2079
2173
  slot,
2080
- ...fence,
2081
- load: () => loadPersistedLkgSlot(db, sessionId, true),
2174
+ ...publicationFence,
2175
+ load: () => loadPersistedLkgSlot(db, sessionId, true, isLoadDeadline),
2082
2176
  commit: () => persistLkgSlot(db, sessionId, slot, publishMetadata)
2083
2177
  });
2084
2178
  }
@@ -2096,7 +2190,7 @@ function clearPersistedLkgSlotStrict(db, sessionId) {
2096
2190
  }).immediate());
2097
2191
  persistedFingerprints.get(db)?.delete(sessionId);
2098
2192
  }
2099
- function loadPersistedLkgSlot(db, sessionId, forPublication = false) {
2193
+ function loadPersistedLkgSlot(db, sessionId, forPublication = false, isLoadDeadline) {
2100
2194
  const rustHost = getHarness2() === "opencode" || getHarness2() === "opencode2";
2101
2195
  if (rustHost && !forPublication && isRustMarkerAdmissionFenced(db, sessionId))
2102
2196
  return;
@@ -2111,6 +2205,10 @@ function loadPersistedLkgSlot(db, sessionId, forPublication = false) {
2111
2205
  return { row: slotRow, chunkRows: slices };
2112
2206
  }).deferred());
2113
2207
  } catch (error) {
2208
+ if (isLoadDeadline?.(error)) {
2209
+ sessionLog2(sessionId, "LKG snapshot durable load denied by outcome clock:", error);
2210
+ throw error;
2211
+ }
2114
2212
  sessionLog2(sessionId, "LKG snapshot durable load failed:", error);
2115
2213
  return;
2116
2214
  }
@@ -2544,6 +2642,7 @@ function buildLkgPrefix(input, output, completeOutput = false) {
2544
2642
  prefix.push(visible);
2545
2643
  }
2546
2644
  }
2645
+ canCountFromArray &&= canCountWithoutToJSON(prefix);
2547
2646
  let jsonPrefix;
2548
2647
  try {
2549
2648
  jsonPrefix = JSON.stringify(prefix);
@@ -2764,10 +2863,19 @@ function validateLkgSeam(prefix, tail, providerKey) {
2764
2863
  }
2765
2864
  return true;
2766
2865
  }
2866
+ function observeReplayStage(onStage, stage) {
2867
+ try {
2868
+ onStage?.(stage);
2869
+ } catch {}
2870
+ }
2767
2871
  function replayLkg(args) {
2872
+ if (args.onStage)
2873
+ observeReplayStage(args.onStage, "savedRequestLoad");
2768
2874
  const slot = getSlot(args.sessionId);
2769
2875
  if (!slot)
2770
2876
  return { ok: false, reason: "lkg_invalidated_reshape" };
2877
+ if (args.onStage)
2878
+ observeReplayStage(args.onStage, "identityCheck");
2771
2879
  const requestedModelKeys = canonicalLkgModelKeys(args.modelKey, args.providerKey);
2772
2880
  const capturedModelKeys = canonicalLkgModelKeys(slot.modelKey, slot.providerKey);
2773
2881
  if (capturedModelKeys.modelKey !== requestedModelKeys.modelKey || capturedModelKeys.providerKey !== requestedModelKeys.providerKey) {
@@ -2783,6 +2891,8 @@ function replayLkg(args) {
2783
2891
  dropSlot(args.sessionId, "lkg_content_mismatch");
2784
2892
  return { ok: false, reason: "lkg_content_mismatch" };
2785
2893
  }
2894
+ if (args.onStage)
2895
+ observeReplayStage(args.onStage, "replayRebuild");
2786
2896
  let prefix;
2787
2897
  try {
2788
2898
  const parsed = JSON.parse(slot.jsonPrefix);
@@ -5242,4 +5352,4 @@ var ERROR_CLASSES = new Set([
5242
5352
  "permission_denied",
5243
5353
  "unknown"
5244
5354
  ]);
5245
- export { advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getNewestCompartmentIds, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, cachedHistoryCoversLatestCompartment, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, hasExplicitRefreshRequest, clearPendingMaterialization, clearReclaimedMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginServedRequest, noteServedPassPermission, noteServedModel, noteServedReplay, noteServedHostInput, noteServedRefusal, countServedRefusal, dropServedRecord, forgetServedRecord, commitServedRequest, lkgInputIdentity, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
5355
+ export { advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, readSummaryCoverage, markHistoryGapAfterCoverageChange, settleHistoryGapAfterReplacement, readHistoryGapMark, clearHistoryGapMark, claimHistoryGapCheck, recordHistoryGapAdmission, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getNewestCompartmentIds, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, cachedHistoryCoversLatestCompartment, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, hasExplicitRefreshRequest, clearPendingMaterialization, clearReclaimedMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginServedRequest, noteServedPassPermission, noteServedModel, noteServedReplay, noteServedHostInput, noteServedRefusal, countServedRefusal, dropServedRecord, forgetServedRecord, commitServedRequest, lkgInputIdentity, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-s7460efs.js";
3
+ } from "./index-zfx7mtqa.js";
4
4
  import {
5
5
  getTagById2
6
- } from "./index-xr1t0fxb.js";
6
+ } from "./index-w7n7qkpf.js";
7
7
  import {
8
8
  expandToolPart,
9
9
  visitRawSessionMessages2,
10
10
  readRawSessionMessageById2
11
- } from "./index-dr6bd4c8.js";
11
+ } from "./index-hp46xe93.js";
12
12
 
13
13
  // src/tools/ctx-expand/render.ts
14
14
  import { createHash } from "node:crypto";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-v0p37hm2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-ywrz4wy2.js";
6
+ } from "./index-3fhb0j32.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getMagicContextStorageDir,
3
3
  log2
4
- } from "./index-ywrz4wy2.js";
4
+ } from "./index-3fhb0j32.js";
5
5
  import {
6
6
  writeStorageFileAtomicSync
7
- } from "./index-5df2fw5b.js";
7
+ } from "./index-6mryx739.js";
8
8
  import {
9
9
  inRootAsyncContext2
10
10
  } from "./index-gzy5w8ya.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-ywrz4wy2.js";
3
+ } from "./index-3fhb0j32.js";
4
4
  import {
5
5
  stripTagPrefix,
6
6
  isRecord,
@@ -9,7 +9,7 @@ import {
9
9
  estimateMessageTokens,
10
10
  getCandidateToolOwners2,
11
11
  pickNearestPriorOwner2
12
- } from "./index-xr1t0fxb.js";
12
+ } from "./index-w7n7qkpf.js";
13
13
  import {
14
14
  OMO_INTERNAL_INITIATOR_MARKER,
15
15
  isSystemDirective,
@@ -24,13 +24,13 @@ import {
24
24
  formatBlock,
25
25
  compactTextForSummary,
26
26
  mergeCommitHashes
27
- } from "./index-s7460efs.js";
27
+ } from "./index-zfx7mtqa.js";
28
28
  import {
29
29
  stableStringify
30
- } from "./index-mg9s2rc3.js";
30
+ } from "./index-cpbr0xvk.js";
31
31
  import {
32
32
  renderToolTemplate
33
- } from "./index-y915t3ey.js";
33
+ } from "./index-r3f85n7y.js";
34
34
  import {
35
35
  readRawSessionMessagesFromDb2,
36
36
  readRawSessionMessagePageFromDb2,
@@ -47,13 +47,13 @@ import {
47
47
  readRawSeedTailFromDb2,
48
48
  readRawSessionBoundaryEndpointsFromDb2,
49
49
  prewarmRawSessionOrdinalsForDb
50
- } from "./index-q7q6qp1f.js";
50
+ } from "./index-hedgz8an.js";
51
51
  import {
52
52
  openCodeDbExists,
53
53
  withReadOnlySessionDb,
54
54
  getRawSessionMessageCountFromDb,
55
55
  getMessageTimesFromOpenCodeDb
56
- } from "./index-sp5pvs95.js";
56
+ } from "./index-k34hc455.js";
57
57
  import {
58
58
  markHostUnservedRow,
59
59
  isHostUnservedRow
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getTokenEstimatorFingerprint,
3
3
  estimateTokens
4
- } from "./index-s7460efs.js";
4
+ } from "./index-zfx7mtqa.js";
5
5
  import {
6
6
  getHarness2
7
7
  } from "./index-pavzsdc6.js";
8
8
  import {
9
9
  log2
10
- } from "./index-ywrz4wy2.js";
10
+ } from "./index-3fhb0j32.js";
11
11
  import {
12
12
  isSynapseEmbeddingTruncated
13
- } from "./index-6r99v53h.js";
13
+ } from "./index-fgw241hh.js";
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped2
16
- } from "./index-s32f8y67.js";
16
+ } from "./index-89xg64wb.js";
17
17
  import {
18
18
  isKnownAutocommit
19
19
  } from "./index-8ajstryz.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-ywrz4wy2.js";
3
+ } from "./index-3fhb0j32.js";
4
4
 
5
5
  // src/shared/safe-notification-target.ts
6
6
  var DEFAULT_TITLE_RE = /^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-pavzsdc6.js";
5
5
  import {
6
6
  log2
7
- } from "./index-ywrz4wy2.js";
7
+ } from "./index-3fhb0j32.js";
8
8
  import {
9
9
  resolveOpenCodeDbPath,
10
10
  assertOpenCodeStoreGeneration,
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  forgetRawSessionOrdinalWatermark2,
21
21
  forgetRawSessionSummaryRows2
22
- } from "./index-q7q6qp1f.js";
22
+ } from "./index-hedgz8an.js";
23
23
  import {
24
24
  closeQuietly
25
25
  } from "./index-8ajstryz.js";
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  importPluginModule,
6
6
  sessionLog2
7
- } from "./index-ywrz4wy2.js";
7
+ } from "./index-3fhb0j32.js";
8
8
  import {
9
9
  isDefaultSessionTitle2
10
- } from "./index-e6ncz7a6.js";
10
+ } from "./index-jzrvdqb8.js";
11
11
  import {
12
12
  shouldHoldIgnoredNotification
13
- } from "./index-sp5pvs95.js";
13
+ } from "./index-k34hc455.js";
14
14
  import {
15
15
  getErrorMessage
16
16
  } from "./index-y8v6yerm.js";
@@ -142,7 +142,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
142
142
  holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
143
143
  return "queued";
144
144
  }
145
- const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-d21swr3n.js"));
145
+ const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-54ns7dv9.js"));
146
146
  if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
147
147
  sessionLog2(sessionId, "notification skipped (session not titled yet)");
148
148
  return "skipped";
@@ -0,0 +1,119 @@
1
+ import {
2
+ TEXT_TAG_IDENTITY_MARKER
3
+ } from "./index-w7n7qkpf.js";
4
+
5
+ // src/features/magic-context/message-fts-session-filter.ts
6
+ var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
7
+ SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?
8
+ ) AND `;
9
+ var coverageCaches = new WeakMap;
10
+ var coverageScansOnThisThread = 0;
11
+ function getCoverageCache(db) {
12
+ let cache = coverageCaches.get(db);
13
+ if (!cache) {
14
+ cache = {
15
+ pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
16
+ stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
17
+ missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
18
+ FROM message_history_fts WHERE rowid IN (
19
+ SELECT id FROM message_history_fts_docsize
20
+ EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
21
+ )`)
22
+ };
23
+ coverageCaches.set(db, cache);
24
+ }
25
+ return cache;
26
+ }
27
+ function withMessageFtsSessionFilter(db, sessionId, read) {
28
+ let cacheable = false;
29
+ try {
30
+ const transaction = db;
31
+ cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
32
+ if (!cacheable)
33
+ coverageCaches.delete(db);
34
+ } catch {
35
+ coverageCaches.delete(db);
36
+ }
37
+ return db.transaction(() => {
38
+ let sessionFirst = false;
39
+ try {
40
+ const cache = getCoverageCache(db);
41
+ cache.pin.get();
42
+ const stamp = cache.stamp.get();
43
+ let incomplete = cache.incompleteSessions;
44
+ if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
45
+ coverageScansOnThisThread += 1;
46
+ const rows = cache.missing.all();
47
+ incomplete = new Set(rows.map((row) => row.sessionId));
48
+ if (cacheable) {
49
+ cache.version = stamp.version;
50
+ cache.changes = stamp.changes;
51
+ cache.incompleteSessions = incomplete;
52
+ }
53
+ }
54
+ sessionFirst = !incomplete.has(sessionId);
55
+ } catch {
56
+ coverageCaches.delete(db);
57
+ }
58
+ return read(sessionFirst);
59
+ }).deferred();
60
+ }
61
+
62
+ // src/features/magic-context/message-visibility.ts
63
+ function partDropSql(session, id, prefix, type, validSuffix) {
64
+ const next = prefix.slice(0, -1) + String.fromCharCode(prefix.charCodeAt(prefix.length - 1) + 1);
65
+ const suffix = `substr(t.message_id, length(${id}) + ${prefix.length + 1})`;
66
+ return `EXISTS (SELECT 1 FROM tags AS t INDEXED BY idx_tags_session_message_id
67
+ WHERE t.session_id = ${session} AND t.message_id >= ${id} || '${prefix}'
68
+ AND t.message_id < ${id} || '${next}' AND t.type = '${type}' AND t.status = 'dropped'
69
+ AND (${validSuffix(suffix)}))`;
70
+ }
71
+ var numericSuffix = (suffix) => `${suffix} <> '' AND ${suffix} NOT GLOB '*[^0-9]*'`;
72
+ function textDropSql(session, id) {
73
+ return `EXISTS (SELECT 1 FROM tags AS t INDEXED BY idx_tags_session_message_id
74
+ WHERE t.session_id = ${session} AND t.message_id = ${id} AND t.status = 'dropped'
75
+ AND t.type = 'message')
76
+ OR ${partDropSql(session, id, ":p", "message", numericSuffix)}
77
+ OR ${partDropSql(session, id, TEXT_TAG_IDENTITY_MARKER, "message", (suffix) => `${suffix} GLOB '[0-9a-f]*:[0-9a-f]*:o[0-9]*' AND ${suffix} NOT GLOB '*[^0-9a-f:o]*'
78
+ AND length(${suffix}) - length(replace(${suffix}, ':', '')) = 2`)}`;
79
+ }
80
+ function unresolvedCoverageSql(session, start, end) {
81
+ return `EXISTS (SELECT 1 FROM compartments AS unresolved
82
+ WHERE unresolved.session_id = ${session} AND unresolved.rebase_status = 'unresolved'
83
+ AND unresolved.start_message <= ${end} AND unresolved.end_message >= ${start})`;
84
+ }
85
+ function visibleSql(session, ordinal, lastSummaryEnd, dropped) {
86
+ return `CASE WHEN ${ordinal} <= ${lastSummaryEnd} THEN 0
87
+ WHEN ${unresolvedCoverageSql(session, ordinal, ordinal)} THEN 1 ELSE NOT (${dropped}) END`;
88
+ }
89
+ function liveTailRangeTouchesUnresolvedCoverage(db, sessionId, start, end, lastSummaryEnd) {
90
+ if (lastSummaryEnd < 0 || start <= lastSummaryEnd)
91
+ return false;
92
+ return !!db.prepare(`SELECT 1 WHERE ${unresolvedCoverageSql("?", "?", "?")}`).get(sessionId, end, start);
93
+ }
94
+ function messageTextVisibleInRequestSql(session, id, ordinal, lastSummaryEnd) {
95
+ return visibleSql(session, ordinal, lastSummaryEnd, textDropSql(session, id));
96
+ }
97
+ function messageVisibleInRequestSql(session, id, ordinal, lastSummaryEnd) {
98
+ return visibleSql(session, ordinal, lastSummaryEnd, `${textDropSql(session, id)}
99
+ OR ${partDropSql(session, id, ":file", "file", numericSuffix)}
100
+ OR EXISTS (SELECT 1 FROM tags AS t INDEXED BY idx_tags_pi_fallback_tool_owner
101
+ WHERE t.session_id = ${session} AND t.tool_owner_message_id = ${id}
102
+ AND t.type = 'tool' AND t.status = 'dropped')`);
103
+ }
104
+ function rangeHasHiddenMessages(db, sessionId, candidates, lastSummaryEnd, start, end) {
105
+ return !!db.prepare(`
106
+ WITH range(sessionId, start, end) AS (VALUES (?, ?, ?)), candidates(id, ordinal) AS (
107
+ SELECT json_extract(value, '$[0]'), json_extract(value, '$[1]') FROM json_each(?)
108
+ UNION
109
+ SELECT message_id, message_ordinal FROM range CROSS JOIN message_history_source
110
+ INDEXED BY idx_message_history_source_session_ordinal
111
+ WHERE session_id = range.sessionId AND message_ordinal BETWEEN range.start AND range.end
112
+ )
113
+ SELECT 1 FROM range CROSS JOIN candidates
114
+ WHERE NOT (${messageVisibleInRequestSql("range.sessionId", "candidates.id", "candidates.ordinal", "?")})
115
+ LIMIT 1
116
+ `).get(sessionId, start, end, JSON.stringify([...candidates]), lastSummaryEnd);
117
+ }
118
+
119
+ export { MESSAGE_FTS_SESSION_FILTER_SQL, withMessageFtsSessionFilter, liveTailRangeTouchesUnresolvedCoverage, messageTextVisibleInRequestSql, rangeHasHiddenMessages };