@cortexkit/opencode-magic-context 0.49.7 → 0.49.9

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 (252) hide show
  1. package/dist/agents/hidden-agent-registrations.d.ts +5 -3
  2. package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
  3. package/dist/auto-search-worker.js +6 -6
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/{compaction-marker-candidates-a0edbqrr.js → compaction-marker-candidates-xxz35vwp.js} +3 -3
  6. package/dist/config/schema/agent-overrides.d.ts +13 -13
  7. package/dist/config/schema/magic-context.d.ts +500 -500
  8. package/dist/{conflict-warning-hook-myk5hbt9.js → conflict-warning-hook-w3crzrar.js} +8 -8
  9. package/dist/{context-ffr7e0g7.js → context-ey3ap3cc.js} +81 -53
  10. package/dist/{derive-budgets-j4ry8j8n.js → derive-budgets-3nbxsyss.js} +2 -2
  11. package/dist/embedding-backfill-3h2m5n0q.js +21 -0
  12. package/dist/embedding-worker-process.js +6 -2
  13. package/dist/embedding-worker.js +6 -5
  14. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/cron.d.ts +2 -0
  16. package/dist/features/magic-context/dreamer/cron.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +1 -0
  18. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
  19. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  20. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  21. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  22. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  23. package/dist/features/magic-context/primer-clustering.d.ts.map +1 -1
  24. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  25. package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts +1 -1
  26. package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts.map +1 -1
  27. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  28. package/dist/features/magic-context/smart-notes/wake-plane.d.ts.map +1 -1
  29. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  30. package/dist/history-owner-ty29fz0f.js +244 -0
  31. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts +34 -0
  33. package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts.map +1 -0
  34. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +1 -0
  39. package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
  42. package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
  44. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/module-transport.d.ts +1 -0
  48. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/provider-visible-parts.d.ts +10 -4
  50. package/dist/hooks/magic-context/provider-visible-parts.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/read-session-chunk.d.ts +8 -4
  53. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
  55. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/supersession-reclaim.d.ts +5 -3
  58. package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +18 -0
  60. package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -0
  61. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +5 -1
  62. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/tool-reclaim.d.ts +5 -2
  65. package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
  67. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  69. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
  70. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  72. package/dist/{index-g8qbdb03.js → index-0jz47061.js} +6 -3
  73. package/dist/{index-wq16ahsn.js → index-0x9cn9w1.js} +8 -8
  74. package/dist/{index-4mjhqadz.js → index-150zz6fh.js} +1 -1
  75. package/dist/{index-n7kwfw2r.js → index-16vwdyy5.js} +7 -7
  76. package/dist/{index-rwmpkss5.js → index-21919gcq.js} +4 -4
  77. package/dist/{index-5tbvdff4.js → index-3403gbzj.js} +200 -135
  78. package/dist/{index-0gyq3djm.js → index-4hb8nt93.js} +3 -3
  79. package/dist/{index-ebnngykq.js → index-6k86es2p.js} +142 -27
  80. package/dist/{index-ax2jhztn.js → index-7bjgyaj1.js} +4 -4
  81. package/dist/{index-h2wc01qk.js → index-9jvab89d.js} +2 -2
  82. package/dist/{index-w6bd03dc.js → index-a43xq1pg.js} +5 -5
  83. package/dist/{index-tqf7yg27.js → index-a4b0gbyg.js} +1 -1
  84. package/dist/{index-j5hce1ab.js → index-a865mj02.js} +5 -5
  85. package/dist/{index-37q80veb.js → index-angx1s0k.js} +4 -3
  86. package/dist/{index-z1tjp257.js → index-b64n4d0h.js} +1 -1
  87. package/dist/{index-gbmqa9x9.js → index-bmwfzz28.js} +9 -6
  88. package/dist/{index-tmtty2x5.js → index-f8cn4xqa.js} +290 -61
  89. package/dist/{index-j58gqrn2.js → index-ffa8x2as.js} +31 -24
  90. package/dist/{index-1bt88epp.js → index-g7jkrz0x.js} +36 -16
  91. package/dist/{index-qx53vezw.js → index-gjvjh960.js} +1 -1
  92. package/dist/{index-w23dh319.js → index-jw4gbfkv.js} +1 -1
  93. package/dist/index-knvkbfvh.js +25 -0
  94. package/dist/{index-vkbqdnkj.js → index-kvw6xew3.js} +6 -3
  95. package/dist/{index-rzmjkdd6.js → index-mp2kghkv.js} +3 -27
  96. package/dist/{index-nsjyysj0.js → index-mvvephtj.js} +5 -1
  97. package/dist/{index-9yyqq3mm.js → index-n78avt2p.js} +1 -1
  98. package/dist/{index-w6vr754t.js → index-nenz4gpb.js} +13 -9
  99. package/dist/{index-vt4sf4ep.js → index-pgy3h49n.js} +4 -4
  100. package/dist/{v2/server-1rfgbjfn.js → index-q28hsbpg.js} +15 -3
  101. package/dist/{index-a8acx4gc.js → index-q76br5zn.js} +3 -3
  102. package/dist/{index-sf94at64.js → index-rg1cezmj.js} +22 -22
  103. package/dist/{index-sh91t19a.js → index-s178h9z8.js} +4 -3
  104. package/dist/{index-4btknbqh.js → index-swgpe402.js} +48 -38
  105. package/dist/{index-k6xvbj2e.js → index-w28y7d0z.js} +2 -0
  106. package/dist/{index-j8epsc0g.js → index-wafzvyhg.js} +33 -10
  107. package/dist/{index-n5a170gs.js → index-wpwpn7nj.js} +166 -63
  108. package/dist/{index-tagss15p.js → index-x57ep4fp.js} +124 -63
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +84 -79
  111. package/dist/{logger-ewak5q1s.js → logger-wn328tfg.js} +1 -1
  112. package/dist/{message-index-rqtse28y.js → message-index-6r1x9cqh.js} +16 -16
  113. package/dist/{message-index-bounded-04rycpx4.js → message-index-bounded-fskdyc81.js} +16 -16
  114. package/dist/{message-time-backfill-a5ytnp53.js → message-time-backfill-nb5hhnrt.js} +3 -3
  115. package/dist/migration-worker.js +11 -11
  116. package/dist/plugin/boot-quiet.d.ts.map +1 -1
  117. package/dist/plugin/dream-timer.d.ts.map +1 -1
  118. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  119. package/dist/plugin/rpc-handlers.d.ts +2 -0
  120. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  121. package/dist/{project-embedding-registry-k0sd9k7v.js → project-embedding-registry-vy7sv9jt.js} +11 -11
  122. package/dist/raw-ordinal-warmup-worker.js +6 -6
  123. package/dist/{read-session-chunk-h1btx938.js → read-session-chunk-zgpvs423.js} +11 -11
  124. package/dist/{read-session-raw-vdf4wh78.js → read-session-raw-gm6xj30v.js} +3 -3
  125. package/dist/recomp-orchestrator-77xc8wpe.js +60 -0
  126. package/dist/{safe-notification-target-q0cyrx3x.js → safe-notification-target-jdynm677.js} +2 -2
  127. package/dist/{search-3rbdx6hw.js → search-72fkjwk2.js} +24 -24
  128. package/dist/{send-session-notification-2tp44tfa.js → send-session-notification-q8ngbap3.js} +6 -6
  129. package/dist/shared/hidden-zen-read.d.ts +24 -0
  130. package/dist/shared/hidden-zen-read.d.ts.map +1 -0
  131. package/dist/shared/history-owner.d.ts +12 -0
  132. package/dist/shared/history-owner.d.ts.map +1 -0
  133. package/dist/shared/off-thread-migration-clock.d.ts +8 -1
  134. package/dist/shared/off-thread-migration-clock.d.ts.map +1 -1
  135. package/dist/shared/reclaim-distance.d.ts +33 -0
  136. package/dist/shared/reclaim-distance.d.ts.map +1 -0
  137. package/dist/shared/redaction.d.ts.map +1 -1
  138. package/dist/shared/rpc-server.d.ts.map +1 -1
  139. package/dist/shared/sqlite.d.ts +2 -0
  140. package/dist/shared/sqlite.d.ts.map +1 -1
  141. package/dist/shared/stable-json.d.ts +7 -0
  142. package/dist/shared/stable-json.d.ts.map +1 -1
  143. package/dist/shared/tail-hygiene-json.d.ts +22 -0
  144. package/dist/shared/tail-hygiene-json.d.ts.map +1 -0
  145. package/dist/shared/transcript.d.ts +5 -0
  146. package/dist/shared/transcript.d.ts.map +1 -1
  147. package/dist/shared/user-facing-codes.d.ts +2 -2
  148. package/dist/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
  149. package/dist/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
  150. package/dist/{storage-tags-61z5j2f9.js → storage-tags-35m4gms2.js} +5 -5
  151. package/dist/{transform-postprocess-phase-7qts7h54.js → transform-postprocess-phase-r8d406j0.js} +30 -30
  152. package/dist/v2/auto-search-worker.js +6 -6
  153. package/dist/v2/{compaction-marker-candidates-6nypjkpf.js → compaction-marker-candidates-a15w3mqh.js} +3 -3
  154. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  155. package/dist/v2/{context-xq4rtywr.js → context-z2yagwy4.js} +293 -91
  156. package/dist/v2/{derive-budgets-enckmg7y.js → derive-budgets-0rmpmxjw.js} +3 -3
  157. package/dist/v2/embedding-backfill-vr7wdtrf.js +20 -0
  158. package/dist/v2/embedding-worker-process.js +6 -2
  159. package/dist/v2/embedding-worker.js +6 -5
  160. package/dist/v2/hidden-completion.d.ts.map +1 -1
  161. package/dist/v2/history-owner-2cr9py37.js +243 -0
  162. package/dist/v2/hooks/context.d.ts.map +1 -1
  163. package/dist/v2/hooks/hidden-child.d.ts +2 -2
  164. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  165. package/dist/v2/hooks/store.d.ts +1 -0
  166. package/dist/v2/hooks/store.d.ts.map +1 -1
  167. package/dist/v2/{logger-pj02s7sr.js → logger-te6e1j72.js} +1 -1
  168. package/dist/v2/{message-index-8e5z2xx8.js → message-index-9ezq6wze.js} +16 -16
  169. package/dist/v2/{message-index-bounded-5vh1h2g7.js → message-index-bounded-rqc603f2.js} +16 -16
  170. package/dist/v2/{message-time-backfill-2z365239.js → message-time-backfill-rz1pnpaj.js} +3 -3
  171. package/dist/v2/migration-worker.js +11 -11
  172. package/dist/v2/{project-embedding-registry-b77awytr.js → project-embedding-registry-ja23aygk.js} +11 -11
  173. package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
  174. package/dist/v2/{read-session-chunk-4sat83cx.js → read-session-chunk-7f87tg2q.js} +11 -11
  175. package/dist/v2/{read-session-raw-a3hw9jsp.js → read-session-raw-h4azh85b.js} +3 -3
  176. package/dist/v2/recomp-orchestrator-s5tdpsbs.js +59 -0
  177. package/dist/v2/{safe-notification-target-y3p1hce9.js → safe-notification-target-936374xx.js} +2 -2
  178. package/dist/v2/search-2td1b1wy.js +46 -0
  179. package/dist/v2/{send-session-notification-ppgc8qdz.js → send-session-notification-6n7chhyp.js} +6 -6
  180. package/dist/v2/{server-v4fwha43.js → server-23znwjqk.js} +48 -38
  181. package/dist/v2/{server-nfan6zb6.js → server-2hxypdx5.js} +31 -24
  182. package/dist/v2/{server-ras2sxnc.js → server-44ryn9rb.js} +9 -6
  183. package/dist/v2/{server-fw31krgq.js → server-4easnf78.js} +19 -19
  184. package/dist/v2/{server-d6g4whc2.js → server-4qr18rfg.js} +3 -3
  185. package/dist/v2/{server-sy4b1sra.js → server-4rs8sm06.js} +5 -5
  186. package/dist/v2/{server-jdwd03ep.js → server-4zwx20yg.js} +7 -7
  187. package/dist/v2/{server-brhj8qtd.js → server-63ha7f0f.js} +3 -27
  188. package/dist/v2/{server-3t0q2cqx.js → server-7dv9wt9r.js} +1 -1
  189. package/dist/v2/{server-cw6521wn.js → server-7e087rvk.js} +2 -0
  190. package/dist/v2/{server-6byqfbqf.js → server-89fcbe37.js} +36 -16
  191. package/dist/v2/{server-hb6xhh9q.js → server-988cqjme.js} +6 -3
  192. package/dist/v2/{server-fpqe39as.js → server-9a6bwc12.js} +4 -4
  193. package/dist/v2/{server-t4k4qexw.js → server-9e5r8y60.js} +5 -1
  194. package/dist/v2/{server-qcw43339.js → server-ak7w74j9.js} +4 -4
  195. package/dist/v2/{server-dd0nja67.js → server-bx59ezg6.js} +4 -3
  196. package/dist/v2/{server-mv1w7t6z.js → server-c9w52qss.js} +99 -43
  197. package/dist/v2/{server-676xw7at.js → server-ckrb5rm8.js} +1 -1
  198. package/dist/{index-w4mw92w3.js → v2/server-cxsr0ng6.js} +15 -3
  199. package/dist/v2/{server-hcvcxzx7.js → server-f27he3j1.js} +5 -5
  200. package/dist/v2/{server-gtv9wbhq.js → server-gc8x2xdb.js} +144 -63
  201. package/dist/v2/{server-t528t8qm.js → server-hn9fb3v0.js} +2 -2
  202. package/dist/v2/{server-w3zeywp1.js → server-kmapq3v0.js} +289 -60
  203. package/dist/v2/server-knvkbfvh.js +25 -0
  204. package/dist/v2/{server-9yyqq3mm.js → server-n78avt2p.js} +1 -1
  205. package/dist/v2/{server-kdrezdy0.js → server-njnx39q2.js} +6 -3
  206. package/dist/v2/{server-x08d1xf3.js → server-npm52h2q.js} +4 -3
  207. package/dist/v2/{server-vb7pbd9p.js → server-nveratm5.js} +1 -1
  208. package/dist/v2/{server-kzns2hbz.js → server-s6jqh8bj.js} +1 -1
  209. package/dist/v2/{server-j8epsc0g.js → server-wafzvyhg.js} +33 -10
  210. package/dist/v2/{server-7ekna9zs.js → server-xqf2d2mg.js} +2 -2
  211. package/dist/v2/{server-7srtwsa4.js → server-z0rjemg1.js} +9 -9
  212. package/dist/v2/{server-wkdgjjch.js → server-zrwaj29a.js} +2 -2
  213. package/dist/v2/server.js +7 -6
  214. package/dist/v2/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
  215. package/dist/v2/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
  216. package/dist/v2/{storage-tags-j2fzq3sw.js → storage-tags-c4zfcxv4.js} +5 -5
  217. package/dist/v2/store-reader.d.ts.map +1 -1
  218. package/dist/v2/{wrapup-orchestrator-s92ebfzv.js → wrapup-orchestrator-wg8dmmm9.js} +38 -35
  219. package/dist/wrapup-orchestrator-b1z99yg5.js +47 -0
  220. package/package.json +1 -1
  221. package/src/agents/hidden-agent-registrations.ts +22 -4
  222. package/src/config/compaction-accessor-guard.test.ts +3 -0
  223. package/src/features/magic-context/dreamer/cron.ts +8 -0
  224. package/src/shared/hidden-zen-read.test.ts +99 -0
  225. package/src/shared/hidden-zen-read.ts +88 -0
  226. package/src/shared/history-owner.test.ts +60 -0
  227. package/src/shared/history-owner.ts +43 -0
  228. package/src/shared/host-stall-profiler-node.ts +3 -1
  229. package/src/shared/host-stall-profiler.ts +3 -1
  230. package/src/shared/off-thread-migration-clock.test.ts +80 -10
  231. package/src/shared/off-thread-migration-clock.ts +37 -13
  232. package/src/shared/reclaim-distance.test.ts +111 -0
  233. package/src/shared/reclaim-distance.ts +91 -0
  234. package/src/shared/redaction.test.ts +16 -0
  235. package/src/shared/redaction.ts +8 -1
  236. package/src/shared/root-async-context.probe.mjs +36 -0
  237. package/src/shared/root-async-context.test.ts +49 -0
  238. package/src/shared/rpc-server.ts +27 -23
  239. package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
  240. package/src/shared/sqlite-foreground-wait.test.ts +253 -1
  241. package/src/shared/sqlite.ts +55 -14
  242. package/src/shared/stable-json.ts +56 -14
  243. package/src/shared/tail-hygiene-json.test.ts +117 -0
  244. package/src/shared/tail-hygiene-json.ts +217 -0
  245. package/src/shared/transcript.ts +7 -0
  246. package/src/shared/user-facing-codes.ts +2 -2
  247. package/dist/embedding-backfill-re16xncd.js +0 -21
  248. package/dist/recomp-orchestrator-trcgmm23.js +0 -60
  249. package/dist/v2/embedding-backfill-xd9ygzgd.js +0 -20
  250. package/dist/v2/recomp-orchestrator-n11zv1f1.js +0 -59
  251. package/dist/v2/search-mvgqtkkz.js +0 -46
  252. package/dist/wrapup-orchestrator-df61jmz9.js +0 -47
