@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
@@ -15,7 +15,7 @@ import {
15
15
  log2,
16
16
  sessionLog2,
17
17
  getLoggerDiagnostics2
18
- } from "./index-nsjyysj0.js";
18
+ } from "./index-mvvephtj.js";
19
19
  import {
20
20
  resolveOpenCodeDbPath,
21
21
  assertOpenCodeStoreGeneration,
@@ -28,6 +28,7 @@ import {
28
28
  claimOpenCodeDbDiagnosticOnce
29
29
  } from "./index-58e3y90n.js";
30
30
  import {
31
+ inRootAsyncContext2,
31
32
  Database2,
32
33
  getSqliteDatabasePath2,
33
34
  getSqliteMemoryStats2,
@@ -38,7 +39,7 @@ import {
38
39
  SqliteAcquisitionBusyError2,
39
40
  withAsyncPrivilegedWriter2,
40
41
  indexCoordinationInput2
41
- } from "./index-j8epsc0g.js";
42
+ } from "./index-wafzvyhg.js";
42
43
  import {
43
44
  shouldSkipHomeProjectMemory,
44
45
  ProjectIdentityError,
@@ -53,7 +54,7 @@ import {
53
54
  storedPathBelongsToIdentity,
54
55
  beginBootQuietPeriod,
55
56
  scheduleAfterBootQuiet
56
- } from "./index-g8qbdb03.js";
57
+ } from "./index-0jz47061.js";
57
58
  import {
58
59
  recordSessionProjectIdentity,
59
60
  hasRecordedSessionProjectIdentity,
@@ -80,7 +81,7 @@ import {
80
81
  drainCommitBacklogForProject2,
81
82
  embedSessionCompartmentChunks2,
82
83
  getEmbeddingCoverageStatus2
83
- } from "./index-sf94at64.js";
84
+ } from "./index-rg1cezmj.js";
84
85
  import {
85
86
  hasTrustedAbsoluteWall,
86
87
  applyProvenInputFloor,
@@ -92,7 +93,7 @@ import {
92
93
  deriveTriggerBudget2,
93
94
  resolveKnownHistorianContextLimit2,
94
95
  resolveHistorianProducerLimits2
95
- } from "./index-w23dh319.js";
96
+ } from "./index-jw4gbfkv.js";
96
97
  import {
97
98
  resolveModelCalibration,
98
99
  calibrateBuckets,
@@ -106,11 +107,12 @@ import {
106
107
  estimateTokens,
107
108
  estimateFixedPromptTokens,
108
109
  normalizeText
109
- } from "./index-qx53vezw.js";
110
+ } from "./index-gjvjh960.js";
110
111
  import {
111
112
  protectedToolTokenCount,
112
113
  peelLeadingMcTagNotation,
113
114
  isThinkingPart,
115
+ currentReclaimableToolOutputCount,
114
116
  isRecord,
115
117
  contentTagOwnerMessageId,
116
118
  normalizeTodoStateJson,
@@ -121,7 +123,6 @@ import {
121
123
  evaluateChannel2,
122
124
  formatChannel1Evaluation,
123
125
  formatChannel2Evaluation,
124
- reclaimableToolOutputCount,
125
126
  buildChannel2Reminder,
126
127
  buildChannel1Reminder,
127
128
  queuePendingOp,
@@ -143,11 +144,11 @@ import {
143
144
  getDroppedTagsByNumbers2,
144
145
  getMaxDroppedTagNumber2,
145
146
  getTagById2
146
- } from "./index-tmtty2x5.js";
147
+ } from "./index-f8cn4xqa.js";
147
148
  import {
148
149
  observeTemporalDecisions,
149
150
  stableStringify
150
- } from "./index-1bt88epp.js";
151
+ } from "./index-g7jkrz0x.js";
151
152
  import {
152
153
  withContentLanguageDirective,
153
154
  parseCron,
@@ -160,13 +161,13 @@ import {
160
161
  DEFAULT_HISTORIAN_TIMEOUT_MS,
161
162
  DEFAULT_LOCAL_EMBEDDING_MODEL,
162
163
  DREAM_TASK_PROMOTION_DEFAULTS
163
- } from "./index-k6xvbj2e.js";
164
+ } from "./index-w28y7d0z.js";
164
165
  import {
165
166
  isRawCompactionSummaryInfo2,
166
167
  extractInMemoryMessageViews2,
167
168
  buildInMemoryTailRawMessages2,
168
169
  runSessionWarmupWorker
169
- } from "./index-37q80veb.js";
170
+ } from "./index-angx1s0k.js";
170
171
  import {
171
172
  openCodeDbExists,
172
173
  withReadOnlySessionDb,
@@ -174,7 +175,7 @@ import {
174
175
  latestPersistedMessageForRecovery,
175
176
  latestRealUserTurnIdFromOpenCodeDb,
176
177
  findLastAssistantModelFromOpenCodeDb
177
- } from "./index-a8acx4gc.js";
178
+ } from "./index-q76br5zn.js";
178
179
  import {
179
180
  expandToolPart,
180
181
  estimateTrueRawMessageTokens,
@@ -291,13 +292,14 @@ import {
291
292
  readRawSessionMessageIdOrdinalsForRange2,
292
293
  readRawSessionMessagePartsById2,
293
294
  readRawSessionBoundaryEndpoints2,
295
+ hasRawSessionMessageById2,
294
296
  readRawSessionMessageById2,
295
297
  readSessionChunk2,
296
298
  readRawSessionSeedTail2
297
- } from "./index-n5a170gs.js";
299
+ } from "./index-wpwpn7nj.js";
298
300
  import {
299
301
  getMeasuredToolDefinitionTokens
300
- } from "./index-h2wc01qk.js";
302
+ } from "./index-9jvab89d.js";
301
303
  import {
302
304
  CANONICAL_DREAM_TASKS,
303
305
  DREAM_TASK_CAPABILITIES,
@@ -325,20 +327,17 @@ import {
325
327
  runSqliteOptimize,
326
328
  openDatabase,
327
329
  openCurrentDatabase
328
- } from "./index-4btknbqh.js";
330
+ } from "./index-swgpe402.js";
329
331
  import {
330
332
  registerOwnRpcServerInstance,
331
333
  rpcPortDir,
332
334
  rpcPortFilePath,
333
335
  parseRpcPortFile,
334
336
  inspectProcessesAsync
335
- } from "./index-w4mw92w3.js";
337
+ } from "./index-q28hsbpg.js";
336
338
  import {
337
339
  configureContextDatabasePragmas2
338
340
  } from "./index-fb3zxn06.js";
