@cortexkit/opencode-magic-context 0.42.6 → 0.43.1

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 (502) hide show
  1. package/README.md +4 -5
  2. package/dist/agents/dreamer.d.ts +7 -9
  3. package/dist/agents/dreamer.d.ts.map +1 -1
  4. package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
  5. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  6. package/dist/{announcement-8mgn61fw.js → announcement-1a8bvswd.js} +2 -1
  7. package/dist/config/index.d.ts +1 -1
  8. package/dist/config/index.d.ts.map +1 -1
  9. package/dist/config/live-run-config.d.ts +12 -0
  10. package/dist/config/live-run-config.d.ts.map +1 -0
  11. package/dist/config/live-snapshot.d.ts +32 -0
  12. package/dist/config/live-snapshot.d.ts.map +1 -0
  13. package/dist/config/schema/magic-context.d.ts +12 -2
  14. package/dist/config/schema/magic-context.d.ts.map +1 -1
  15. package/dist/{conflict-warning-hook-aktepwpz.js → conflict-warning-hook-956fkedc.js} +6 -4
  16. package/dist/{derive-budgets-v1fkhjjr.js → derive-budgets-b8ybssh9.js} +7 -3
  17. package/dist/features/builtin-commands/commands.d.ts +0 -4
  18. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  19. package/dist/features/magic-context/compaction-marker.d.ts +6 -0
  20. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  21. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
  22. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  23. package/dist/features/magic-context/compartment-lease.d.ts +8 -0
  24. package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
  25. package/dist/features/magic-context/compartment-storage.d.ts +21 -0
  26. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  27. package/dist/features/magic-context/context-authority.d.ts +9 -2
  28. package/dist/features/magic-context/context-authority.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +23 -0
  31. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -0
  32. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +5 -1
  33. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  34. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +51 -0
  35. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -0
  36. package/dist/features/magic-context/dreamer/manual-summary.d.ts +7 -0
  37. package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -0
  38. package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -1
  39. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  40. package/dist/features/magic-context/dreamer/promote-primers.d.ts +8 -1
  41. package/dist/features/magic-context/dreamer/promote-primers.d.ts.map +1 -1
  42. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +3 -1
  43. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  44. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +5 -2
  45. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
  46. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +22 -13
  47. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  48. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +9 -0
  49. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
  50. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  51. package/dist/features/magic-context/dreamer/task-executor.d.ts +3 -0
  52. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  53. package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -4
  54. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  55. package/dist/features/magic-context/dreamer/task-registry.d.ts +53 -2
  56. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  57. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -0
  58. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  59. package/dist/features/magic-context/dreamer/tick-failure.d.ts +38 -0
  60. package/dist/features/magic-context/dreamer/tick-failure.d.ts.map +1 -0
  61. package/dist/features/magic-context/dreamer/verify.d.ts +4 -1
  62. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  63. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
  64. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  65. package/dist/features/magic-context/memory/embedding-identity.d.ts +1 -0
  66. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  67. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  68. package/dist/features/magic-context/memory/memory-diagnostics.d.ts +6 -0
  69. package/dist/features/magic-context/memory/memory-diagnostics.d.ts.map +1 -0
  70. package/dist/features/magic-context/memory/memory-selection.d.ts +12 -0
  71. package/dist/features/magic-context/memory/memory-selection.d.ts.map +1 -0
  72. package/dist/features/magic-context/memory/memory-visibility.d.ts +46 -0
  73. package/dist/features/magic-context/memory/memory-visibility.d.ts.map +1 -0
  74. package/dist/features/magic-context/memory/mirror-reembed.d.ts +22 -0
  75. package/dist/features/magic-context/memory/mirror-reembed.d.ts.map +1 -0
  76. package/dist/features/magic-context/memory/project-identity.d.ts +9 -0
  77. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  78. package/dist/features/magic-context/memory/storage-memory-fts.d.ts +6 -2
  79. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  80. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  81. package/dist/features/magic-context/memory/transformers-remote-host.d.ts +6 -0
  82. package/dist/features/magic-context/memory/transformers-remote-host.d.ts.map +1 -0
  83. package/dist/features/magic-context/memory/transformers-web-entry.d.ts.map +1 -1
  84. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  85. package/dist/features/magic-context/message-fts-rowid-map.d.ts +3 -1
  86. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
  87. package/dist/features/magic-context/message-index-async.d.ts +8 -3
  88. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  89. package/dist/features/magic-context/message-index.d.ts +7 -1
  90. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  91. package/dist/features/magic-context/message-time-backfill.d.ts +19 -0
  92. package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -0
  93. package/dist/features/magic-context/migrations.d.ts +10 -6
  94. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  95. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  96. package/dist/features/magic-context/mural/storage-mural.d.ts +5 -0
  97. package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
  98. package/dist/features/magic-context/opencode2-relabel.d.ts +132 -0
  99. package/dist/features/magic-context/opencode2-relabel.d.ts.map +1 -0
  100. package/dist/features/magic-context/overflow-detection.d.ts +3 -0
  101. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  102. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  103. package/dist/features/magic-context/protection-window.d.ts +1 -1
  104. package/dist/features/magic-context/protection-window.d.ts.map +1 -1
  105. package/dist/features/magic-context/search.d.ts +6 -0
  106. package/dist/features/magic-context/search.d.ts.map +1 -1
  107. package/dist/features/magic-context/session-decision-calibration.d.ts +31 -0
  108. package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -0
  109. package/dist/features/magic-context/shadow-backfill-state.d.ts +1 -1
  110. package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -1
  111. package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -1
  112. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  113. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  114. package/dist/features/magic-context/storage-db.d.ts +1 -1
  115. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  116. package/dist/features/magic-context/storage-historian-runs.d.ts +4 -2
  117. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
  118. package/dist/features/magic-context/storage-meta-persisted.d.ts +16 -2
  119. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  120. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
  121. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  122. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  123. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  124. package/dist/features/magic-context/storage-notes.d.ts +1 -0
  125. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  126. package/dist/features/magic-context/storage-replay-document.d.ts +2 -0
  127. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  128. package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
  129. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  130. package/dist/features/magic-context/storage-tags.d.ts +42 -4
  131. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  132. package/dist/features/magic-context/storage.d.ts +2 -2
  133. package/dist/features/magic-context/storage.d.ts.map +1 -1
  134. package/dist/features/magic-context/store-generation-rebase.d.ts +95 -0
  135. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -0
  136. package/dist/features/magic-context/subagent-token-capture.d.ts +1 -0
  137. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  138. package/dist/features/magic-context/tagger.d.ts +2 -0
  139. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  140. package/dist/features/magic-context/tool-definition-tokens.d.ts +1 -0
  141. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  142. package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
  143. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +5 -1
  144. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  145. package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
  146. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  147. package/dist/hooks/magic-context/apply-operations.d.ts +10 -1
  148. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  149. package/dist/hooks/magic-context/cache-busting-signals.d.ts +19 -3
  150. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  151. package/dist/hooks/magic-context/command-handler.d.ts +5 -4
  152. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  153. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  154. package/dist/hooks/magic-context/compaction-off-transition.d.ts +1 -0
  155. package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
  156. package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -1
  157. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  158. package/dist/hooks/magic-context/compartment-render-epoch.d.ts +3 -1
  159. package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
  160. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +1 -1
  161. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
  162. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
  163. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  164. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +8 -1
  165. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  166. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  167. package/dist/hooks/magic-context/compartment-runner-types.d.ts +19 -11
  168. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  169. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +4 -1
  170. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  171. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  172. package/dist/hooks/magic-context/compartment-trigger.d.ts +2 -1
  173. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  174. package/dist/hooks/magic-context/decay-render.d.ts +1 -0
  175. package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
  176. package/dist/hooks/magic-context/decision-calibration.d.ts +24 -0
  177. package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -0
  178. package/dist/hooks/magic-context/derive-budgets.d.ts +2 -0
  179. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
  180. package/dist/hooks/magic-context/dropped-input-guard.d.ts +50 -4
  181. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  182. package/dist/hooks/magic-context/embed-history-runner.d.ts +30 -0
  183. package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -0
  184. package/dist/hooks/magic-context/emergency-drop.d.ts +13 -8
  185. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  186. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  187. package/dist/hooks/magic-context/event-payloads.d.ts +2 -1
  188. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  189. package/dist/hooks/magic-context/execute-status.d.ts +2 -1
  190. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  191. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
  192. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  193. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  194. package/dist/hooks/magic-context/historian-no-fire-cause.d.ts +5 -0
  195. package/dist/hooks/magic-context/historian-no-fire-cause.d.ts.map +1 -0
  196. package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts +3 -0
  197. package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts.map +1 -0
  198. package/dist/hooks/magic-context/hook-handlers.d.ts +0 -3
  199. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  200. package/dist/hooks/magic-context/hook.d.ts +4 -4
  201. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  202. package/dist/hooks/magic-context/host-served-rows.d.ts +58 -0
  203. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -0
  204. package/dist/hooks/magic-context/inject-compartments.d.ts +38 -0
  205. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  206. package/dist/hooks/magic-context/legacy-compartments.d.ts +20 -0
  207. package/dist/hooks/magic-context/legacy-compartments.d.ts.map +1 -0
  208. package/dist/hooks/magic-context/live-session-state.d.ts +7 -7
  209. package/dist/hooks/magic-context/lkg-slot.d.ts +1 -0
  210. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  211. package/dist/hooks/magic-context/m0-token-breakdown.d.ts +6 -0
  212. package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -1
  213. package/dist/hooks/magic-context/maintenance-authority.d.ts +0 -1
  214. package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
  215. package/dist/hooks/magic-context/module-state-sync.d.ts +1 -1
  216. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  217. package/dist/hooks/magic-context/module-transport.d.ts +1 -1
  218. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  219. package/dist/hooks/magic-context/module-wire.d.ts +42 -0
  220. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  221. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  222. package/dist/hooks/magic-context/postprocess-read-cache.d.ts +8 -0
  223. package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -0
  224. package/dist/hooks/magic-context/producer-window-guard.d.ts +16 -0
  225. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  226. package/dist/hooks/magic-context/producer-window-test-support.d.ts +14 -0
  227. package/dist/hooks/magic-context/producer-window-test-support.d.ts.map +1 -0
  228. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
  229. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  230. package/dist/hooks/magic-context/read-session-chunk.d.ts +45 -10
  231. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  232. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  233. package/dist/hooks/magic-context/read-session-raw.d.ts +4 -0
  234. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  235. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +6 -0
  236. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  237. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +17 -39
  238. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  239. package/dist/hooks/magic-context/rust-mode-transform.d.ts +26 -3
  240. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  241. package/dist/hooks/magic-context/send-session-notification.d.ts +1 -0
  242. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  243. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
  244. package/dist/hooks/magic-context/system-prompt-hash.d.ts +6 -7
  245. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  246. package/dist/hooks/magic-context/tag-messages.d.ts +21 -1
  247. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  248. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +63 -0
  249. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  250. package/dist/hooks/magic-context/tokenizer-calibration.d.ts +19 -12
  251. package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
  252. package/dist/hooks/magic-context/tool-drop-target.d.ts +52 -1
  253. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  254. package/dist/hooks/magic-context/tool-sweep-policy.d.ts +50 -0
  255. package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -0
  256. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +20 -1
  257. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  258. package/dist/hooks/magic-context/transform-context-state.d.ts +9 -0
  259. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  260. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -3
  261. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  262. package/dist/hooks/magic-context/transform.d.ts +37 -4
  263. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  264. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  265. package/dist/{index-f9gem5cr.js → index-0ccmyzbj.js} +90 -10
  266. package/dist/index-1gtwrdc4.js +393 -0
  267. package/dist/{index-ntbmt6rq.js → index-4b30nf6z.js} +1 -1
  268. package/dist/index-6w9p73jz.js +170 -0
  269. package/dist/{index-4ftb5hcq.js → index-6z9g64js.js} +7 -1
  270. package/dist/{index-djp6rwz6.js → index-7wpwr2e2.js} +28002 -30125
  271. package/dist/index-9r1cbh9e.js +16 -0
  272. package/dist/{safe-notification-target-fepvcbsj.js → index-febg06dy.js} +6 -7
  273. package/dist/index-j7cnyvq1.js +5409 -0
  274. package/dist/{index-s61hh7gv.js → index-kpmmr8s0.js} +95 -73
  275. package/dist/{index-a9ssj59b.js → index-v8qr6tt2.js} +56 -16
  276. package/dist/{index-qp20p2py.js → index-wgzyeyf5.js} +1 -1
  277. package/dist/index-y5145x8k.js +619 -0
  278. package/dist/{index-ngjmj6xx.js → index-yc81txp4.js} +38 -4
  279. package/dist/index.d.ts.map +1 -1
  280. package/dist/index.js +6274 -3180
  281. package/dist/message-time-backfill-0ccvyk9n.js +109 -0
  282. package/dist/plugin/dream-timer.d.ts +13 -0
  283. package/dist/plugin/dream-timer.d.ts.map +1 -1
  284. package/dist/plugin/hooks/create-session-hooks.d.ts +5 -2
  285. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  286. package/dist/plugin/memory-id-translation.d.ts +86 -0
  287. package/dist/plugin/memory-id-translation.d.ts.map +1 -1
  288. package/dist/plugin/messages-transform.d.ts.map +1 -1
  289. package/dist/plugin/rpc-handlers.d.ts +10 -0
  290. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  291. package/dist/plugin/rust-note-backend.d.ts +84 -0
  292. package/dist/plugin/rust-note-backend.d.ts.map +1 -0
  293. package/dist/plugin/tool-registry.d.ts +1 -0
  294. package/dist/plugin/tool-registry.d.ts.map +1 -1
  295. package/dist/read-session-chunk-z7fv0qjv.js +62 -0
  296. package/dist/recomp-orchestrator-r00aa5t3.js +21 -0
  297. package/dist/safe-notification-target-vrkjrbgb.js +10 -0
  298. package/dist/{send-session-notification-jbxknvar.js → send-session-notification-3warjyjp.js} +7 -3
  299. package/dist/shared/assistant-message-extractor.d.ts +6 -0
  300. package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
  301. package/dist/shared/conflict-detector.d.ts +9 -4
  302. package/dist/shared/conflict-detector.d.ts.map +1 -1
  303. package/dist/shared/data-path.d.ts.map +1 -1
  304. package/dist/shared/hidden-variant-warnings.d.ts +5 -0
  305. package/dist/shared/hidden-variant-warnings.d.ts.map +1 -0
  306. package/dist/shared/host-limitations.d.ts +14 -0
  307. package/dist/shared/host-limitations.d.ts.map +1 -0
  308. package/dist/shared/keep-subagents.d.ts +1 -1
  309. package/dist/shared/keep-subagents.d.ts.map +1 -1
  310. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  311. package/dist/shared/models-dev-cache.d.ts +1 -0
  312. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  313. package/dist/shared/opencode-config-dir.d.ts +52 -0
  314. package/dist/shared/opencode-config-dir.d.ts.map +1 -1
  315. package/dist/shared/opencode-db-path.d.ts +15 -0
  316. package/dist/shared/opencode-db-path.d.ts.map +1 -1
  317. package/dist/shared/prompt-surface-runtime.d.ts +5 -5
  318. package/dist/shared/rpc-server.d.ts +10 -0
  319. package/dist/shared/rpc-server.d.ts.map +1 -1
  320. package/dist/shared/rpc-types.d.ts +64 -5
  321. package/dist/shared/rpc-types.d.ts.map +1 -1
  322. package/dist/shared/status-detail-text.d.ts +1 -3
  323. package/dist/shared/status-detail-text.d.ts.map +1 -1
  324. package/dist/shared/status-summary.d.ts +7 -0
  325. package/dist/shared/status-summary.d.ts.map +1 -1
  326. package/dist/shared/status-view.d.ts +229 -0
  327. package/dist/shared/status-view.d.ts.map +1 -0
  328. package/dist/shared/tag-transcript.d.ts.map +1 -1
  329. package/dist/shared/tail-hygiene-status.d.ts +8 -0
  330. package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
  331. package/dist/shared/test-temp-dir.d.ts +1 -1
  332. package/dist/shared/test-temp-dir.d.ts.map +1 -1
  333. package/dist/shared/user-facing-codes.d.ts +32 -7
  334. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  335. package/dist/shared/window-geometry.d.ts +3 -0
  336. package/dist/shared/window-geometry.d.ts.map +1 -1
  337. package/dist/{task-config-cv8k9y8r.js → task-config-mgf5nsh3.js} +1 -1
  338. package/dist/tools/ctx-expand/constants.d.ts +1 -1
  339. package/dist/tools/ctx-expand/constants.d.ts.map +1 -1
  340. package/dist/tools/ctx-expand/render.d.ts.map +1 -1
  341. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  342. package/dist/tools/ctx-memory/constants.d.ts +3 -1
  343. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  344. package/dist/tools/ctx-memory/tools.d.ts +1 -0
  345. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  346. package/dist/tools/ctx-memory/types.d.ts +2 -2
  347. package/dist/tools/ctx-note/constants.d.ts +1 -1
  348. package/dist/tools/ctx-note/constants.d.ts.map +1 -1
  349. package/dist/tools/ctx-note/render.d.ts +88 -0
  350. package/dist/tools/ctx-note/render.d.ts.map +1 -0
  351. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  352. package/dist/tools/ctx-reduce/constants.d.ts +1 -1
  353. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  354. package/dist/tools/ctx-search/constants.d.ts +1 -1
  355. package/dist/tools/ctx-search/constants.d.ts.map +1 -1
  356. package/dist/tools/ctx-search/date-range.d.ts +9 -0
  357. package/dist/tools/ctx-search/date-range.d.ts.map +1 -0
  358. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  359. package/dist/tools/ctx-search/types.d.ts +2 -0
  360. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  361. package/dist/tools/light-descriptions.d.ts +5 -5
  362. package/dist/tools/light-descriptions.d.ts.map +1 -1
  363. package/dist/tools/parameter-descriptions.d.ts +75 -0
  364. package/dist/tools/parameter-descriptions.d.ts.map +1 -0
  365. package/dist/transformers-node-wasm.js +1918 -826
  366. package/dist/transformers-web.js +1736 -636
  367. package/dist/{transformers.node-dpmf3wpx.js → transformers.node-3zqr6k1w.js} +4087 -2898
  368. package/dist/tui/data/context-db.d.ts +19 -7
  369. package/dist/tui/data/context-db.d.ts.map +1 -1
  370. package/dist/tui-compiled/data/context-db.d.ts +19 -7
  371. package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
  372. package/dist/v2/fold/host-media.d.ts +36 -0
  373. package/dist/v2/fold/host-media.d.ts.map +1 -0
  374. package/dist/v2/fold/restore.d.ts +21 -1
  375. package/dist/v2/fold/restore.d.ts.map +1 -1
  376. package/dist/v2/hidden-completion.d.ts +45 -1
  377. package/dist/v2/hidden-completion.d.ts.map +1 -1
  378. package/dist/v2/hooks/commands.d.ts +29 -0
  379. package/dist/v2/hooks/commands.d.ts.map +1 -0
  380. package/dist/v2/hooks/context.d.ts +46 -2
  381. package/dist/v2/hooks/context.d.ts.map +1 -1
  382. package/dist/v2/hooks/deleted-session-tombstones.d.ts +10 -0
  383. package/dist/v2/hooks/deleted-session-tombstones.d.ts.map +1 -0
  384. package/dist/v2/hooks/dream-manual.d.ts +43 -0
  385. package/dist/v2/hooks/dream-manual.d.ts.map +1 -0
  386. package/dist/v2/hooks/dream-trigger.d.ts +7 -0
  387. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  388. package/dist/v2/hooks/hidden-child.d.ts +7 -0
  389. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  390. package/dist/v2/hooks/model-limit-cache.d.ts +19 -0
  391. package/dist/v2/hooks/model-limit-cache.d.ts.map +1 -0
  392. package/dist/v2/hooks/payload.d.ts.map +1 -1
  393. package/dist/v2/hooks/provider-admission.d.ts +22 -0
  394. package/dist/v2/hooks/provider-admission.d.ts.map +1 -0
  395. package/dist/v2/hooks/rpc-live-state.d.ts +9 -0
  396. package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -0
  397. package/dist/v2/hooks/store.d.ts +38 -2
  398. package/dist/v2/hooks/store.d.ts.map +1 -1
  399. package/dist/v2/hooks/tools.d.ts +8 -0
  400. package/dist/v2/hooks/tools.d.ts.map +1 -0
  401. package/dist/v2/hooks/types.d.ts +59 -0
  402. package/dist/v2/hooks/types.d.ts.map +1 -1
  403. package/dist/v2/hooks/usage-reading.d.ts +42 -0
  404. package/dist/v2/hooks/usage-reading.d.ts.map +1 -0
  405. package/dist/v2/host-service.d.ts +65 -0
  406. package/dist/v2/host-service.d.ts.map +1 -0
  407. package/dist/v2/server.js +142236 -112052
  408. package/dist/v2/store-reader.d.ts +67 -1
  409. package/dist/v2/store-reader.d.ts.map +1 -1
  410. package/dist/v2/tui/events.d.ts +7 -0
  411. package/dist/v2/tui/events.d.ts.map +1 -0
  412. package/dist/v2/tui/index.d.ts +23 -0
  413. package/dist/v2/tui/index.d.ts.map +1 -1
  414. package/dist/v2/tui/sidebar-mount.d.ts +40 -0
  415. package/dist/v2/tui/sidebar-mount.d.ts.map +1 -0
  416. package/dist/v2/tui/status-dialog-mount.d.ts +29 -0
  417. package/dist/v2/tui/status-dialog-mount.d.ts.map +1 -0
  418. package/dist/v2/tui/types.d.ts +74 -6
  419. package/dist/v2/tui/types.d.ts.map +1 -1
  420. package/dist/wrapup-orchestrator-y0bs7t5a.js +18 -0
  421. package/package.json +9 -7
  422. package/src/agents/dreamer.ts +7 -16
  423. package/src/agents/hidden-agent-registrations.ts +10 -22
  424. package/src/agents/magic-context-prompt.test.ts +29 -39
  425. package/src/agents/magic-context-prompt.ts +99 -122
  426. package/src/agents/permissions.test.ts +17 -21
  427. package/src/config/index.ts +8 -3
  428. package/src/config/live-run-config.test.ts +237 -0
  429. package/src/config/live-run-config.ts +80 -0
  430. package/src/config/live-schema-drift.test.ts +67 -0
  431. package/src/config/live-snapshot.test.ts +85 -0
  432. package/src/config/live-snapshot.ts +191 -0
  433. package/src/config/raw-loader.test.ts +1 -0
  434. package/src/config/schema/magic-context.test.ts +13 -5
  435. package/src/config/schema/magic-context.ts +101 -10
  436. package/src/features/magic-context/dreamer/task-registry.ts +137 -13
  437. package/src/shared/assistant-message-extractor.test.ts +21 -0
  438. package/src/shared/assistant-message-extractor.ts +43 -8
  439. package/src/shared/child-session-teardown.test.ts +38 -3
  440. package/src/shared/child-session-teardown.ts +3 -3
  441. package/src/shared/conflict-detector.test.ts +224 -7
  442. package/src/shared/conflict-detector.ts +161 -89
  443. package/src/shared/data-path.ts +6 -6
  444. package/src/shared/hidden-variant-warnings.ts +21 -0
  445. package/src/shared/host-limitations.ts +43 -0
  446. package/src/shared/keep-subagents.ts +6 -6
  447. package/src/shared/model-suggestion-retry.test.ts +86 -0
  448. package/src/shared/model-suggestion-retry.ts +29 -0
  449. package/src/shared/models-dev-cache.ts +5 -0
  450. package/src/shared/opencode-config-dir.ts +80 -7
  451. package/src/shared/opencode-db-path.test.ts +78 -0
  452. package/src/shared/opencode-db-path.ts +49 -2
  453. package/src/shared/opencode-host-generation.test.ts +29 -0
  454. package/src/shared/prompt-surface-a1-golden.md +142 -211
  455. package/src/shared/rpc-server.ts +18 -0
  456. package/src/shared/rpc-types.ts +63 -4
  457. package/src/shared/status-detail-text.test.ts +52 -18
  458. package/src/shared/status-detail-text.ts +1 -90
  459. package/src/shared/status-summary.ts +37 -2
  460. package/src/shared/status-view.test.ts +441 -0
  461. package/src/shared/status-view.ts +707 -0
  462. package/src/shared/tag-transcript.ts +115 -16
  463. package/src/shared/tail-hygiene-status.ts +9 -1
  464. package/src/shared/test-temp-dir.ts +3 -0
  465. package/src/shared/user-facing-codes.test.ts +3 -4
  466. package/src/shared/user-facing-codes.ts +33 -8
  467. package/src/shared/window-geometry.test.ts +23 -5
  468. package/src/shared/window-geometry.ts +13 -3
  469. package/src/tui/data/context-db.ts +50 -15
  470. package/src/tui/dialogs/status-dialog-colors.test.ts +58 -0
  471. package/src/tui/dialogs/status-dialog.tsx +288 -0
  472. package/src/tui/index.tsx +7 -464
  473. package/src/tui/slots/sidebar-content.tsx +21 -5
  474. package/src/tui-compiled/data/context-db.ts +50 -15
  475. package/src/tui-compiled/dialogs/status-dialog.tsx +552 -0
  476. package/src/tui-compiled/index.tsx +43 -1025
  477. package/src/tui-compiled/slots/sidebar-content.tsx +173 -152
  478. package/src/v2/tui/__fixtures__/ga-host-theme.json +160 -0
  479. package/src/v2/tui/events.ts +23 -0
  480. package/src/v2/tui/host-contract.test.ts +57 -8
  481. package/src/v2/tui/index.ts +315 -59
  482. package/src/v2/tui/load-compiled-sidebar.d.mts +59 -0
  483. package/src/v2/tui/load-compiled-sidebar.mjs +24 -0
  484. package/src/v2/tui/load-compiled-status-dialog.d.mts +17 -0
  485. package/src/v2/tui/load-compiled-status-dialog.mjs +16 -0
  486. package/src/v2/tui/sidebar-fallback.test.ts +100 -0
  487. package/src/v2/tui/sidebar-mount.ts +164 -0
  488. package/src/v2/tui/sidebar-text.test.ts +70 -0
  489. package/src/v2/tui/status-dialog-fallback.test.ts +97 -0
  490. package/src/v2/tui/status-dialog-mount.ts +76 -0
  491. package/src/v2/tui/theme-mapping.test.ts +57 -0
  492. package/src/v2/tui/types.ts +69 -4
  493. package/tui.js +1 -0
  494. package/dist/features/magic-context/memory/memory-migration.d.ts +0 -129
  495. package/dist/features/magic-context/memory/memory-migration.d.ts.map +0 -1
  496. package/dist/hooks/magic-context/upgrade-reminder.d.ts +0 -76
  497. package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +0 -1
  498. package/dist/index-4wwr6cz0.js +0 -112
  499. package/dist/index-avwt563y.js +0 -62
  500. package/dist/index-znraa0kv.js +0 -637
  501. package/dist/recomp-orchestrator-0xx1364v.js +0 -19
  502. package/dist/storage-meta-session-z818pn1e.js +0 -20
@@ -0,0 +1,393 @@
1
+ import {
2
+ sessionLog
3
+ } from "./index-wgzyeyf5.js";
4
+ import {
5
+ COMPARTMENT_LEASE_RENEWAL_MS,
6
+ acquireCompartmentLease,
7
+ renewCompartmentLease,
8
+ releaseCompartmentLeaseBestEffort,
9
+ getCompartments,
10
+ getLastCompartmentEndMessage,
11
+ getWrapupInProgressState,
12
+ acquireWrapupInProgress,
13
+ updateWrapupInProgress,
14
+ releaseWrapupInProgress,
15
+ getHistorianFailureState,
16
+ clearEmergencyRecovery,
17
+ describeBoundaryDiagnostics,
18
+ resolveWrapupProtectedTailBoundary,
19
+ hasRunnableCompartmentWindow,
20
+ runCompartmentAgent,
21
+ getActiveCompartmentRun,
22
+ markActiveCompartmentRunPublished,
23
+ registerActiveCompartmentRun,
24
+ setRecompStarting2,
25
+ setRecompTerminal2
26
+ } from "./index-7wpwr2e2.js";
27
+ import {
28
+ pushNotification2
29
+ } from "./index-jdxxq8cz.js";
30
+ import {
31
+ sendStatusNotification2
32
+ } from "./index-yc81txp4.js";
33
+
34
+ // src/hooks/magic-context/wrapup-orchestrator.ts
35
+ import * as crypto from "node:crypto";
36
+ var WAIT_FOR_LEASE_MS = 1000;
37
+ var MAX_WRAPUP_LEASE_WAIT_MS = 10 * 60 * 1000;
38
+ function sleep(ms) {
39
+ return new Promise((resolve) => setTimeout(resolve, ms));
40
+ }
41
+ function plural(value, word) {
42
+ return `${value} ${word}${value === 1 ? "" : "s"}`;
43
+ }
44
+ function resolveWrapupLeaseWaitTimeout(ctx) {
45
+ const configured = ctx.wrapupLeaseWaitTimeoutMs ?? MAX_WRAPUP_LEASE_WAIT_MS;
46
+ return Number.isFinite(configured) && configured >= 0 ? configured : MAX_WRAPUP_LEASE_WAIT_MS;
47
+ }
48
+ async function waitForActiveRunWithin(promise, timeoutMs) {
49
+ if (timeoutMs <= 0)
50
+ return "timeout";
51
+ return Promise.race([
52
+ promise.then(() => "settled", () => "settled"),
53
+ sleep(timeoutMs).then(() => "timeout")
54
+ ]);
55
+ }
56
+ function formatAlreadyRunningMessage(state) {
57
+ if (!state)
58
+ return "/ctx-wrapup is already running for this session.";
59
+ const chunk = state.expectedChunks > 0 ? ` chunk ${state.chunkIndex}/${state.expectedChunks}` : "";
60
+ const through = state.lastCompartmentEnd > 0 ? ` through message ${state.lastCompartmentEnd}` : "";
61
+ return `/ctx-wrapup is already running for this session${chunk}${through}. Wait for it to finish, then run /ctx-wrapup again if more history remains.`;
62
+ }
63
+ function appendFlushHint(ctx, sessionId, message) {
64
+ if (ctx.hasPendingNaturalBust?.(sessionId))
65
+ return message;
66
+ return `${message} If you want it applied on the very next message, run /ctx-flush first.`;
67
+ }
68
+ function buildPlan(ctx, sessionId, messagesToKeep, anchorRawMessageCount) {
69
+ return resolveWrapupProtectedTailBoundary({
70
+ db: ctx.db,
71
+ sessionId,
72
+ mode: "manual-wrapup",
73
+ contextLimit: ctx.contextLimit,
74
+ executeThresholdPercentage: ctx.executeThresholdPercentage,
75
+ usage: null,
76
+ usageSource: "manual-none",
77
+ providerShapeVersion: "opencode-v1",
78
+ cacheNamespace: `opencode:${sessionId}`,
79
+ messagesToKeep,
80
+ anchorRawMessageCount
81
+ });
82
+ }
83
+ function emitWrapupProgress(ctx, sessionId, progress) {
84
+ const current = ctx.liveSessionState.recompProgressBySession.get(sessionId);
85
+ ctx.liveSessionState.recompProgressBySession.set(sessionId, {
86
+ sessionId,
87
+ kind: "wrapup",
88
+ phase: "recomp",
89
+ processedMessages: progress.processedMessages ?? current?.processedMessages ?? 0,
90
+ totalMessages: progress.totalMessages ?? current?.totalMessages ?? 0,
91
+ passCount: progress.passCount ?? current?.passCount ?? 0,
92
+ compartmentsCreated: progress.compartmentsCreated ?? current?.compartmentsCreated ?? 0,
93
+ startedAt: current?.startedAt ?? Date.now(),
94
+ updatedAt: Date.now(),
95
+ note: progress.note
96
+ });
97
+ }
98
+ async function waitForExistingIncrementalRun(sessionId, maxWaitMs) {
99
+ const active = getActiveCompartmentRun(sessionId);
100
+ if (!active)
101
+ return "ok";
102
+ if (active.kind === "recomp" || active.kind === "wrapup")
103
+ return "busy";
104
+ const outcome = await waitForActiveRunWithin(active.promise, maxWaitMs);
105
+ if (outcome === "timeout")
106
+ return "timeout";
107
+ return "ok";
108
+ }
109
+ async function acquireCompartmentLeaseForWrapup(ctx, sessionId, renewWrapupMarker) {
110
+ const holderId = crypto.randomUUID();
111
+ const waitStartedAt = Date.now();
112
+ const maxWaitMs = resolveWrapupLeaseWaitTimeout(ctx);
113
+ const remainingMs = () => Math.max(0, waitStartedAt + maxWaitMs - Date.now());
114
+ for (;; ) {
115
+ if (remainingMs() <= 0) {
116
+ sessionLog(sessionId, "wrapup: timed out waiting for the compartment-state lease");
117
+ return { ok: false, reason: "timeout" };
118
+ }
119
+ const active = getActiveCompartmentRun(sessionId);
120
+ if (active?.kind === "recomp" || active?.kind === "wrapup") {
121
+ return { ok: false, reason: "busy" };
122
+ }
123
+ if (active) {
124
+ emitWrapupProgress(ctx, sessionId, { note: "Waiting for the active historian run…" });
125
+ const outcome = await waitForActiveRunWithin(active.promise, remainingMs());
126
+ if (outcome === "timeout") {
127
+ sessionLog(sessionId, "wrapup: timed out waiting for the active historian run");
128
+ return { ok: false, reason: "timeout" };
129
+ }
130
+ continue;
131
+ }
132
+ const lease = acquireCompartmentLease(ctx.db, sessionId, holderId);
133
+ if (lease)
134
+ return { ok: true, holderId };
135
+ emitWrapupProgress(ctx, sessionId, { note: "Waiting for the compartment-state lease…" });
136
+ if (!renewWrapupMarker({}))
137
+ return { ok: false, reason: "ownership_lost" };
138
+ await sleep(Math.min(WAIT_FOR_LEASE_MS, remainingMs()));
139
+ }
140
+ }
141
+ async function runOneWrapupIteration(args) {
142
+ const { ctx, sessionId, plan, messagesToKeep, anchorRawMessageCount } = args;
143
+ const acquired = await acquireCompartmentLeaseForWrapup(ctx, sessionId, args.renewWrapupMarker);
144
+ if (!acquired.ok)
145
+ return { ran: false, reason: acquired.reason };
146
+ const leaseHolderId = acquired.holderId;
147
+ const renewal = setInterval(() => {
148
+ try {
149
+ if (!renewCompartmentLease(ctx.db, sessionId, leaseHolderId)) {
150
+ sessionLog(sessionId, "wrapup: compartment lease renewal failed");
151
+ }
152
+ } catch (err) {
153
+ sessionLog(sessionId, `wrapup: compartment lease renewal threw; continuing (${err instanceof Error ? err.message : String(err)})`);
154
+ }
155
+ }, COMPARTMENT_LEASE_RENEWAL_MS);
156
+ const runCompartmentAgentForWrapup = ctx.runCompartmentAgentForWrapup ?? runCompartmentAgent;
157
+ const runnerPromise = runCompartmentAgentForWrapup({
158
+ client: ctx.client,
159
+ hiddenCompletionExecutor: ctx.hiddenCompletionExecutor,
160
+ db: ctx.db,
161
+ sessionId,
162
+ historianChunkTokens: ctx.historianChunkTokens,
163
+ historianTimeoutMs: ctx.historianTimeoutMs,
164
+ boundarySnapshot: plan.snapshot,
165
+ currentContextLimit: ctx.contextLimit,
166
+ directory: ctx.directory,
167
+ model: ctx.historianModel,
168
+ fallbackModels: ctx.fallbackModels,
169
+ fallbackModelId: ctx.fallbackModelId,
170
+ language: ctx.language,
171
+ historianTwoPass: ctx.historianTwoPass,
172
+ memoryEnabled: ctx.memoryEnabled,
173
+ autoPromote: ctx.autoPromote,
174
+ experimentalUserMemories: ctx.userMemoriesEnabled,
175
+ ensureProjectRegistered: ctx.ensureProjectRegistered,
176
+ getNotificationParams: () => ctx.getNotificationParams(sessionId),
177
+ preserveInjectionCacheUntilConsumed: true,
178
+ compartmentLeaseHolderId: leaseHolderId,
179
+ forceDrainQuota: true,
180
+ forceKeepLastCompartment: plan.snapshot.eligibleEndOrdinal >= plan.targetEligibleEndOrdinal,
181
+ refreshBoundarySnapshot: () => buildPlan(ctx, sessionId, messagesToKeep, anchorRawMessageCount).snapshot,
182
+ onCompartmentStatePublished: (sid) => {
183
+ markActiveCompartmentRunPublished(sid);
184
+ ctx.liveSessionState.deferredHistoryRefreshSessions.add(sid);
185
+ ctx.liveSessionState.deferredMaterializationSessions.add(sid);
186
+ },
187
+ onDeferredMarkerPending: (sid) => {
188
+ ctx.liveSessionState.deferredHistoryRefreshSessions.add(sid);
189
+ }
190
+ });
191
+ registerActiveCompartmentRun(sessionId, runnerPromise, "wrapup");
192
+ try {
193
+ await runnerPromise;
194
+ return { ran: true };
195
+ } finally {
196
+ clearInterval(renewal);
197
+ releaseCompartmentLeaseBestEffort(ctx.db, sessionId, leaseHolderId, sessionLog);
198
+ }
199
+ }
200
+ async function runManagedWrapup2(ctx, sessionId, options) {
201
+ const messagesToKeep = Math.max(1, Math.floor(options.messagesToKeep));
202
+ setRecompStarting2(ctx.liveSessionState, sessionId, "Estimating wrapup…", "wrapup");
203
+ const existingWrapup = getWrapupInProgressState(ctx.db, sessionId);
204
+ if (existingWrapup) {
205
+ const message = formatAlreadyRunningMessage(existingWrapup);
206
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "skipped", message);
207
+ return `## Magic Wrapup — Skipped
208
+
209
+ ${message}`;
210
+ }
211
+ const initialPlan = buildPlan(ctx, sessionId, messagesToKeep);
212
+ if (initialPlan.rawMessagesAboveLastCompartment <= messagesToKeep || !hasRunnableCompartmentWindow(initialPlan.snapshot)) {
213
+ const message = `Nothing to wrap up — only ${initialPlan.rawMessagesAboveLastCompartment} messages above the last compartment.`;
214
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "done", message);
215
+ return message;
216
+ }
217
+ const expectedChunks = Math.max(1, Math.ceil(initialPlan.snapshot.trueRawEligibleTokens / Math.max(1, ctx.historianChunkTokens)));
218
+ const wrapupHolderId = crypto.randomUUID();
219
+ const acquired = acquireWrapupInProgress(ctx.db, sessionId, {
220
+ holderId: wrapupHolderId,
221
+ messagesToKeep,
222
+ anchorRawMessageCount: initialPlan.anchorRawMessageCount,
223
+ targetEligibleEndOrdinal: initialPlan.targetEligibleEndOrdinal,
224
+ lastCompartmentEnd: getLastCompartmentEndMessage(ctx.db, sessionId),
225
+ chunkIndex: 0,
226
+ expectedChunks
227
+ });
228
+ if (!acquired.ok) {
229
+ const message = formatAlreadyRunningMessage(acquired.state);
230
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "skipped", message);
231
+ return `## Magic Wrapup — Skipped
232
+
233
+ ${message}`;
234
+ }
235
+ const startLastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
236
+ const startCompartmentCount = getCompartments(ctx.db, sessionId).length;
237
+ let chunkIndex = 0;
238
+ let lastEnd = startLastEnd;
239
+ let stoppedForFailure = false;
240
+ let stoppedReason = "";
241
+ let ownershipLost = false;
242
+ const ownershipLostReason = "another process took over this session's wrapup.";
243
+ const markOwnershipLost = () => {
244
+ if (ownershipLost)
245
+ return;
246
+ ownershipLost = true;
247
+ sessionLog(sessionId, "wrapup: durable marker ownership lost; aborting loop");
248
+ };
249
+ const renewWrapupMarker = (updates) => {
250
+ const updated = updateWrapupInProgress(ctx.db, sessionId, wrapupHolderId, updates);
251
+ if (!updated) {
252
+ markOwnershipLost();
253
+ return false;
254
+ }
255
+ return true;
256
+ };
257
+ const markerRenewal = setInterval(() => {
258
+ try {
259
+ renewWrapupMarker({
260
+ lastCompartmentEnd: getLastCompartmentEndMessage(ctx.db, sessionId),
261
+ chunkIndex
262
+ });
263
+ } catch (err) {
264
+ sessionLog(sessionId, `wrapup: marker renewal threw; continuing (${err instanceof Error ? err.message : String(err)})`);
265
+ }
266
+ }, 60000);
267
+ markerRenewal.unref?.();
268
+ try {
269
+ const activeAtStart = await waitForExistingIncrementalRun(sessionId, resolveWrapupLeaseWaitTimeout(ctx));
270
+ if (activeAtStart === "busy") {
271
+ const message = "Another Magic Context rebuild is already running for this session.";
272
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "skipped", message);
273
+ return `## Magic Wrapup — Skipped
274
+
275
+ ${message}`;
276
+ }
277
+ if (activeAtStart === "timeout") {
278
+ stoppedForFailure = true;
279
+ stoppedReason = "Timed out waiting for the active historian run.";
280
+ }
281
+ if (!stoppedForFailure) {
282
+ try {
283
+ sendStatusNotification2(ctx.client, sessionId, `Magic Wrapup started — compacting about ${plural(expectedChunks, "chunk")} of history. This can take a few minutes; the result posts here when done.`, ctx.getNotificationParams(sessionId));
284
+ } catch {}
285
+ try {
286
+ pushNotification2("action", { action: "wrapup-progress-kick" }, sessionId);
287
+ } catch {}
288
+ }
289
+ if (!stoppedForFailure && ownershipLost) {
290
+ stoppedForFailure = true;
291
+ stoppedReason = ownershipLostReason;
292
+ } else if (!stoppedForFailure) {
293
+ emitWrapupProgress(ctx, sessionId, {
294
+ processedMessages: Math.max(0, lastEnd),
295
+ totalMessages: Math.max(0, initialPlan.targetEligibleEndOrdinal - 1),
296
+ passCount: 0,
297
+ compartmentsCreated: 0,
298
+ note: `Eligible ${plural(initialPlan.snapshot.trueRawEligibleTokens, "token")} across about ${plural(expectedChunks, "chunk")}.`
299
+ });
300
+ for (;; ) {
301
+ if (ownershipLost) {
302
+ stoppedForFailure = true;
303
+ stoppedReason = ownershipLostReason;
304
+ break;
305
+ }
306
+ if (!renewWrapupMarker({
307
+ lastCompartmentEnd: getLastCompartmentEndMessage(ctx.db, sessionId),
308
+ chunkIndex,
309
+ expectedChunks
310
+ })) {
311
+ stoppedForFailure = true;
312
+ stoppedReason = ownershipLostReason;
313
+ break;
314
+ }
315
+ const plan = buildPlan(ctx, sessionId, messagesToKeep, initialPlan.anchorRawMessageCount);
316
+ lastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
317
+ if (lastEnd + 1 >= plan.targetEligibleEndOrdinal)
318
+ break;
319
+ chunkIndex += 1;
320
+ sessionLog(sessionId, `wrapup chunk ${chunkIndex}: ${describeBoundaryDiagnostics(plan.snapshot)}`);
321
+ emitWrapupProgress(ctx, sessionId, {
322
+ processedMessages: Math.max(0, lastEnd),
323
+ totalMessages: Math.max(0, plan.targetEligibleEndOrdinal - 1),
324
+ passCount: chunkIndex - 1,
325
+ compartmentsCreated: Math.max(0, getCompartments(ctx.db, sessionId).length - startCompartmentCount),
326
+ note: `Chunk ${chunkIndex}/${expectedChunks}: messages ${plan.snapshot.offset}-${plan.snapshot.eligibleEndOrdinal - 1}…`
327
+ });
328
+ if (!renewWrapupMarker({
329
+ lastCompartmentEnd: lastEnd,
330
+ chunkIndex,
331
+ expectedChunks,
332
+ targetEligibleEndOrdinal: plan.targetEligibleEndOrdinal
333
+ })) {
334
+ stoppedForFailure = true;
335
+ stoppedReason = ownershipLostReason;
336
+ break;
337
+ }
338
+ const beforeEnd = lastEnd;
339
+ const beforeFailures = getHistorianFailureState(ctx.db, sessionId).failureCount;
340
+ const iteration = await runOneWrapupIteration({
341
+ ctx,
342
+ sessionId,
343
+ plan,
344
+ messagesToKeep,
345
+ anchorRawMessageCount: initialPlan.anchorRawMessageCount,
346
+ renewWrapupMarker
347
+ });
348
+ if (!iteration.ran) {
349
+ stoppedForFailure = true;
350
+ stoppedReason = ownershipLost || iteration.reason === "ownership_lost" ? ownershipLostReason : iteration.reason === "timeout" ? "Timed out waiting for another process to release the compartment-state lease." : "Another Magic Context rebuild started while wrapup was waiting.";
351
+ break;
352
+ }
353
+ const afterEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
354
+ const afterFailures = getHistorianFailureState(ctx.db, sessionId).failureCount;
355
+ if (afterEnd <= beforeEnd) {
356
+ stoppedForFailure = true;
357
+ stoppedReason = afterFailures > beforeFailures ? "The historian failed on the current chunk." : "The historian made no forward progress on the current chunk.";
358
+ break;
359
+ }
360
+ lastEnd = afterEnd;
361
+ emitWrapupProgress(ctx, sessionId, {
362
+ processedMessages: Math.max(0, lastEnd),
363
+ totalMessages: Math.max(0, plan.targetEligibleEndOrdinal - 1),
364
+ passCount: chunkIndex,
365
+ compartmentsCreated: Math.max(0, getCompartments(ctx.db, sessionId).length - startCompartmentCount),
366
+ note: `Wrapped through message ${lastEnd}.`
367
+ });
368
+ }
369
+ }
370
+ } finally {
371
+ clearInterval(markerRenewal);
372
+ releaseWrapupInProgress(ctx.db, sessionId, wrapupHolderId);
373
+ }
374
+ const finalEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
375
+ const compartmentsCreated = Math.max(0, getCompartments(ctx.db, sessionId).length - startCompartmentCount);
376
+ const messagesWrapped = Math.max(0, finalEnd - Math.max(0, startLastEnd));
377
+ if (stoppedForFailure) {
378
+ const message = `Wrapped up through message ${Math.max(0, finalEnd)} (${plural(messagesWrapped, "message")} into ${plural(compartmentsCreated, "compartment")}). ${stoppedReason} Run /ctx-wrapup again to continue.`;
379
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "failed", message);
380
+ return `## Magic Wrapup — Partial
381
+
382
+ ${message}`;
383
+ }
384
+ try {
385
+ clearEmergencyRecovery(ctx.db, sessionId);
386
+ } catch {}
387
+ const base = `Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments. The compacted history is queued and materializes on your next message.`;
388
+ const message = appendFlushHint(ctx, sessionId, base);
389
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "done", message);
390
+ return message;
391
+ }
392
+
393
+ export { runManagedWrapup2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMagicContextStorageDir
3
- } from "./index-4ftb5hcq.js";
3
+ } from "./index-6z9g64js.js";
4
4
 