@@ -4,25 +4,26 @@ import {
4
4
  import {
5
5
  sanitizeDiagnosticText,
6
6
  log2
7
- } from "./index-nsjyysj0.js";
7
+ } from "./index-mvvephtj.js";
8
8
  import {
9
9
  isUserHomeDirectory,
10
10
  setBootQuietPeriodForTests
11
- } from "./index-g8qbdb03.js";
11
+ } from "./index-0jz47061.js";
12
12
  import {
13
+ inRootAsyncContext2,
13
14
  withSqliteBackgroundWriter2,
14
15
  withoutSqliteTransformPass2,
15
16
  isTransientSqliteError2
16
- } from "./index-j8epsc0g.js";
17
+ } from "./index-wafzvyhg.js";
17
18
  import {
18
19
  estimateTokens
19
- } from "./index-qx53vezw.js";
20
+ } from "./index-gjvjh960.js";
20
21
  import {
21
22
  SYNAPSE_DEFAULT_MODEL,
22
23
  isSynapseEmbeddingTruncated,
23
24
  getSynapseBatchRequestKey,
24
25
  SynapseEmbeddingProvider
25
- } from "./index-vkbqdnkj.js";
26
+ } from "./index-kvw6xew3.js";
26
27
  import {
27
28
  CHUNK_WINDOW_SAFETY_RATIO,
28
29
  normalizeCompartmentChunkMaxInputTokens,
@@ -39,10 +40,17 @@ import {
39
40
  countSessionCompartmentEmbedCoverage,
40
41
  countSessionCompartmentEmbedCoveragePolite,
41
42
  countUnembeddedSessionCompartmentsPolite
42
- } from "./index-ax2jhztn.js";
43
+ } from "./index-7bjgyaj1.js";
43
44
  import {
44
45
  DEFAULT_LOCAL_EMBEDDING_MODEL
45
- } from "./index-k6xvbj2e.js";
46
+ } from "./index-w28y7d0z.js";
47
+ import {
48
+ embeddingModelsMatch,
49
+ resolveEmbeddingTextPrefixes,
50
+ getEmbeddingProviderIdentity,
51
+ dominantEmbeddingFailure,
52
+ LocalEmbeddingProvider
53
+ } from "./index-bmwfzz28.js";
46
54
  import {
47
55
  isEmbeddingHostBusy2
48
56
  } from "./index-qt1qqasc.js";