339
- import {
340
- canonicalProjectDirectory
341
- } from "./index-rzmjkdd6.js";
342
341
  import {
343
342
  unescapeXml,
344
343
  resolveWorkspaceShareCategories,
@@ -347,7 +346,7 @@ import {
347
346
  resolveStoredPathWorkspaceIdentity,
348
347
  storedPathBelongsToWorkspace,
349
348
  computeWorkspaceEpochFingerprint
350
- } from "./index-j5hce1ab.js";
349
+ } from "./index-a865mj02.js";
351
350
  import {
352
351
  V2_MEMORY_CATEGORIES,
353
352
  CATEGORY_PRIORITY
@@ -521,7 +520,7 @@ import {
521
520
  snapRangeToCompartments,
522
521
  getActiveCompartmentRun,
523
522
  startCompartmentAgent
524
- } from "./index-5tbvdff4.js";
523
+ } from "./index-3403gbzj.js";
525
524
  import {
526
525
  SubcClient,
527
526
  connectionFileExists,
@@ -529,7 +528,7 @@ import {
529
528
  toSynapseLaneDescriptor,
530
529
  formatSynapseLaneDescriptor,
531
530
  SynapseEmbeddingProvider
532
- } from "./index-vkbqdnkj.js";
531
+ } from "./index-kvw6xew3.js";
533
532
  import {
534
533
  BoundedSessionMap,
535
534
  LkgRecoveryFenceError,
@@ -550,7 +549,7 @@ import {
550
549
  indexSingleMessage2,
551
550
  indexMessagesAfterOrdinal2,
552
551
  sweepOrphanedOpenCodeMessageIndexes2
553
- } from "./index-wq16ahsn.js";
552
+ } from "./index-0x9cn9w1.js";
554
553
  import {
555
554
  renderUserFacingFailure,
556
555
  userFacingFailureCode,
@@ -594,7 +593,7 @@ import {
594
593
  readGitFileChangeTimesSince,
595
594
  verificationFileExists,
596
595
  normalizeVerificationFiles
597
- } from "./index-n7kwfw2r.js";
596
+ } from "./index-16vwdyy5.js";
598
597
  import {
599
598
  registerNotificationSink2,
600
599
  pushNotification2,
@@ -604,7 +603,7 @@ import {
604
603
  } from "./index-x8a7jmkh.js";
605
604
  import {
606
605
  getLocalEmbeddingNativeMemoryStats
607
- } from "./index-gbmqa9x9.js";
606
+ } from "./index-bmwfzz28.js";
608
607
  import {
609
608
  saveEmbeddingIfHashMatches,
610
609
  invalidateProject2,
@@ -612,7 +611,7 @@ import {
612
611
  } from "./index-4dhv7mqz.js";
613
612
  import {
614
613
  cosineSimilarity
615
- } from "./index-w6bd03dc.js";
614
+ } from "./index-a43xq1pg.js";
616
615
  import {
617
616
  computeCueContentHash,
618
617
  hasMuralCueColumns,
@@ -637,7 +636,7 @@ import {
637
636
  mergeMemoryStats2,
638
637
  archiveMemory2,
639
638
  getMemoryCountsByStatus2
640
- } from "./index-9yyqq3mm.js";
639
+ } from "./index-n78avt2p.js";
641
640
  import {
642
641
  renderSingleStoreMigrationRequiredRefusal,
643
642
  SingleStoreMigrationRequiredError,
@@ -659,17 +658,17 @@ import {
659
658
  resolveMemoriesByIdsForSearch2,
660
659
  unifiedSearch2,
661
660
  formatSearchResults2
662
- } from "./index-j58gqrn2.js";
661
+ } from "./index-ffa8x2as.js";
663
662
  import {
664
663
  flushIgnoredMessages2,
665
664
  clearIgnoredMessages2,
666
665
  observeIgnoredNotificationEvent2,
667
666
  sendStatusNotification2
668
- } from "./index-vt4sf4ep.js";
667
+ } from "./index-pgy3h49n.js";
669
668
  import {
670
669
  setRecompStarting2,
671
670
  setRecompTerminal2
672
- } from "./index-rwmpkss5.js";
671
+ } from "./index-21919gcq.js";
673
672
  import {
674
673
  makeToolCompositeKey,
675
674
  searchMessageHistoryOffThread,
@@ -720,7 +719,7 @@ import {
720
719
  abortSessionFailClosed2,
721
720
  evaluateEmergencyFailClosed2,
722
721
  runPostTransformPhase2
723
- } from "./index-ebnngykq.js";
722
+ } from "./index-6k86es2p.js";
724
723
  import {
725
724
  ANNOUNCEMENT_VERSION2,
726
725
  ANNOUNCEMENT_FEATURES2,
@@ -737,6 +736,9 @@ import {
737
736
  import {
738
737
  computeNormalizedHash
739
738
  } from "./index-2bvekkfy.js";
739
+ import {
740
+ canonicalProjectDirectory
741
+ } from "./index-knvkbfvh.js";
740
742
  import {
741
743
  getErrorMessage,
742
744
  describeError
@@ -759,7 +761,7 @@ import {
759
761
  } from "./index-8ajstryz.js";
760
762
  import {
761
763
  logSlowWriteTransaction
762
- } from "./index-4mjhqadz.js";
764
+ } from "./index-150zz6fh.js";
763
765
 
764
766
  // src/features/magic-context/dreamer/open-opencode-db.ts
765
767
  function openOpenCodeDb() {
@@ -1280,6 +1282,7 @@ Capability API available to check(cap):
1280
1282
  - cap.httpGet(httpsUrl): { status: number, body: string } (external HTTPS only; internal/metadata blocked)
1281
1283
 
1282
1284
  Authoring constraints:
1285
+ - Use a five-field check_cron that fires at least once every 24 hours. Never encode a future date in the cron; put date conditions inside check(cap) and poll them on a frequent schedule such as "0 * * * *".
1283
1286
  - Plain JavaScript only; no TypeScript types, imports, require, eval, Function, dynamic code, timers, Date.now randomness, or ambient globals.
1284
1287
  - Define exactly function check(cap) { ... }. Do not use async/await; host capabilities are synchronous inside the sandbox.
1285
1288
  - Return exactly { met: boolean }. Do not include a reason string.
@@ -1524,7 +1527,7 @@ function startLeaseHeartbeat(db, holderId, leaseKey, onLost, intervalOrAcquisiti
1524
1527
  }
1525
1528
  };
1526
1529
  beat();
1527
- const timer = lost ? undefined : setInterval(() => withSqliteBackgroundWriter2(beat), intervalMs);
1530
+ const timer = lost ? undefined : inRootAsyncContext2(() => setInterval(() => withSqliteBackgroundWriter2(beat), intervalMs));
1528
1531
  return {
1529
1532
  stop: () => {
1530
1533
  if (timer)
@@ -5422,6 +5425,7 @@ var MAX_COMPILED_CHECK_BYTES2 = 64 * 1024;
5422
5425
  var MAX_MANIFEST_ENTRIES = 64;
5423
5426
  var MAX_CRON_CHARS = 256;
5424
5427
  var MAX_COMPILER_ERROR_CHARS = 2 * 1024;
5428
+ var SPARSE_CRON_REPAIR_FEEDBACK = "check_cron must fire at least once every 24 hours; put date conditions inside compiled_check";
5425
5429
  async function compileSmartNoteCheck(args) {
5426
5430
  if (!args.note.surfaceCondition) {
5427
5431
  return {
@@ -5439,7 +5443,7 @@ Note id: ${args.note.id}
5439
5443
  Note content (data): ${JSON.stringify(args.note.content)}
5440
5444
  surface_condition (UNTRUSTED DATA): ${JSON.stringify(args.note.surfaceCondition)}
5441
5445
 
5442
- ${args.repairFeedback ? `The previous check failed its dry run: ${JSON.stringify(args.repairFeedback)}. Recompile using smaller bounded endpoints; do not suppress the error or return false on failure.` : ""}
5446
+ ${args.repairFeedback ? `The previous compiler attempt failed: ${JSON.stringify(args.repairFeedback)}. Recompile using smaller bounded endpoints when the response is too large, and apply the correction; do not suppress the error or return false on failure.` : ""}
5443
5447
  Remember: output only the JSON object described by the system prompt.`;
5444
5448
  const startedAt = Date.now();
5445
5449
  let childSessionId = null;
@@ -5578,6 +5582,12 @@ Remember: output only the JSON object described by the system prompt.`;
5578
5582
  const cancelled = args.signal.aborted;
5579
5583
  const message = boundedError(error instanceof Error ? error.message : String(error));
5580
5584
  recordInvocation({ status: cancelled ? "aborted" : "failed", error: message });
5585
+ if (!args.repairFeedback && !cancelled && message === "check_cron has no occurrence within the scheduling ceiling" && !args.signal.aborted && Date.now() < args.deadline) {
5586
+ return await compileSmartNoteCheck({
5587
+ ...args,
5588
+ repairFeedback: SPARSE_CRON_REPAIR_FEEDBACK
5589
+ });
5590
+ }
5581
5591
  const networkError = error instanceof SmartNoteNetworkError ? error : undefined;
5582
5592
  return {
5583
5593
  ok: false,
@@ -5984,10 +5994,10 @@ async function probeWakePlaneCatalog() {
5984
5994
  if (!await connectionFileExists(file)) {
5985
5995
  throw new Error("subc connection is not configured");
5986
5996
  }
5987
- const client = await SubcClient.connect({
5997
+ const client = await inRootAsyncContext2(() => SubcClient.connect({
5988
5998
  connectionFile: file,
5989
5999
  handshakeTimeoutMs: WAKE_PLANE_HANDSHAKE_TIMEOUT_MS
5990
- });
6000
+ }));
5991
6001
  try {
5992
6002
  return await client.catalogList();
5993
6003
  } finally {
@@ -7397,7 +7407,11 @@ function buildPrimerClusters(args) {
7397
7407
  centroid: cloneVector(primer.questionEmbedding),
7398
7408
  modelId: primer.questionEmbeddingModelId
7399
7409
  }));
7400
- const sorted = args.candidates.slice().sort((a, b) => candidateSortKey(a).localeCompare(candidateSortKey(b)));
7410
+ const sorted = args.candidates.slice().sort((a, b) => {
7411
+ const left = candidateSortKey(a);
7412
+ const right = candidateSortKey(b);
7413
+ return left < right ? -1 : left > right ? 1 : 0;
7414
+ });
7401
7415
  for (const candidate of sorted) {
7402
7416
  let best = null;
7403
7417
  for (const cluster of clusters) {
@@ -11120,10 +11134,10 @@ async function sourceReady(source, sessionId) {
11120
11134
  function defer(fn) {
11121
11135
  const immediate = globalThis.setImmediate;
11122
11136
  if (typeof immediate === "function") {
11123
- immediate(fn);
11137
+ inRootAsyncContext2(() => immediate(fn));
11124
11138
  return;
11125
11139
  }
11126
- setTimeout(fn, 0);
11140
+ inRootAsyncContext2(() => setTimeout(fn, 0));
11127
11141
  }
11128
11142
  function yieldToEventLoop() {
11129
11143
  return new Promise((resolve) => defer(resolve));
@@ -11207,14 +11221,14 @@ function scheduleReconciliation(db, sessionId, readMessages) {
11207
11221
  reconcileSessionIndex(db, sessionId, readMessages).then((ran) => {
11208
11222
  if (ran)
11209
11223
  return;
11210
- setTimeout(() => {
11224
+ inRootAsyncContext2(() => setTimeout(() => {
11211
11225
  heapHolder.reconciliationScheduledSessions.delete(sessionId);
11212
11226
  scheduleReconciliation(db, sessionId, readMessages);
11213
- }, PREPARE_RETRY_MS).unref?.();
11227
+ }, PREPARE_RETRY_MS)).unref?.();
11214
11228
  }).catch((error) => {
11215
11229
  logIndexingError(sessionId, "reconciliation", error);
11216
11230
  if (isDatabaseLockedError(error))
11217
- setTimeout(() => scheduleReconciliation(db, sessionId, readMessages), 1000).unref();
11231
+ inRootAsyncContext2(() => setTimeout(() => scheduleReconciliation(db, sessionId, readMessages), 1000)).unref();
11218
11232
  }).finally(() => {
11219
11233
  heapHolder.reconciliationScheduledSessions.delete(sessionId);
11220
11234
  });
@@ -11229,7 +11243,7 @@ function scheduleIncrementalIndex(db, sessionId, messageId, messageSource) {
11229
11243
  const activeTimer = heapHolder.incrementalTimers.get(schedulingKey);
11230
11244
  if (activeTimer)
11231
11245
  clearTimeout(activeTimer);
11232
- const timer = setTimeout(() => {
11246
+ const timer = inRootAsyncContext2(() => setTimeout(() => {
11233
11247
  heapHolder.incrementalTimers.delete(schedulingKey);
11234
11248
  heapHolder.pendingIncrementalKeys.add(schedulingKey);
11235
11249
  const indexMessage = async () => {
@@ -11273,7 +11287,7 @@ function scheduleIncrementalIndex(db, sessionId, messageId, messageSource) {
11273
11287
  if ((sessionEpochs.get(sessionId) ?? 0) === epoch)
11274
11288
  heapHolder.pendingIncrementalKeys.delete(schedulingKey);
11275
11289
  });
11276
- }, INCREMENTAL_DEBOUNCE_MS);
11290
+ }, INCREMENTAL_DEBOUNCE_MS));
11277
11291
  heapHolder.incrementalTimers.set(schedulingKey, timer);
11278
11292
  }
11279
11293
  async function indexSingleMessageOffThread(db, sessionId, message) {
@@ -11490,7 +11504,7 @@ async function startDreamScheduleTimer(args) {
11490
11504
  startupTickTimer = null;
11491
11505
  runTick("startup");
11492
11506
  });
11493
- const timer = setInterval(() => runTick("interval"), DREAM_TIMER_INTERVAL_MS);
11507
+ const timer = inRootAsyncContext2(() => setInterval(() => runTick("interval"), DREAM_TIMER_INTERVAL_MS));
11494
11508
  if (typeof timer === "object" && "unref" in timer) {
11495
11509
  timer.unref();
11496
11510
  }
@@ -11786,7 +11800,7 @@ async function runCompiledSmartNoteSweep(reg, db) {
11786
11800
  }
11787
11801
  }
11788
11802
  function startGitSweepLeaseRenewal(db, projectIdentity, holderId) {
11789
- const timer = setInterval(() => {
11803
+ const timer = inRootAsyncContext2(() => setInterval(() => {
11790
11804
  try {
11791
11805
  if (!renewGitSweepLease(db, projectIdentity, holderId)) {
11792
11806
  log2(`[git-commits] sweep lease renewal failed for ${projectIdentity}`);
@@ -11794,7 +11808,7 @@ function startGitSweepLeaseRenewal(db, projectIdentity, holderId) {
11794
11808
  } catch (error) {
11795
11809
  log2(`[git-commits] sweep lease renewal errored for ${projectIdentity}: ${error instanceof Error ? error.message : String(error)}`);
11796
11810
  }
11797
- }, GIT_SWEEP_LEASE_RENEWAL_MS);
11811
+ }, GIT_SWEEP_LEASE_RENEWAL_MS));
11798
11812
  timer.unref?.();
11799
11813
  return () => clearInterval(timer);
11800
11814
  }
@@ -14819,7 +14833,7 @@ function maybeInjectChannel1Nudge(args, sessionId, tool, output) {
14819
14833
  setChannel1NudgeState(args.db, sessionId, nextNudgeState);
14820
14834
  return;
14821
14835
  }
14822
- out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens, reclaimableToolOutputCount(state.baselineParts), state.oldestReclaimableToolTags, decision.sticky);
14836
+ out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens, currentReclaimableToolOutputCount(state), state.oldestReclaimableToolTags, decision.sticky);
14823
14837
  setChannel1NudgeState(args.db, sessionId, {
14824
14838
  ...nextNudgeState,
14825
14839
  ordinal: state.realUserTurnCount
@@ -15491,6 +15505,7 @@ function buildStatusDetail(db, sessionId, directory, modelKey, config, liveSessi
15491
15505
  const ops = db.prepare("SELECT tag_id, operation FROM pending_ops WHERE session_id = ? LIMIT 100").all(sessionId);
15492
15506
  detail.pendingOps = ops.map((o) => ({ tagId: o.tag_id, operation: o.operation }));
15493
15507
  } catch {}
15508
+ modelKey ??= persistedModelKey ?? undefined;
15494
15509
  const modelSlash = modelKey?.indexOf("/") ?? -1;
15495
15510
  if (modelKey && modelSlash > 0) {
15496
15511
  detail.windowGeometry = resolveContextWindowGeometry(modelKey.slice(0, modelSlash), modelKey.slice(modelSlash + 1), { db, sessionID: sessionId });
@@ -15835,7 +15850,7 @@ function registerRpcHandlers(rpcServer, args) {
15835
15850
  const sessionId = String(params.sessionId ?? "");
15836
15851
  if (!sessionId)
15837
15852
  return { owner: false };
15838
- const sessionDirectory = liveSessionState.sessionDirectoryBySession.get(sessionId) ?? await readHostSessionDirectory(args.client, sessionId);
15853
+ const sessionDirectory = args.readSessionDirectory ? await args.readSessionDirectory(sessionId) : await readHostSessionDirectory(args.client, sessionId) ?? liveSessionState.sessionDirectoryBySession.get(sessionId);
15839
15854
  if (!sessionDirectory)
15840
15855
  return { owner: false };
15841
15856
  return {
@@ -15906,7 +15921,7 @@ function registerRpcHandlers(rpcServer, args) {
15906
15921
  return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
15907
15922
  });
15908
15923
  const buildManagedCtx = async (db) => {
15909
- const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-j4ry8j8n.js"));
15924
+ const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-3nbxsyss.js"));
15910
15925
  const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-nx97z3x7.js"));
15911
15926
  const { userMemoryCollectionEnabled } = await importPluginModule(() => import("./task-config-cgpg0nvh.js"));
15912
15927
  const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
@@ -15921,6 +15936,7 @@ function registerRpcHandlers(rpcServer, args) {
15921
15936
  directory,
15922
15937
  historianChunkTokens: deriveHistorianChunkTokens(resolveHistorianContextLimit(historianModel.primary?.model)),
15923
15938
  historianTimeoutMs: runConfig.historian_timeout_ms ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
15939
+ historianMaxOutputTokens: runConfig.historian?.maxTokens,
15924
15940
  memoryEnabled: config.memory?.enabled ?? true,
15925
15941
  autoPromote: runConfig.memory?.auto_promote ?? true,
15926
15942
  historianModel: historianModel.primary,
@@ -15935,6 +15951,20 @@ function registerRpcHandlers(rpcServer, args) {
15935
15951
  const sessionId = String(params.sessionId ?? "");
15936
15952
  if (!sessionId)
15937
15953
  return { ok: false, error: "no session" };
15954
+ const readDirectory = args.readSessionDirectory;
15955
+ if (readDirectory) {
15956
+ const { handoffHistoryWork } = await import("./history-owner-ty29fz0f.js");
15957
+ const handed = await handoffHistoryWork({
15958
+ storageDir: args.storageDir ?? getMagicContextStorageDir(),
15959
+ directory,
15960
+ sessionId,
15961
+ method: "recomp",
15962
+ params,
15963
+ readDirectory: () => readDirectory(sessionId)
15964
+ });
15965
+ if (handed)
15966
+ return handed;
15967
+ }
15938
15968
  const dir = String(params.directory ?? directory);
15939
15969
  if (config.transform_mode === "rust") {
15940
15970
  return executeRustRecompRpc(rustModeModuleClient, sessionId, dir);
@@ -15942,8 +15972,8 @@ function registerRpcHandlers(rpcServer, args) {
15942
15972
  const db = readDatabase();
15943
15973
  if (!db)
15944
15974
  return { ok: false, error: "db unavailable" };
15945
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-trcgmm23.js"));
15946
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-2tp44tfa.js"));
15975
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-77xc8wpe.js"));
15976
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-q8ngbap3.js"));
15947
15977
  log2(`[rpc] recomp requested for session ${sessionId}`);
15948
15978
  if (!args.client && !args.hiddenCompletionExecutor) {
15949
15979
  return {
@@ -15999,6 +16029,21 @@ function registerRpcHandlers(rpcServer, args) {
15999
16029
  return { ok: true, message };
16000
16030
  });
16001
16031
  rpcServer.handle("wrapup", async (params) => {
16032
+ const readDirectory = args.readSessionDirectory;
16033
+ if (readDirectory && params.sessionId) {
16034
+ const { handoffHistoryWork } = await import("./history-owner-ty29fz0f.js");
16035
+ const sessionId = String(params.sessionId);
16036
+ const handed = await handoffHistoryWork({
16037
+ storageDir: args.storageDir ?? getMagicContextStorageDir(),
16038
+ directory,
16039
+ sessionId,
16040
+ method: "wrapup",
16041
+ params,
16042
+ readDirectory: () => readDirectory(sessionId)
16043
+ });
16044
+ if (handed)
16045
+ return handed;
16046
+ }
16002
16047
  const sessionId = String(params.sessionId ?? "");
16003
16048
  if (!sessionId)
16004
16049
  return { ok: false, error: "no session" };
@@ -16012,7 +16057,7 @@ function registerRpcHandlers(rpcServer, args) {
16012
16057
  const db = readDatabase();
16013
16058
  if (!db)
16014
16059
  return { ok: false, error: "db unavailable" };
16015
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-df61jmz9.js"));
16060
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-b1z99yg5.js"));
16016
16061
  const model = liveSessionState.liveModelBySession.get(sessionId);
16017
16062
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16018
16063
  const ctx = {
@@ -16203,7 +16248,7 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
16203
16248
  lastBoundMessageIdBySession.set(args.sessionId, args.messageId);
16204
16249
  pendingDecisionBySession.delete(args.sessionId);
16205
16250
  const token = addScheduledWriteToken(args.sessionId);
16206
- setTimeout(() => {
16251
+ inRootAsyncContext2(() => setTimeout(() => {
16207
16252
  try {
16208
16253
  if (!hasScheduledWriteToken(args.sessionId, token))
16209
16254
  return;
@@ -16217,7 +16262,7 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
16217
16262
  } finally {
16218
16263
  deleteScheduledWriteToken(args.sessionId, token);
16219
16264
  }
16220
- }, 0);
16265
+ }, 0));
16221
16266
  return true;
16222
16267
  }
16223
16268
  function addScheduledWriteToken(sessionId) {
@@ -16378,7 +16423,7 @@ async function maybeDeliverChannel2(sessionId, deps) {
16378
16423
  return false;
16379
16424
  }
16380
16425
  try {
16381
- const reminder = deps.directiveText ?? buildChannel2Reminder(effectiveU, reclaimableToolOutputCount(deps.baseline?.baselineParts ?? []), deps.oldestReclaimableToolTags);
16426
+ const reminder = deps.directiveText ?? buildChannel2Reminder(effectiveU, currentReclaimableToolOutputCount(deps.baseline), deps.oldestReclaimableToolTags);
16382
16427
  const sent = await deliverSyntheticUserMessage(sessionId, {
16383
16428
  client,
16384
16429
  text: reminder,
@@ -19927,16 +19972,19 @@ function rustCaptureDigests(inputs, prior, acceptedInputs) {
19927
19972
  } : undefined);
19928
19973
  return { ...incremental, inputContentSignatures };
19929
19974
  }
19975
+ var contentSnapshotFieldVisitObserverForTests;
19930
19976
  function messageMatchesContentSnapshot(message, snapshot) {
19931
19977
  let fieldIndex = 0;
19932
19978
  const matched = visitMessageContentFields(contentSnapshotValue(message), {
19933
19979
  field(value) {
19980
+ contentSnapshotFieldVisitObserverForTests?.();
19934
19981
  if (!Object.is(value, snapshot.fields[fieldIndex]))
19935
19982
  return false;
19936
19983
  fieldIndex += 1;
19937
19984
  return true;
19938
19985
  },
19939
19986
  beginObject() {
19987
+ contentSnapshotFieldVisitObserverForTests?.();
19940
19988
  const expectedCount = snapshot.fields[fieldIndex];
19941
19989
  if (typeof expectedCount !== "number")
19942
19990
  return;
@@ -23282,15 +23330,27 @@ class UnmanagedOverWindowError extends Error {
23282
23330
  }
23283
23331
 
23284
23332
  // src/hooks/magic-context/unresolved-history-boundary.ts
23333
+ function storedHistoryBoundaryPresence(db, sessionId) {
23334
+ try {
23335
+ const row = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id = ?").get(sessionId);
23336
+ return row?.id ? hasRawSessionMessageById2(sessionId, row.id) : undefined;
23337
+ } catch {
23338
+ return;
23339
+ }
23340
+ }
23341
+
23285
23342
  class UnresolvedHistoryBoundaryError extends Error {
23286
23343
  estimatedTokens;
23287
23344
  contextLimitTokens;
23345
+ boundaryPresent;
23288
23346
  code = "UNRESOLVED_HISTORY_BOUNDARY";
23289
23347
  recoverable = true;
23290
- constructor(estimatedTokens, contextLimitTokens) {
23291
- super(renderUserFacingFailure("history_boundary_unresolved", "plain"));
23348
+ constructor(estimatedTokens, contextLimitTokens, boundaryPresent) {
23349
+ const reason = boundaryPresent === true ? "The boundary row is present in the host store but out of order relative to the loaded history. " : boundaryPresent === false ? "The boundary row is missing from the host store. " : "";
23350
+ super(reason + renderUserFacingFailure("history_boundary_unresolved", "plain"));
23292
23351
  this.estimatedTokens = estimatedTokens;
23293
23352
  this.contextLimitTokens = contextLimitTokens;
23353
+ this.boundaryPresent = boundaryPresent;
23294
23354
  this.name = "UnresolvedHistoryBoundaryError";
23295
23355
  }
23296
23356
  }
@@ -24296,6 +24356,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24296
24356
  const protectedCutoff = protectionWindow.cutoff;
24297
24357
  const tPostProcess = performance.now();
24298
24358
  const postTransformResult = await runPostTransformPhase2({
24359
+ opencode2: deps.storeGeneration === "v2",
24299
24360
  normalizeRecoveryTail,
24300
24361
  compactionMarkerStrategy: deps.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy2,
24301
24362
  sessionId,
@@ -24456,7 +24517,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24456
24517
  });
24457
24518
  if (untrimmed.tokens > boundaryContextLimit) {
24458
24519
  sessionLog2(sessionId, `history boundary unresolved: prefix trim refused and the untrimmed request estimate ${untrimmed.tokens} (trusted=${untrimmed.trusted}) exceeds the context limit ${boundaryContextLimit}; not sending it`);
24459
- throw new UnresolvedHistoryBoundaryError(untrimmed.tokens, boundaryContextLimit);
24520
+ throw new UnresolvedHistoryBoundaryError(untrimmed.tokens, boundaryContextLimit, storedHistoryBoundaryPresence(db, sessionId));
24460
24521
  }
24461
24522
  }
24462
24523
  if (unmanagedOverWindowPass) {
@@ -24854,12 +24915,12 @@ function createRustRefusalRecovery(options) {
24854
24915
  watchers.delete(sessionId);
24855
24916
  };
24856
24917
  const schedule = (sessionId, watcher) => {
24857
- watcher.timer = setTimeout(() => void poll(sessionId, watcher), pollIntervalMs);
24918
+ watcher.timer = inRootAsyncContext2(() => setTimeout(() => void poll(sessionId, watcher), pollIntervalMs));
24858
24919
  };
24859
24920
  const probe = async (watcher, sessionId) => {
24860
24921
  const controller = new AbortController;
24861
24922
  const timeoutError = new Error("rust refusal recovery probe timed out");
24862
- const timer = setTimeout(() => controller.abort(timeoutError), probeTimeoutMs);
24923
+ const timer = inRootAsyncContext2(() => setTimeout(() => controller.abort(timeoutError), probeTimeoutMs));
24863
24924
  try {
24864
24925
  await Promise.race([
24865
24926
  options.moduleClient.call({
@@ -28264,7 +28325,7 @@ class MagicContextRpcServer {
28264
28325
  }
28265
28326
  this.startedAt = Date.now();
28266
28327
  const self = this;
28267
- const server = Bun.serve({
28328
+ const server = inRootAsyncContext2(() => Bun.serve({
28268
28329
  port: 0,
28269
28330
  hostname: "127.0.0.1",
28270
28331
  fetch(req, srv) {
@@ -28287,7 +28348,7 @@ class MagicContextRpcServer {
28287
28348
  self.sockets.delete(ws);
28288
28349
  }
28289
28350
  }
28290
- });
28351
+ }));
28291
28352
  this.server = server;
28292
28353
  this.port = server.port ?? 0;
28293
28354
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA4GvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAqiCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA8GvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAuiCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}