@cortexkit/opencode-magic-context 0.49.16 → 0.49.18

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 (235) hide show
  1. package/dist/auto-search-worker.js +76 -63
  2. package/dist/chunk-embedding-write-worker.js +11 -11
  3. package/dist/{compaction-marker-candidates-v5c6997n.js → compaction-marker-candidates-n4krhat4.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/config/schema/magic-context.d.ts +394 -394
  6. package/dist/{conflict-warning-hook-znry4j76.js → conflict-warning-hook-4pmz879v.js} +5 -5
  7. package/dist/{context-3znk23va.js → context-m897gfp9.js} +304 -145
  8. package/dist/{embedding-backfill-q4n8dend.js → embedding-backfill-fmz50tsy.js} +11 -11
  9. package/dist/embedding-worker-process.js +1 -1
  10. package/dist/embedding-worker.js +4 -4
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
  12. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  14. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  15. package/dist/features/magic-context/memory/project-identity-cache.d.ts +2 -0
  16. package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
  17. package/dist/features/magic-context/message-index-async.d.ts +1 -1
  18. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  19. package/dist/features/magic-context/message-index.d.ts +5 -0
  20. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  21. package/dist/features/magic-context/search.d.ts +6 -1
  22. package/dist/features/magic-context/search.d.ts.map +1 -1
  23. package/dist/features/magic-context/storage-host-instruction-retention.d.ts +11 -0
  24. package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
  25. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  26. package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
  27. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  28. package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
  29. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/auto-search-deadline.d.ts +2 -1
  32. package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
  34. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
  37. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/cache-busting-signals.d.ts +22 -1
  39. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -0
  41. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/compartment-trigger.d.ts +4 -2
  43. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
  45. package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
  46. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +9 -0
  47. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/host-served-rows.d.ts +25 -0
  51. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/inject-compartments.d.ts +7 -1
  53. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/lkg-slot.d.ts +1 -1
  57. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
  59. package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -1
  61. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/signed-thinking-hold.d.ts +59 -0
  64. package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -0
  65. package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts +8 -0
  66. package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts.map +1 -0
  67. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
  69. package/dist/hooks/magic-context/tag-messages.d.ts +6 -1
  70. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/todo-view.d.ts +2 -2
  72. package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
  73. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +6 -0
  75. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/transform-context-state.d.ts +19 -0
  77. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +19 -0
  79. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
  81. package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/transform.d.ts +1 -0
  83. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  84. package/dist/{index-9nkg2dzk.js → index-24fezq97.js} +3 -3
  85. package/dist/{index-v9asb16b.js → index-24jbw52d.js} +5 -5
  86. package/dist/{index-a8bvhwqs.js → index-2vxtcb95.js} +32 -3
  87. package/dist/{index-f71thw8j.js → index-4s3t0nd0.js} +1 -1
  88. package/dist/{index-6a6dq53h.js → index-6s5941tm.js} +5 -5
  89. package/dist/{index-fkx2qnvw.js → index-6x57ar45.js} +2 -2
  90. package/dist/{index-ek1yxvvz.js → index-936py2wm.js} +361 -70
  91. package/dist/{index-dqe8pq4x.js → index-a6mc0v4d.js} +6 -3
  92. package/dist/{index-hehkf6zm.js → index-b5vqckbw.js} +12 -6
  93. package/dist/{v2/server-wafzvyhg.js → index-beht37jy.js} +8 -0
  94. package/dist/{index-7b2cfmaz.js → index-bjcnntmz.js} +2 -2
  95. package/dist/{index-hqkczed7.js → index-c5pytzne.js} +22 -2
  96. package/dist/{index-nd7m2a5a.js → index-cf74k5ak.js} +27 -5
  97. package/dist/{index-kn4t1haw.js → index-e4xv8890.js} +531 -253
  98. package/dist/{index-cj9g0j7a.js → index-fgncb0ng.js} +7 -7
  99. package/dist/{index-5mwk1nek.js → index-jn12fvvh.js} +1 -1
  100. package/dist/{index-n6m03s3n.js → index-ke416mdc.js} +1 -1
  101. package/dist/{index-mtw9e71a.js → index-kq82mtg0.js} +2 -2
  102. package/dist/{index-n78avt2p.js → index-n37sebck.js} +1 -1
  103. package/dist/{index-wk0n1cgt.js → index-qn7xstt2.js} +2 -2
  104. package/dist/{index-v63beg1z.js → index-r4nkrs05.js} +3 -3
  105. package/dist/{index-j6zw70pf.js → index-rmwykbbb.js} +60 -21
  106. package/dist/{index-saews2s3.js → index-rr2bb45z.js} +1 -1
  107. package/dist/{index-ayym1x7f.js → index-s1ex9y6p.js} +195 -748
  108. package/dist/{index-7pa32z07.js → index-s734jcsr.js} +1 -1
  109. package/dist/{index-b17m64g9.js → index-s74zqahq.js} +1 -1
  110. package/dist/{index-4qfy7v57.js → index-s7j8tvhv.js} +31 -20
  111. package/dist/{index-wv9n2zcq.js → index-v8awdgvd.js} +4 -4
  112. package/dist/{index-p4vde22c.js → index-x4njr8df.js} +965 -77
  113. package/dist/{index-qrahzcqv.js → index-ze7mvk54.js} +10 -7
  114. package/dist/index.js +39 -39
  115. package/dist/{message-fts-rowid-map-yvx5a9jw.js → message-fts-rowid-map-17s0dfn4.js} +5 -3
  116. package/dist/{message-index-t4pz7akd.js → message-index-66jv6fh4.js} +13 -13
  117. package/dist/{message-index-bounded-6th8djy9.js → message-index-bounded-n1frdn85.js} +17 -17
  118. package/dist/{message-time-backfill-8egzkd3z.js → message-time-backfill-73mmm76q.js} +1 -1
  119. package/dist/migration-worker.js +8 -8
  120. package/dist/plugin/dream-timer.d.ts +11 -0
  121. package/dist/plugin/dream-timer.d.ts.map +1 -1
  122. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  123. package/dist/{project-embedding-registry-2dea0a77.js → project-embedding-registry-z74mhqkf.js} +10 -10
  124. package/dist/raw-ordinal-warmup-worker.js +10 -10
  125. package/dist/{read-session-chunk-4pwqxm5a.js → read-session-chunk-v06g3vka.js} +7 -7
  126. package/dist/{read-session-raw-5ar8se5v.js → read-session-raw-rsc8c7qy.js} +2 -2
  127. package/dist/{recomp-orchestrator-tjcaj5x7.js → recomp-orchestrator-ghpk2dtq.js} +24 -24
  128. package/dist/{search-archive-02jws7hw.js → search-archive-4d53y23e.js} +8 -8
  129. package/dist/{search-rb01n29x.js → search-nkf271d4.js} +20 -20
  130. package/dist/{send-session-notification-2x9edkrp.js → send-session-notification-6ve0e8p4.js} +4 -4
  131. package/dist/shared/historian-cache.d.ts +8 -0
  132. package/dist/shared/historian-cache.d.ts.map +1 -0
  133. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  134. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  135. package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
  136. package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
  137. package/dist/shared/rpc-server.d.ts +2 -0
  138. package/dist/shared/rpc-server.d.ts.map +1 -1
  139. package/dist/shared/search-text.d.ts +8 -0
  140. package/dist/shared/search-text.d.ts.map +1 -0
  141. package/dist/shared/sqlite.d.ts +4 -2
  142. package/dist/shared/sqlite.d.ts.map +1 -1
  143. package/dist/shared/storage-file-mutex.d.ts.map +1 -1
  144. package/dist/shared/subagent-runner.d.ts +2 -0
  145. package/dist/shared/subagent-runner.d.ts.map +1 -1
  146. package/dist/shared/system-directive.d.ts +2 -0
  147. package/dist/shared/system-directive.d.ts.map +1 -1
  148. package/dist/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
  149. package/dist/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
  150. package/dist/{storage-tags-4z1w27xa.js → storage-tags-r7k9tjcv.js} +8 -4
  151. package/dist/{transform-postprocess-phase-xaw5c3xp.js → transform-postprocess-phase-zpgav0h7.js} +24 -24
  152. package/dist/v2/auto-search-worker.js +76 -63
  153. package/dist/v2/chunk-embedding-write-worker.js +11 -11
  154. package/dist/v2/{compaction-marker-candidates-1vqwr3s5.js → compaction-marker-candidates-ebx3388k.js} +2 -2
  155. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  156. package/dist/v2/{context-acw1nhv8.js → context-f2xh7ba4.js} +1171 -448
  157. package/dist/v2/embedding-backfill-7c7yr69y.js +23 -0
  158. package/dist/v2/embedding-worker-process.js +1 -1
  159. package/dist/v2/embedding-worker.js +4 -4
  160. package/dist/v2/fold/native-replay.d.ts +11 -2
  161. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  162. package/dist/v2/fold/policy.d.ts.map +1 -1
  163. package/dist/v2/fold/restore.d.ts.map +1 -1
  164. package/dist/v2/hooks/context.d.ts.map +1 -1
  165. package/dist/v2/hooks/hidden-child.d.ts +8 -0
  166. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  167. package/dist/v2/hooks/payload.d.ts.map +1 -1
  168. package/dist/v2/hooks/types.d.ts +17 -0
  169. package/dist/v2/hooks/types.d.ts.map +1 -1
  170. package/dist/v2/{message-fts-rowid-map-8vf0v7cr.js → message-fts-rowid-map-wfx67gfd.js} +5 -3
  171. package/dist/v2/{message-index-e6qzw477.js → message-index-48f7hw7a.js} +13 -13
  172. package/dist/v2/{message-index-bounded-dsrf49y7.js → message-index-bounded-w3hfm29z.js} +17 -17
  173. package/dist/v2/{message-time-backfill-q5pgxf0d.js → message-time-backfill-04t0km1z.js} +1 -1
  174. package/dist/v2/migration-worker.js +8 -8
  175. package/dist/v2/{project-embedding-registry-rek75aqw.js → project-embedding-registry-gnkj56xp.js} +10 -10
  176. package/dist/v2/raw-ordinal-warmup-worker.js +10 -10
  177. package/dist/v2/{read-session-chunk-7bpygfv2.js → read-session-chunk-zpgmxwte.js} +7 -7
  178. package/dist/v2/{read-session-raw-pw2n1qgc.js → read-session-raw-yaegtjzh.js} +2 -2
  179. package/dist/v2/{recomp-orchestrator-hzpgg06e.js → recomp-orchestrator-4vfxej9t.js} +24 -24
  180. package/dist/v2/{search-archive-fn4wy8sx.js → search-archive-vv48s2aa.js} +8 -8
  181. package/dist/v2/{search-sf2vg5pk.js → search-kza414f0.js} +20 -20
  182. package/dist/v2/{send-session-notification-hmr7q0nt.js → send-session-notification-3pxn658x.js} +4 -4
  183. package/dist/v2/{server-n5q841qn.js → server-1nyybqan.js} +31 -20
  184. package/dist/v2/{server-785mb90s.js → server-1wy7b9de.js} +6 -3
  185. package/dist/v2/{server-0mzjjw3s.js → server-27gq4mfz.js} +27 -5
  186. package/dist/v2/{server-g59aatsz.js → server-2ehj0bw7.js} +965 -77
  187. package/dist/v2/{server-kqpawe1a.js → server-46neh5fa.js} +12 -6
  188. package/dist/v2/{server-rrqpvwqd.js → server-6tmj0s7j.js} +2 -2
  189. package/dist/v2/{server-kr2kc9dz.js → server-8by8qfec.js} +10 -7
  190. package/dist/v2/{server-r9gjxcte.js → server-a2eqhkxr.js} +7 -7
  191. package/dist/v2/{server-vbe4se57.js → server-a9xqj88f.js} +1 -1
  192. package/dist/{index-wafzvyhg.js → v2/server-beht37jy.js} +8 -0
  193. package/dist/v2/{server-6fyp0v67.js → server-bfpda1tb.js} +195 -749
  194. package/dist/v2/{server-05xjtq6c.js → server-d04vrx0j.js} +1 -1
  195. package/dist/v2/{server-zs8d0s3b.js → server-g3qma5c0.js} +1 -1
  196. package/dist/v2/{server-00hx04yn.js → server-gpvay0xz.js} +2 -2
  197. package/dist/v2/{server-gha9x4qq.js → server-h1v0pyxb.js} +2 -2
  198. package/dist/v2/{server-hgg55hde.js → server-hy3d3vsx.js} +1 -1
  199. package/dist/v2/{server-vgpab6rd.js → server-my7k4eds.js} +4 -4
  200. package/dist/v2/{server-d8tj10db.js → server-n1prf1g6.js} +1 -1
  201. package/dist/v2/{server-n78avt2p.js → server-n37sebck.js} +1 -1
  202. package/dist/v2/{server-y5pznjt9.js → server-nj659894.js} +5 -5
  203. package/dist/v2/{server-zyw55ygv.js → server-qv7f0hhe.js} +5 -5
  204. package/dist/v2/{server-e3ftpk7v.js → server-rmygf5pn.js} +32 -3
  205. package/dist/v2/{server-0ppsweh6.js → server-tgnbmwah.js} +22 -2
  206. package/dist/v2/{server-1hcbw661.js → server-xhab8jx8.js} +60 -21
  207. package/dist/v2/{server-6714jebr.js → server-xj136kt8.js} +1 -1
  208. package/dist/v2/{server-aavz8pm6.js → server-zzkj2fch.js} +3 -3
  209. package/dist/v2/server.js +4 -4
  210. package/dist/v2/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
  211. package/dist/v2/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
  212. package/dist/v2/{storage-tags-hkwtbp3g.js → storage-tags-3wdb8zph.js} +8 -4
  213. package/dist/v2/store-reader.d.ts +8 -0
  214. package/dist/v2/store-reader.d.ts.map +1 -1
  215. package/dist/v2/{wrapup-orchestrator-x4xj1782.js → wrapup-orchestrator-psqz7yh0.js} +24 -24
  216. package/dist/wrapup-orchestrator-s9zc5b00.js +48 -0
  217. package/package.json +1 -1
  218. package/src/config/latch-permanence-guard.test.ts +4 -0
  219. package/src/shared/historian-cache.test.ts +69 -0
  220. package/src/shared/historian-cache.ts +55 -0
  221. package/src/shared/model-suggestion-retry.ts +2 -0
  222. package/src/shared/rpc-discovery-cleanup.test.ts +57 -0
  223. package/src/shared/rpc-discovery-cleanup.ts +57 -0
  224. package/src/shared/rpc-server.ts +36 -13
  225. package/src/shared/search-text.test.ts +47 -0
  226. package/src/shared/search-text.ts +63 -0
  227. package/src/shared/sqlite.test.ts +56 -0
  228. package/src/shared/sqlite.ts +51 -2
  229. package/src/shared/storage-file-mutex-review.test.ts +22 -2
  230. package/src/shared/storage-file-mutex.ts +11 -1
  231. package/src/shared/subagent-runner.ts +2 -0
  232. package/src/shared/system-directive.ts +19 -1
  233. package/src/shared/tag-transcript.ts +12 -4
  234. package/dist/v2/embedding-backfill-jyd6492b.js +0 -23
  235. package/dist/wrapup-orchestrator-vj2tbp22.js +0 -48
@@ -2,10 +2,10 @@ import {
2
2
  getSqliteDatabasePath2,
3
3
  withSqliteBackgroundWriter2,
4
4
  withoutSqliteTransformPass2
5
- } from "./index-wafzvyhg.js";
5
+ } from "./index-beht37jy.js";
6
6
  import {
7
7
  runSessionWarmupWorker
8
- } from "./index-7pa32z07.js";
8
+ } from "./index-s734jcsr.js";
9
9
  import {
10
10
  logSlowWriteTransaction
11
11
  } from "./index-k29z4aqh.js";