@@ -51,16 +59,9 @@ import {
51
59
  getMemoryEmbedCoverage,
52
60
  invalidateProject2
53
61
  } from "./index-4dhv7mqz.js";
54
- import {
55
- embeddingModelsMatch,
56
- resolveEmbeddingTextPrefixes,
57
- getEmbeddingProviderIdentity,
58
- dominantEmbeddingFailure,
59
- LocalEmbeddingProvider
60
- } from "./index-gbmqa9x9.js";
61
62
  import {
62
63
  logSlowWriteTransaction
63
- } from "./index-4mjhqadz.js";
64
+ } from "./index-150zz6fh.js";
64
65
 
65
66
  // src/features/magic-context/session-project-storage.ts
66
67
  var SESSION_CHUNK_REPAIR_BATCH_SIZE = 100;
@@ -1016,7 +1017,6 @@ function listShadowBackfillStalls2(db, projectIdentity) {
1016
1017
  }
1017
1018
  return stalls;
1018
1019
  }
1019
-
1020
1020
  // src/features/magic-context/project-embedding-registry.ts
1021
1021
  var OFF_PROVIDER_IDENTITY = "embedding-provider:off";
1022
1022
  var SWEEP_MAX_WALL_CLOCK_MS = 10 * 60 * 1000;
