@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
@@ -1,3 +1,98 @@
1
+ import {
2
+ isToolFreeHiddenAgent,
3
+ TOOL_USE_DISABLED,
4
+ ZEN_READ_AGENT_SUFFIX,
5
+ needsBlockedRead,
6
+ withBlockedReadInstruction,
7
+ rememberV1HiddenRun,
8
+ retreatPastHostUnservedRows,
9
+ snapTerminalCompartmentToServedRow,
10
+ isHostRenderedSystemMessage,
11
+ completedToolArcCrossesBoundary,
12
+ buildToolArcs,
13
+ fenceBoundaryForCompletedToolArcs,
14
+ fenceBoundaryForToolArcs,
15
+ buildTrueRawTokenIndex,
16
+ computeRawRangeFingerprint,
17
+ DreamTokenBudgetExceeded,
18
+ TOKEN_BUDGET_FINALIZE_MESSAGE,
19
+ registerBudgetFinalizeChild,
20
+ releaseBudgetFinalizeChild,
21
+ createDreamTokenBudget,
22
+ MERGED_REASONING_PARTS_PREFIX,
23
+ decodeMergedReasoningParts,
24
+ escalationBands,
25
+ sessionDecisionCalibration,
26
+ SESSION_META_SELECT_COLUMNS,
27
+ META_COLUMNS,
28
+ BOOLEAN_META_KEYS,
29
+ NULL_BIND_META_KEYS,
30
+ isSessionMetaRow,
31
+ getDefaultSessionMeta,
32
+ ensureSessionMetaRow,
33
+ toSessionMeta,
34
+ persistCachedM0,
35
+ clearCachedM0M1,
36
+ isRustMarkerAdmissionFenced,
37
+ readReplayEnvelope,
38
+ readReplayDocument,
39
+ writeReplayDocument,
40
+ describeProtectedTailDrainBudgetSkip,
41
+ loadProtectedTailMeta,
42
+ markProtectedTailPolicyV3Seeded,
43
+ recordProtectedTailPublicationFloor,
44
+ recordProtectedTailNoEligibleHead,
45
+ isWrapupInProgress,
46
+ reserveProtectedTailDrainTokens,
47
+ clearEmergencyDrainLatch,
48
+ recordHistorianDrainFailure,
49
+ clearHistorianDrainFailure,
50
+ rollbackProtectedTailDrainReservation,
51
+ getPersistedNoteNudge,
52
+ setPersistedNoteNudgeTrigger,
53
+ setPersistedNoteNudgeTriggerMessageId,
54
+ getNoteNudgeAnchors,
55
+ deliverNoteNudgeAtomic,
56
+ queueAutoSearchHintDecisionRetirement,
57
+ getNoteLastReadAt,
58
+ getHistorianFailureState,
59
+ incrementHistorianFailure,
60
+ clearHistorianFailureState,
61
+ getOverflowState,
62
+ clearEmergencyRecovery,
63
+ getPersistedCompactionMarkerState,
64
+ setPersistedCompactionMarkerState,
65
+ parseStrippedPlaceholderState,
66
+ serializeStrippedPlaceholderState,
67
+ THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
68
+ THINKING_BINDING_STRIP_ORDER_END_MARKER,
69
+ getMergedReasoningStrippedIds,
70
+ addMergedReasoningStrippedIds,
71
+ parseProcessedImageMarkers,
72
+ serializeProcessedImageMarkers,
73
+ getPendingCompactionMarkerState,
74
+ setPendingCompactionMarkerState,
75
+ clearPendingCompactionMarkerStateIf,
76
+ getPendingPiCompactionMarkerState,
77
+ logPiCompactionMarkerClear,
78
+ detectOverflow,
79
+ resolveHostServedBoundaryId2,
80
+ hasRawMessageProvider2,
81
+ withRawSessionMessageCache2,
82
+ getRawSessionMessageOrdinalCount2,
83
+ readRawSessionMessageRange2,
84
+ prepareRawSessionOrdinals2,
85
+ primeTailRawMessageCache2,
86
+ getCachedAbsoluteMessageCount2,
87
+ readRawSessionMessageIdOrdinalsForRange2,
88
+ hasRawSessionMessageById2,
89
+ readRawSessionMessageOrdinalById2,
90
+ compareRawSessionMessageOrder2,
91
+ getRawSessionMessageCount2,
92
+ getRawSessionTagKeysThrough2,
93
+ getLegacyProtectedTailStartOrdinal2,
94
+ readSessionChunk2
95
+ } from "./index-wpwpn7nj.js";
1
96
  import {
2
97
  getHarness2,
3
98
  harnessOwnsOpenCodeStore2
@@ -11,7 +106,7 @@ import {
11
106
  sanitizeDiagnosticText,
12
107
  log2,
13
108
  sessionLog2
14
- } from "./index-nsjyysj0.js";
109
+ } from "./index-mvvephtj.js";
15
110
  import {
16
111
  createScanner,
17
112
  parseTree,
@@ -34,7 +129,7 @@ import {
34
129
  deriveTriggerBudget2,
35
130
  resolveHistorianProducerLimits2,
36
131
  producerSourceLocalBudget2
37
- } from "./index-w23dh319.js";
132
+ } from "./index-jw4gbfkv.js";
38
133
  import {
39
134
  withContentLanguageDirective,
40
135
  buildPrimaryLanguageDirective,
@@ -47,7 +142,7 @@ import {
47
142
  ConfigProfilesSchema,
48
143
  MagicContextConfigSchema,
49
144
  LIVE_RELOAD_CONFIG_PATHS
50
- } from "./index-k6xvbj2e.js";
145
+ } from "./index-w28y7d0z.js";
51
146
  import {
52
147
  providerMass,
53
148
  calibrationForModelKey,
@@ -57,26 +152,28 @@ import {
57
152
  hasMeaningfulUserText2,
58
153
  estimateTokens,
59
154
  estimateFixedPromptTokens
60
- } from "./index-qx53vezw.js";
155
+ } from "./index-gjvjh960.js";
61
156
  import {
62
157
  FAIL_CLOSED_DOCTOR_COMMAND,
63
158
  getSchemaFenceRejection,
64
159
  LATEST_SUPPORTED_VERSION,
65
160
  getPersistedSchemaVersion,
66
161
  openDatabase
67
- } from "./index-4btknbqh.js";
68
- import {
69
- isPidAlive
70
- } from "./index-w4mw92w3.js";
162
+ } from "./index-swgpe402.js";
71
163
  import {
164
+ inRootAsyncContext2,
72
165
  Database2,
73
166
  withSqliteBackgroundWriter2,
74
167
  withoutSqliteTransformPass2,
75
168
  beginSqliteWriterAsync2
76
- } from "./index-j8epsc0g.js";
169
+ } from "./index-wafzvyhg.js";
77
170
  import {
78
- sameProjectDirectory
79
- } from "./index-rzmjkdd6.js";
171
+ shouldSkipHomeProjectMemory,
172
+ resolveProjectIdentity
173
+ } from "./index-0jz47061.js";
174
+ import {
175
+ isPidAlive
176
+ } from "./index-q28hsbpg.js";
80
177
  import {
81
178
  layoutLkgPrefix,
82
179
  assembleLkgPrefix,
@@ -87,10 +184,10 @@ import {
87
184
  resolveStoredPathWorkspaceIdentity,
88
185
  sourceNameForMemory,
89
186
  computeWorkspaceEpochFingerprint
90
- } from "./index-j5hce1ab.js";
187
+ } from "./index-a865mj02.js";
91
188
  import {
92
189
  getTableColumnNames
93
- } from "./index-1bt88epp.js";
190
+ } from "./index-g7jkrz0x.js";
94
191
  import {
95
192
  V2_MEMORY_CATEGORIES,
96
193
  CATEGORY_PRIORITY,
@@ -102,13 +199,9 @@ import {
102
199
  openCodeDbPathExists,
103
200
  claimOpenCodeDbDiagnosticOnce
104
201
  } from "./index-58e3y90n.js";
105
- import {
106
- shouldSkipHomeProjectMemory,
107
- resolveProjectIdentity
108
- } from "./index-g8qbdb03.js";
109
202
  import {
110
203
  getMeasuredToolDefinitionTokens
111
- } from "./index-h2wc01qk.js";
204
+ } from "./index-9jvab89d.js";
112
205
  import {
113
206
  buildCanonicalChunkTextFromFts,
114
207
  buildCompartmentSummaryFallbackText,
@@ -118,7 +211,7 @@ import {
118
211
  replaceCompartmentChunkEmbeddings,
119
212
  deleteChunkEmbedBackoffForSession,
120
213
  chunkWindowSourceKey
121
- } from "./index-ax2jhztn.js";
214
+ } from "./index-7bjgyaj1.js";
122
215
  import {
123
216
  BoundedSessionMap,
124
217
  clearCompressionDepth,
@@ -133,96 +226,7 @@ import {
133
226
  toMessageIndexSource2,
134
227
  clearIndexedMessagesInTransaction2,
135
228
  indexSourcesAfterOrdinal2
136
- } from "./index-wq16ahsn.js";
137
- import {
138
- retreatPastHostUnservedRows,
139
- snapTerminalCompartmentToServedRow,
140
- isHostRenderedSystemMessage,
141
- completedToolArcCrossesBoundary,
142
- buildToolArcs,
143
- fenceBoundaryForCompletedToolArcs,
144
- fenceBoundaryForToolArcs,
145
- buildTrueRawTokenIndex,
146
- computeRawRangeFingerprint,
147
- DreamTokenBudgetExceeded,
148
- TOKEN_BUDGET_FINALIZE_MESSAGE,
149
- registerBudgetFinalizeChild,
150
- releaseBudgetFinalizeChild,
151
- createDreamTokenBudget,
152
- MERGED_REASONING_PARTS_PREFIX,
153
- decodeMergedReasoningParts,
154
- escalationBands,
155
- sessionDecisionCalibration,
156
- SESSION_META_SELECT_COLUMNS,
157
- META_COLUMNS,
158
- BOOLEAN_META_KEYS,
159
- NULL_BIND_META_KEYS,
160
- isSessionMetaRow,
161
- getDefaultSessionMeta,
162
- ensureSessionMetaRow,
163
- toSessionMeta,
164
- persistCachedM0,
165
- clearCachedM0M1,
166
- isRustMarkerAdmissionFenced,
167
- readReplayEnvelope,
168
- readReplayDocument,
169
- writeReplayDocument,
170
- describeProtectedTailDrainBudgetSkip,
171
- loadProtectedTailMeta,
172
- markProtectedTailPolicyV3Seeded,
173
- recordProtectedTailPublicationFloor,
174
- recordProtectedTailNoEligibleHead,
175
- isWrapupInProgress,
176
- reserveProtectedTailDrainTokens,
177
- clearEmergencyDrainLatch,
178
- recordHistorianDrainFailure,
179
- clearHistorianDrainFailure,
180
- rollbackProtectedTailDrainReservation,
181
- getPersistedNoteNudge,
182
- setPersistedNoteNudgeTrigger,
183
- setPersistedNoteNudgeTriggerMessageId,
184
- getNoteNudgeAnchors,
185
- deliverNoteNudgeAtomic,
186
- queueAutoSearchHintDecisionRetirement,
187
- getNoteLastReadAt,
188
- getHistorianFailureState,
189
- incrementHistorianFailure,
190
- clearHistorianFailureState,
191
- getOverflowState,
192
- clearEmergencyRecovery,
193
- getPersistedCompactionMarkerState,
194
- setPersistedCompactionMarkerState,
195
- parseStrippedPlaceholderState,
196
- serializeStrippedPlaceholderState,
197
- THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
198
- THINKING_BINDING_STRIP_ORDER_END_MARKER,
199
- getMergedReasoningStrippedIds,
200
- addMergedReasoningStrippedIds,
201
- parseProcessedImageMarkers,
202
- serializeProcessedImageMarkers,
203
- getPendingCompactionMarkerState,
204
- setPendingCompactionMarkerState,
205
- clearPendingCompactionMarkerStateIf,
206
- getPendingPiCompactionMarkerState,
207
- logPiCompactionMarkerClear,
208
- detectOverflow,
209
- resolveHostServedBoundaryId2,
210
- hasRawMessageProvider2,
211
- withRawSessionMessageCache2,
212
- getRawSessionMessageOrdinalCount2,
213
- readRawSessionMessageRange2,
214
- prepareRawSessionOrdinals2,
215
- primeTailRawMessageCache2,
216
- getCachedAbsoluteMessageCount2,
217
- readRawSessionMessageIdOrdinalsForRange2,
218
- hasRawSessionMessageById2,
219
- readRawSessionMessageOrdinalById2,
220
- compareRawSessionMessageOrder2,
221
- getRawSessionMessageCount2,
222
- getRawSessionTagKeysThrough2,
223
- getLegacyProtectedTailStartOrdinal2,
224
- readSessionChunk2
225
- } from "./index-n5a170gs.js";
229
+ } from "./index-0x9cn9w1.js";
226
230
  import {
227
231
  stripWellFormedLeadingTagPrefix,
228
232
  stripTagPrefix,
@@ -235,15 +239,15 @@ import {
235
239
  foldShrunkPartTags2,
236
240
  getTagNumberByMessageId2,
237
241
  getActiveTagsBySession2
238
- } from "./index-tmtty2x5.js";
242
+ } from "./index-f8cn4xqa.js";
239
243
  import {
240
244
  isStrictGapHealingMessage2,
241
245
  noteRawSessionSummaryRowWritten2
242
- } from "./index-37q80veb.js";
246
+ } from "./index-angx1s0k.js";
243
247
  import {
244
248
  withReadOnlySessionDb,
245
249
  getMessageTimesFromOpenCodeDb
246
- } from "./index-a8acx4gc.js";
250
+ } from "./index-q76br5zn.js";
247
251
  import {
248
252
  drainBackgroundBatches,
249
253
  contentSha2562,
@@ -251,7 +255,7 @@ import {
251
255
  getProjectChunkEmbeddingModelId2,
252
256
  getProjectEmbeddingMaxInputTokens2,
253
257
  embedItemsForProject2
254
- } from "./index-sf94at64.js";
258
+ } from "./index-rg1cezmj.js";
255
259
  import {
256
260
  renderUserFacingFailure,
257
261
  userFacingFailureCode,
@@ -260,7 +264,7 @@ import {
260
264
  insertPrimerCandidates,
261
265
  promoteSessionFactsDurable,
262
266
  embedPromotedFacts
263
- } from "./index-n7kwfw2r.js";
267
+ } from "./index-16vwdyy5.js";
264
268
  import {
265
269
  pushNotification2
266
270
  } from "./index-x8a7jmkh.js";