@@ -168,6 +168,9 @@ function messageFtsOrdinalRangeIsMapped2(db, sessionId, startOrdinal, endOrdinal
168
168
  const ordinalCount = endOrdinal - startOrdinal + 1;
169
169
  return row?.sourceOrdinalCount === ordinalCount && row.expectedMapCount === row.mappedCount;
170
170
  }
171
+ function getMessageFtsRowidMapBackfillProgress2(db) {
172
+ return getBackfillState(db);
173
+ }
171
174
  function deleteUnmappedMessageFtsRows2(db, sessionIds) {
172
175
  if (sessionIds.length === 0)
173
176
  return;
@@ -179,4 +182,4 @@ function deleteUnmappedMessageFtsRows2(db, sessionIds) {
179
182
  WHERE rowid > ? AND session_id IN (${placeholders})`).run(state.watermarkRowid, ...sessionIds);
180
183
  }
181
184
 
182
- export { recordMessageFtsRowid2, recordIndexedMessageTime2, runMessageFtsRowidMapBackfill2, startMessageFtsRowidMapBackfill2, messageFtsOrdinalRangeIsMapped2, deleteUnmappedMessageFtsRows2 };
185
+ export { recordMessageFtsRowid2, recordIndexedMessageTime2, runMessageFtsRowidMapBackfill2, startMessageFtsRowidMapBackfill2, messageFtsOrdinalRangeIsMapped2, getMessageFtsRowidMapBackfillProgress2, deleteUnmappedMessageFtsRows2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getTokenEstimatorFingerprint,
3
3
  estimateTokens
4
- } from "./index-hqkczed7.js";
4
+ } from "./index-c5pytzne.js";
5
5
  import {
6
6
  getHarness2
7
7
  } from "./index-pavzsdc6.js";
@@ -10,10 +10,10 @@ import {
10
10
  } from "./index-j75v2476.js";
11
11
  import {
12
12
  isSynapseEmbeddingTruncated
13
- } from "./index-fkx2qnvw.js";
13
+ } from "./index-6x57ar45.js";
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped2
16
- } from "./index-dqe8pq4x.js";
16
+ } from "./index-a6mc0v4d.js";
17
17
 
18
18
  // src/features/magic-context/compartment-chunk-embedding.ts
19
19
  import { createHash } from "node:crypto";
@@ -900,12 +900,18 @@ var BACKOFF_PREFIX = "chunk_embed_backoff:";
900
900
  function backoffKey(compartmentId) {
901
901
  return `${BACKOFF_PREFIX}${compartmentId}`;
902
902
  }
903
- function deleteChunkEmbedBackoffForSession(db, sessionId) {
904
- db.prepare(`DELETE FROM schema_migrations_meta WHERE key IN (
903
+ function deleteChunkEmbedBackoffForSession(db, sessionId, limit) {
904
+ if (limit !== undefined)
905
+ return db.prepare(`DELETE FROM schema_migrations_meta WHERE key IN (
906
+ SELECT key FROM schema_migrations_meta JOIN compartments
907
+ ON key = ? || compartments.id OR key = ? || compartments.id
908
+ WHERE compartments.session_id = ? LIMIT ?
909
+ )`).run(BACKOFF_PREFIX, WINDOW_SOURCE_PREFIX, sessionId, limit).changes;
910
+ return db.prepare(`DELETE FROM schema_migrations_meta WHERE key IN (
905
911
  SELECT ? || id FROM compartments WHERE session_id = ?
906
912
  UNION ALL
907
913
  SELECT ? || id FROM compartments WHERE session_id = ?
908
- )`).run(BACKOFF_PREFIX, sessionId, WINDOW_SOURCE_PREFIX, sessionId);
914
+ )`).run(BACKOFF_PREFIX, sessionId, WINDOW_SOURCE_PREFIX, sessionId).changes;
909
915
  }
910
916
  function recordChunkEmbedBackoff(db, candidate, projectPath, modelId) {
911
917
  const mapped = buildCanonicalChunkTextFromFts(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
@@ -29,6 +29,14 @@ function detectSqliteRuntime2() {
29
29
  var bunSpec = "bun:" + "sqlite";
30
30
  var nodeSpec = "node:" + "sqlite";
31
31
  async function importSqliteModule(specifier) {
32
+ if (specifier === nodeSpec && typeof process.getBuiltinModule === "function") {
33
+ const loaded = process.getBuiltinModule(specifier);
34
+ if (loaded)
35
+ return loaded;
36
+ throw Object.assign(new Error(`No such built-in module: ${specifier}`), {
37
+ code: "ERR_UNKNOWN_BUILTIN_MODULE"
38
+ });
39
+ }
32
40
  return await import(specifier);
33
41
  }
34
42
  function isModuleNotFoundError(error, specifier) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-wgypt3cs.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
- } from "./index-fkx2qnvw.js";
6
+ } from "./index-6x57ar45.js";
7
7
  import {
8
8
  getHarness2
9
9
  } from "./index-pavzsdc6.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./index-j75v2476.js";
17
17
  import {
18
18
  inRootAsyncContext2
19
- } from "./index-wafzvyhg.js";
19
+ } from "./index-beht37jy.js";
20
20
  import {
21
21
  computeNormalizedHash
22
22
  } from "./index-2bvekkfy.js";
@@ -29,7 +29,27 @@ function isSystemDirective(text) {
29
29
  return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
30
30
  }
31
31
  function removeSystemReminders(text) {
32
- return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
32
+ return removeNestedBlocks(text, ["system-reminder"]).trim();
33
+ }
34
+ function removeNestedBlocks(text, names) {
35
+ const tags = new RegExp(`<(/?)(${names.join("|")})(?:\\s[^<>]*?)?\\s*(/?)>`, "gi");
36
+ const stack = [];
37
+ let end = 0;
38
+ let result = "";
39
+ for (const match of text.matchAll(tags)) {
40
+ if (stack.length === 0)
41
+ result += text.slice(end, match.index);
42
+ const name = match[2].toLowerCase();
43
+ if (match[1]) {
44
+ if (stack[stack.length - 1] === name)
45
+ stack.pop();
46
+ } else if (!match[3])
47
+ stack.push(name);
48
+ end = match.index + match[0].length;
49
+ }
50
+ if (stack.length === 0)
51
+ result += text.slice(end);
52
+ return result;
33
53
  }
34
54
 
35
55
  // src/hooks/magic-context/token-count-exact.ts
@@ -730,4 +750,4 @@ function mergeCommitHashes(existing, next) {
730
750
  return merged;
731
751
  }
732
752
 
733
- export { textMentionsRecentCommit, OMO_INTERNAL_INITIATOR_MARKER, isSystemDirective, removeSystemReminders, hasMeaningfulUserText2, extractTexts2, extractToolResultBodyTokens, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, getTokenEstimatorFingerprint, hasTokenizerForFit, tokenCountUsesByteBound, estimateTokens, createTokenCountMemo, estimateFixedPromptTokens, normalizeText, compactRole, formatBlock, compactTextForSummary, mergeCommitHashes };
753
+ export { textMentionsRecentCommit, OMO_INTERNAL_INITIATOR_MARKER, isSystemDirective, removeSystemReminders, removeNestedBlocks, hasMeaningfulUserText2, extractTexts2, extractToolResultBodyTokens, extractToolCallSummaries, getTokenizerNativeMemoryStats, preloadTokenizer, getTokenEstimatorFingerprint, hasTokenizerForFit, tokenCountUsesByteBound, estimateTokens, createTokenCountMemo, estimateFixedPromptTokens, normalizeText, compactRole, formatBlock, compactTextForSummary, mergeCommitHashes };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./index-hqkczed7.js";
7
+ } from "./index-c5pytzne.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./index-pavzsdc6.js";
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
17
- } from "./index-wafzvyhg.js";
17
+ } from "./index-beht37jy.js";
18
18
  import {
19
19
  tagIdentityRevisionKey,
20
20
  tagOrderConstraintIndex,
@@ -68,8 +68,8 @@ function protectedToolTokenCount(tags, counts, calibration) {
68
68
  var encoder = new TextEncoder;
69
69
  var TAG_PREFIX_REGEX = /^(?:§\d+§\s*)+/;
70
70
  var MALFORMED_TAG_PREFIX_REGEX = /^(?:§\d+">§(?:\d+§)?\s*)+/;
71
- var DANGLING_TAG_GLOBAL_REGEX = /\u00a7\d+(?!\.\d)[^\s\u00a7\w.]?/g;
72
- var DANGLING_TAG_PREFIX_REGEX = /^(?:\u00a7\d+(?!\.\d)[^\s\u00a7\w.]?\s*)+/;
71
+ var DANGLING_TAG_GLOBAL_REGEX = /\u00a7\d+(?!\d)(?!\.\d)[^\s\u00a7\w.]?/g;
72
+ var DANGLING_TAG_PREFIX_REGEX = /^(?:\u00a7\d+(?!\d)(?!\.\d)[^\s\u00a7\w.]?\s*)+/;
73
73
  var COMPLETE_TAG_PAIR_GLOBAL_REGEX = /\u00a7\d+\u00a7/g;
74
74
  var MALFORMED_TAG_GLOBAL_REGEX = /\u00a7\d+">(?:\u00a7(?:\d+\u00a7)?)?/g;
75
75
  var STRAY_SECTION_CHAR_REGEX = /\u00a7/g;
@@ -2279,6 +2279,17 @@ function getUpdateTagDropModeStatement(db) {
2279
2279
  }
2280
2280
  var updateTagByteSizeStatements = new WeakMap;
2281
2281
  var updateTagInputByteSizeStatements = new WeakMap;
2282
+ function getUpdateTagByteSizeStatement(db) {
2283
+ let stmt = updateTagByteSizeStatements.get(db);
2284
+ if (!stmt) {
2285
+ stmt = db.prepare("UPDATE tags SET byte_size = ? WHERE session_id = ? AND tag_number = ?");
2286
+ updateTagByteSizeStatements.set(db, stmt);
2287
+ }
2288
+ return stmt;
2289
+ }
2290
+ function updateTagByteSize2(db, sessionId, tagNumber, newByteSize) {
2291
+ getUpdateTagByteSizeStatement(db).run(newByteSize, sessionId, tagNumber);
2292
+ }
2282
2293
  var RECENT_OWNER_SCAN_PAGE_SIZE = 128;
2283
2294
  var recentTagOwnerStatements = new WeakMap;
2284
2295
  function ownerMessageIdForTagRow(row) {
@@ -2477,6 +2488,17 @@ function getActiveTagTokenTotalsByMessage2(db, sessionId, messageIds) {
2477
2488
  }
2478
2489
  var updateTagTokenCountStatements = new WeakMap;
2479
2490
  var updateTagInputTokenCountStatements = new WeakMap;
2491
+ function getUpdateTagTokenCountStatement(db) {
2492
+ let stmt = updateTagTokenCountStatements.get(db);
2493
+ if (!stmt) {
2494
+ stmt = db.prepare("UPDATE tags SET token_count = MAX(COALESCE(token_count, 0), ?) WHERE session_id = ? AND tag_number = ?");
2495
+ updateTagTokenCountStatements.set(db, stmt);
2496
+ }
2497
+ return stmt;
2498
+ }
2499
+ function updateTagTokenCount2(db, sessionId, tagNumber, newTokenCount) {
2500
+ getUpdateTagTokenCountStatement(db).run(newTokenCount, sessionId, tagNumber);
2501
+ }
2480
2502
  function getPersistedToolTagAccounting2(db, sessionId, tagNumber) {
2481
2503
  const row = db.prepare(`SELECT byte_size AS byteSize,
2482
2504
  token_count AS tokenCount,
@@ -3848,4 +3870,4 @@ function deleteToolTagsByOwner(db, sessionId, ownerMsgId) {
3848
3870
  return getDeleteToolTagsByOwnerStatement(db).all(sessionId, ownerMsgId).length;
3849
3871
  }
3850
3872
 
3851
- export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
3873
+ export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, updateTagByteSize2, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, updateTagTokenCount2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };