@cortexkit/opencode-magic-context 0.42.5 → 0.43.0

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 (511) hide show
  1. package/README.md +6 -7
  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/config/index.d.ts +10 -1
  7. package/dist/config/index.d.ts.map +1 -1
  8. package/dist/config/live-run-config.d.ts +12 -0
  9. package/dist/config/live-run-config.d.ts.map +1 -0
  10. package/dist/config/live-snapshot.d.ts +32 -0
  11. package/dist/config/live-snapshot.d.ts.map +1 -0
  12. package/dist/config/schema/magic-context.d.ts +13 -2
  13. package/dist/config/schema/magic-context.d.ts.map +1 -1
  14. package/dist/{conflict-warning-hook-jyj54gbe.js → conflict-warning-hook-t2vb0wnx.js} +3 -3
  15. package/dist/{derive-budgets-v1fkhjjr.js → derive-budgets-0sg5vp61.js} +5 -2
  16. package/dist/features/builtin-commands/commands.d.ts +0 -4
  17. package/dist/features/builtin-commands/commands.d.ts.map +1 -1
  18. package/dist/features/magic-context/compaction-marker.d.ts +6 -0
  19. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  20. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
  21. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  22. package/dist/features/magic-context/compartment-lease.d.ts +8 -0
  23. package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
  24. package/dist/features/magic-context/compartment-storage.d.ts +21 -0
  25. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  26. package/dist/features/magic-context/context-authority.d.ts +37 -3
  27. package/dist/features/magic-context/context-authority.d.ts.map +1 -1
  28. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +23 -0
  30. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -0
  31. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +5 -1
  32. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  33. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +48 -0
  34. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -0
  35. package/dist/features/magic-context/dreamer/manual-summary.d.ts +7 -0
  36. package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -0
  37. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  38. package/dist/features/magic-context/dreamer/open-opencode-db.d.ts.map +1 -1
  39. package/dist/features/magic-context/dreamer/promote-primers.d.ts +8 -1
  40. package/dist/features/magic-context/dreamer/promote-primers.d.ts.map +1 -1
  41. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  42. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +5 -2
  43. package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
  44. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +22 -13
  45. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  46. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +9 -0
  47. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
  48. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  49. package/dist/features/magic-context/dreamer/task-executor.d.ts +3 -0
  50. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  51. package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -4
  52. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  53. package/dist/features/magic-context/dreamer/task-registry.d.ts +53 -2
  54. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  55. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -0
  56. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  57. package/dist/features/magic-context/dreamer/tick-failure.d.ts +38 -0
  58. package/dist/features/magic-context/dreamer/tick-failure.d.ts.map +1 -0
  59. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  60. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
  61. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  62. package/dist/features/magic-context/memory/embedding-identity.d.ts +1 -0
  63. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  64. package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
  65. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  66. package/dist/features/magic-context/memory/embedding.d.ts +1 -1
  67. package/dist/features/magic-context/memory/embedding.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/message-fts-rowid-map.d.ts +3 -1
  85. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
  86. package/dist/features/magic-context/message-index-async.d.ts +8 -3
  87. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  88. package/dist/features/magic-context/message-index.d.ts +7 -1
  89. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  90. package/dist/features/magic-context/message-time-backfill.d.ts +19 -0
  91. package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -0
  92. package/dist/features/magic-context/migrations.d.ts +16 -0
  93. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  94. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  95. package/dist/features/magic-context/mural/storage-mural.d.ts +5 -0
  96. package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
  97. package/dist/features/magic-context/opencode2-relabel.d.ts +132 -0
  98. package/dist/features/magic-context/opencode2-relabel.d.ts.map +1 -0
  99. package/dist/features/magic-context/overflow-detection.d.ts +3 -0
  100. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  101. package/dist/features/magic-context/project-embedding-registry.d.ts +1 -0
  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/session-project-backfill.d.ts.map +1 -1
  110. package/dist/features/magic-context/shadow-backfill-state.d.ts +1 -1
  111. package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -1
  112. package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -1
  113. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  114. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  115. package/dist/features/magic-context/storage-db.d.ts +1 -1
  116. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  117. package/dist/features/magic-context/storage-historian-runs.d.ts +4 -2
  118. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
  119. package/dist/features/magic-context/storage-meta-persisted.d.ts +16 -2
  120. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  121. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
  122. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  123. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  124. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  125. package/dist/features/magic-context/storage-notes.d.ts +1 -0
  126. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  127. package/dist/features/magic-context/storage-replay-document.d.ts +2 -0
  128. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  129. package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
  130. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  131. package/dist/features/magic-context/storage-tags.d.ts +42 -4
  132. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  133. package/dist/features/magic-context/storage.d.ts +2 -2
  134. package/dist/features/magic-context/storage.d.ts.map +1 -1
  135. package/dist/features/magic-context/store-generation-rebase.d.ts +95 -0
  136. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -0
  137. package/dist/features/magic-context/subagent-token-capture.d.ts +1 -0
  138. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  139. package/dist/features/magic-context/tagger.d.ts +2 -0
  140. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  141. package/dist/features/magic-context/tool-definition-tokens.d.ts +1 -0
  142. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  143. package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
  144. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +5 -1
  145. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  146. package/dist/hooks/auto-update-checker/index.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 -4
  150. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  151. package/dist/hooks/magic-context/channel2-delivery.d.ts +8 -0
  152. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  153. package/dist/hooks/magic-context/command-handler.d.ts +5 -4
  154. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  155. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  156. package/dist/hooks/magic-context/compaction-off-transition.d.ts +1 -0
  157. package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
  158. package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -1
  159. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  160. package/dist/hooks/magic-context/compartment-render-epoch.d.ts +3 -1
  161. package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
  162. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +1 -1
  163. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
  164. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
  165. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  166. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +19 -0
  167. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  168. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  169. package/dist/hooks/magic-context/compartment-runner-types.d.ts +19 -11
  170. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  171. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +4 -1
  172. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  173. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  174. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  175. package/dist/hooks/magic-context/decay-render.d.ts +1 -0
  176. package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
  177. package/dist/hooks/magic-context/decision-calibration.d.ts +24 -0
  178. package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -0
  179. package/dist/hooks/magic-context/derive-budgets.d.ts +2 -0
  180. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
  181. package/dist/hooks/magic-context/dropped-input-guard.d.ts +50 -4
  182. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  183. package/dist/hooks/magic-context/embed-history-runner.d.ts +30 -0
  184. package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -0
  185. package/dist/hooks/magic-context/emergency-drop.d.ts +13 -8
  186. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  187. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  188. package/dist/hooks/magic-context/event-payloads.d.ts +2 -1
  189. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  190. package/dist/hooks/magic-context/execute-status.d.ts +2 -1
  191. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  192. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
  193. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  194. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  195. package/dist/hooks/magic-context/historian-no-fire-cause.d.ts +5 -0
  196. package/dist/hooks/magic-context/historian-no-fire-cause.d.ts.map +1 -0
  197. package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts +3 -0
  198. package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts.map +1 -0
  199. package/dist/hooks/magic-context/hook-handlers.d.ts +0 -3
  200. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  201. package/dist/hooks/magic-context/hook.d.ts +4 -4
  202. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  203. package/dist/hooks/magic-context/host-served-rows.d.ts +58 -0
  204. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -0
  205. package/dist/hooks/magic-context/inject-compartments.d.ts +38 -0
  206. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  207. package/dist/hooks/magic-context/legacy-compartments.d.ts +20 -0
  208. package/dist/hooks/magic-context/legacy-compartments.d.ts.map +1 -0
  209. package/dist/hooks/magic-context/live-session-state.d.ts +7 -7
  210. package/dist/hooks/magic-context/m0-token-breakdown.d.ts +6 -0
  211. package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -1
  212. package/dist/hooks/magic-context/maintenance-authority.d.ts +0 -1
  213. package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
  214. package/dist/hooks/magic-context/module-state-sync.d.ts +4 -1
  215. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  216. package/dist/hooks/magic-context/module-transport.d.ts +24 -2
  217. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  218. package/dist/hooks/magic-context/module-wire.d.ts +43 -1
  219. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  220. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  221. package/dist/hooks/magic-context/postprocess-read-cache.d.ts +8 -0
  222. package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -0
  223. package/dist/hooks/magic-context/producer-window-guard.d.ts +47 -1
  224. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  225. package/dist/hooks/magic-context/producer-window-test-support.d.ts +14 -0
  226. package/dist/hooks/magic-context/producer-window-test-support.d.ts.map +1 -0
  227. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
  228. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  229. package/dist/hooks/magic-context/read-session-chunk.d.ts +51 -10
  230. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  231. package/dist/hooks/magic-context/read-session-db.d.ts +8 -0
  232. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  233. package/dist/hooks/magic-context/read-session-formatting.d.ts +6 -0
  234. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  235. package/dist/hooks/magic-context/read-session-raw.d.ts +4 -0
  236. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  237. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +6 -0
  238. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  239. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +17 -39
  240. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  241. package/dist/hooks/magic-context/rust-mode-transform.d.ts +51 -0
  242. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  243. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +28 -0
  244. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -0
  245. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
  246. package/dist/hooks/magic-context/system-prompt-hash.d.ts +6 -7
  247. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  248. package/dist/hooks/magic-context/tag-messages.d.ts +21 -1
  249. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  250. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +63 -0
  251. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  252. package/dist/hooks/magic-context/tokenizer-calibration.d.ts +19 -12
  253. package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
  254. package/dist/hooks/magic-context/tool-drop-target.d.ts +52 -1
  255. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  256. package/dist/hooks/magic-context/tool-sweep-policy.d.ts +50 -0
  257. package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -0
  258. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +20 -1
  259. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  260. package/dist/hooks/magic-context/transform-context-state.d.ts +9 -0
  261. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  262. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -3
  263. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  264. package/dist/hooks/magic-context/transform.d.ts +44 -4
  265. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  266. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  267. package/dist/{index-f9gem5cr.js → index-8w1skpnm.js} +85 -5
  268. package/dist/index-99sfbrrf.js +170 -0
  269. package/dist/index-9skq8m9y.js +16 -0
  270. package/dist/{index-3wbd8sdq.js → index-d0dh7v0f.js} +28107 -29850
  271. package/dist/{index-d8mgqezq.js → index-rpz2me0v.js} +133 -78
  272. package/dist/{index-p474rw9p.js → index-rvwvdq59.js} +1 -1
  273. package/dist/index-w2ety11c.js +393 -0
  274. package/dist/index-y5145x8k.js +619 -0
  275. package/dist/index-ygwdyntq.js +5407 -0
  276. package/dist/{index-jkrqhc7y.js → index-ykg9sdzz.js} +147 -28
  277. package/dist/index.d.ts.map +1 -1
  278. package/dist/index.js +7065 -3197
  279. package/dist/message-time-backfill-gzjer78y.js +108 -0
  280. package/dist/plugin/dream-timer.d.ts +13 -0
  281. package/dist/plugin/dream-timer.d.ts.map +1 -1
  282. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  283. package/dist/plugin/hooks/create-session-hooks.d.ts +5 -2
  284. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  285. package/dist/plugin/memory-id-translation.d.ts +109 -0
  286. package/dist/plugin/memory-id-translation.d.ts.map +1 -0
  287. package/dist/plugin/messages-transform.d.ts.map +1 -1
  288. package/dist/plugin/rpc-handlers.d.ts +10 -0
  289. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  290. package/dist/plugin/rust-note-backend.d.ts +84 -0
  291. package/dist/plugin/rust-note-backend.d.ts.map +1 -0
  292. package/dist/plugin/rust-tool-backends.d.ts +1 -1
  293. package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
  294. package/dist/plugin/tool-registry.d.ts +1 -0
  295. package/dist/plugin/tool-registry.d.ts.map +1 -1
  296. package/dist/read-session-chunk-ec3jkvhg.js +61 -0
  297. package/dist/{recomp-orchestrator-k20sfpm2.js → recomp-orchestrator-6akjp11f.js} +8 -8
  298. package/dist/{send-session-notification-xnypkxpx.js → send-session-notification-f6gwkesy.js} +2 -2
  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/auto-update-provenance.d.ts +9 -0
  302. package/dist/shared/auto-update-provenance.d.ts.map +1 -0
  303. package/dist/shared/conflict-detector.d.ts +14 -5
  304. package/dist/shared/conflict-detector.d.ts.map +1 -1
  305. package/dist/shared/hidden-variant-warnings.d.ts +5 -0
  306. package/dist/shared/hidden-variant-warnings.d.ts.map +1 -0
  307. package/dist/shared/host-limitations.d.ts +14 -0
  308. package/dist/shared/host-limitations.d.ts.map +1 -0
  309. package/dist/shared/keep-subagents.d.ts +1 -1
  310. package/dist/shared/keep-subagents.d.ts.map +1 -1
  311. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  312. package/dist/shared/models-dev-cache.d.ts +1 -0
  313. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  314. package/dist/shared/opencode-config-dir.d.ts +52 -0
  315. package/dist/shared/opencode-config-dir.d.ts.map +1 -1
  316. package/dist/shared/opencode-db-path.d.ts +46 -2
  317. package/dist/shared/opencode-db-path.d.ts.map +1 -1
  318. package/dist/shared/prompt-surface-runtime.d.ts +6 -6
  319. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  320. package/dist/shared/rpc-server.d.ts +10 -0
  321. package/dist/shared/rpc-server.d.ts.map +1 -1
  322. package/dist/shared/rpc-types.d.ts +64 -5
  323. package/dist/shared/rpc-types.d.ts.map +1 -1
  324. package/dist/shared/status-detail-text.d.ts +1 -3
  325. package/dist/shared/status-detail-text.d.ts.map +1 -1
  326. package/dist/shared/status-summary.d.ts +7 -0
  327. package/dist/shared/status-summary.d.ts.map +1 -1
  328. package/dist/shared/status-view.d.ts +229 -0
  329. package/dist/shared/status-view.d.ts.map +1 -0
  330. package/dist/shared/tag-transcript.d.ts.map +1 -1
  331. package/dist/shared/tail-hygiene-status.d.ts +8 -0
  332. package/dist/shared/tail-hygiene-status.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-ex4nt0q0.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/mode.d.ts +31 -0
  341. package/dist/tools/ctx-expand/mode.d.ts.map +1 -0
  342. package/dist/tools/ctx-expand/render.d.ts.map +1 -1
  343. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  344. package/dist/tools/ctx-memory/constants.d.ts +3 -1
  345. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  346. package/dist/tools/ctx-memory/tools.d.ts +1 -0
  347. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  348. package/dist/tools/ctx-memory/types.d.ts +2 -2
  349. package/dist/tools/ctx-note/constants.d.ts +1 -1
  350. package/dist/tools/ctx-note/constants.d.ts.map +1 -1
  351. package/dist/tools/ctx-note/render.d.ts +88 -0
  352. package/dist/tools/ctx-note/render.d.ts.map +1 -0
  353. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  354. package/dist/tools/ctx-note/types.d.ts +1 -1
  355. package/dist/tools/ctx-note/types.d.ts.map +1 -1
  356. package/dist/tools/ctx-reduce/constants.d.ts +1 -1
  357. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  358. package/dist/tools/ctx-search/constants.d.ts +1 -1
  359. package/dist/tools/ctx-search/constants.d.ts.map +1 -1
  360. package/dist/tools/ctx-search/date-range.d.ts +9 -0
  361. package/dist/tools/ctx-search/date-range.d.ts.map +1 -0
  362. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  363. package/dist/tools/ctx-search/types.d.ts +3 -1
  364. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  365. package/dist/tools/light-descriptions.d.ts +5 -5
  366. package/dist/tools/light-descriptions.d.ts.map +1 -1
  367. package/dist/tools/parameter-descriptions.d.ts +75 -0
  368. package/dist/tools/parameter-descriptions.d.ts.map +1 -0
  369. package/dist/transformers-node-wasm.js +1918 -826
  370. package/dist/transformers-web.js +1736 -636
  371. package/dist/{transformers.node-dpmf3wpx.js → transformers.node-3zqr6k1w.js} +4087 -2898
  372. package/dist/tui/data/context-db.d.ts +19 -7
  373. package/dist/tui/data/context-db.d.ts.map +1 -1
  374. package/dist/tui-compiled/data/context-db.d.ts +19 -7
  375. package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
  376. package/dist/v2/fold/host-media.d.ts +36 -0
  377. package/dist/v2/fold/host-media.d.ts.map +1 -0
  378. package/dist/v2/fold/restore.d.ts +21 -1
  379. package/dist/v2/fold/restore.d.ts.map +1 -1
  380. package/dist/v2/hidden-completion.d.ts +114 -14
  381. package/dist/v2/hidden-completion.d.ts.map +1 -1
  382. package/dist/v2/hooks/commands.d.ts +29 -0
  383. package/dist/v2/hooks/commands.d.ts.map +1 -0
  384. package/dist/v2/hooks/context.d.ts +58 -2
  385. package/dist/v2/hooks/context.d.ts.map +1 -1
  386. package/dist/v2/hooks/deleted-session-tombstones.d.ts +10 -0
  387. package/dist/v2/hooks/deleted-session-tombstones.d.ts.map +1 -0
  388. package/dist/v2/hooks/dream-manual.d.ts +43 -0
  389. package/dist/v2/hooks/dream-manual.d.ts.map +1 -0
  390. package/dist/v2/hooks/dream-trigger.d.ts +7 -0
  391. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  392. package/dist/v2/hooks/hidden-child.d.ts +32 -0
  393. package/dist/v2/hooks/hidden-child.d.ts.map +1 -0
  394. package/dist/v2/hooks/model-limit-cache.d.ts +19 -0
  395. package/dist/v2/hooks/model-limit-cache.d.ts.map +1 -0
  396. package/dist/v2/hooks/payload.d.ts.map +1 -1
  397. package/dist/v2/hooks/provider-admission.d.ts +22 -0
  398. package/dist/v2/hooks/provider-admission.d.ts.map +1 -0
  399. package/dist/v2/hooks/rpc-live-state.d.ts +9 -0
  400. package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -0
  401. package/dist/v2/hooks/store.d.ts +38 -2
  402. package/dist/v2/hooks/store.d.ts.map +1 -1
  403. package/dist/v2/hooks/tools.d.ts +8 -0
  404. package/dist/v2/hooks/tools.d.ts.map +1 -0
  405. package/dist/v2/hooks/types.d.ts +157 -19
  406. package/dist/v2/hooks/types.d.ts.map +1 -1
  407. package/dist/v2/hooks/usage-reading.d.ts +42 -0
  408. package/dist/v2/hooks/usage-reading.d.ts.map +1 -0
  409. package/dist/v2/host-service.d.ts +65 -0
  410. package/dist/v2/host-service.d.ts.map +1 -0
  411. package/dist/v2/server.d.ts +19 -0
  412. package/dist/v2/server.d.ts.map +1 -1
  413. package/dist/v2/server.js +141849 -110533
  414. package/dist/v2/store-reader.d.ts +78 -6
  415. package/dist/v2/store-reader.d.ts.map +1 -1
  416. package/dist/v2/tui/events.d.ts +7 -0
  417. package/dist/v2/tui/events.d.ts.map +1 -0
  418. package/dist/v2/tui/index.d.ts +33 -0
  419. package/dist/v2/tui/index.d.ts.map +1 -0
  420. package/dist/v2/tui/sidebar-mount.d.ts +40 -0
  421. package/dist/v2/tui/sidebar-mount.d.ts.map +1 -0
  422. package/dist/v2/tui/status-dialog-mount.d.ts +29 -0
  423. package/dist/v2/tui/status-dialog-mount.d.ts.map +1 -0
  424. package/dist/v2/tui/types.d.ts +148 -0
  425. package/dist/v2/tui/types.d.ts.map +1 -0
  426. package/dist/wrapup-orchestrator-5akc87gr.js +16 -0
  427. package/package.json +9 -7
  428. package/src/agents/dreamer.ts +7 -16
  429. package/src/agents/hidden-agent-registrations.ts +10 -22
  430. package/src/agents/magic-context-prompt.test.ts +29 -39
  431. package/src/agents/magic-context-prompt.ts +99 -122
  432. package/src/agents/permissions.test.ts +17 -21
  433. package/src/config/index.ts +39 -4
  434. package/src/config/live-run-config.test.ts +237 -0
  435. package/src/config/live-run-config.ts +80 -0
  436. package/src/config/live-schema-drift.test.ts +67 -0
  437. package/src/config/live-snapshot.test.ts +85 -0
  438. package/src/config/live-snapshot.ts +191 -0
  439. package/src/config/protected-tokens.test.ts +40 -0
  440. package/src/config/raw-loader.test.ts +1 -0
  441. package/src/config/schema/magic-context.test.ts +13 -5
  442. package/src/config/schema/magic-context.ts +109 -13
  443. package/src/features/magic-context/dreamer/task-registry.ts +137 -13
  444. package/src/shared/assistant-message-extractor.test.ts +21 -0
  445. package/src/shared/assistant-message-extractor.ts +43 -8
  446. package/src/shared/auto-update-provenance.ts +42 -0
  447. package/src/shared/child-session-teardown.test.ts +38 -3
  448. package/src/shared/child-session-teardown.ts +3 -3
  449. package/src/shared/conflict-detector.test.ts +277 -7
  450. package/src/shared/conflict-detector.ts +221 -80
  451. package/src/shared/hidden-variant-warnings.ts +21 -0
  452. package/src/shared/host-limitations.ts +43 -0
  453. package/src/shared/keep-subagents.ts +6 -6
  454. package/src/shared/model-suggestion-retry.test.ts +43 -0
  455. package/src/shared/model-suggestion-retry.ts +12 -0
  456. package/src/shared/models-dev-cache.test.ts +25 -0
  457. package/src/shared/models-dev-cache.ts +5 -0
  458. package/src/shared/opencode-config-dir.ts +80 -7
  459. package/src/shared/opencode-db-path.test.ts +174 -0
  460. package/src/shared/opencode-db-path.ts +193 -15
  461. package/src/shared/opencode-host-generation.test.ts +29 -0
  462. package/src/shared/prompt-surface-a1-golden.md +142 -215
  463. package/src/shared/prompt-surface-runtime.test.ts +20 -0
  464. package/src/shared/prompt-surface-runtime.ts +7 -5
  465. package/src/shared/rpc-server.ts +18 -0
  466. package/src/shared/rpc-types.ts +63 -4
  467. package/src/shared/status-detail-text.test.ts +52 -18
  468. package/src/shared/status-detail-text.ts +1 -90
  469. package/src/shared/status-summary.ts +37 -2
  470. package/src/shared/status-view.test.ts +441 -0
  471. package/src/shared/status-view.ts +707 -0
  472. package/src/shared/tag-transcript.ts +115 -16
  473. package/src/shared/tail-hygiene-status.ts +9 -1
  474. package/src/shared/user-facing-codes.test.ts +3 -4
  475. package/src/shared/user-facing-codes.ts +33 -8
  476. package/src/shared/window-geometry.test.ts +23 -5
  477. package/src/shared/window-geometry.ts +13 -3
  478. package/src/tui/data/context-db.ts +50 -15
  479. package/src/tui/dialogs/status-dialog-colors.test.ts +58 -0
  480. package/src/tui/dialogs/status-dialog.tsx +288 -0
  481. package/src/tui/entry.mjs +11 -1
  482. package/src/tui/index.tsx +7 -464
  483. package/src/tui/slots/sidebar-content.tsx +21 -5
  484. package/src/tui-compiled/data/context-db.ts +50 -15
  485. package/src/tui-compiled/dialogs/status-dialog.tsx +552 -0
  486. package/src/tui-compiled/index.tsx +43 -1025
  487. package/src/tui-compiled/slots/sidebar-content.tsx +173 -152
  488. package/src/v2/tui/__fixtures__/ga-host-theme.json +160 -0
  489. package/src/v2/tui/events.ts +23 -0
  490. package/src/v2/tui/host-contract.test.ts +251 -0
  491. package/src/v2/tui/index.ts +526 -0
  492. package/src/v2/tui/load-compiled-sidebar.d.mts +59 -0
  493. package/src/v2/tui/load-compiled-sidebar.mjs +24 -0
  494. package/src/v2/tui/load-compiled-status-dialog.d.mts +17 -0
  495. package/src/v2/tui/load-compiled-status-dialog.mjs +16 -0
  496. package/src/v2/tui/sidebar-fallback.test.ts +100 -0
  497. package/src/v2/tui/sidebar-mount.ts +164 -0
  498. package/src/v2/tui/sidebar-text.test.ts +70 -0
  499. package/src/v2/tui/status-dialog-fallback.test.ts +97 -0
  500. package/src/v2/tui/status-dialog-mount.ts +76 -0
  501. package/src/v2/tui/theme-mapping.test.ts +57 -0
  502. package/src/v2/tui/types.ts +132 -0
  503. package/tui.js +1 -0
  504. package/dist/features/magic-context/memory/memory-migration.d.ts +0 -129
  505. package/dist/features/magic-context/memory/memory-migration.d.ts.map +0 -1
  506. package/dist/hooks/magic-context/upgrade-reminder.d.ts +0 -76
  507. package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +0 -1
  508. package/dist/index-1ar7b3e9.js +0 -637
  509. package/dist/index-4wwr6cz0.js +0 -112
  510. package/dist/index-avwt563y.js +0 -62
  511. package/dist/storage-meta-session-x3j0q9qy.js +0 -20
