@cortexkit/opencode-magic-context 0.49.6 → 0.49.8

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 (255) hide show
  1. package/dist/auto-search-worker.js +10 -7
  2. package/dist/compaction-marker-candidates-worker.js +2 -2
  3. package/dist/{compaction-marker-candidates-cz72pm1t.js → compaction-marker-candidates-xxz35vwp.js} +3 -3
  4. package/dist/{conflict-warning-hook-1jq1rxx7.js → conflict-warning-hook-w3crzrar.js} +8 -8
  5. package/dist/{context-ae3gxdye.js → context-x0ccfv0f.js} +88 -53
  6. package/dist/{derive-budgets-j4ry8j8n.js → derive-budgets-3nbxsyss.js} +2 -2
  7. package/dist/embedding-backfill-3h2m5n0q.js +21 -0
  8. package/dist/embedding-worker-process.js +6 -2
  9. package/dist/embedding-worker.js +6 -5
  10. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
  11. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  12. package/dist/features/magic-context/dreamer/cron.d.ts +2 -0
  13. package/dist/features/magic-context/dreamer/cron.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +6 -3
  15. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +7 -1
  17. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/map-memories.d.ts +2 -2
  19. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/primer-seed.d.ts +2 -0
  21. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +1 -0
  23. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +2 -2
  25. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  26. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  27. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  28. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  29. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  30. package/dist/features/magic-context/smart-notes/wake-plane.d.ts.map +1 -1
  31. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  32. package/dist/features/magic-context/storage-meta-persisted.d.ts +10 -3
  33. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  34. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  35. package/dist/features/magic-context/storage-replay-document.d.ts +4 -0
  36. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  37. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  38. package/dist/history-owner-ty29fz0f.js +244 -0
  39. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
  41. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
  46. package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/module-transport.d.ts +1 -0
  52. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/note-nudger.d.ts +5 -3
  54. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/read-session-chunk.d.ts +15 -4
  58. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/replay-committed-drops.d.ts +9 -0
  60. package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -0
  61. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts +2 -2
  62. package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/rust-mode-transform.d.ts +4 -0
  64. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/rust-served-raw.d.ts +29 -0
  67. package/dist/hooks/magic-context/rust-served-raw.d.ts.map +1 -0
  68. package/dist/hooks/magic-context/strip-content.d.ts +23 -24
  69. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
  71. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  72. package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
  73. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
  77. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  79. package/dist/{index-g9exahnx.js → index-0jz47061.js} +6 -3
  80. package/dist/{index-4mjhqadz.js → index-150zz6fh.js} +1 -1
  81. package/dist/{index-ch08qwgd.js → index-2rw244rh.js} +88 -81
  82. package/dist/{index-6q5h70h2.js → index-4hb8nt93.js} +3 -3
  83. package/dist/{index-j55vn694.js → index-7bjgyaj1.js} +4 -4
  84. package/dist/{index-h2wc01qk.js → index-8kk7yh6m.js} +2 -2
  85. package/dist/{index-vztbgcdk.js → index-9g1c4bt9.js} +304 -92
  86. package/dist/{index-7q1m1qjk.js → index-a43xq1pg.js} +5 -5
  87. package/dist/{index-tqf7yg27.js → index-a4b0gbyg.js} +1 -1
  88. package/dist/{index-vnjhmkwk.js → index-angx1s0k.js} +4 -3
  89. package/dist/{index-1xaw2pq8.js → index-b4gcb3rk.js} +8 -8
  90. package/dist/{index-z1tjp257.js → index-b64n4d0h.js} +1 -1
  91. package/dist/{index-1bt88epp.js → index-bd9cjab3.js} +1 -1
  92. package/dist/{index-gbmqa9x9.js → index-bmwfzz28.js} +9 -6
  93. package/dist/{index-qx53vezw.js → index-gjvjh960.js} +1 -1
  94. package/dist/{index-zgzdm6dg.js → index-gzg9ekc1.js} +155 -103
  95. package/dist/{index-vh3e2mvr.js → index-hxrvx6cy.js} +121 -51
  96. package/dist/{index-w23dh319.js → index-jw4gbfkv.js} +1 -1
  97. package/dist/index-knvkbfvh.js +25 -0
  98. package/dist/{index-vkbqdnkj.js → index-kvw6xew3.js} +6 -3
  99. package/dist/{index-bg5qqene.js → index-mp2kghkv.js} +3 -27
  100. package/dist/{index-nsjyysj0.js → index-mvvephtj.js} +5 -1
  101. package/dist/{index-cm4hmxyk.js → index-n78avt2p.js} +1 -1
  102. package/dist/{index-hr64sth2.js → index-pgy3h49n.js} +4 -4
  103. package/dist/{index-a796ct3s.js → index-pjgzdezw.js} +13 -9
  104. package/dist/{index-9m7bn21d.js → index-q28hsbpg.js} +15 -3
  105. package/dist/{index-ab3bgm2m.js → index-q76br5zn.js} +3 -3
  106. package/dist/{index-xqyj5c85.js → index-qgp5vnt4.js} +5 -5
  107. package/dist/{index-9s58tq95.js → index-rg1cezmj.js} +22 -22
  108. package/dist/{index-f3dnvnw6.js → index-s178h9z8.js} +4 -3
  109. package/dist/{index-mj1fgfrk.js → index-w1ejb9qr.js} +939 -160
  110. package/dist/{index-k6xvbj2e.js → index-w28y7d0z.js} +2 -0
  111. package/dist/{index-0nnd4bry.js → index-wafzvyhg.js} +63 -19
  112. package/dist/{index-ck6y3td2.js → index-xf6k8szp.js} +4 -4
  113. package/dist/{index-1j8jcjpa.js → index-xpn05jxq.js} +4 -4
  114. package/dist/{index-s0gsmthp.js → index-ydjgz36f.js} +7 -7
  115. package/dist/{index-besxhcsh.js → index-zf9nydbd.js} +50 -39
  116. package/dist/index.js +53 -52
  117. package/dist/{logger-ewak5q1s.js → logger-wn328tfg.js} +1 -1
  118. package/dist/{message-index-bounded-630j53ps.js → message-index-bounded-hxjp56qk.js} +16 -16
  119. package/dist/{message-index-c84wm2g0.js → message-index-zs882h8e.js} +16 -16
  120. package/dist/{message-time-backfill-8kj57qe3.js → message-time-backfill-nb5hhnrt.js} +3 -3
  121. package/dist/migration-worker.js +11 -11
  122. package/dist/plugin/boot-quiet.d.ts.map +1 -1
  123. package/dist/plugin/dream-timer.d.ts.map +1 -1
  124. package/dist/plugin/messages-transform.d.ts.map +1 -1
  125. package/dist/plugin/rpc-handlers.d.ts +2 -0
  126. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  127. package/dist/{project-embedding-registry-vv59t7ah.js → project-embedding-registry-vy7sv9jt.js} +11 -11
  128. package/dist/raw-ordinal-warmup-worker.js +17 -15
  129. package/dist/{read-session-chunk-t3vjd0h0.js → read-session-chunk-t9r7r0sg.js} +13 -11
  130. package/dist/{read-session-raw-gf7eytnm.js → read-session-raw-gm6xj30v.js} +3 -3
  131. package/dist/recomp-orchestrator-gr36zvd2.js +60 -0
  132. package/dist/{safe-notification-target-q0cyrx3x.js → safe-notification-target-jdynm677.js} +2 -2
  133. package/dist/{search-kth2p6cc.js → search-qjen1pmz.js} +24 -24
  134. package/dist/{send-session-notification-3j6krd4w.js → send-session-notification-q8ngbap3.js} +6 -6
  135. package/dist/shared/history-owner.d.ts +12 -0
  136. package/dist/shared/history-owner.d.ts.map +1 -0
  137. package/dist/shared/off-thread-migration-clock.d.ts +8 -1
  138. package/dist/shared/off-thread-migration-clock.d.ts.map +1 -1
  139. package/dist/shared/processed-image-eligibility.d.ts +22 -0
  140. package/dist/shared/processed-image-eligibility.d.ts.map +1 -0
  141. package/dist/shared/recovery-reasoning-prefix.d.ts +9 -0
  142. package/dist/shared/recovery-reasoning-prefix.d.ts.map +1 -0
  143. package/dist/shared/redaction.d.ts.map +1 -1
  144. package/dist/shared/rpc-server.d.ts.map +1 -1
  145. package/dist/shared/sqlite.d.ts +3 -1
  146. package/dist/shared/sqlite.d.ts.map +1 -1
  147. package/dist/shared/tag-transcript.d.ts +9 -0
  148. package/dist/shared/tag-transcript.d.ts.map +1 -1
  149. package/dist/shared/user-facing-codes.d.ts +2 -2
  150. package/dist/{sqlite-d7edbk1s.js → sqlite-4pqyynrs.js} +3 -1
  151. package/dist/{storage-memory-af5zdz98.js → storage-memory-j3v3hc83.js} +2 -2
  152. package/dist/{storage-tags-dyj7mmbq.js → storage-tags-a513rkj3.js} +5 -5
  153. package/dist/tools/ctx-expand/search-archive.d.ts +4 -0
  154. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -0
  155. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  156. package/dist/{transform-postprocess-phase-bv3kb5s1.js → transform-postprocess-phase-yv463b7y.js} +30 -30
  157. package/dist/v2/auto-search-worker.js +10 -7
  158. package/dist/v2/{compaction-marker-candidates-6gqp5wrc.js → compaction-marker-candidates-a15w3mqh.js} +3 -3
  159. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  160. package/dist/v2/{context-p8f2shp1.js → context-wd82v9z6.js} +1133 -278
  161. package/dist/v2/{derive-budgets-enckmg7y.js → derive-budgets-0rmpmxjw.js} +3 -3
  162. package/dist/v2/embedding-backfill-vr7wdtrf.js +20 -0
  163. package/dist/v2/embedding-worker-process.js +6 -2
  164. package/dist/v2/embedding-worker.js +6 -5
  165. package/dist/v2/hidden-completion.d.ts.map +1 -1
  166. package/dist/v2/history-owner-2cr9py37.js +243 -0
  167. package/dist/v2/hooks/context.d.ts.map +1 -1
  168. package/dist/v2/hooks/payload.d.ts.map +1 -1
  169. package/dist/v2/hooks/store.d.ts +1 -0
  170. package/dist/v2/hooks/store.d.ts.map +1 -1
  171. package/dist/v2/{logger-pj02s7sr.js → logger-te6e1j72.js} +1 -1
  172. package/dist/v2/{message-index-bounded-yzxmf6vp.js → message-index-bounded-madg2kfr.js} +16 -16
  173. package/dist/v2/{message-index-3ws17x1g.js → message-index-yd94vt9n.js} +16 -16
  174. package/dist/v2/{message-time-backfill-5nf10c65.js → message-time-backfill-rz1pnpaj.js} +3 -3
  175. package/dist/v2/migration-worker.js +11 -11
  176. package/dist/v2/{project-embedding-registry-rsnf2263.js → project-embedding-registry-ja23aygk.js} +11 -11
  177. package/dist/v2/raw-ordinal-warmup-worker.js +17 -15
  178. package/dist/v2/{read-session-chunk-vtb0w2kd.js → read-session-chunk-7qs791f3.js} +13 -11
  179. package/dist/v2/{read-session-raw-gpcddemt.js → read-session-raw-h4azh85b.js} +3 -3
  180. package/dist/v2/recomp-orchestrator-ee91r9s6.js +59 -0
  181. package/dist/v2/{safe-notification-target-y3p1hce9.js → safe-notification-target-936374xx.js} +2 -2
  182. package/dist/v2/search-pn15rr52.js +46 -0
  183. package/dist/v2/{send-session-notification-5aj2j7vf.js → send-session-notification-6n7chhyp.js} +6 -6
  184. package/dist/v2/{server-09g9pkvx.js → server-08k4zkfk.js} +50 -39
  185. package/dist/v2/{server-ras2sxnc.js → server-44ryn9rb.js} +9 -6
  186. package/dist/v2/{server-158ehmk2.js → server-4easnf78.js} +19 -19
  187. package/dist/v2/{server-ww9nr8pe.js → server-4gz0xkrc.js} +5 -5
  188. package/dist/v2/{server-d6g4whc2.js → server-4qr18rfg.js} +3 -3
  189. package/dist/v2/{server-f9py7s7a.js → server-4rs8sm06.js} +5 -5
  190. package/dist/v2/{server-yezz0cp2.js → server-63ha7f0f.js} +3 -27
  191. package/dist/v2/{server-3t0q2cqx.js → server-7dv9wt9r.js} +1 -1
  192. package/dist/v2/{server-cw6521wn.js → server-7e087rvk.js} +2 -0
  193. package/dist/v2/{server-hb6xhh9q.js → server-988cqjme.js} +6 -3
  194. package/dist/v2/{server-keswwkvv.js → server-9a6bwc12.js} +4 -4
  195. package/dist/v2/{server-t4k4qexw.js → server-9e5r8y60.js} +5 -1
  196. package/dist/v2/{server-7ekna9zs.js → server-adfte03x.js} +2 -2
  197. package/dist/v2/{server-9zqewm6g.js → server-ak7w74j9.js} +4 -4
  198. package/dist/v2/{server-387vkhjq.js → server-bx59ezg6.js} +4 -3
  199. package/dist/v2/{server-676xw7at.js → server-ckrb5rm8.js} +1 -1
  200. package/dist/v2/{server-wrem2nmz.js → server-cxsr0ng6.js} +15 -3
  201. package/dist/v2/{server-t528t8qm.js → server-hn9fb3v0.js} +2 -2
  202. package/dist/v2/{server-qn23p4h7.js → server-j3dm74ey.js} +9 -9
  203. package/dist/v2/{server-yd01snxq.js → server-jjsf29aq.js} +4 -4
  204. package/dist/v2/server-knvkbfvh.js +25 -0
  205. package/dist/v2/{server-cm4hmxyk.js → server-n78avt2p.js} +1 -1
  206. package/dist/v2/{server-btgnsv7w.js → server-njnx39q2.js} +6 -3
  207. package/dist/v2/{server-6a9mxnb2.js → server-npm52h2q.js} +4 -3
  208. package/dist/v2/{server-vb7pbd9p.js → server-nveratm5.js} +1 -1
  209. package/dist/v2/{server-7skbfb81.js → server-q360kdb8.js} +121 -51
  210. package/dist/v2/{server-kzns2hbz.js → server-s6jqh8bj.js} +1 -1
  211. package/dist/v2/{server-6byqfbqf.js → server-shme41gj.js} +1 -1
  212. package/dist/v2/{server-0nnd4bry.js → server-wafzvyhg.js} +63 -19
  213. package/dist/v2/{server-fby0cxbq.js → server-xj4mewze.js} +304 -92
  214. package/dist/v2/{server-aa9w15cs.js → server-y5g32dhq.js} +88 -81
  215. package/dist/v2/{server-x2r63c0x.js → server-yak3sxya.js} +7 -7
  216. package/dist/v2/{server-4tn95znb.js → server-zrwaj29a.js} +2 -2
  217. package/dist/v2/server.js +9 -8
  218. package/dist/v2/{sqlite-d7edbk1s.js → sqlite-4pqyynrs.js} +3 -1
  219. package/dist/v2/{storage-memory-af5zdz98.js → storage-memory-j3v3hc83.js} +2 -2
  220. package/dist/v2/{storage-tags-d47bpaqa.js → storage-tags-spa92sgj.js} +5 -5
  221. package/dist/v2/store-reader.d.ts.map +1 -1
  222. package/dist/v2/{wrapup-orchestrator-cahk37n7.js → wrapup-orchestrator-5wxy1ggv.js} +38 -35
  223. package/dist/wrapup-orchestrator-gv08c6f9.js +47 -0
  224. package/package.json +3 -3
  225. package/src/config/compaction-accessor-guard.test.ts +3 -0
  226. package/src/features/magic-context/dreamer/cron.ts +8 -0
  227. package/src/shared/history-owner.test.ts +60 -0
  228. package/src/shared/history-owner.ts +43 -0
  229. package/src/shared/host-stall-profiler-node.ts +3 -1
  230. package/src/shared/host-stall-profiler.ts +3 -1
  231. package/src/shared/off-thread-migration-clock.test.ts +80 -10
  232. package/src/shared/off-thread-migration-clock.ts +37 -13
  233. package/src/shared/processed-image-eligibility.test.ts +68 -0
  234. package/src/shared/processed-image-eligibility.ts +41 -0
  235. package/src/shared/processed-image-position-review.json +20 -0
  236. package/src/shared/processed-image-position-review.test.ts +19 -0
  237. package/src/shared/recovery-reasoning-prefix.test.ts +34 -0
  238. package/src/shared/recovery-reasoning-prefix.ts +35 -0
  239. package/src/shared/redaction.test.ts +16 -0
  240. package/src/shared/redaction.ts +8 -1
  241. package/src/shared/root-async-context.probe.mjs +36 -0
  242. package/src/shared/root-async-context.test.ts +49 -0
  243. package/src/shared/rpc-server.ts +27 -23
  244. package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
  245. package/src/shared/sqlite-foreground-wait.test.ts +253 -1
  246. package/src/shared/sqlite-writer-diagnostics.test.ts +31 -0
  247. package/src/shared/sqlite.ts +112 -30
  248. package/src/shared/tag-transcript.ts +118 -0
  249. package/src/shared/user-facing-codes.ts +2 -2
  250. package/dist/embedding-backfill-dtjmyktb.js +0 -21
  251. package/dist/recomp-orchestrator-1d08g57a.js +0 -60
  252. package/dist/v2/embedding-backfill-cg4rv90f.js +0 -20
  253. package/dist/v2/recomp-orchestrator-v64r4s4r.js +0 -59
  254. package/dist/v2/search-bpa4fxq1.js +0 -46
  255. package/dist/wrapup-orchestrator-mqp0v195.js +0 -47