@@ -2608,12 +2608,12 @@ async function drainCommitBacklogForProject2(db, projectIdentity, deadline) {
2608
2608
  }
2609
2609
  let total = 0;
2610
2610
  let leaseLost = false;
2611
- const renewal = setInterval(() => {
2611
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2612
2612
  try {
2613
2613
  if (!renewGitSweepLease(db, projectIdentity, holderId))
2614
2614
  leaseLost = true;
2615
2615
  } catch {}
2616
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2616
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2617
2617
  renewal.unref?.();
2618
2618
  try {
2619
2619
  while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < COMMIT_DRAIN_MAX_PER_SWEEP) {
@@ -2777,12 +2777,12 @@ async function drainCompartmentChunkBacklogForProject(db, projectIdentity, deadl
2777
2777
  }
2778
2778
  let total = 0;
2779
2779
  let leaseLost = false;
2780
- const renewal = setInterval(() => {
2780
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2781
2781
  try {
2782
2782
  if (!renewGitSweepLease(db, projectIdentity, holderId))
2783
2783
  leaseLost = true;
2784
2784
  } catch {}
2785
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2785
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2786
2786
  renewal.unref?.();
2787
2787
  try {
2788
2788
  while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < CHUNK_DRAIN_MAX_PER_SWEEP) {
@@ -2823,14 +2823,14 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
2823
2823
  drainAbort.abort();
2824
2824
  else
2825
2825
  options?.signal?.addEventListener("abort", forwardCallerAbort, { once: true });
2826
- const renewal = setInterval(() => {
2826
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2827
2827
  try {
2828
2828
  if (!renewGitSweepLease(db, projectIdentity, holderId)) {
2829
2829
  leaseLost = true;
2830
2830
  drainAbort.abort();
2831
2831
  }
2832
2832
  } catch {}
2833
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2833
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2834
2834
  renewal.unref?.();
2835
2835
  const batchSize = Math.max(1, options?.batchSize ?? CHUNK_DRAIN_BATCH_SIZE);
2836
2836
  const skipIds = [];
@@ -3,10 +3,11 @@ import {
3
3
  } from "./index-v0p37hm2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-nsjyysj0.js";
6
+ } from "./index-mvvephtj.js";
7
7
  import {
8
+ inRootAsyncContext2,
8
9
  getSqliteDatabasePath2
9
- } from "./index-j8epsc0g.js";
10
+ } from "./index-wafzvyhg.js";
10
11
 
11
12
  // src/features/magic-context/compaction-marker-candidates.ts
12
13
  import { existsSync, realpathSync } from "node:fs";
@@ -152,7 +153,7 @@ function runCandidateWorker(path, sessionId, options) {
152
153
  timer.unref?.();
153
154
  };
154
155
  try {
155
- worker = new Worker(entry, { workerData: { path, sessionId } });
156
+ worker = inRootAsyncContext2(() => new Worker(entry, { workerData: { path, sessionId } }));
156
157
  workers.add(worker);
157
158
  worker.unref();
158
159
  deadline(options.acceptMs ?? 2000);
@@ -3,7 +3,22 @@ import {
3
3
  importPluginModule,
4
4
  writeForwardedLogLine2,
5
5
  log2
6
- } from "./index-nsjyysj0.js";
6
+ } from "./index-mvvephtj.js";
7
+ import {
8
+ inRootAsyncContext2,
9
+ registerSlowWriteReporter2,
10
+ registerSqliteDiagnosticSink2,
11
+ detectSqliteRuntime2,
12
+ Database2,
13
+ withSqliteBackgroundWriter2,
14
+ withoutSqliteTransformPass2,
15
+ isTransientSqliteError2,
16
+ withPrivilegedWriter2
17
+ } from "./index-wafzvyhg.js";
18
+ import {
19
+ bootQuietRemainingMs,
20
+ scheduleAfterBootQuiet
21
+ } from "./index-0jz47061.js";
7
22
  import {
8
23
  getHarness2,
9
24
  harnessOwnsOpenCodeStore2
@@ -22,23 +37,13 @@ import {
22
37
  parseRpcPortFile,
23
38
  inspectProcessesAsync,
24
39
  inspectWindowsProcessesSync
25
- } from "./index-w4mw92w3.js";
26
- import {
27
- registerSlowWriteReporter2,
28
- registerSqliteDiagnosticSink2,
29
- detectSqliteRuntime2,
30
- Database2,
31
- withSqliteBackgroundWriter2,
32
- withoutSqliteTransformPass2,
33
- isTransientSqliteError2,
34
- withPrivilegedWriter2
35
- } from "./index-j8epsc0g.js";
40
+ } from "./index-q28hsbpg.js";
36
41
  import {
37
42
  configureContextDatabasePragmas2
38
43
  } from "./index-fb3zxn06.js";
39
44
  import {
40
45
  startMessageFtsRowidMapBackfill
41
- } from "./index-rzmjkdd6.js";
46
+ } from "./index-mp2kghkv.js";
42
47
  import {
43
48
  LKG_SLOT_CHUNKS_DDL,
44
49
  SESSION_REPLAY_DECISIONS_DDL,
@@ -48,24 +53,20 @@ import {
48
53
  hasPendingMigrations,
49
54
  getMainThreadMigrationBodyCount,
50
55
  runMigrations
51
- } from "./index-j5hce1ab.js";
56
+ } from "./index-a865mj02.js";
52
57
  import {
53
58
  installTagIdentityRevisionTrigger,
54
59
  ensureColumn,
55
60
  installV95PerfSchema
56
- } from "./index-1bt88epp.js";
61
+ } from "./index-g7jkrz0x.js";
57
62
  import {
58
63
  resolveOpenCodeDbPath,
59
64
  hasV1MessageTables
60
65
  } from "./index-58e3y90n.js";
61
- import {
62
- bootQuietRemainingMs,
63
- scheduleAfterBootQuiet
64
- } from "./index-g8qbdb03.js";
65
66
  import {
66
67
  setDatabase,
67
68
  loadToolDefinitionMeasurements
68
- } from "./index-h2wc01qk.js";
69
+ } from "./index-9jvab89d.js";
69
70
  import {
70
71
  getErrorMessage
71
72
  } from "./index-y8v6yerm.js";
@@ -82,7 +83,7 @@ import {
82
83
  } from "./index-8ajstryz.js";
83
84
  import {
84
85
  logSlowWriteTransaction
85
- } from "./index-4mjhqadz.js";
86
+ } from "./index-150zz6fh.js";
86
87
 
87
88
  // src/features/magic-context/fail-closed-block.ts
88
89
  var FAIL_CLOSED_DOCTOR_COMMAND = "npx @cortexkit/magic-context@latest doctor";
@@ -382,15 +383,25 @@ var activeMigrations = 0;
382
383
  var activeSince = 0;
383
384
  var accumulatedMs = 0;
384
385
  var idleWaiters = [];
385
- function offThreadMigrationMs(now = performance.now()) {
386
- return accumulatedMs + (activeMigrations > 0 ? Math.max(0, now - activeSince) : 0);
386
+ var testClock;
387
+ function now() {
388
+ return testClock?.now() ?? performance.now();
389
+ }
390
+ function scheduleTimeout(callback, delayMs) {
391
+ if (testClock)
392
+ return testClock.setTimeout(callback, delayMs);
393
+ const timer = setTimeout(callback, delayMs);
394
+ return () => clearTimeout(timer);
395
+ }
396
+ function offThreadMigrationMs(at = now()) {
397
+ return accumulatedMs + (activeMigrations > 0 ? Math.max(0, at - activeSince) : 0);
387
398
  }
388
399
  function isOffThreadMigrationRunning() {
389
400
  return activeMigrations > 0;
390
401
  }
391
402
  function beginOffThreadMigration() {
392
403
  if (activeMigrations === 0)
393
- activeSince = performance.now();
404
+ activeSince = now();
394
405
  activeMigrations += 1;
395
406
  let ended = false;
396
407
  return () => {
@@ -400,7 +411,7 @@ function beginOffThreadMigration() {
400
411
  activeMigrations -= 1;
401
412
  if (activeMigrations > 0)
402
413
  return;
403
- accumulatedMs += Math.max(0, performance.now() - activeSince);
414
+ accumulatedMs += Math.max(0, now() - activeSince);
404
415
  const waiters = idleWaiters;
405
416
  idleWaiters = [];
406
417
  for (const wake of waiters)
@@ -413,10 +424,10 @@ function whenOffThreadMigrationIdle() {
413
424
  return new Promise((resolve) => idleWaiters.push(resolve));
414
425
  }
415
426
  function startBootDeadline(timeoutMs, onDeferred) {
416
- const startedAt = performance.now();
427
+ const startedAt = now();
417
428
  const migratedAtStart = offThreadMigrationMs(startedAt);
418
429
  const budgetMs = Math.max(0, timeoutMs);
419
- let timer;
430
+ let cancelTimer;
420
431
  let cancelled = false;
421
432
  let deferredReported = false;
422
433
  let resolveExpired;
@@ -424,12 +435,12 @@ function startBootDeadline(timeoutMs, onDeferred) {
424
435
  resolveExpired = resolve;
425
436
  });
426
437
  const remainingMs = () => {
427
- const now = performance.now();
428
- const countedMs = now - startedAt - (offThreadMigrationMs(now) - migratedAtStart);
438
+ const currentTime = now();
439
+ const countedMs = currentTime - startedAt - (offThreadMigrationMs(currentTime) - migratedAtStart);
429
440
  return budgetMs - countedMs;
430
441
  };
431
442
  const check = () => {
432
- timer = undefined;
443
+ cancelTimer = undefined;
433
444
  if (cancelled)
434
445
  return;
435
446
  if (isOffThreadMigrationRunning()) {
@@ -442,19 +453,18 @@ function startBootDeadline(timeoutMs, onDeferred) {
442
453
  }
443
454
  const left = remainingMs();
444
455
  if (left > 0) {
445
- timer = setTimeout(check, left);
456
+ cancelTimer = scheduleTimeout(check, left);
446
457
  return;
447
458
  }
448
459
  resolveExpired();
449
460
  };
450
- timer = setTimeout(check, budgetMs);
461
+ cancelTimer = scheduleTimeout(check, budgetMs);
451
462
  return {
452
463
  expired,
453
464
  cancel: () => {
454
465
  cancelled = true;
455
- if (timer)
456
- clearTimeout(timer);
457
- timer = undefined;
466
+ cancelTimer?.();
467
+ cancelTimer = undefined;
458
468
  }
459
469
  };
460
470
  }
@@ -471,7 +481,7 @@ function runMigrationsOffThread(data) {
471
481
  return new Promise((resolve, reject) => {
472
482
  let worker;
473
483
  try {
474
- worker = new Worker(workerEntryOverride ?? defaultWorkerEntry(), { workerData: data });
484
+ worker = inRootAsyncContext2(() => new Worker(workerEntryOverride ?? defaultWorkerEntry(), { workerData: data }));
475
485
  } catch (error) {
476
486
  reject(workerStartError(error instanceof Error ? error.message : String(error)));
477
487
  return;
@@ -1260,8 +1270,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1260
1270
  startMessageFtsRowidMapBackfill(db).then(async () => {
1261
1271
  if (!readsOpenCodeStore)
1262
1272
  return;
1263
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-h1btx938.js"));
1264
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-a5ytnp53.js"));
1273
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-zgpvs423.js"));
1274
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-nb5hhnrt.js"));
1265
1275
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1266
1276
  readPage: readRawSessionMessagePage
1267
1277
  }));
@@ -4947,6 +4947,7 @@ var FIELDS = [
4947
4947
  ];
4948
4948
  var MINUTE_MS = 60000;
4949
4949
  var MAX_SEARCH_MS = 4 * 366 * 24 * 60 * MINUTE_MS;
4950
+ var candidateVisitsForTests;
4950
4951
  function parseField(token, spec) {
4951
4952
  const values = new Set;
4952
4953
  const normalize = (n) => spec.name === "day-of-week" && n === 7 ? 0 : n;
@@ -5066,6 +5067,7 @@ function nextOccurrence(cron, after, excludeCivilMinute, maxSearchMs = MAX_SEARC
5066
5067
  let cursorMs = Math.floor(afterMs / MINUTE_MS) * MINUTE_MS + MINUTE_MS;
5067
5068
  const capMs = afterMs + Math.max(0, Math.min(MAX_SEARCH_MS, maxSearchMs));
5068
5069
  while (cursorMs <= capMs) {
5070
+ candidateVisitsForTests?.();
5069
5071
  const candidate = new Date(cursorMs);
5070
5072
  if (matchesCron(cron, candidate)) {
5071
5073
  if (!excludeCivilMinute || civilMinuteKey(candidate) !== excludeCivilMinute) {
@@ -1,6 +1,10 @@
1
1
  // src/shared/sqlite.ts
2
- import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
3
3
  import { statSync } from "node:fs";
4
+ var resourceRoot = new AsyncResource("magic-context:root");
5
+ function inRootAsyncContext2(operation) {
6
+ return resourceRoot.runInAsyncScope(operation);
7
+ }
4
8
  var reportSlowPrivilegedWrite;
5
9
  function registerSlowWriteReporter2(reporter) {
6
10
  reportSlowPrivilegedWrite = reporter;
@@ -191,7 +195,7 @@ function installTransactionRouting(db, readonly) {
191
195
  return endWriterTransaction(db, () => nativeExec(sql), sql);
192
196
  if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
193
197
  try {
194
- return withAutocommitTimeout(db, () => nativeExec(sql));
198
+ return withAutocommitTimeout(db, () => nativeExec(sql), false);
195
199
  } finally {
196
200
  if (mayChangeTagIdentity(sql))
197
201
  tagIdentityWriteGeneration += 1;
@@ -333,7 +337,7 @@ function trackSqliteConnection(db, filename, options) {
333
337
  }
334
338
  var TrackedDatabase = new Proxy(DatabaseImpl, {
335
339
  construct(target, args) {
336
- const db = Reflect.construct(target, args, target);
340
+ const db = inRootAsyncContext2(() => Reflect.construct(target, args, target));
337
341
  return trackSqliteConnection(db, args[0], args[1]);
338
342
  }
339
343
  });
@@ -577,29 +581,48 @@ function foregroundWaitLease() {
577
581
  const lease = transformPassScope.getStore();
578
582
  return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
579
583
  }
580
- function withAutocommitTimeout(db, operation) {
584
+ function withAutocommitTimeout(db, operation, singleStatement = true) {
581
585
  assertTransformWrite2();
582
586
  const lease = foregroundWaitLease();
583
587
  if (isInTransaction(db))
584
588
  return operation();
585
589
  const scoped = lease || backgroundWriterScope.getStore();
586
590
  const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
587
- if (scoped)
588
- db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
589
591
  const started = performance.now();
590
592
  let completed = false;
591
- try {
593
+ const execute = () => {
592
594
  const result = operation();
593
595
  completed = true;
594
596
  return result;
597
+ };
598
+ try {
599
+ if (!scoped)
600
+ return execute();
601
+ if (singleStatement) {
602
+ db.exec("PRAGMA busy_timeout=0");
603
+ try {
604
+ return execute();
605
+ } catch (error) {
606
+ if (!isTransientSqliteError2(error) || isInTransaction(db))
607
+ throw error;
608
+ }
609
+ assertTransformWrite2();
610
+ }
611
+ const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
612
+ db.exec(`PRAGMA busy_timeout=${timeout}`);
613
+ const waitStarted = performance.now();
614
+ try {
615
+ return execute();
616
+ } finally {
617
+ if (lease)
618
+ lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
619
+ }
595
620
  } catch (error) {
596
621
  if (lease && isTransientSqliteError2(error))
597
622
  throw new SqliteAcquisitionBusyError2(error, "autocommit");
598
623
  throw error;
599
624
  } finally {
600
625
  const elapsed = performance.now() - started;
601
- if (lease)
602
- lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
603
626
  if (previous !== null)
604
627
  db.exec(`PRAGMA busy_timeout=${previous}`);
605
628
  if (elapsed >= SLOW_WRITER_LOG_MS)
@@ -859,4 +882,4 @@ async function yieldIndexChunk2() {
859
882
  await yieldIndexTurn();
860
883
  }
861
884
 
862
- export { registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
885
+ export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };