@cortexkit/opencode-magic-context 0.43.2 → 0.44.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 (252) hide show
  1. package/README.md +18 -2
  2. package/dist/config/index.d.ts +13 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/project-security.d.ts +6 -3
  5. package/dist/config/project-security.d.ts.map +1 -1
  6. package/dist/config/schema/magic-context.d.ts +27 -0
  7. package/dist/config/schema/magic-context.d.ts.map +1 -1
  8. package/dist/{conflict-warning-hook-hyk9y29x.js → conflict-warning-hook-48f7np9d.js} +5 -5
  9. package/dist/{derive-budgets-b8ybssh9.js → derive-budgets-8kgevxmx.js} +2 -2
  10. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  11. package/dist/features/magic-context/compartment-embedding.d.ts +3 -2
  12. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts +13 -0
  18. package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts.map +1 -0
  19. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/lease.d.ts +5 -2
  21. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/memory-claim-safety.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/module-apply.d.ts +1 -0
  25. package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
  26. package/dist/features/magic-context/dreamer/retrospective-learnings.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +1 -1
  28. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
  31. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  32. package/dist/features/magic-context/dreamer/verify.d.ts +19 -0
  33. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  34. package/dist/features/magic-context/fail-closed-block.d.ts +7 -0
  35. package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
  36. package/dist/features/magic-context/index.d.ts +1 -0
  37. package/dist/features/magic-context/index.d.ts.map +1 -1
  38. package/dist/features/magic-context/install-instance-id.d.ts +33 -0
  39. package/dist/features/magic-context/install-instance-id.d.ts.map +1 -0
  40. package/dist/features/magic-context/memory/constants.d.ts.map +1 -1
  41. package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
  42. package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts +35 -0
  43. package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts.map +1 -0
  44. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  45. package/dist/features/magic-context/message-index.d.ts +23 -0
  46. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  47. package/dist/features/magic-context/migrations.d.ts +7 -0
  48. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  49. package/dist/features/magic-context/overflow-detection.d.ts +31 -8
  50. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  51. package/dist/features/magic-context/project-embedding-registry.d.ts +40 -1
  52. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  53. package/dist/features/magic-context/search.d.ts.map +1 -1
  54. package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
  55. package/dist/features/magic-context/storage-db.d.ts +1 -1
  56. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  57. package/dist/features/magic-context/storage-meta-persisted.d.ts +20 -5
  58. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  59. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  60. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  61. package/dist/features/magic-context/storage-notes.d.ts +1 -0
  62. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  63. package/dist/features/magic-context/storage-primers.d.ts.map +1 -1
  64. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  65. package/dist/features/magic-context/storage-unavailable-reason.d.ts +17 -0
  66. package/dist/features/magic-context/storage-unavailable-reason.d.ts.map +1 -0
  67. package/dist/features/magic-context/storage.d.ts +1 -1
  68. package/dist/features/magic-context/storage.d.ts.map +1 -1
  69. package/dist/features/magic-context/store-generation-rebase.d.ts +33 -1
  70. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  71. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  72. package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
  73. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  74. package/dist/features/magic-context/types.d.ts +8 -3
  75. package/dist/features/magic-context/types.d.ts.map +1 -1
  76. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/apply-operations.d.ts +105 -9
  78. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/compartment-parser.d.ts +2 -0
  81. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
  83. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -0
  88. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  89. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/context-limit-resolution.d.ts +31 -0
  91. package/dist/hooks/magic-context/context-limit-resolution.d.ts.map +1 -0
  92. package/dist/hooks/magic-context/embed-history-runner.d.ts +0 -1
  93. package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -1
  94. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/historian-host-runner.d.ts +233 -0
  99. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -0
  100. package/dist/hooks/magic-context/hook.d.ts +1 -3
  101. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/image-token-estimate.d.ts +9 -0
  103. package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -1
  104. package/dist/hooks/magic-context/inject-compartments.d.ts +60 -1
  105. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  106. package/dist/hooks/magic-context/lkg-slot.d.ts +6 -0
  107. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/module-client.d.ts +21 -0
  109. package/dist/hooks/magic-context/module-client.d.ts.map +1 -0
  110. package/dist/hooks/magic-context/module-state-sync.d.ts +6 -2
  111. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/module-tool-backends.d.ts +47 -0
  113. package/dist/hooks/magic-context/module-tool-backends.d.ts.map +1 -0
  114. package/dist/hooks/magic-context/module-transport.d.ts +1 -1
  115. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -1
  117. package/dist/hooks/magic-context/read-session-chunk.d.ts +12 -0
  118. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  119. package/dist/hooks/magic-context/rust-mode-transform.d.ts +35 -0
  120. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  121. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +18 -0
  122. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/rust-served-m0.d.ts +20 -0
  124. package/dist/hooks/magic-context/rust-served-m0.d.ts.map +1 -0
  125. package/dist/hooks/magic-context/store-ahead-refusal.d.ts +40 -0
  126. package/dist/hooks/magic-context/store-ahead-refusal.d.ts.map +1 -0
  127. package/dist/hooks/magic-context/strip-content.d.ts +5 -5
  128. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  129. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  130. package/dist/hooks/magic-context/tag-messages.d.ts +19 -0
  131. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  132. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/tool-drop-target.d.ts +14 -0
  134. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/tool-input-size.d.ts +21 -0
  136. package/dist/hooks/magic-context/tool-input-size.d.ts.map +1 -0
  137. package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -1
  138. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +124 -11
  139. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  140. package/dist/hooks/magic-context/transform.d.ts +13 -0
  141. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  142. package/dist/{index-0ccmyzbj.js → index-01ft0h3p.js} +1 -1
  143. package/dist/{index-tdrv6nd0.js → index-2zf5fv89.js} +254 -61
  144. package/dist/{index-6j8th2hd.js → index-5f4qsnaq.js} +2 -2
  145. package/dist/{index-jgnag7sa.js → index-c906f3ff.js} +4 -4
  146. package/dist/{index-pa67brzn.js → index-cj5qe2nw.js} +3 -3
  147. package/dist/{index-febg06dy.js → index-dx0xnd4q.js} +1 -1
  148. package/dist/{index-bmzt6xgy.js → index-pye48m79.js} +1 -1
  149. package/dist/{index-g6hpfkqa.js → index-rdey8znw.js} +932 -261
  150. package/dist/{index-wgzyeyf5.js → index-tjq5jztd.js} +22 -6
  151. package/dist/{index-9r1cbh9e.js → index-v6wsttqt.js} +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3323 -1629
  154. package/dist/{message-time-backfill-0ccvyk9n.js → message-time-backfill-rm9wmcem.js} +3 -3
  155. package/dist/plugin/dream-timer.d.ts +2 -0
  156. package/dist/plugin/dream-timer.d.ts.map +1 -1
  157. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  158. package/dist/plugin/messages-transform.d.ts.map +1 -1
  159. package/dist/plugin/native-compaction-guard.d.ts +22 -0
  160. package/dist/plugin/native-compaction-guard.d.ts.map +1 -0
  161. package/dist/plugin/rpc-handlers.d.ts +11 -0
  162. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  163. package/dist/{read-session-chunk-53a7qbrh.js → read-session-chunk-ktz5zt70.js} +5 -3
  164. package/dist/{recomp-orchestrator-adsgqgse.js → recomp-orchestrator-ahekzt0s.js} +8 -8
  165. package/dist/{safe-notification-target-vrkjrbgb.js → safe-notification-target-6w0esgd6.js} +2 -2
  166. package/dist/{send-session-notification-e28r4xx2.js → send-session-notification-w7xbnrsm.js} +4 -4
  167. package/dist/shared/index.d.ts +1 -0
  168. package/dist/shared/index.d.ts.map +1 -1
  169. package/dist/shared/logger.d.ts.map +1 -1
  170. package/dist/shared/model-suggestion-retry.d.ts +13 -1
  171. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  172. package/dist/shared/prompt-async-transport.d.ts +25 -0
  173. package/dist/shared/prompt-async-transport.d.ts.map +1 -0
  174. package/dist/shared/rpc-server.d.ts +1 -0
  175. package/dist/shared/rpc-server.d.ts.map +1 -1
  176. package/dist/shared/rpc-types.d.ts +16 -0
  177. package/dist/shared/rpc-types.d.ts.map +1 -1
  178. package/dist/shared/rpc-utils.d.ts +3 -0
  179. package/dist/shared/rpc-utils.d.ts.map +1 -1
  180. package/dist/shared/sqlite-write-locker-test-support.d.ts +7 -0
  181. package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -0
  182. package/dist/shared/status-summary.d.ts +9 -1
  183. package/dist/shared/status-summary.d.ts.map +1 -1
  184. package/dist/shared/tag-transcript.d.ts.map +1 -1
  185. package/dist/shared/user-facing-codes.d.ts +10 -5
  186. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  187. package/dist/shared/window-geometry.d.ts +6 -3
  188. package/dist/shared/window-geometry.d.ts.map +1 -1
  189. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  190. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  191. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  192. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  193. package/dist/v2/fold/boundary.d.ts +61 -0
  194. package/dist/v2/fold/boundary.d.ts.map +1 -0
  195. package/dist/v2/fold/restore.d.ts.map +1 -1
  196. package/dist/v2/hidden-completion.d.ts +16 -3
  197. package/dist/v2/hidden-completion.d.ts.map +1 -1
  198. package/dist/v2/hooks/context.d.ts +45 -14
  199. package/dist/v2/hooks/context.d.ts.map +1 -1
  200. package/dist/v2/hooks/hidden-child.d.ts +6 -0
  201. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  202. package/dist/v2/hooks/payload.d.ts.map +1 -1
  203. package/dist/v2/hooks/rpc-live-state.d.ts +1 -1
  204. package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -1
  205. package/dist/v2/hooks/rust-mode.d.ts +47 -0
  206. package/dist/v2/hooks/rust-mode.d.ts.map +1 -0
  207. package/dist/v2/hooks/session-project-backfill.d.ts +15 -0
  208. package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -0
  209. package/dist/v2/hooks/storage-gate.d.ts +42 -0
  210. package/dist/v2/hooks/storage-gate.d.ts.map +1 -0
  211. package/dist/v2/hooks/storage-notice.d.ts +29 -0
  212. package/dist/v2/hooks/storage-notice.d.ts.map +1 -0
  213. package/dist/v2/hooks/store.d.ts +16 -0
  214. package/dist/v2/hooks/store.d.ts.map +1 -1
  215. package/dist/v2/hooks/tools.d.ts +11 -2
  216. package/dist/v2/hooks/tools.d.ts.map +1 -1
  217. package/dist/v2/hooks/types.d.ts +4 -0
  218. package/dist/v2/hooks/types.d.ts.map +1 -1
  219. package/dist/v2/hooks/usage-persist.d.ts +31 -0
  220. package/dist/v2/hooks/usage-persist.d.ts.map +1 -0
  221. package/dist/v2/server.js +12216 -7963
  222. package/dist/v2/store-reader.d.ts +9 -0
  223. package/dist/v2/store-reader.d.ts.map +1 -1
  224. package/dist/wrapup-orchestrator-9srk0kjf.js +18 -0
  225. package/package.json +1 -1
  226. package/src/agents/magic-context-prompt.ts +3 -3
  227. package/src/config/index.ts +40 -0
  228. package/src/config/misplaced-agent-model.test.ts +61 -0
  229. package/src/config/project-security.test.ts +17 -0
  230. package/src/config/project-security.ts +28 -4
  231. package/src/config/schema/magic-context.ts +29 -2
  232. package/src/shared/index.ts +1 -0
  233. package/src/shared/logger.test.ts +63 -2
  234. package/src/shared/logger.ts +23 -5
  235. package/src/shared/model-suggestion-retry.test.ts +115 -4
  236. package/src/shared/model-suggestion-retry.ts +57 -12
  237. package/src/shared/prompt-async-transport.test.ts +217 -0
  238. package/src/shared/prompt-async-transport.ts +242 -0
  239. package/src/shared/prompt-surface-a1-golden.md +8 -8
  240. package/src/shared/rpc-server.ts +13 -1
  241. package/src/shared/rpc-types.ts +17 -0
  242. package/src/shared/rpc-utils.ts +28 -0
  243. package/src/shared/sqlite-transaction-mode-guard.test.ts +198 -0
  244. package/src/shared/sqlite-write-locker-test-support.ts +62 -0
  245. package/src/shared/status-detail-text.test.ts +23 -0
  246. package/src/shared/status-summary.ts +25 -1
  247. package/src/shared/tag-transcript.ts +82 -19
  248. package/src/shared/user-facing-codes.ts +12 -5
  249. package/src/shared/window-geometry.ts +6 -3
  250. package/dist/v2/hooks/provider-admission.d.ts +0 -22
  251. package/dist/v2/hooks/provider-admission.d.ts.map +0 -1
  252. package/dist/wrapup-orchestrator-8xzbpvm8.js +0 -18
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-reduce/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAEH,KAAK,sBAAsB,EAC9B,MAAM,gDAAgD,CAAC;AAUxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,QAAQ,CAAC;IACb;;;;;OAKG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,sBAAsB,CAAC;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAiPD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-reduce/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAEH,KAAK,sBAAsB,EAC9B,MAAM,gDAAgD,CAAC;AAUxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,QAAQ,CAAC;IACb;;;;;OAKG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,sBAAsB,CAAC;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAmPD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAyBhE,OAAO,KAAK,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAwMrE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAyBhE,OAAO,KAAK,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AA0MrE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
@@ -0,0 +1,61 @@
1
+ import type { ContextDatabase } from "../../features/magic-context/storage";
2
+ import type { RawMessage } from "../../hooks/magic-context/read-session-raw";
3
+ import type { CompactionMarkerStrategy } from "../../hooks/magic-context/transform-postprocess-phase";
4
+ /**
5
+ * Resolve the boundary the served array starts at, given the module's baseline end.
6
+ *
7
+ * OpenCode 1 answers this question by writing a compaction row: it picks the
8
+ * nearest user message at or before the module's baseline end and serves the
9
+ * conversation from there. OpenCode 2 has no such row, so the same rule is
10
+ * applied here against the same raw projection. Keeping the rule identical is
11
+ * what makes the two hosts hand the module the same array for the same baseline.
12
+ *
13
+ * Returns null when the baseline end is unknown or no user message precedes it,
14
+ * which is the case a caller must treat as "do not move the boundary".
15
+ */
16
+ export declare function resolveBoundaryUserMessage(messages: readonly RawMessage[], endMessageId: string): RawMessage | null;
17
+ /**
18
+ * Marker lifecycle for Rust mode on OpenCode 2.
19
+ *
20
+ * On OpenCode 1 the module's materialized boundary becomes a real compaction row
21
+ * in the host's store. OpenCode 2 exposes no way to write such a row, so the
22
+ * boundary is recorded here instead, in the same `session_meta` columns the
23
+ * OpenCode 1 marker state already uses.
24
+ *
25
+ * Only the carrier differs. The advance-only rule and the compare-and-swap on the
26
+ * pending blob are the shared caller's, unchanged: this records a boundary that
27
+ * moved forward and declines one that did not.
28
+ */
29
+ export declare function createV2RustCompactionMarkerStrategy(
30
+ /**
31
+ * The nearest user turn at or before `endMessageId`, by the rule
32
+ * `resolveBoundaryUserMessage` states; null when there is none. The caller
33
+ * answers it from the store with a bounded backward read.
34
+ */
35
+ findBoundaryUserMessage: (sessionId: string, endMessageId: string) => RawMessage | null): CompactionMarkerStrategy;
36
+ /**
37
+ * Drop everything before the recorded boundary from the array about to be sent.
38
+ *
39
+ * This is the trim OpenCode 1 gets for free from its compaction row. OpenCode 2
40
+ * writes such a row only when it decides to compact, and a healthy Rust-mode
41
+ * session folds before the host's own trigger is ever reached — so on the normal
42
+ * path there is no host cut and this is the ONLY thing that keeps a folded
43
+ * session from handing the module its whole history again on every later turn.
44
+ * Measured with it removed: the array handed to the module grew from 15 to 53
45
+ * messages over twenty post-fold turns while the boundary stood still.
46
+ *
47
+ * It is silent when the host HAS cut, because the boundary message is then
48
+ * already gone from the array. An earlier pass mutated it under a fixture whose
49
+ * mock reported a constant usage — which kept the host compacting on every turn,
50
+ * and therefore always cutting — and concluded from the silence that it never
51
+ * fires at all.
52
+ *
53
+ * Returns the number of messages removed. A boundary that is not in the array is
54
+ * left alone: it either has not been reached yet or belongs to history the host
55
+ * has already dropped, and guessing in either direction would change what the
56
+ * model sees.
57
+ */
58
+ export declare function trimToRecordedBoundary(db: ContextDatabase, sessionId: string, messages: Array<{
59
+ id?: string;
60
+ }>): number;
61
+ //# sourceMappingURL=boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAO5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAItG;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC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CAAA;CAAE,EACzC,KAAK,CAAC,EAAE,YAAY,GACrB,SAAS,EAAE,CA+Hb"}
1
+ {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/restore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAWhD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IACzB,yEAAyE;IACzE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACxD,uDAAuD;IACvD,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAClG;AAED,2FAA2F;AAC3F,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7F;AA6ED;;;GAGG;AACH,wBAAgB,UAAU,CACtB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EACzC,KAAK,CAAC,EAAE,YAAY,GACrB,SAAS,EAAE,CAmIb"}
@@ -109,12 +109,25 @@ export interface V2HiddenCompletionOptions {
109
109
  export declare function hiddenChildrenMetaKey(projectIdentity: string): string;
110
110
  /**
111
111
  * A terminal provider or model-resolution failure persisted by the host, as opposed to an unsettled
112
- * dispatch error, timeout, or abort. Only this class keeps the now-idle child alive, so reuse does
113
- * not depend on wording that a later editor could accidentally change.
112
+ * dispatch error, timeout, or abort. The type keeps lifecycle handling independent of provider
113
+ * wording; terminal provider failures are quarantined by retiring the child before its attempt
114
+ * marker is released.
114
115
  */
115
116
  export declare class HiddenProviderError extends Error {
116
- constructor(detail: string);
117
+ readonly settled: boolean;
118
+ constructor(detail: string, options?: {
119
+ settled?: boolean;
120
+ });
117
121
  }
122
+ /** What the OpenCode 2 hidden executor can do; fixed for this host. */
123
+ export declare const V2_HIDDEN_EXECUTOR_CAPABILITIES: HiddenCompletionExecutor["capabilities"];
124
+ /**
125
+ * An executor that forwards to whichever executor `current` returns and refuses
126
+ * while there is none. Holders registered once at setup (RPC handlers and
127
+ * commands) get this after a refused storage open, so the executor wired on the
128
+ * first successful open later reaches them without a restart.
129
+ */
130
+ export declare function createLateHiddenExecutor(current: () => HiddenCompletionExecutor | undefined): HiddenCompletionExecutor;
118
131
  export declare function createV2HiddenCompletionExecutor(host: HiddenChildHost, options: V2HiddenCompletionOptions): Promise<HiddenCompletionExecutor>;
119
132
  export {};
120
133
  //# sourceMappingURL=hidden-completion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hidden-completion.d.ts","sourceRoot":"","sources":["../../src/v2/hidden-completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,wBAAwB,EAG3B,MAAM,iDAAiD,CAAC;AAQzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAKH,KAAK,eAAe,EAGvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,gBAAgB,EAA4C,MAAM,gBAAgB,CAAC;AACjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C,KAAK,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,gBAAgB,CAAC;AA0ClE,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,KAAK,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAC;YAAC,OAAO,C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ACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,MAAM,wBAAwB,GAAG,SAAS,GACpD,wBAAwB,CAiB1B;AAED,wBAAsB,gCAAgC,CAClD,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,yBAAyB,GACnC,OAAO,CAAC,wBAAwB,CAAC,CA6fnC"}
@@ -1,9 +1,30 @@
1
+ import { loadPluginConfigDetailed } from "../../config";
2
+ import { createSystemPromptHashHandler } from "../../hooks/magic-context/system-prompt-hash";
1
3
  import { type TransformDeps } from "../../hooks/magic-context/transform";
2
4
  import type { PromptSurfaceConfig } from "../../shared/prompt-surface";
3
5
  import { type PromptSurfaceRuntime } from "../../shared/prompt-surface-runtime";
4
6
  import type { SessionContext, V2Context } from "./types";
5
7
  export declare function isBlockingV2TransformError(error: unknown): boolean;
8
+ /**
9
+ * Cache the directory the host bound a session to, looked up once per session.
10
+ *
11
+ * On OpenCode 1 the shared transform asks the SDK client for this and records
12
+ * the session-to-project binding (`session_projects`) only when the host
13
+ * answered. OpenCode 2 gives plugins no SDK client, so without this lookup the
14
+ * transform always fell back to the launch directory, never recorded a binding,
15
+ * and the Dashboard found no project for any OpenCode 2 session. The session's
16
+ * directory is fixed at creation, so one successful answer is kept for the
17
+ * session's lifetime; a failed lookup is retried on the next pass.
18
+ */
19
+ export declare function cacheV2SessionDirectory(session: Pick<V2Context["session"], "get">, sessionID: string, directories: Map<string, string>): Promise<void>;
6
20
  export declare function createHostSeams(context: V2Context, readAllForConversion: TransformDeps["hostRawMessages"] & {}, reconciliationSource: NonNullable<TransformDeps["hostMessageReconciliationSource"]>, liveModels: NonNullable<TransformDeps["liveModelBySession"]>): Required<Pick<TransformDeps, "hostRawMessages" | "hostMessageReconciliationSource" | "hostProtectedTailBoundary" | "hostModelFallback" | "hostRefusalNotice" | "hostRefuse">>;
21
+ type V2ThresholdConfig = Pick<ReturnType<typeof loadPluginConfigDetailed>["config"], "execute_threshold_percentage" | "execute_threshold_tokens">;
22
+ /**
23
+ * The execute thresholds the shared transform and its scheduler read, built the way the
24
+ * OpenCode 1 hook builds them: the percentage and the absolute token threshold, which
25
+ * overrides the percentage when set. Like OpenCode 1, both are read once at startup.
26
+ */
27
+ export declare function createV2ThresholdDeps(config: V2ThresholdConfig): Pick<TransformDeps, "scheduler" | "executeThresholdPercentage" | "executeThresholdTokens">;
7
28
  /**
8
29
  * Record why a turn is about to be refused before the model is called.
9
30
  *
@@ -30,20 +51,6 @@ export declare function catalogModels(listed: unknown, draftModel?: SessionConte
30
51
  export declare function removeDreamerOnlyTools(draft: SessionContext): void;
31
52
  /** Rewrite Magic Context ctx_* tool descriptions for this draft's model. */
32
53
  export declare function applyV2PromptSurfaceTools(draft: SessionContext, runtime: PromptSurfaceRuntime, config: PromptSurfaceConfig | undefined): void;
33
- /**
34
- * Experimental Rust mode is a v1-only route: the Rust transform reaches the module over a subc
35
- * transport that only the v1 server lane constructs, and nothing on this lane builds or owns one.
36
- * Rather than accepting the setting and quietly running something else, downgrade it here, once,
37
- * where every later reader of the config sees the mode that is actually running — including the
38
- * RPC status and sidebar handlers, which otherwise ask a Rust module that does not exist for the
39
- * session state and answer every status request with an error.
40
- *
41
- * The downgrade is announced twice on purpose: once in the log for whoever is reading it, and as a
42
- * named limitation that /ctx-status and the sidebar keep showing for as long as the process runs.
43
- */
44
- export declare function resolveV2TransformMode<T extends {
45
- transform_mode?: "ts" | "rust";
46
- }>(config: T): T;
47
54
  /**
48
55
  * Measure the tool definitions this request is actually going to send.
49
56
  *
@@ -57,7 +64,31 @@ export declare function resolveV2TransformMode<T extends {
57
64
  * m[0] materialization decision records but never folds on.
58
65
  */
59
66
  export declare function recordV2ToolDefinitions(draft: SessionContext): void;
67
+ /**
68
+ * Run the system-prompt handler over one context draft and write its result back.
69
+ *
70
+ * The handler only compares and records the system-prompt hash once the session's
71
+ * ctx_reduce verdict is frozen, because that verdict chooses the guidance text.
72
+ * When nothing has frozen the verdict yet in this process, the handler falls
73
+ * back to reading the first user message from OpenCode 1's `message` table. On
74
+ * OpenCode 2 that read never succeeds (its store has a different schema), so
75
+ * without freezing the verdict here first, the first pass after every restart
76
+ * left the verdict provisional and skipped the hash comparison. A restart that changed the system
77
+ * prompt then sent the new prompt on that first pass (so the provider cache was
78
+ * lost there anyway) and only detected the change on the second pass, whose
79
+ * separate HARD fold rebuilt the cache a second time.
80
+ *
81
+ * The verdict is therefore frozen first, from this draft's messages, with the
82
+ * same resolver and the same message shape the message transform later in this
83
+ * pass freezes it from (the adapted messages carry no per-message tools map, see
84
+ * payload.ts), so it can only freeze to the value the transform would have
85
+ * frozen. A draft with no user message leaves the verdict provisional, as before.
86
+ * Any future read of OpenCode 2's ctx_reduce permissions has to run before this
87
+ * call: once frozen, the verdict never changes for the session.
88
+ */
89
+ export declare function applyV2SystemPrompt(systemPrompt: Pick<ReturnType<typeof createSystemPromptHashHandler>, "handler">, draft: Pick<SessionContext, "sessionID" | "model" | "messages" | "system">): Promise<void>;
60
90
  export declare function registerContext(context: V2Context): Promise<{
61
91
  dispose(): Promise<void>;
62
92
  } | undefined>;
93
+ export {};
63
94
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/context.ts"],"names":[],"mappings":"AAsDA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAc1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAGH,KAAK,oBAAoB,EAC5B,MAAM,qCAAqC,CAAC;AA+B7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElE;AA4BD,wBAAgB,eAAe,CAC3B,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAC3D,oBAAoB,EAAE,WAAW,C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dreamer";
7
7
  export declare function hiddenAgentFor(identity: HiddenRunIdentity): string;
8
8
  export declare function hiddenToolLoop(identity: HiddenRunIdentity): boolean;
9
9
  export declare function registerHiddenChildAgents(agent: Pick<V2AgentDomain, "transform">): Promise<void>;
10
+ export declare class HiddenAgentStepLimit extends Error {
11
+ readonly agent: string;
12
+ readonly cap: number;
13
+ constructor(agent: string, cap: number);
14
+ }
10
15
  export interface HiddenChildAttempt {
11
16
  childSessionId: string;
12
17
  identity: HiddenRunIdentity;
13
18
  request: PromptArgs;
14
19
  shaped: boolean;
15
20
  steps?: number;
21
+ stepLimit?: HiddenAgentStepLimit;
16
22
  observedMessages?: SessionContext["messages"];
17
23
  marker?: string;
18
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hidden-child.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/hidden-child.ts"],"names":[],"mappings":"AAOA,OAAO,EAEH,KAAK,iBAAiB,EACzB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAClD,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AACzD,eAAO,MAAM,mBAAmB,YAAgB,CAAC;AAmBjD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAQlE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAEnE;AAED,wBAAsB,yBAAyB,CAC3C,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,E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","sources":["../../../src/v2/hooks/payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,QAAQ,iEAAkE,CAAC;AAiGxF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,GAAE,WAAW,CAAC,MAAM,CAAa;;;EA+R/F"}
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,QAAQ,iEAAkE,CAAC;AAgKxF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,GAAE,WAAW,CAAC,MAAM,CAAa;;;EAmT/F"}
@@ -5,5 +5,5 @@ import { type LiveSessionState } from "../../hooks/magic-context/live-session-st
5
5
  * RPC signals it, and only the shared instance is the one the next
6
6
  * system-prompt transform drains.
7
7
  */
8
- export declare function createV2RpcLiveSessionState(overrides: Pick<LiveSessionState, "liveModelBySession" | "variantBySession" | "agentBySession" | "channel1StateBySession" | "historyRefreshSessions" | "pendingMaterializationSessions" | "systemPromptRefreshSessions">): LiveSessionState;
8
+ export declare function createV2RpcLiveSessionState(overrides: Pick<LiveSessionState, "liveModelBySession" | "variantBySession" | "agentBySession" | "channel1StateBySession" | "historyRefreshSessions" | "pendingMaterializationSessions" | "systemPromptRefreshSessions" | "sessionDirectoryBySession">): LiveSessionState;
9
9
  //# sourceMappingURL=rpc-live-state.d.ts.map
@@ -1 +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
+ {"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,GAC7B,2BAA2B,CAChC,GACF,gBAAgB,CAElB"}
@@ -0,0 +1,47 @@
1
+ import type { RustModeModuleClient } from "../../hooks/magic-context/rust-mode-transform";
2
+ import { type RustRefusalRecovery, type RustRefusalRecoveryOptions } from "../../hooks/magic-context/rust-refusal-recovery";
3
+ import type { StoreRow } from "../store-reader";
4
+ import type { V2Context } from "./types";
5
+ /**
6
+ * Build the module client for this lane when Rust mode is the configured mode.
7
+ *
8
+ * Returns undefined for TypeScript mode so every later reader — the transform,
9
+ * the RPC status handlers, the sidebar — sees the same "no module here" answer
10
+ * rather than each deciding for itself.
11
+ */
12
+ export declare function resolveV2RustModeModuleClient(config: {
13
+ transform_mode?: "ts" | "rust";
14
+ subc?: {
15
+ connection_file?: string;
16
+ };
17
+ }, directory: string): RustModeModuleClient | undefined;
18
+ /**
19
+ * Whether the refused turn is still the step the conversation is waiting on.
20
+ *
21
+ * The answer comes from the v2 store's own rows. A user turn recorded after the
22
+ * refused one means the user already retried or moved on, and delivering the
23
+ * synthetic continue then would inject an instruction about a turn nobody is
24
+ * waiting for any more.
25
+ */
26
+ export declare function refusedStepStillCurrent(rows: readonly StoreRow[], refusedUserMessageId: string): boolean;
27
+ /**
28
+ * Refusal recovery for Rust mode on OpenCode 2.
29
+ *
30
+ * The behavior is the OpenCode 1 behavior; only the two host-owned edges move.
31
+ * The synthetic continue goes out through this host's own synthetic carrier, the
32
+ * same one Channel 2 nudges use, so the message is admitted and recognized like
33
+ * every other Magic Context synthetic. The "has the conversation moved on?" check
34
+ * reads the v2 store rather than OpenCode 1's message table, which on this host
35
+ * holds a different session's history or no history at all.
36
+ */
37
+ export declare function createV2RustRefusalRecovery(args: {
38
+ context: Pick<V2Context, "session" | "storage">;
39
+ moduleClient: RustModeModuleClient;
40
+ /**
41
+ * The session's rows from `messageID` onward, oldest first; empty when the
42
+ * message is not in the store. Bounded to the tail so a long session is
43
+ * never read whole on a refusal poll.
44
+ */
45
+ readRowsFrom: (sessionID: string, messageID: string) => readonly StoreRow[];
46
+ } & Pick<RustRefusalRecoveryOptions, "pollIntervalMs" | "maxDurationMs" | "probeTimeoutMs">): RustRefusalRecovery;
47
+ //# sourceMappingURL=rust-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust-mode.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/rust-mode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAClC,MAAM,iDAAiD,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CACzC,MAAM,EAAE;IAAE,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC/E,SAAS,EAAE,MAAM,GAClB,oBAAoB,GAAG,SAAS,CAQlC;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,oBAAoB,EAAE,MAAM,GAC7B,OAAO,CAIT;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACvC,IAAI,EAAE;IACF,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IAChD,YAAY,EAAE,oBAAoB,CAAC;IACnC;;;;OAIG;IACH,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,QAAQ,EAAE,CAAC;CAC/E,GAAG,IAAI,CAAC,0BAA0B,EAAE,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC,GAC5F,mBAAmB,CAkBrB"}
@@ -0,0 +1,15 @@
1
+ import { type BackfillResult } from "../../features/magic-context/session-project-backfill";
2
+ import type { Database } from "../../shared/sqlite";
3
+ import type { V2StoreReader } from "../store-reader";
4
+ /**
5
+ * Bind every existing OpenCode 2 session to its project.
6
+ *
7
+ * The OpenCode 1 lane runs the same backfill at boot over the host's `session`
8
+ * table. OpenCode 2 never runs that lane, and its sessions live in
9
+ * `session_v2`, so sessions created before the plugin started recording the
10
+ * binding (or while it could not) stayed projectless: the Dashboard groups
11
+ * sessions into projects only through `session_projects`. The backfill records
12
+ * completion per harness, so this pass runs to completion once per store.
13
+ */
14
+ export declare function runV2SessionProjectBackfill(db: Database, openStoreReader: () => Pick<V2StoreReader, "sessionDirectoryPage" | "close">): Promise<BackfillResult>;
15
+ //# sourceMappingURL=session-project-backfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-project-backfill.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/session-project-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,cAAc,EAEtB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,eAAe,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAC7E,OAAO,CAAC,cAAc,CAAC,CASzB"}
@@ -0,0 +1,42 @@
1
+ import { type FailClosedReason } from "../../features/magic-context/fail-closed-block";
2
+ import { type ContextDatabase } from "../../features/magic-context/storage";
3
+ /**
4
+ * The shortest time between two storage open attempts while the context database
5
+ * is unavailable. A refused open is not free: the migration guard lists processes
6
+ * and reads every RPC discovery file, so a session that sends turns quickly must
7
+ * not repeat it on every pass. Five seconds still lets the first turn a user sends
8
+ * after stopping the blocking host go through.
9
+ */
10
+ export declare const V2_STORAGE_REOPEN_INTERVAL_MS = 5000;
11
+ export interface V2StorageGate {
12
+ /** The durable database once an open has succeeded; never attempts an open. */
13
+ current(): ContextDatabase | undefined;
14
+ /** Why the last attempt left no durable database, or null when none has failed. */
15
+ reason(): FailClosedReason | null;
16
+ /** Attempt an open now, whatever the interval, without throwing. */
17
+ probe(): ContextDatabase | undefined;
18
+ /**
19
+ * The durable database. While storage is unavailable this re-attempts the open
20
+ * at most once per interval and otherwise throws a `FailClosedBlockingError`
21
+ * whose message names the recorded reason.
22
+ */
23
+ require(): ContextDatabase;
24
+ }
25
+ export interface V2StorageGateOptions {
26
+ open?: () => ContextDatabase | null;
27
+ now?: () => number;
28
+ reopenIntervalMs?: number;
29
+ /** Called when an attempt fails for a reason different from the previous one. */
30
+ onUnavailable?: (reason: FailClosedReason) => void;
31
+ /** Called when an attempt succeeds after an earlier one failed. */
32
+ onRecovered?: (db: ContextDatabase) => void;
33
+ }
34
+ /**
35
+ * Own the OpenCode 2 lane's context database handle across the life of the host
36
+ * process. A refused open (a migration blocked by an older host, a database
37
+ * newer than this build, an open error) is remembered with its reason and
38
+ * retried on later turns, so the lane recovers without a host restart once the
39
+ * cause is gone.
40
+ */
41
+ export declare function createV2StorageGate(options?: V2StorageGateOptions): V2StorageGate;
42
+ //# sourceMappingURL=storage-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-gate.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/storage-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,gBAAgB,EACxB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACH,KAAK,eAAe,EAIvB,MAAM,sCAAsC,CAAC;AAI9C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAQ,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC1B,+EAA+E;IAC/E,OAAO,IAAI,eAAe,GAAG,SAAS,CAAC;IACvC,mFAAmF;IACnF,MAAM,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAClC,oEAAoE;IACpE,KAAK,IAAI,eAAe,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,OAAO,IAAI,eAAe,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACnD,mEAAmE;IACnE,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,eAAe,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAoDrF"}
@@ -0,0 +1,29 @@
1
+ import { type FailClosedReason } from "../../features/magic-context/fail-closed-block";
2
+ import type { V2Message } from "./types";
3
+ /**
4
+ * Every notice Magic Context stores in an OpenCode 2 conversation about its own
5
+ * storage starts with this text. The notices are for the user: none of them may
6
+ * reach the model, and the conversation keeps them across restarts, so they are
7
+ * recognized by this fixed prefix together with the host's own record that the
8
+ * message is a synthetic one Magic Context sent, never by process memory.
9
+ */
10
+ export declare const STORAGE_NOTICE_PREFIX = "[Magic Context storage notice] ";
11
+ /** The notice stored when a turn is refused because the context database is unavailable. */
12
+ export declare function formatStorageRefusalNotice(reason: FailClosedReason): string;
13
+ /** The notice stored once when the context database opens after a refused start. */
14
+ export declare function formatStorageRecoveryNotice(hiddenWorkRecovered: boolean): string;
15
+ export declare function isStorageNoticeText(text: unknown): boolean;
16
+ /**
17
+ * Whether a request message has the shape the host gives a stored notice: a user
18
+ * message whose only part is the notice text. The caller still confirms that the
19
+ * host recorded the message as a Magic Context synthetic.
20
+ */
21
+ export declare function hasStorageNoticeShape(message: V2Message): boolean;
22
+ /**
23
+ * Remove stored storage notices from a request draft in place. A message counts
24
+ * only when it has the notice shape and `isAdmittedSynthetic` confirms, from the
25
+ * host's durable plugin storage, that Magic Context sent it as a synthetic; a
26
+ * user who types the same text keeps their message. Returns how many were removed.
27
+ */
28
+ export declare function dropStorageNotices(messages: V2Message[], isAdmittedSynthetic: (id: string) => Promise<boolean>): Promise<number>;
29
+ //# sourceMappingURL=storage-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-notice.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/storage-notice.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,gBAAgB,EAExB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AAEvE,4FAA4F;AAC5F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAE3E;AAED,oFAAoF;AACpF,wBAAgB,2BAA2B,CAAC,mBAAmB,EAAE,OAAO,GAAG,MAAM,CAIhF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAKjE;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACpC,QAAQ,EAAE,SAAS,EAAE,EACrB,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GACtD,OAAO,CAAC,MAAM,CAAC,CAUjB"}
@@ -34,8 +34,24 @@ export interface V2RawMessageReader {
34
34
  * the store or no earlier served row exists; callers then keep the stored id.
35
35
  */
36
36
  export declare function servedBoundaryRow(reader: Pick<V2StoreReader, "messageById" | "rawRowsThrough">, sessionID: string, messageID: string): StoreRow | null;
37
+ /**
38
+ * The nearest user message at or before `endMessageID`, searched backward
39
+ * through the store a page at a time rather than by reading the whole session.
40
+ * Returns null when the id is absent, is not a conversational row, or has no
41
+ * user message at or before it (the rule `resolveBoundaryUserMessage` applies
42
+ * to an in-memory history).
43
+ */
44
+ export declare function resolveV2BoundaryUserMessage(reader: Pick<V2StoreReader, "messageById" | "rawRowsThrough">, sessionID: string, endMessageID: string): RawMessage | null;
37
45
  /** The only V2 full-history reader: store-generation conversion must inspect every part. */
38
46
  export declare function readAllV2RawMessagesForConversion(openReader: () => V2StoreReader, sessionID: string): RawMessage[];
47
+ /**
48
+ * `readAllV2RawMessagesForConversion`, a page at a time: the same messages with
49
+ * the same ordinals, but only one page of store rows is decoded and held at
50
+ * once. Ordinals count conversational rows across the whole session, so each
51
+ * page continues the count where the previous one stopped. The reader is
52
+ * closed when iteration ends, including when the consumer stops early.
53
+ */
54
+ export declare function readV2RawMessagePagesForConversion(openReader: () => V2StoreReader, sessionID: string, pageRows?: number): Generator<RawMessage[], void, void>;
39
55
  /** Build the SQL-bounded reader used by context, indexing, and historian passes. */
40
56
  export declare function createV2RawMessageReader(openReader: () => V2StoreReader): V2RawMessageReader;
41
57
  export declare function createV2RawMessageProvider(reader: V2RawMessageReader, sessionID: string): BoundedRawMessageProvider;
@@ -1 +1 @@
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,GAAG,EAAE,QAAQ,GAAG,OAAO,CAExD;AA4CD;gGACgG;AAChG,wBAAgB,WAAW,CACvB,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,OAAO,GAAE,SAAS,QAAQ,EAAS,GACpC,UAAU,EAAE,CAQd;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,UAAU,EAAE,CAE5F;AAED,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CACJ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACvB,UAAU,EAAE,CAAC;IAChB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAClE,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;IAC5E,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACvD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,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AAS,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,oFAAoF;IACpF,kBAAkB,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,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;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CACxC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,gBAAgB,CAAC,EAC7D,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACrB,UAAU,GAAG,IAAI,CAYnB;AAED,4FAA4F;AAC5F,wBAAgB,iCAAiC,CAC7C,UAAU,EAAE,MAAM,aAAa,EAC/B,SAAS,EAAE,MAAM,GAClB,UAAU,EAAE,CAOd;AAKD;;;;;;GAMG;AACH,wBAAiB,kCAAkC,CAC/C,UAAU,EAAE,MAAM,aAAa,EAC/B,SAAS,EAAE,MAAM,EACjB,QAAQ,SAAuB,GAChC,SAAS,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAgBrC;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"}
@@ -1,8 +1,17 @@
1
1
  import type { MagicContextPluginConfig } from "../../config";
2
+ import type { RustToolBackends } from "../../plugin/rust-tool-backends";
2
3
  import type { Database } from "../../shared/sqlite";
3
4
  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<{
5
+ /**
6
+ * OpenCode 2 requires explicit tool-editor registration; it does not load the v1
7
+ * tool map.
8
+ *
9
+ * `rustToolBackends` is what routes a tool call through the module instead of
10
+ * writing only the host read model. Registering these tools without it in Rust
11
+ * mode would let an agent's note or memory land in `context.db` alone, where the
12
+ * module — the authority for both — would never see it.
13
+ */
14
+ export declare function registerTools(context: V2Context, db: Database, config: MagicContextPluginConfig, rustToolBackends?: RustToolBackends): Promise<{
6
15
  dispose: () => void;
7
16
  }>;
8
17
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +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"}
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,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAC/B,OAAO,EAAE,SAAS,EAClB,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,wBAAwB,EAChC,gBAAgB,CAAC,EAAE,gBAAgB;;GA6EtC"}
@@ -183,6 +183,10 @@ export interface V2Context {
183
183
  id: string;
184
184
  variant?: string;
185
185
  };
186
+ /** The directory the host bound the session to when it was created. */
187
+ location?: {
188
+ directory?: string;
189
+ };
186
190
  }>;
187
191
  switchModel(input: {
188
192
  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;QACH,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAChE,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,C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AAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;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,31 @@
1
+ import { type ContextDatabase } from "../../features/magic-context/storage";
2
+ import type { TransformDeps } from "../../hooks/magic-context/transform";
3
+ import { type UsageReading } from "./usage-reading";
4
+ export interface PersistV2UsageReadingArgs {
5
+ db: ContextDatabase;
6
+ sessionID: string;
7
+ draftModel: {
8
+ providerID: string;
9
+ id: string;
10
+ };
11
+ reading: UsageReading;
12
+ contextUsageMap: TransformDeps["contextUsageMap"];
13
+ }
14
+ /**
15
+ * Record the usage OpenCode stored for the latest completed reply.
16
+ *
17
+ * The reading is the prompt size of a request the provider accepted, so it is
18
+ * real pressure at any size. It is never compared with the configured window:
19
+ * that window can be smaller than what the model actually serves, and a reading
20
+ * past it is real overflow of the user's limit for the scheduler to handle.
21
+ *
22
+ * A reading never refuses the next request by itself. However high it is, the
23
+ * next transform pass has to run, because that pass is the only thing that can
24
+ * shrink the session (the force band's queued drops and emergency reclaim, the
25
+ * historian, a fold). Refusing on the reading would leave it unchanged and
26
+ * refuse again on every later turn. The transform refuses only after its own
27
+ * pass, and only when the provider has rejected the request as too large and
28
+ * that pass folded nothing, the same rule OpenCode 1 and Pi follow.
29
+ */
30
+ export declare function persistV2UsageReading(args: PersistV2UsageReadingArgs): void;
31
+ //# sourceMappingURL=usage-persist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-persist.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/usage-persist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,KAAK,YAAY,EAA4B,MAAM,iBAAiB,CAAC;AAE9E,MAAM,WAAW,yBAAyB;IACtC,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CA6B3E"}