@@ -271,16 +275,19 @@ import {
271
275
  getMemoriesByProject2,
272
276
  getMemoriesByProjects2,
273
277
  getMaxMemoryIdForProjects2
274
- } from "./index-9yyqq3mm.js";
278
+ } from "./index-n78avt2p.js";
275
279
  import {
276
280
  isMarkerCandidateBasisCurrent2,
277
281
  invalidateMarkerCandidateBasis2,
278
282
  readMarkerCandidateBasis2,
279
283
  prepareMarkerCandidateBasis2
280
- } from "./index-sh91t19a.js";
284
+ } from "./index-s178h9z8.js";
281
285
  import {
282
286
  sendStatusNotification2
283
- } from "./index-vt4sf4ep.js";
287
+ } from "./index-pgy3h49n.js";
288
+ import {
289
+ sameProjectDirectory
290
+ } from "./index-knvkbfvh.js";
284
291
  import {
285
292
  getErrorMessage,
286
293
  describeError
@@ -298,7 +305,7 @@ import {
298
305
  import {
299
306
  logSlowWriteTransaction,
300
307
  WriteTransactionSteps
301
- } from "./index-4mjhqadz.js";
308
+ } from "./index-150zz6fh.js";
302
309
 
303
310
  // src/agents/permissions.ts
304
311
  function buildAllowOnlyPermission(allowedTools, agentLabel) {
@@ -497,6 +504,13 @@ function buildHiddenAgentRegistrations(args) {
497
504
  }
498
505
  ];
499
506
  }