5
5
  // src/shared/announcement.ts
6
6
  import * as fs from "node:fs";
@@ -0,0 +1,170 @@
1
+ import {
2
+ resolveDreamerTaskModel2
3
+ } from "./index-7k55qm8a.js";
4
+
5
+ // src/features/magic-context/dreamer/task-registry.ts
6
+ var CANONICAL_DREAM_TASKS = [
7
+ "map-memories",
8
+ "verify",
9
+ "verify-broad",
10
+ "curate",
11
+ "compress-cues",
12
+ "classify-memories",
13
+ "retrospective",
14
+ "maintain-docs",
15
+ "evaluate-smart-notes",
16
+ "review-user-memories",
17
+ "promote-primers",
18
+ "refresh-primers"
19
+ ];
20
+ var DREAM_TASK_CAPABILITIES = {
21
+ "map-memories": {
22
+ requiresTools: true,
23
+ transport: "tool-loop",
24
+ toolLoopPurpose: "needs read-only file tools to locate the code each memory describes"
25
+ },
26
+ verify: {
27
+ requiresTools: true,
28
+ transport: "tool-loop",
29
+ toolLoopPurpose: "needs read-only file tools to re-check each memory against the code"
30
+ },
31
+ "verify-broad": {
32
+ requiresTools: true,
33
+ transport: "tool-loop",
34
+ toolLoopPurpose: "needs read-only file tools to re-check each memory against the code"
35
+ },
36
+ curate: {
37
+ requiresTools: true,
38
+ transport: "tool-loop",
39
+ toolLoopPurpose: "needs the ctx_memory tool to apply its merge and archive decisions"
40
+ },
41
+ "compress-cues": { requiresTools: false, transport: "single-shot" },
42
+ "classify-memories": { requiresTools: false, transport: "single-shot" },
43
+ retrospective: {
44
+ requiresTools: true,
45
+ transport: "tool-loop",
46
+ toolLoopPurpose: "needs search tools to investigate the friction it finds in past sessions"
47
+ },
48
+ "maintain-docs": {
49
+ requiresTools: true,
50
+ transport: "tool-loop",
51
+ toolLoopPurpose: "needs read-only file tools to investigate documentation corrections"
52
+ },
53
+ "evaluate-smart-notes": { requiresTools: false, transport: "single-shot" },
54
+ "review-user-memories": { requiresTools: false, transport: "single-shot" },
55
+ "promote-primers": { requiresTools: false, transport: "host-only" },
56
+ "refresh-primers": {
57
+ requiresTools: true,
58
+ transport: "tool-loop",
59
+ toolLoopPurpose: "needs read-only investigation tools to answer each standing question"
60
+ }
61
+ };
62
+ function toolLoopDreamTasks() {
63
+ return CANONICAL_DREAM_TASKS.filter((task) => DREAM_TASK_CAPABILITIES[task].requiresTools);
64
+ }
65
+ function formatUnsupportedDreamTasks(tasks, code) {
66
+ return tasks.map((task) => {
67
+ const purpose = DREAM_TASK_CAPABILITIES[task].toolLoopPurpose;
68
+ return `- ${task}: unavailable on this host (${code})${purpose ? ` — ${purpose}` : ""}`;
69
+ }).join(`
70
+ `);
71
+ }
72
+ function formatDreamTaskBacklogs(backlogs, tasks = CANONICAL_DREAM_TASKS) {
73
+ return tasks.filter((task) => backlogs[task] !== undefined).map((task) => {
74
+ const backlog = backlogs[task];
75
+ if (task === "curate" && backlog?.category) {
76
+ return `- curate: ${backlog.category} (${backlog.pending})`;
77
+ }
78
+ return `- ${task}: ${backlog?.pending ?? 0} pending / ${backlog?.total ?? 0} total`;
79
+ }).join(`
80
+ `);
81
+ }
82
+ var FAILURE_TEXT_BUDGET = 180;
83
+ function sinceLabel(lastSucceededAt, now) {
84
+ if (lastSucceededAt === null || lastSucceededAt <= 0)
85
+ return "never succeeded";
86
+ const hours = Math.max(0, Math.floor((now - lastSucceededAt) / 3600000));
87
+ if (hours < 1)
88
+ return "last succeeded under an hour ago";
89
+ if (hours < 48)
90
+ return `last succeeded ${hours}h ago`;
91
+ return `last succeeded ${Math.floor(hours / 24)}d ago`;
92
+ }
93
+ function formatDreamTaskFailures(failures, now = Date.now()) {
94
+ return failures.map((failure) => {
95
+ const error = failure.error.length > FAILURE_TEXT_BUDGET ? `${failure.error.slice(0, FAILURE_TEXT_BUDGET)}…` : failure.error;
96
+ return `- ${failure.task}: failing (${sinceLabel(failure.lastSucceededAt, now)}) — ${error}`;
97
+ }).join(`
98
+ `);
99
+ }
100
+ function processedDreamTaskItems(startPending, endPending) {
101
+ return Math.max(0, startPending - endPending);
102
+ }
103
+ var MEMORY_DOMAIN_TASKS = [
104
+ "map-memories",
105
+ "verify",
106
+ "verify-broad",
107
+ "curate",
108
+ "compress-cues",
109
+ "classify-memories",
110
+ "retrospective",
111
+ "promote-primers",
112
+ "refresh-primers"
113
+ ];
114
+ var MEMORY_DOMAIN_SET = new Set(MEMORY_DOMAIN_TASKS);
115
+ function leaseKindFor(task) {
116
+ if (MEMORY_DOMAIN_SET.has(task))
117
+ return "memory";
118
+ switch (task) {
119
+ case "review-user-memories":
120
+ return "user-memories";
121
+ case "promote-primers":
122
+ case "refresh-primers":
123
+ return "memory";
124
+ case "maintain-docs":
125
+ return "maintain-docs";
126
+ case "evaluate-smart-notes":
127
+ return "evaluate-smart-notes";
128
+ default:
129
+ return "memory";
130
+ }
131
+ }
132
+ function leaseKeyFor(task, projectIdentity) {
133
+ const kind = leaseKindFor(task);
134
+ return kind === "user-memories" ? "user-memories" : `${kind}:${projectIdentity}`;
135
+ }
136
+ function isCanonicalDreamTask(value) {
137
+ return CANONICAL_DREAM_TASKS.includes(value);
138
+ }
139
+ function compareTaskOrder(a, b) {
140
+ return CANONICAL_DREAM_TASKS.indexOf(a) - CANONICAL_DREAM_TASKS.indexOf(b);
141
+ }
142
+
143
+ // src/features/magic-context/dreamer/task-config.ts
144
+ function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, muralModel) {
145
+ return CANONICAL_DREAM_TASKS.map((task) => {
146
+ const resolved = resolveDreamerTaskModel2({
147
+ config: { dreamer },
148
+ harness,
149
+ task,
150
+ muralModel
151
+ });
152
+ return {
153
+ task,
154
+ schedule: resolved.schedule ?? "",
155
+ model: resolved.primary,
156
+ fallbackModels: resolved.fallbacks,
157
+ thinkingLevel: harness === "pi" ? resolved.primary?.qualifier : undefined,
158
+ language,
159
+ timeoutMinutes: resolved.timeoutMinutes ?? 20,
160
+ promotionThreshold: resolved.promotionThreshold,
161
+ docsMaxTokens: task === "maintain-docs" ? dreamer?.tasks?.["maintain-docs"]?.max_tokens ?? 12000 : undefined,
162
+ retrospectiveRecencyDays: task === "retrospective" ? dreamer?.tasks?.retrospective?.recency_days ?? 30 : undefined
163
+ };
164
+ });
165
+ }
166
+ function userMemoryCollectionEnabled2(dreamer) {
167
+ const schedule = dreamer?.tasks?.["review-user-memories"]?.schedule;
168
+ return typeof schedule === "string" && schedule.trim() !== "";
169
+ }
170
+ export { CANONICAL_DREAM_TASKS, DREAM_TASK_CAPABILITIES, toolLoopDreamTasks, formatUnsupportedDreamTasks, formatDreamTaskBacklogs, formatDreamTaskFailures, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs2, userMemoryCollectionEnabled2 };
@@ -13,9 +13,15 @@ function getHarness() {
13
13
  }
14
14
 
15
15
  // src/shared/data-path.ts
16
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
16
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
17
17
  import * as os from "node:os";
18
18
  import * as path from "node:path";
19
+
20
+ // src/shared/test-temp-dir.ts
21
+ var STALE_TEMP_DIR_AGE_MS = 60 * 60 * 1000;
22
+ var registeredTempDirs = new Set;
23
+
24
+ // src/shared/data-path.ts
19
25
  function getDataDir() {
20
26
  return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
21
27
  }