@@ -0,0 +1,9 @@
1
+ import { type LiveSessionState } from "../../hooks/magic-context/live-session-state";
2
+ /**
3
+ * The RPC surface must read and write the SAME live sets the v2 pass uses.
4
+ * `systemPromptRefreshSessions` is part of that: a `/ctx-flush` arriving over
5
+ * RPC signals it, and only the shared instance is the one the next
6
+ * system-prompt transform drains.
7
+ */
8
+ export declare function createV2RpcLiveSessionState(overrides: Pick<LiveSessionState, "liveModelBySession" | "variantBySession" | "agentBySession" | "channel1StateBySession" | "historyRefreshSessions" | "pendingMaterializationSessions" | "systemPromptRefreshSessions">): LiveSessionState;
9
+ //# sourceMappingURL=rpc-live-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-live-state.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/rpc-live-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,gBAAgB,EACxB,MAAM,8CAA8C,CAAC;AAEtD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,IAAI,CACX,gBAAgB,EACd,oBAAoB,GACpB,kBAAkB,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,CAClC,GACF,gBAAgB,CAElB"}
@@ -1,6 +1,42 @@
1
- import type { RawMessage } from "../../hooks/magic-context/read-session-raw";
2
- import type { StoreRow } from "../store-reader";
1
+ import type { BoundedRawMessageProvider } from "../../hooks/magic-context/read-session-chunk";
2
+ import type { RawMessage, RawMessageOrdinalAnchor, RawMessageOrdinalEntry, RawMessageParts } from "../../hooks/magic-context/read-session-raw";
3
+ import { type StoreRow, type V2StoreReader } from "../store-reader";
4
+ /**
5
+ * Whether the host puts this row into the request draft under its own id. The
6
+ * decision reuses restoreRow, the local mirror of the host's row-to-message
7
+ * rendering, so the two cannot drift: an instruction-update `system` row, a
8
+ * background shell row or an empty user turn renders without the row id (or not
9
+ * at all) and can never be found again by a boundary lookup.
10
+ */
11
+ export declare function hostServesRowById(row: StoreRow): boolean;
3
12
  /** Ordinals count conversational rows in the complete session, never a post-fold window.
4
13
  * A window caller must supply the full history so compaction cannot reassign tag identities. */