507
+ function buildZenReadAgentRegistrations(registrations) {
508
+ return registrations.filter((registration) => isToolFreeHiddenAgent(registration.id)).map((registration) => ({
509
+ ...registration,
510
+ id: `${registration.id}${ZEN_READ_AGENT_SUFFIX}`,
511
+ allowedTools: ["read"]
512
+ }));
513
+ }
500
514
  function buildHiddenAgentConfig(prompt, allowedTools, maxSteps, overrides, agentLabel, lockPermissions = false, description) {
501
515
  const {
502
516
  permission: overridePermission,
@@ -515,7 +529,7 @@ function buildHiddenAgentConfig(prompt, allowedTools, maxSteps, overrides, agent
515
529
  ...overrideTools !== undefined ? { tools: overrideTools } : {}
516
530
  };
517
531
  const basePermission = buildAllowOnlyPermission(allowedTools, agentLabel);
518
- if (lockPermissions && agentLabel?.startsWith("historian") && allowedTools.length === 0) {
532
+ if (lockPermissions && (agentLabel?.startsWith("historian") && allowedTools.length === 0 || agentLabel?.endsWith(ZEN_READ_AGENT_SUFFIX))) {
519
533
  basePermission.task = "deny";
520
534
  }
521
535
  return {
@@ -5035,7 +5049,7 @@ var V2_MESSAGE_PAGE_SQL = `WITH bounds AS (
5035
5049
  SELECT seq FROM session_message
5036
5050
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
5037
5051
  ORDER BY seq ASC LIMIT 1 OFFSET ?
5038
- ), -1) END AS after_seq,
5052
+ ), (SELECT MAX(seq) FROM session_message WHERE session_id = ?), -1) END AS after_seq,
5039
5053
  COALESCE((
5040
5054
  SELECT seq FROM session_message
5041
5055
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
@@ -5296,7 +5310,7 @@ class V2StoreReader {
5296
5310
  }
5297
5311
  }
5298
5312
  const maximumSeq = Number.MAX_SAFE_INTEGER;
5299
- const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
5313
+ const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
5300
5314
  return rows.map(decode);
5301
5315
  });
5302
5316
  }
@@ -8966,10 +8980,12 @@ function hiddenToolLoop(identity) {
8966
8980
  function hiddenAgentAllowedTools(agent) {
8967
8981
  return agent !== undefined && Object.hasOwn(AGENT_TOOLS, agent) ? AGENT_TOOLS[agent] : undefined;
8968
8982
  }
8969
- function hiddenChildPermissions(agent) {
8983
+ function hiddenChildPermissions(agent, providerID) {
8984
+ const tools = AGENT_TOOLS[agent] ?? [];
8985
+ const visible = tools.length === 0 && needsBlockedRead(agent, providerID) ? ["read"] : tools;
8970
8986
  return [
8971
8987
  { action: "*", resource: "*", effect: "deny" },
8972
- ...(AGENT_TOOLS[agent] ?? []).map((tool) => ({
8988
+ ...visible.map((tool) => ({
8973
8989
  action: tool,
8974
8990
  resource: "*",
8975
8991
  effect: "allow"
@@ -8988,7 +9004,7 @@ async function registerHiddenChildAgents(agent) {
8988
9004
  config.request.headers = {};
8989
9005
  config.request.body = {};
8990
9006
  config.steps = AGENT_STEPS[id];
8991
- config.permissions = hiddenChildPermissions(id);
9007
+ config.permissions = hiddenChildPermissions(id, "opencode");
8992
9008
  });
8993
9009
  }
8994
9010
  });
@@ -9002,6 +9018,8 @@ function hiddenToolCallRefusal(call, hook) {
9002
9018
  }
9003
9019
  if (allowed.includes(call.tool))
9004
9020
  return;
9021
+ if (owned && allowed.length === 0)
9022
+ return `${TOOL_USE_DISABLED}; ${call.tool} refused`;
9005
9023
  return `Magic Context hidden agent ${agent} may only use ${allowed.length > 0 ? allowed.join(", ") : "no tools"}; ${call.tool} refused`;
9006
9024
  }
9007
9025
 
@@ -9205,7 +9223,13 @@ class HiddenChildHook {
9205
9223
  }
9206
9224
  selected.steps = steps;
9207
9225
  const system = typeof selected.request.body.system === "string" ? selected.request.body.system : selected.identity.system;
9208
- draft.system = [{ type: "text", text: system }];
9226
+ const blockedRead = needsBlockedRead(selected.identity.agent, draft.model.providerID) && draft.tools.read !== undefined;
9227
+ draft.system = [
9228
+ {
9229
+ type: "text",
9230
+ text: blockedRead ? withBlockedReadInstruction(system, selected.identity) : system
9231
+ }
9232
+ ];
9209
9233
  if (!selected.shaped) {
9210
9234
  draft.messages = [
9211
9235
  { role: "user", content: this.calibratedParts(selected, draft, raw) }
@@ -9227,7 +9251,7 @@ class HiddenChildHook {
9227
9251
  ];
9228
9252
  }
9229
9253
  draft.options = authoredOptions(selected);
9230
- const allowed = AGENT_TOOLS[hiddenAgentFor(selected.identity)] ?? [];
9254
+ const allowed = blockedRead ? ["read"] : AGENT_TOOLS[hiddenAgentFor(selected.identity)] ?? [];
9231
9255
  draft.tools = Object.fromEntries(allowed.flatMap((id) => draft.tools[id] ? [[id, draft.tools[id]]] : []));
9232
9256
  if (selected.identity.agent === DREAMER_MEMORY_MAPPER_AGENT && steps >= cap - 2) {
9233
9257
  selected.budget ??= createDreamTokenBudget(typeof selected.identity.metadata?.tokenBudget === "number" ? selected.identity.metadata.tokenBudget : Number.MAX_SAFE_INTEGER);
@@ -15180,6 +15204,37 @@ function capturePrefixTrimSourceOrder(messages) {
15180
15204
  invalidReason
15181
15205
  });
15182
15206
  }
15207
+ function reanchorStoredBoundary(options, boundary) {
15208
+ if (!options.messages)
15209
+ return;
15210
+ const source = options.prefixTrimSourceOrder ?? capturePrefixTrimSourceOrder(options.messages);
15211
+ if (source.invalidReason)
15212
+ return;
15213
+ try {
15214
+ if (compareRawSessionMessageOrder2(options.sessionId, boundary, boundary) !== 0)
15215
+ return;
15216
+ const messageIds = [...source.messageIds];
15217
+ let previous;
15218
+ let insertion = messageIds.length;
15219
+ for (const [index, id] of messageIds.entries()) {
15220
+ if (previous) {
15221
+ const increasing = compareRawSessionMessageOrder2(options.sessionId, previous, id);
15222
+ if (increasing === null || !Number.isFinite(increasing) || increasing >= 0)
15223
+ return;
15224
+ }
15225
+ const order = compareRawSessionMessageOrder2(options.sessionId, boundary, id);
15226
+ if (order === null || !Number.isFinite(order) || order === 0)
15227
+ return;
15228
+ if (order < 0 && insertion === messageIds.length)
15229
+ insertion = index;
15230
+ previous = id;
15231
+ }
15232
+ messageIds.splice(insertion, 0, boundary);
15233
+ return { ...source, messageIds };
15234
+ } catch {
15235
+ return;
15236
+ }
15237
+ }
15183
15238
  function trimToPreparedPrefix(options, prepared) {
15184
15239
  if (options.compactionOff || !options.messages)
15185
15240
  return "not-attempted";
@@ -15204,7 +15259,8 @@ function trimToPreparedPrefix(options, prepared) {
15204
15259
  });
15205
15260
  const boundaryPosition = sourcePosition.get(boundary) ?? sourcePosition.get(resolveHostServedBoundaryId2(options.sessionId, boundary));
15206
15261
  if (boundaryPosition === undefined) {
15207
- status = refuse("boundary absent from immutable source order");
15262
+ const reanchored = reanchorStoredBoundary(options, boundary);
15263
+ status = reanchored ? trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared) : refuse("boundary absent from immutable source order");
15208
15264
  } else {
15209
15265
  let lastSourcePosition = -1;
15210
15266
  let sawPersistedRow = false;
@@ -15215,8 +15271,7 @@ function trimToPreparedPrefix(options, prepared) {
15215
15271
  for (const [index, message] of options.messages.entries()) {
15216
15272
  const id = message.info.id;
15217
15273
  if (isHostRenderedSystemMessage(message)) {
15218
- if (lastSourcePosition >= boundaryPosition)
15219
- retained.push(message);
15274
+ retained.push(message);
15220
15275
  continue;
15221
15276
  }
15222
15277
  if (typeof id !== "string" || id.length === 0) {
@@ -15259,12 +15314,19 @@ function trimToPreparedPrefix(options, prepared) {
15259
15314
  } else {
15260
15315
  const index = findBoundaryIndex(options.sessionId, options.messages, boundary);
15261
15316
  if (index >= 0) {
15262
- const removed = options.messages.splice(0, index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1));
15317
+ const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
15318
+ const unplaced = options.messages.slice(0, cut).filter(isHostRenderedSystemMessage);
15319
+ const removed = options.messages.splice(0, cut, ...unplaced);
15263
15320
  retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
15264
15321
  resetPrefixTrimFallbackState(options.sessionId);
15265
15322
  status = "applied";
15266
15323
  } else {
15267
- status = classifyAbsentBoundary(options, options.messages, boundary);
15324
+ const reanchored = reanchorStoredBoundary(options, boundary);
15325
+ if (reanchored && reanchored.messageIds[0] !== boundary) {
15326
+ status = trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
15327
+ } else {
15328
+ status = classifyAbsentBoundary(options, options.messages, boundary);
15329
+ }
15268
15330
  }
15269
15331
  }
15270
15332
  }
@@ -17535,6 +17597,8 @@ function createV1HiddenCompletionExecutor(client, db, directory) {
17535
17597
  preferResponseOnMissingData: true
17536
17598
  });
17537
17599
  const id = typeof created?.id === "string" ? created.id : "";
17600
+ if (id)
17601
+ rememberV1HiddenRun(id, run);
17538
17602
  if (id && run.kind !== "dreamer-task") {
17539
17603
  historianChildren.add(id);
17540
17604
  rememberHistorianOutputCap(id, run.maxOutputTokens);
@@ -17585,6 +17649,7 @@ function createV1HiddenCompletionExecutor(client, db, directory) {
17585
17649
  },
17586
17650
  async close(handle, settlement) {
17587
17651
  if (handle?.id) {
17652
+ rememberV1HiddenRun(handle.id, undefined);
17588
17653
  historianChildren.delete(handle.id);
17589
17654
  forgetHistorianOutputCap(handle.id);
17590
17655
  }
@@ -20900,6 +20965,7 @@ Historian pass ${passCount + 1}, attempt ${passAttempt} started for messages ${c
20900
20965
  sequenceOffset: candidateCompartments.length,
20901
20966
  dumpLabelBase: `recomp-${sessionId}-${chunk.startIndex}-${chunk.endIndex}-pass-${passCount + 1}`,
20902
20967
  timeoutMs: historianTimeoutMs,
20968
+ maxOutputTokens: deps.historianMaxOutputTokens,
20903
20969
  model: deps.model,
20904
20970
  fallbackModelId: deps.fallbackModelId,
20905
20971
  fallbackModels: deps.fallbackModels,
@@ -21414,7 +21480,6 @@ ${renderUserFacingFailure("recomp_unavailable")}`;
21414
21480
  }
21415
21481
  }
21416
21482
  }
21417
-
21418
21483
  // src/hooks/magic-context/compartment-runner.ts
21419
21484
  var activeRuns = new Map;
21420
21485
  function getActiveCompartmentRun(sessionId) {
@@ -21450,7 +21515,7 @@ function withPublishedCallback(deps) {
21450
21515
  };
21451
21516
  }
21452
21517
  function startLeaseRenewal(deps, holderId) {
21453
- return setInterval(() => {
21518
+ return inRootAsyncContext2(() => setInterval(() => {
21454
21519
  try {
21455
21520
  if (!renewCompartmentLease(deps.db, deps.sessionId, holderId)) {
21456
21521
  sessionLog2(deps.sessionId, "compartment lease renewal failed; publish will be skipped if holder is stale");
@@ -21458,7 +21523,7 @@ function startLeaseRenewal(deps, holderId) {
21458
21523
  } catch (err) {
21459
21524
  sessionLog2(deps.sessionId, `compartment lease renewal threw; publish will be skipped if holder is stale (${err instanceof Error ? err.message : String(err)})`);
21460
21525
  }
21461
- }, COMPARTMENT_LEASE_RENEWAL_MS);
21526
+ }, COMPARTMENT_LEASE_RENEWAL_MS));
21462
21527
  }
21463
21528
  function startCompartmentAgent(deps, runAgent = runCompartmentAgent, prepareBoundary) {
21464
21529
  withoutSqliteTransformPass2(() => startBackgroundCompartmentAgent(deps, runAgent, prepareBoundary));
@@ -21594,4 +21659,4 @@ async function executeContextRecomp(deps, options = {}) {
21594
21659
  return (await executeContextRecompWithResult(deps, options)).message;
21595
21660
  }
21596
21661
 
21597
- export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, COMPACTION_ENABLED_PATH, isDreamerRunnable, isHistorianRunnable, isCompactionEnabled, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, embedPauseBySession, embedRunStateBySession, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
21662
+ export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, COMPACTION_ENABLED_PATH, isDreamerRunnable, isHistorianRunnable, isCompactionEnabled, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, embedPauseBySession, embedRunStateBySession, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  importPluginModule,
3
3
  log2
4
- } from "./index-nsjyysj0.js";
4
+ } from "./index-mvvephtj.js";
5
5
  import {
6
6
  sendStatusNotification2
7
- } from "./index-vt4sf4ep.js";
7
+ } from "./index-pgy3h49n.js";
8
8
  import {
9
9
  formatConflictShort
10
- } from "./index-z1tjp257.js";
10
+ } from "./index-b64n4d0h.js";
11
11
 
12
12
  // src/plugin/conflict-warning-hook.ts
13
13
  import { existsSync, readFileSync } from "node:fs";