@@ -55,6 +55,7 @@ import {
55
55
  updateTagTokenCount,
56
56
  } from "../features/magic-context/storage-tags";
57
57
  import { makeToolCompositeKey, type Tagger } from "../features/magic-context/tagger";
58
+ import type { TagEntry } from "../features/magic-context/types";
58
59
  import { droppedInputMarker } from "../hooks/magic-context/dropped-input-guard";
59
60
  import { applyEditMarkerToInput } from "../hooks/magic-context/edit-marker";
60
61
  import { estimateImageTokensFromDataUrl } from "../hooks/magic-context/image-token-estimate";
@@ -121,6 +122,122 @@ export interface TagTranscriptResult {
121
122
  targets: Map<number, TagTarget>;
122
123
  }
123
124
 
125
+ /**
126
+ * Bind durable drops to a saved request without tagging it again. Recovery must
127
+ * not allocate identities, inject prefixes, or write accounting while the store
128
+ * is failing. Reuse the normal targets so persisted modes render identically.
129
+ */
130
+ export function buildPersistedDropTargets(
131
+ transcript: Transcript,
132
+ tags: readonly TagEntry[],
133
+ options: { allowReasoningPrefixRewrite?: boolean } = {},
134
+ ): Map<number, TagTarget> {
135
+ const targets = new Map<number, TagTarget>();
136
+ const tools = new Map(
137
+ tags
138
+ .filter((tag) => tag.type === "tool")
139
+ .map((tag) => [makeToolCompositeKey(tag.toolOwnerMessageId ?? "", tag.messageId), tag]),
140
+ );
141
+ const textTags = new Map(
142
+ tags.filter((tag) => tag.type !== "tool").map((tag) => [tag.messageId, tag]),
143
+ );
144
+ const byNumber = new Map(tags.map((tag) => [tag.tagNumber, tag]));
145
+ const aggregates = new Map<
146
+ string,
147
+ { tag?: TagEntry; occurrences: ToolOccurrence[]; reasoning: boolean }
148
+ >();
149
+ const pending = new Map<string, string[]>();
150
+ const resolved = new Map<string, string>();
151
+ const ambiguousCalls = new Set<string>();
152
+ const end = new ConversationEndGuard(transcript.messages);
153
+ for (const message of transcript.messages) {
154
+ let ordinal = 0;
155
+ let resultRun: { callId: string; key: string } | undefined;
156
+ const parts = message.parts;
157
+ const reasoning =
158
+ message.requiresToolArcSkeleton ??
159
+ (message.info.role === "assistant" && parts.some((part) => part.kind === "thinking"));
160
+ for (const part of parts) {
161
+ if (part.kind !== "tool_result") resultRun = undefined;
162
+ if (part.kind === "text") {
163
+ const prefix = /^§(\d+)§\s/.exec(part.getText() ?? "");
164
+ const tag =
165
+ (prefix ? byNumber.get(Number(prefix[1])) : undefined) ??
166
+ textTags.get(`${message.info.id}:p${ordinal}`);
167
+ ordinal++;
168
+ if (tag && tag.type !== "tool")
169
+ targets.set(tag.tagNumber, buildTextTarget(part, message, ""));
170
+ } else if ((part.kind === "tool_use" || part.kind === "tool_result") && part.id) {
171
+ const open = pending.get(part.id) ?? [];
172
+ if (open.length > 1) ambiguousCalls.add(part.id);
173
+ const key =
174
+ (part.kind === "tool_result"
175
+ ? resultRun?.callId === part.id
176
+ ? resultRun.key
177
+ : (open.at(-1) ?? resolved.get(part.id))
178
+ : undefined) ?? makeToolCompositeKey(message.info.id ?? "", part.id);
179
+ if (part.kind === "tool_use") open.push(key);
180
+ else {
181
+ const position = open.lastIndexOf(key);
182
+ if (position >= 0) open.splice(position, 1);
183
+ resultRun = { callId: part.id, key };
184
+ resolved.set(part.id, key);
185
+ }
186
+ pending.set(part.id, open);
187
+ let aggregate = aggregates.get(key);
188
+ if (!aggregate) {
189
+ aggregate = {
190
+ tag: tools.get(key),
191
+ occurrences: [],
192
+ reasoning: false,
193
+ };
194
+ aggregates.set(key, aggregate);
195
+ }
196
+ aggregate.occurrences.push({ message, part, kind: part.kind });
197
+ aggregate.reasoning ||= reasoning;
198
+ }
199
+ }
200
+ }
201
+ const arcsByCall = new Map<string, number>();
202
+ for (const { occurrences } of aggregates.values()) {
203
+ const callId = occurrences[0]?.part.id ?? "";
204
+ arcsByCall.set(callId, (arcsByCall.get(callId) ?? 0) + 1);
205
+ }
206
+ for (const aggregate of aggregates.values()) {
207
+ const { occurrences, reasoning } = aggregate;
208
+ const callId = occurrences[0]?.part.id ?? "";
209
+ if (ambiguousCalls.has(callId)) continue;
210
+ const tag =
211
+ aggregate.tag ??
212
+ (arcsByCall.get(callId) === 1
213
+ ? tools.get(makeToolCompositeKey("", callId))
214
+ : undefined);
215
+ if (tag)
216
+ targets.set(
217
+ tag.tagNumber,
218
+ buildAggregateTarget(tag.tagNumber, occurrences, reasoning, end),
219
+ );
220
+ }
221
+ if (!options.allowReasoningPrefixRewrite) {
222
+ // This target builder cannot persist removal of thinking. By default,
223
+ // withhold edits before reasoning rather than invalidate its signature.
224
+ // The Pi recovery handler opts in only to test edits on a saved copy;
225
+ // it must compare final request prefixes and refuse unsafe changes.
226
+ let lastThinking = -1;
227
+ transcript.messages.forEach((message, index) => {
228
+ if (message.parts.some((part) => part.kind === "thinking")) lastThinking = index;
229
+ });
230
+ const protectedIds = new Set(
231
+ transcript.messages.slice(0, lastThinking + 1).map((message) => message.info.id),
232
+ );
233
+ for (const [number, target] of targets) {
234
+ if (target.mutationParts?.some(({ message }) => protectedIds.has(message.info.id)))
235
+ targets.delete(number);
236
+ }
237
+ }
238
+ return targets;
239
+ }
240
+
124
241
  /**
125
242
  * Tag eligible parts of a transcript and build TagTargets for them.
126
243
  *
@@ -1289,6 +1406,7 @@ function buildAggregateTarget(
1289
1406
  return any ? "truncated" : "absent";
1290
1407
  },
1291
1408
  // Open invocations still belong to the current turn; only complete arcs reclaim.
1409
+ prepareDrop: () => !occurrences.some((occ) => occ.part.canRemove?.() === "defer"),
1292
1410
  canDrop: () => complete() && !occurrences.some((occ) => occ.part.hasUserAnswer?.()),
1293
1411
  requiresToolArcSkeleton,
1294
1412
  // Non-mutating read of the invocation input (the tool_use occurrence
@@ -17,8 +17,8 @@ export const USER_FACING_FAILURES = {
17
17
  history_boundary_unresolved: {
18
18
  code: "MC-H04",
19
19
  sentence:
20
- "This request was not sent: the message that marks where this session's history summary ends is missing from the OpenCode store, and without it the request is larger than the model's context window.",
21
- action: "Run /ctx-recomp to rebuild the history summary.",
20
+ "This request was not sent: Magic Context could not safely place the history summary boundary in the loaded conversation, and the untrimmed request is larger than the model's context window.",
21
+ action: "Reopen this session in its current project directory, then run /ctx-recomp to rebuild the history summary. A model with a larger context window can also help.",
22
22
  },
23
23
  history_over_window_unmanaged: {
24
24
  code: "MC-H06",
@@ -1,21 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./index-7q1m1qjk.js";
4
- import"./index-9s58tq95.js";
5
- import"./index-j55vn694.js";
6
- import"./index-4dhv7mqz.js";
7
- import"./index-qt1qqasc.js";
8
- import"./index-gbmqa9x9.js";
9
- import"./index-vkbqdnkj.js";
10
- import"./index-g9exahnx.js";
11
- import"./index-bg5qqene.js";
12
- import"./index-k6xvbj2e.js";
13
- import"./index-4mjhqadz.js";
14
- import"./index-0nnd4bry.js";
15
- import"./index-qx53vezw.js";
16
- import"./index-nsjyysj0.js";
17
- import"./index-0sahzkwr.js";
18
- import"./index-pavzsdc6.js";
19
- export {
20
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
21
- };
@@ -1,60 +0,0 @@
1
- import {
2
- isRecompFailure2,
3
- isRecompSkip2,
4
- extractRecompReason2,
5
- setRecompStarting2,
6
- setRecompNote2,
7
- setRecompTerminal2,
8
- buildRecompDeps2,
9
- runManagedRecomp2
10
- } from "./index-ck6y3td2.js";
11
- import"./index-vh3e2mvr.js";
12
- import"./index-f3dnvnw6.js";
13
- import"./index-sd3egckz.js";
14
- import"./index-s0gsmthp.js";
15
- import"./index-1xaw2pq8.js";
16
- import"./index-7q1m1qjk.js";
17
- import"./index-cm4hmxyk.js";
18
- import"./index-9s58tq95.js";
19
- import"./index-j55vn694.js";
20
- import"./index-4dhv7mqz.js";
21
- import"./index-w23dh319.js";
22
- import"./index-hr64sth2.js";
23
- import"./index-qt1qqasc.js";
24
- import"./index-x8a7jmkh.js";
25
- import"./index-tqf7yg27.js";
26
- import"./index-gbmqa9x9.js";
27
- import"./index-vkbqdnkj.js";
28
- import"./index-besxhcsh.js";
29
- import"./index-fb3zxn06.js";
30
- import"./index-xqyj5c85.js";
31
- import"./index-9m7bn21d.js";
32
- import"./index-fr0wbhdn.js";
33
- import"./index-g9exahnx.js";
34
- import"./index-bg5qqene.js";
35
- import"./index-vztbgcdk.js";
36
- import"./index-1j8jcjpa.js";
37
- import"./index-1zx87sdm.js";
38
- import"./index-ab3bgm2m.js";
39
- import"./index-vnjhmkwk.js";
40
- import"./index-v0p37hm2.js";
41
- import"./index-k6xvbj2e.js";
42
- import"./index-h2wc01qk.js";
43
- import"./index-1bt88epp.js";
44
- import"./index-58e3y90n.js";
45
- import"./index-4mjhqadz.js";
46
- import"./index-0nnd4bry.js";
47
- import"./index-qx53vezw.js";
48
- import"./index-nsjyysj0.js";
49
- import"./index-0sahzkwr.js";
50
- import"./index-pavzsdc6.js";
51
- export {
52
- buildRecompDeps2 as buildRecompDeps,
53
- extractRecompReason2 as extractRecompReason,
54
- isRecompFailure2 as isRecompFailure,
55
- isRecompSkip2 as isRecompSkip,
56
- runManagedRecomp2 as runManagedRecomp,
57
- setRecompNote2 as setRecompNote,
58
- setRecompStarting2 as setRecompStarting,
59
- setRecompTerminal2 as setRecompTerminal
60
- };
@@ -1,20 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./server-f9py7s7a.js";
4
- import"./server-158ehmk2.js";
5
- import"./server-keswwkvv.js";
6
- import"./server-4dhv7mqz.js";
7
- import"./server-qt1qqasc.js";
8
- import"./server-ras2sxnc.js";
9
- import"./server-hb6xhh9q.js";
10
- import"./server-btgnsv7w.js";
11
- import"./server-yezz0cp2.js";
12
- import"./server-cw6521wn.js";
13
- import"./server-3t0q2cqx.js";
14
- import"./server-0nnd4bry.js";
15
- import"./server-kzns2hbz.js";
16
- import"./server-t4k4qexw.js";
17
- import"./server-pavzsdc6.js";
18
- export {
19
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
20
- };
@@ -1,59 +0,0 @@
1
- import {
2
- isRecompFailure2,
3
- isRecompSkip2,
4
- extractRecompReason2,
5
- setRecompStarting2,
6
- setRecompNote2,
7
- setRecompTerminal2,
8
- buildRecompDeps2,
9
- runManagedRecomp2
10
- } from "./server-7skbfb81.js";
11
- import"./server-6a9mxnb2.js";
12
- import"./server-x2r63c0x.js";
13
- import"./server-qn23p4h7.js";
14
- import"./server-f9py7s7a.js";
15
- import"./server-cm4hmxyk.js";
16
- import"./server-158ehmk2.js";
17
- import"./server-keswwkvv.js";
18
- import"./server-4dhv7mqz.js";
19
- import"./server-t528t8qm.js";
20
- import"./server-9zqewm6g.js";
21
- import"./server-qt1qqasc.js";
22
- import"./server-676xw7at.js";
23
- import"./server-d6g4whc2.js";
24
- import"./server-vb7pbd9p.js";
25
- import"./server-x8a7jmkh.js";
26
- import"./server-ras2sxnc.js";
27
- import"./server-hb6xhh9q.js";
28
- import"./server-09g9pkvx.js";
29
- import"./server-fb3zxn06.js";
30
- import"./server-ww9nr8pe.js";
31
- import"./server-wrem2nmz.js";
32
- import"./server-fr0wbhdn.js";
33
- import"./server-btgnsv7w.js";
34
- import"./server-yezz0cp2.js";
35
- import"./server-fby0cxbq.js";
36
- import"./server-yd01snxq.js";
37
- import"./server-1zx87sdm.js";
38
- import"./server-4tn95znb.js";
39
- import"./server-387vkhjq.js";
40
- import"./server-51779zs2.js";
41
- import"./server-cw6521wn.js";
42
- import"./server-7ekna9zs.js";
43
- import"./server-6byqfbqf.js";
44
- import"./server-2ra6pwf3.js";
45
- import"./server-3t0q2cqx.js";
46
- import"./server-0nnd4bry.js";
47
- import"./server-kzns2hbz.js";
48
- import"./server-t4k4qexw.js";
49
- import"./server-pavzsdc6.js";
50
- export {
51
- buildRecompDeps2 as buildRecompDeps,
52
- extractRecompReason2 as extractRecompReason,
53
- isRecompFailure2 as isRecompFailure,
54
- isRecompSkip2 as isRecompSkip,
55
- runManagedRecomp2 as runManagedRecomp,
56
- setRecompNote2 as setRecompNote,
57
- setRecompStarting2 as setRecompStarting,
58
- setRecompTerminal2 as setRecompTerminal
59
- };
@@ -1,46 +0,0 @@
1
- import {
2
- createUnifiedSearchDiagnostics2,
3
- searchMessageHistory2,
4
- parseIdShapedQuery2,
5
- resolveMemoriesByIdsForSearch2,
6
- unifiedSearch2,
7
- formatSearchResults2
8
- } from "./server-aa9w15cs.js";
9
- import"./server-x2r63c0x.js";
10
- import"./server-qn23p4h7.js";
11
- import"./server-f9py7s7a.js";
12
- import"./server-cm4hmxyk.js";
13
- import"./server-158ehmk2.js";
14
- import"./server-keswwkvv.js";
15
- import"./server-4dhv7mqz.js";
16
- import"./server-qt1qqasc.js";
17
- import"./server-ras2sxnc.js";
18
- import"./server-hb6xhh9q.js";
19
- import"./server-ww9nr8pe.js";
20
- import"./server-wrem2nmz.js";
21
- import"./server-fr0wbhdn.js";
22
- import"./server-btgnsv7w.js";
23
- import"./server-yezz0cp2.js";
24
- import"./server-fby0cxbq.js";
25
- import"./server-yd01snxq.js";
26
- import"./server-1zx87sdm.js";
27
- import"./server-4tn95znb.js";
28
- import"./server-387vkhjq.js";
29
- import"./server-51779zs2.js";
30
- import"./server-cw6521wn.js";
31
- import"./server-7ekna9zs.js";
32
- import"./server-6byqfbqf.js";
33
- import"./server-2ra6pwf3.js";
34
- import"./server-3t0q2cqx.js";
35
- import"./server-0nnd4bry.js";
36
- import"./server-kzns2hbz.js";
37
- import"./server-t4k4qexw.js";
38
- import"./server-pavzsdc6.js";
39
- export {
40
- createUnifiedSearchDiagnostics2 as createUnifiedSearchDiagnostics,
41
- formatSearchResults2 as formatSearchResults,
42
- parseIdShapedQuery2 as parseIdShapedQuery,
43
- resolveMemoriesByIdsForSearch2 as resolveMemoriesByIdsForSearch,
44
- searchMessageHistory2 as searchMessageHistory,
45
- unifiedSearch2 as unifiedSearch
46
- };
@@ -1,47 +0,0 @@
1
- import {
2
- runManagedWrapup2
3
- } from "./index-a796ct3s.js";
4
- import"./index-ck6y3td2.js";
5
- import"./index-vh3e2mvr.js";
6
- import"./index-f3dnvnw6.js";
7
- import"./index-sd3egckz.js";
8
- import"./index-s0gsmthp.js";
9
- import"./index-1xaw2pq8.js";
10
- import"./index-7q1m1qjk.js";
11
- import"./index-cm4hmxyk.js";
12
- import"./index-9s58tq95.js";
13
- import"./index-j55vn694.js";
14
- import"./index-4dhv7mqz.js";
15
- import"./index-w23dh319.js";
16
- import"./index-hr64sth2.js";
17
- import"./index-qt1qqasc.js";
18
- import"./index-x8a7jmkh.js";
19
- import"./index-tqf7yg27.js";
20
- import"./index-gbmqa9x9.js";
21
- import"./index-vkbqdnkj.js";
22
- import"./index-besxhcsh.js";
23
- import"./index-fb3zxn06.js";
24
- import"./index-xqyj5c85.js";
25
- import"./index-9m7bn21d.js";
26
- import"./index-fr0wbhdn.js";
27
- import"./index-g9exahnx.js";
28
- import"./index-bg5qqene.js";
29
- import"./index-vztbgcdk.js";
30
- import"./index-1j8jcjpa.js";
31
- import"./index-1zx87sdm.js";
32
- import"./index-ab3bgm2m.js";
33
- import"./index-vnjhmkwk.js";
34
- import"./index-v0p37hm2.js";
35
- import"./index-k6xvbj2e.js";
36
- import"./index-h2wc01qk.js";
37
- import"./index-1bt88epp.js";
38
- import"./index-58e3y90n.js";
39
- import"./index-4mjhqadz.js";
40
- import"./index-0nnd4bry.js";
41
- import"./index-qx53vezw.js";
42
- import"./index-nsjyysj0.js";
43
- import"./index-0sahzkwr.js";
44
- import"./index-pavzsdc6.js";
45
- export {
46
- runManagedWrapup2 as runManagedWrapup
47
- };