5
14
  export declare function rawMessages(rows: readonly StoreRow[], history?: readonly StoreRow[]): RawMessage[];
15
+ /** Project a SQL-bounded page whose first row follows `afterOrdinal`. */
16
+ export declare function rawMessagePage(rows: readonly StoreRow[], afterOrdinal: number): RawMessage[];
17
+ export interface V2RawMessageReader {
18
+ readPage(sessionID: string, afterOrdinal: number, limit: number, finalWatermark: number): RawMessage[];
19
+ findById(sessionID: string, messageID: string): RawMessage | null;
20
+ findPartsById(sessionID: string, messageID: string): RawMessageParts | null;
21
+ hasById(sessionID: string, messageID: string): boolean;
22
+ ordinalOf(sessionID: string, messageID: string): number | null;
23
+ ordinalMapForRange(sessionID: string, fromOrdinal: number, toOrdinal: number): Map<string, number>;
24
+ readOrdinalPage(sessionID: string, after: RawMessageOrdinalAnchor | null, limit: number): RawMessageOrdinalEntry[];
25
+ getCount(sessionID: string): number;
26
+ getStoredCount(sessionID: string): number;
27
+ /** Id of the row the host serves in place of `messageID`; see servedBoundaryRow. */
28
+ servedBoundaryIdOf?(sessionID: string, messageID: string): string | null;
29
+ }
30
+ /**
31
+ * The row a stored compartment boundary stands for in a request: the boundary
32
+ * row itself when the host serves it by id, otherwise the nearest earlier row
33
+ * that it does serve. Returns null when the id is not a conversational row in
34
+ * the store or no earlier served row exists; callers then keep the stored id.
35
+ */
36
+ export declare function servedBoundaryRow(reader: Pick<V2StoreReader, "messageById" | "rawRowsThrough">, sessionID: string, messageID: string): StoreRow | null;
37
+ /** The only V2 full-history reader: store-generation conversion must inspect every part. */
38
+ export declare function readAllV2RawMessagesForConversion(openReader: () => V2StoreReader, sessionID: string): RawMessage[];
39
+ /** Build the SQL-bounded reader used by context, indexing, and historian passes. */
40
+ export declare function createV2RawMessageReader(openReader: () => V2StoreReader): V2RawMessageReader;
41
+ export declare function createV2RawMessageProvider(reader: V2RawMessageReader, sessionID: string): BoundedRawMessageProvider;
6
42
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD;gGACgG;AAChG,wBAAgB,WAAW,CACvB,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,OAAO,GAAE,SAAS,QAAQ,EAAS,GACpC,UAAU,EAAE,CA+Bd"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,KAAK,EACR,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EAClB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAGH,KAAK,QAAQ,EACb,KAAK,aAAa,EACrB,MAAM,iBAAiB,CAAC;AAUzB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GA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,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5E;AAID;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,gBAAgB,CAAC,EAC7D,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,QAAQ,GAAG,IAAI,CAajB;AAED,4FAA4F;AAC5F,wBAAgB,iCAAiC,CAC7C,UAAU,EAAE,MAAM,aAAa,EAC/B,SAAS,EAAE,MAAM,GAClB,UAAU,EAAE,CAOd;AAED,oFAAoF;AACpF,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,aAAa,GAAG,kBAAkB,CA4G5F;AAED,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,GAClB,yBAAyB,CAoB3B"}
@@ -0,0 +1,8 @@
1
+ import type { MagicContextPluginConfig } from "../../config";
2
+ import type { Database } from "../../shared/sqlite";
3
+ import type { V2Context } from "./types";
4
+ /** OpenCode 2 requires explicit tool-editor registration; it does not load the v1 tool map. */
5
+ export declare function registerTools(context: V2Context, db: Database, config: MagicContextPluginConfig): Promise<{
6
+ dispose: () => void;
7
+ }>;
8
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,+FAA+F;AAC/F,wBAAsB,aAAa,CAC/B,OAAO,EAAE,SAAS,EAClB,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,wBAAwB;;GA+DnC"}
@@ -10,6 +10,11 @@ export interface SessionContext {
10
10
  providerID: string;
11
11
  id: string;
12
12
  variant?: string;
13
+ limit?: {
14
+ context: number;
15
+ input?: number;
16
+ output?: number;
17
+ };
13
18
  };
14
19
  agent: string;
15
20
  messages: V2Message[];
@@ -23,29 +28,94 @@ export interface SessionContext {
23
28
  summary: string;
24
29
  };
25
30
  }
31
+ export interface V2AgentEditor {
32
+ update(id: string, update: (agent: {
33
+ system?: string;
34
+ description?: string;
35
+ mode: "subagent" | "primary" | "all";
36
+ hidden: boolean;
37
+ request: {
38
+ settings: Record<string, unknown>;
39
+ headers: Record<string, string>;
40
+ body: Record<string, unknown>;
41
+ };
42
+ permissions: Array<{
43
+ action: string;
44
+ resource: string;
45
+ effect: "allow" | "deny" | "ask";
46
+ }>;
47
+ }) => void): void;
48
+ }
49
+ export interface V2AgentDomain {
50
+ reload(): Promise<void>;
51
+ transform(callback: (editor: V2AgentEditor) => void): Promise<unknown>;
52
+ }
53
+ /** What the host hands a registered command when a client invokes it. */
54
+ export interface V2CommandInvocation {
55
+ sessionID: string;
56
+ /** `text` is the argument remainder the client typed after the command name. */
57
+ prompt: {
58
+ text: string;
59
+ };
60
+ delivery: string;
61
+ }
62
+ export interface V2CommandEditor {
63
+ add(definition: {
64
+ name: string;
65
+ description?: string;
66
+ execute: (input: V2CommandInvocation) => Promise<void>;
67
+ }): void;
68
+ }
69
+ /**
70
+ * Server-side command registry. The host keeps the added definitions in a
71
+ * location-scoped map that `GET /api/command` lists and
72
+ * `POST /api/session/:sessionID/command` executes, so a command registered here
73
+ * is reachable from every client, not only the terminal UI.
74
+ */
75
+ export interface V2CommandDomain {
76
+ transform(callback: (editor: V2CommandEditor) => void): Promise<unknown>;
77
+ reload(): Promise<void>;
78
+ }
26
79
  export interface V2Context {
27
80
  location: {
28
81
  directory: string;
29
82
  };
83
+ agent: V2AgentDomain;
84
+ /** Absent on hosts predating the command domain; registration is then skipped. */
85
+ command?: V2CommandDomain;
30
86
  event: {
31
87
  subscribe(options: {
32
88
  signal: AbortSignal;
33
89
  }): AsyncIterable<unknown>;
34
90
  };
35
- catalog: {
36
- model: {
37
- list(input: {
38
- location: {
39
- directory: string;
91
+ model: {
92
+ list(): Promise<{
93
+ data: Array<{
94
+ id: string;
95
+ providerID: string;
96
+ limit: {
97
+ context: number;
98
+ };
99
+ }>;
100
+ }> | Promise<Array<{
101
+ id: string;
102
+ providerID: string;
103
+ limit: {
104
+ context: number;
105
+ };
106
+ }>> | Array<{
107
+ id: string;
108
+ providerID: string;
109
+ limit: {
110
+ context: number;
111
+ };
112
+ }> | {
113
+ data: Array<{
114
+ id: string;
115
+ providerID: string;
116
+ limit: {
117
+ context: number;
40
118
  };
41
- }): Promise<{
42
- data: Array<{
43
- id: string;
44
- providerID: string;
45
- limit: {
46
- context: number;
47
- };
48
- }>;
49
119
  }>;
50
120
  };
51
121
  };
@@ -54,6 +124,27 @@ export interface V2Context {
54
124
  set(key: string, value: unknown): Promise<void>;
55
125
  };
56
126
  tool: {
127
+ transform?(callback: (editor: {
128
+ update(id: string, update: (tool: {
129
+ description: string;
130
+ }) => void): void;
131
+ add?(tool: {
132
+ name: string;
133
+ description: string;
134
+ input: unknown;
135
+ options?: {
136
+ codemode: boolean;
137
+ };
138
+ execute(input: unknown, context: {
139
+ sessionID: string;
140
+ messageID: string;
141
+ agent: string;
142
+ progress(value: Record<string, unknown>): Promise<void>;
143
+ }): Promise<{
144
+ content: string;
145
+ }>;
146
+ }): void;
147
+ }) => void): Promise<unknown>;
57
148
  hook(name: "execute.before" | "execute.after", callback: (draft: {
58
149
  tool: string;
59
150
  sessionID: string;
@@ -65,20 +156,67 @@ export interface V2Context {
65
156
  }) => void | Promise<void>): Promise<unknown>;
66
157
  };
67
158
  session: {
68
- generate?: (input: {
159
+ create(input: {
160
+ title: string;
161
+ agent: string;
162
+ model: {
163
+ providerID: string;
164
+ id: string;
165
+ variant?: string;
166
+ };
167
+ location: {
168
+ directory: string;
169
+ };
170
+ metadata: {
171
+ magic_context: "hidden-run";
172
+ role: "historian" | "dreamer";
173
+ };
174
+ }): Promise<{
175
+ id: string;
176
+ }>;
177
+ get(input: {
69
178
  sessionID: string;
70
- prompt: string;
71
- }, options?: {
72
- signal?: AbortSignal;
73
- }) => Promise<{
74
- text: string;
179
+ }): Promise<{
180
+ model?: {
181
+ providerID: string;
182
+ id: string;
183
+ variant?: string;
184
+ };
75
185
  }>;
186
+ switchModel(input: {
187
+ sessionID: string;
188
+ model: {
189
+ providerID: string;
190
+ id: string;
191
+ variant?: string;
192
+ };
193
+ }): Promise<void>;
194
+ prompt(input: {
195
+ sessionID: string;
196
+ text: string;
197
+ }): Promise<unknown>;
198
+ wait(input: {
199
+ sessionID: string;
200
+ }): Promise<void>;
201
+ update(input: {
202
+ sessionID: string;
203
+ title: string;
204
+ }): Promise<void>;
76
205
  synthetic(input: {
77
206
  sessionID: string;
78
207
  id: string;
79
208
  text: string;
80
209
  delivery: "steer";
81
210
  }): Promise<unknown>;
211
+ hook(name: "http.response", callback: (draft: {
212
+ sessionID: string;
213
+ model: {
214
+ providerID: string;
215
+ id: string;
216
+ };
217
+ kind: string;
218
+ response: Response;
219
+ }) => Promise<void>): Promise<unknown>;
82
220
  hook(name: "context" | "compaction" | "generate", callback: (draft: SessionContext) => Promise<void>): Promise<unknown>;
83
221
  interrupt(input: {
84
222
  sessionID: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AACD,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EA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;QACnE,SAAS,CAAC,KAAK,EAAE;YACb,SAAS,EAAE,MAAM,CAAC;YAClB,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,OAAO,CAAC;SACrB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CACA,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE;YACd,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE;gBAAE,UAAU,EAAE,MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;YAC1C,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,QAAQ,CAAC;SACtB,KAAK,OAAO,CAAC,IAAI,CAAC,GACpB,OAAO,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CACA,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,EAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GACnD,OAAO,CAAC,OAAO,CAAC,CAAC;QACpB,SAAS,CAAC,KAAK,EAAE;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC;YAAE,WAAW,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KAC9E,CAAC;CACL"}
@@ -0,0 +1,42 @@
1
+ export interface UsageReadingInput {
2
+ rowModel?: {
3
+ providerID?: unknown;
4
+ id?: unknown;
5
+ };
6
+ draftModel: {
7
+ providerID: string;
8
+ id: string;
9
+ };
10
+ tokens?: {
11
+ input?: number;
12
+ output?: number;
13
+ cache?: {
14
+ read?: number;
15
+ write?: number;
16
+ };
17
+ };
18
+ completed?: number;
19
+ /** Resolve the output-reserved usable window for a model. */
20
+ limitFor: (providerID: string, modelID: string) => number;
21
+ }
22
+ export interface UsageReading {
23
+ inputTokens: number;
24
+ /** Window of the model that produced the persisted reading. */
25
+ limit: number;
26
+ /** Window the outgoing draft will use for admission. */
27
+ admissionLimit: number;
28
+ /** Absent when a legacy row carries no model metadata. */
29
+ modelKey?: string;
30
+ completed?: number;
31
+ }
32
+ export declare function usageReadingMatchesDraft(reading: UsageReading, draftModel: {
33
+ providerID: string;
34
+ id: string;
35
+ }): boolean;
36
+ /**
37
+ * Attribute stored usage to the model that produced it while measuring the next
38
+ * request against the outgoing draft model. Partial or non-finite token fields
39
+ * contribute zero rather than poisoning persisted percentages.
40
+ */
41
+ export declare function resolveUsageReading(input: UsageReadingInput): UsageReading | undefined;
42
+ //# sourceMappingURL=usage-reading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-reading.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/usage-reading.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,MAAM,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7D;AAED,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/C,OAAO,CAKT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS,CA+BtF"}
@@ -0,0 +1,65 @@
1
+ /** The channel this plugin's host is running on; matches the host's own default. */
2
+ export declare function serviceChannel(env?: NodeJS.ProcessEnv): string;
3
+ /** Registration filename for one channel, following OpenCode 2's own naming rule. */
4
+ export declare function serviceRegistrationFilename(channel: string): string;
5
+ /** Directory the host writes every channel's registration into. */
6
+ export declare function serviceRegistrationDirectory(env?: NodeJS.ProcessEnv): string;
7
+ /** Registration path for this environment's channel. */
8
+ export declare function serviceRegistrationPath(env?: NodeJS.ProcessEnv): string;
9
+ export interface HostService {
10
+ /** Absolute path of the registration file this was read from. */
11
+ readonly path: string;
12
+ /** Base URL with no trailing slash. */
13
+ readonly url: string;
14
+ readonly headers: Record<string, string>;
15
+ /** Process id of the host that wrote the registration. */
16
+ readonly pid: number;
17
+ /** Service identifier from the registration, when it carries one. */
18
+ readonly serviceID?: string;
19
+ }
20
+ /**
21
+ * The binding persisted alongside a hidden child so its cleanup can find the same host again after
22
+ * a restart. The registration path is the durable part: it names the channel, and the channel names
23
+ * the store the child's session lives in. The service id and pid describe the process that created
24
+ * the child and are kept for diagnosis, not as a gate — a restarted host on the same channel is
25
+ * still the owner of the same sessions.
26
+ */
27
+ export interface HostServiceOwner {
28
+ readonly registration: string;
29
+ readonly serviceID?: string;
30
+ readonly pid: number;
31
+ }
32
+ /** A cleanup that cannot be attempted right now and must be retried later. */
33
+ export declare class HostServiceUnavailable extends Error {
34
+ constructor(message: string);
35
+ }
36
+ /** Every readable registration in the state directory, whichever channel wrote it. */
37
+ export declare function readServiceRegistrations(env?: NodeJS.ProcessEnv): HostService[];
38
+ /**
39
+ * The registration written by the process this plugin is loaded in, or undefined when the host
40
+ * registered nothing (a plain `opencode serve`, or a `--standalone` host).
41
+ *
42
+ * Matching on process id rather than on the channel's expected filename means a host whose channel
43
+ * we guessed wrong, or one running on a channel we have never heard of, is still recognised — and,
44
+ * more importantly, an unrelated service belonging to a different store never is.
45
+ */
46
+ export declare function discoverOwnHostService(env?: NodeJS.ProcessEnv, pid?: number): HostService | undefined;
47
+ /** The owner binding to persist with a hidden child created by this process. */
48
+ export declare function hostServiceOwner(env?: NodeJS.ProcessEnv, pid?: number): HostServiceOwner | undefined;
49
+ /**
50
+ * Resolve the host to delete an owned session through, or explain why there is none.
51
+ *
52
+ * The only acceptable route is the registration this process itself wrote AND that the child
53
+ * recorded when it was created. Any other live service is a different endpoint — very possibly a
54
+ * different channel's store — where the session was never created, so its 404 would mean "I never
55
+ * had it", not "it is gone".
56
+ */
57
+ export declare function resolveOwnerHostService(owner: HostServiceOwner | undefined, env?: NodeJS.ProcessEnv, pid?: number): HostService;
58
+ /**
59
+ * Deletes a session through the host that created it, which interrupts whatever it is doing, waits
60
+ * for it to go idle, removes its children, and publishes the deletion so the rest of the host keeps
61
+ * up. This is the same route the OpenCode client's session removal calls, so it inherits all of
62
+ * that.
63
+ */
64
+ export declare function removeHostSession(sessionID: string, owner: HostServiceOwner | undefined, env?: NodeJS.ProcessEnv): Promise<void>;
65
+ //# sourceMappingURL=host-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-service.d.ts","sourceRoot":"","sources":["../../src/v2/host-service.ts"],"names":[],"mappings":"AAkCA,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAI3E;AAED,qFAAqF;AACrF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,mEAAmE;AACnE,wB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AAG,GAAE,MAAM,CAAC,UAAwB,EACpC,GAAG,GAAE,MAAoB,GAC1B,WAAW,CAkBb;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,gBAAgB,GAAG,SAAS,EACnC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -1,4 +1,23 @@
1
1
  import type { V2Context } from "./hooks/types";
2
+ /**
3
+ * Only an OpenCode 2 host hands `setup` a context carrying `session.hook`.
4
+ * The package's default export is the union `{ id, server, setup }`, and a
5
+ * v1 host that finds `setup` on it must not run the v2 lane: locking the
6
+ * harness to "opencode2" there mis-tags every row that seat writes.
7
+ *
8
+ * Proven against the shipped OpenCode 1.18.30 binary and traced to source at
9
+ * tag v1.18.31: the v1 loader (`packages/opencode/src/plugin/index.ts`) calls
10
+ * `server()`, and independently the bundled core external-plugin layer
11
+ * (`packages/core/src/plugin/promise.ts:90`) adopts any module whose default
12
+ * export matches `{ id, setup }` (`core/src/config/plugin/external.ts:15-30`)
13
+ * and calls `setup(context)` with the 1.18-era v2 host surface
14
+ * (`core/src/plugin/host.ts:30-208`): keys `[options, agent, aisdk, catalog,
15
+ * command, integration, plugin, reference, skill]`, no `session`.
16
+ * `registerContext` then throws on `context.session.hook`; that layer discards
17
+ * the failure with `Effect.ignoreCause`, so nothing surfaced while the harness
18
+ * stayed locked to "opencode2" for the rest of the v1 process.
19
+ */
20
+ export declare function isOpenCode2HostContext(context: unknown): context is V2Context;
2
21
  export declare function setup(context: V2Context): Promise<() => Promise<void>>;
3
22
  declare const _default: {
4
23
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/v2/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,wBAAsB,KAAK,CAAC,OAAO,EAAE,SAAS,gCAY7C;;;;;AAED,wBAGE"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/v2/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,SAAS,CAQ7E;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,SAAS,gCAsB7C;;;;;AAED,wBAGE"}