@coool/opencode-adaptive 1.0.0 → 1.2.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 (381) hide show
  1. package/README.md +8 -7
  2. package/dist/adapters/codex-capacity/index.d.ts +0 -1
  3. package/dist/adapters/codex-capacity/index.js.map +1 -1
  4. package/dist/adapters/codex-capacity/parse.d.ts +2 -2
  5. package/dist/adapters/codex-capacity/parse.js +19 -3
  6. package/dist/adapters/codex-capacity/parse.js.map +1 -1
  7. package/dist/adapters/codex-capacity/reading.d.ts +0 -1
  8. package/dist/adapters/codex-capacity/reading.js.map +1 -1
  9. package/dist/adapters/codex-capacity/sensor.d.ts +0 -1
  10. package/dist/adapters/codex-capacity/sensor.js.map +1 -1
  11. package/dist/adapters/codex-capacity/types.d.ts +0 -4
  12. package/dist/adapters/codex-capacity/types.js +14 -0
  13. package/dist/adapters/codex-capacity/types.js.map +1 -1
  14. package/dist/adapters/opencode/escalation-tool.d.ts +0 -1
  15. package/dist/adapters/opencode/escalation-tool.js +5 -3
  16. package/dist/adapters/opencode/escalation-tool.js.map +1 -1
  17. package/dist/adapters/opencode/events.d.ts +0 -1
  18. package/dist/adapters/opencode/events.js.map +1 -1
  19. package/dist/adapters/opencode/hooks.d.ts +0 -1
  20. package/dist/adapters/opencode/hooks.js +24 -7
  21. package/dist/adapters/opencode/hooks.js.map +1 -1
  22. package/dist/adapters/opencode/index.d.ts +0 -1
  23. package/dist/adapters/opencode/index.js.map +1 -1
  24. package/dist/adapters/opencode/inventory.d.ts +0 -1
  25. package/dist/adapters/opencode/inventory.js.map +1 -1
  26. package/dist/adapters/opencode/report.d.ts +0 -1
  27. package/dist/adapters/opencode/report.js.map +1 -1
  28. package/dist/adapters/opencode/session-ops.d.ts +0 -1
  29. package/dist/adapters/opencode/session-ops.js.map +1 -1
  30. package/dist/adapters/opencode/storage.d.ts +0 -1
  31. package/dist/adapters/opencode/storage.js.map +1 -1
  32. package/dist/adapters/opencode/tier-tool.d.ts +0 -1
  33. package/dist/adapters/opencode/tier-tool.js.map +1 -1
  34. package/dist/adapters/opencode/types.d.ts +0 -1
  35. package/dist/adapters/opencode/types.js.map +1 -1
  36. package/dist/core/compatibility/gate.d.ts +0 -3
  37. package/dist/core/compatibility/gate.js +0 -4
  38. package/dist/core/compatibility/gate.js.map +1 -1
  39. package/dist/core/compatibility/index.d.ts +0 -1
  40. package/dist/core/compatibility/index.js.map +1 -1
  41. package/dist/core/compatibility/types.d.ts +0 -1
  42. package/dist/core/compatibility/types.js.map +1 -1
  43. package/dist/core/scheduler/admit.d.ts +0 -1
  44. package/dist/core/scheduler/admit.js +22 -21
  45. package/dist/core/scheduler/admit.js.map +1 -1
  46. package/dist/core/scheduler/escalate.d.ts +0 -1
  47. package/dist/core/scheduler/escalate.js +6 -17
  48. package/dist/core/scheduler/escalate.js.map +1 -1
  49. package/dist/core/scheduler/index.d.ts +0 -1
  50. package/dist/core/scheduler/index.js.map +1 -1
  51. package/dist/core/scheduler/mode.d.ts +0 -1
  52. package/dist/core/scheduler/mode.js.map +1 -1
  53. package/dist/core/scheduler/types.d.ts +2 -9
  54. package/dist/core/scheduler/types.js +2 -1
  55. package/dist/core/scheduler/types.js.map +1 -1
  56. package/dist/core/tier-policy/index.d.ts +0 -1
  57. package/dist/core/tier-policy/index.js.map +1 -1
  58. package/dist/core/tier-policy/resolve.d.ts +0 -1
  59. package/dist/core/tier-policy/resolve.js.map +1 -1
  60. package/dist/core/tier-policy/tier-list.d.ts +0 -1
  61. package/dist/core/tier-policy/tier-list.js.map +1 -1
  62. package/dist/core/tier-policy/types.d.ts +2 -1
  63. package/dist/core/tier-policy/types.js +4 -0
  64. package/dist/core/tier-policy/types.js.map +1 -1
  65. package/dist/core/work-unit/index.d.ts +0 -1
  66. package/dist/core/work-unit/index.js.map +1 -1
  67. package/dist/core/work-unit/interruption.d.ts +0 -1
  68. package/dist/core/work-unit/interruption.js.map +1 -1
  69. package/dist/core/work-unit/tracker.d.ts +11 -4
  70. package/dist/core/work-unit/tracker.js +26 -6
  71. package/dist/core/work-unit/tracker.js.map +1 -1
  72. package/dist/core/work-unit/types.d.ts +6 -1
  73. package/dist/core/work-unit/types.js.map +1 -1
  74. package/dist/execution/continuation/execute.d.ts +0 -1
  75. package/dist/execution/continuation/execute.js.map +1 -1
  76. package/dist/execution/continuation/index.d.ts +0 -2
  77. package/dist/execution/continuation/index.js +0 -1
  78. package/dist/execution/continuation/index.js.map +1 -1
  79. package/dist/execution/continuation/plan.d.ts +0 -1
  80. package/dist/execution/continuation/plan.js +1 -3
  81. package/dist/execution/continuation/plan.js.map +1 -1
  82. package/dist/execution/continuation/prompts.d.ts +0 -1
  83. package/dist/execution/continuation/prompts.js.map +1 -1
  84. package/dist/execution/continuation/types.d.ts +0 -2
  85. package/dist/execution/continuation/types.js.map +1 -1
  86. package/dist/execution/escalation/index.d.ts +0 -1
  87. package/dist/execution/escalation/index.js.map +1 -1
  88. package/dist/execution/escalation/types.d.ts +0 -1
  89. package/dist/execution/escalation/types.js.map +1 -1
  90. package/dist/execution/index.d.ts +0 -1
  91. package/dist/execution/index.js.map +1 -1
  92. package/dist/execution/parking/index.d.ts +0 -1
  93. package/dist/execution/parking/index.js.map +1 -1
  94. package/dist/execution/parking/plan.d.ts +0 -1
  95. package/dist/execution/parking/plan.js.map +1 -1
  96. package/dist/execution/retry/decide.d.ts +0 -1
  97. package/dist/execution/retry/decide.js +1 -2
  98. package/dist/execution/retry/decide.js.map +1 -1
  99. package/dist/execution/retry/index.d.ts +0 -1
  100. package/dist/execution/retry/index.js.map +1 -1
  101. package/dist/execution/retry/types.d.ts +0 -2
  102. package/dist/execution/retry/types.js.map +1 -1
  103. package/dist/gui-experimental.cjs +1 -1
  104. package/dist/gui.d.ts +0 -1
  105. package/dist/gui.js +6 -3
  106. package/dist/gui.js.map +1 -1
  107. package/dist/health/capacity/index.d.ts +0 -1
  108. package/dist/health/capacity/index.js.map +1 -1
  109. package/dist/health/capacity/merge.d.ts +0 -1
  110. package/dist/health/capacity/merge.js.map +1 -1
  111. package/dist/health/capacity/registry.d.ts +0 -1
  112. package/dist/health/capacity/registry.js.map +1 -1
  113. package/dist/health/capacity/types.d.ts +0 -1
  114. package/dist/health/capacity/types.js.map +1 -1
  115. package/dist/health/circuit-breaker/breaker.d.ts +8 -1
  116. package/dist/health/circuit-breaker/breaker.js +18 -0
  117. package/dist/health/circuit-breaker/breaker.js.map +1 -1
  118. package/dist/health/circuit-breaker/index.d.ts +0 -1
  119. package/dist/health/circuit-breaker/index.js.map +1 -1
  120. package/dist/health/circuit-breaker/types.d.ts +0 -1
  121. package/dist/health/circuit-breaker/types.js.map +1 -1
  122. package/dist/health/classifier/classify.d.ts +0 -1
  123. package/dist/health/classifier/classify.js +13 -1
  124. package/dist/health/classifier/classify.js.map +1 -1
  125. package/dist/health/classifier/index.d.ts +0 -1
  126. package/dist/health/classifier/index.js.map +1 -1
  127. package/dist/health/classifier/types.d.ts +0 -1
  128. package/dist/health/classifier/types.js.map +1 -1
  129. package/dist/health/index.d.ts +0 -1
  130. package/dist/health/index.js.map +1 -1
  131. package/dist/health/resource-health/index.d.ts +0 -1
  132. package/dist/health/resource-health/index.js.map +1 -1
  133. package/dist/health/resource-health/key.d.ts +0 -1
  134. package/dist/health/resource-health/key.js.map +1 -1
  135. package/dist/health/resource-health/registry.d.ts +6 -1
  136. package/dist/health/resource-health/registry.js +19 -1
  137. package/dist/health/resource-health/registry.js.map +1 -1
  138. package/dist/health/resource-health/transitions.d.ts +2 -4
  139. package/dist/health/resource-health/transitions.js +10 -18
  140. package/dist/health/resource-health/transitions.js.map +1 -1
  141. package/dist/health/resource-health/types.d.ts +7 -1
  142. package/dist/health/resource-health/types.js +1 -0
  143. package/dist/health/resource-health/types.js.map +1 -1
  144. package/dist/index.d.ts +0 -6
  145. package/dist/index.js +44 -19
  146. package/dist/index.js.map +1 -1
  147. package/dist/plugin-id.d.ts +0 -1
  148. package/dist/plugin-id.js.map +1 -1
  149. package/dist/rpc/definition.d.ts +24 -1
  150. package/dist/rpc/definition.js +28 -2
  151. package/dist/rpc/definition.js.map +1 -1
  152. package/dist/rpc/handlers.d.ts +12 -24
  153. package/dist/rpc/handlers.js +22 -8
  154. package/dist/rpc/handlers.js.map +1 -1
  155. package/dist/rpc/status.d.ts +0 -1
  156. package/dist/rpc/status.js.map +1 -1
  157. package/dist/rpc.d.ts +0 -1
  158. package/dist/rpc.js.map +1 -1
  159. package/dist/state/capacity/index.d.ts +0 -1
  160. package/dist/state/capacity/index.js.map +1 -1
  161. package/dist/state/capacity/parse.d.ts +0 -1
  162. package/dist/state/capacity/parse.js +14 -2
  163. package/dist/state/capacity/parse.js.map +1 -1
  164. package/dist/state/capacity/store.d.ts +0 -1
  165. package/dist/state/capacity/store.js +16 -2
  166. package/dist/state/capacity/store.js.map +1 -1
  167. package/dist/state/capacity/types.d.ts +0 -1
  168. package/dist/state/capacity/types.js.map +1 -1
  169. package/dist/state/health/index.d.ts +0 -1
  170. package/dist/state/health/index.js.map +1 -1
  171. package/dist/state/health/parse.d.ts +0 -1
  172. package/dist/state/health/parse.js +20 -4
  173. package/dist/state/health/parse.js.map +1 -1
  174. package/dist/state/health/store.d.ts +0 -1
  175. package/dist/state/health/store.js +16 -2
  176. package/dist/state/health/store.js.map +1 -1
  177. package/dist/state/health/types.d.ts +0 -1
  178. package/dist/state/health/types.js.map +1 -1
  179. package/dist/state/parked-work/index.d.ts +0 -1
  180. package/dist/state/parked-work/index.js.map +1 -1
  181. package/dist/state/parked-work/parse.d.ts +0 -1
  182. package/dist/state/parked-work/parse.js.map +1 -1
  183. package/dist/state/parked-work/store.d.ts +0 -1
  184. package/dist/state/parked-work/store.js +20 -3
  185. package/dist/state/parked-work/store.js.map +1 -1
  186. package/dist/state/parked-work/types.d.ts +0 -1
  187. package/dist/state/parked-work/types.js.map +1 -1
  188. package/dist/state/receipts/bound.d.ts +0 -1
  189. package/dist/state/receipts/bound.js.map +1 -1
  190. package/dist/state/receipts/index.d.ts +0 -1
  191. package/dist/state/receipts/index.js.map +1 -1
  192. package/dist/state/receipts/parse.d.ts +0 -1
  193. package/dist/state/receipts/parse.js.map +1 -1
  194. package/dist/state/receipts/store.d.ts +0 -1
  195. package/dist/state/receipts/store.js +24 -4
  196. package/dist/state/receipts/store.js.map +1 -1
  197. package/dist/state/receipts/types.d.ts +0 -1
  198. package/dist/state/receipts/types.js.map +1 -1
  199. package/dist/state/session-modes/index.d.ts +0 -1
  200. package/dist/state/session-modes/index.js.map +1 -1
  201. package/dist/state/session-modes/parse.d.ts +0 -1
  202. package/dist/state/session-modes/parse.js.map +1 -1
  203. package/dist/state/session-modes/store.d.ts +0 -1
  204. package/dist/state/session-modes/store.js +15 -1
  205. package/dist/state/session-modes/store.js.map +1 -1
  206. package/dist/state/session-modes/types.d.ts +0 -1
  207. package/dist/state/session-modes/types.js.map +1 -1
  208. package/dist/state/settings/index.d.ts +0 -1
  209. package/dist/state/settings/index.js.map +1 -1
  210. package/dist/state/settings/parse.d.ts +0 -1
  211. package/dist/state/settings/parse.js.map +1 -1
  212. package/dist/state/settings/store.d.ts +0 -1
  213. package/dist/state/settings/store.js +9 -1
  214. package/dist/state/settings/store.js.map +1 -1
  215. package/dist/state/settings/types.d.ts +0 -1
  216. package/dist/state/settings/types.js.map +1 -1
  217. package/dist/state/tier-requests/index.d.ts +4 -0
  218. package/dist/state/tier-requests/index.js +4 -0
  219. package/dist/state/tier-requests/index.js.map +1 -0
  220. package/dist/state/tier-requests/parse.d.ts +3 -0
  221. package/dist/state/tier-requests/parse.js +53 -0
  222. package/dist/state/tier-requests/parse.js.map +1 -0
  223. package/dist/state/tier-requests/store.d.ts +27 -0
  224. package/dist/state/tier-requests/store.js +96 -0
  225. package/dist/state/tier-requests/store.js.map +1 -0
  226. package/dist/state/tier-requests/types.d.ts +30 -0
  227. package/dist/state/tier-requests/types.js +7 -0
  228. package/dist/state/tier-requests/types.js.map +1 -0
  229. package/dist/supervisor/index.d.ts +0 -1
  230. package/dist/supervisor/index.js.map +1 -1
  231. package/dist/supervisor/log.d.ts +0 -1
  232. package/dist/supervisor/log.js.map +1 -1
  233. package/dist/supervisor/supervisor.d.ts +23 -6
  234. package/dist/supervisor/supervisor.js +414 -111
  235. package/dist/supervisor/supervisor.js.map +1 -1
  236. package/dist/supervisor/types.d.ts +0 -1
  237. package/dist/supervisor/types.js.map +1 -1
  238. package/dist/supervisor/view.d.ts +0 -1
  239. package/dist/supervisor/view.js.map +1 -1
  240. package/dist/tui.d.ts +0 -1
  241. package/dist/tui.js +14 -10
  242. package/dist/tui.js.map +1 -1
  243. package/dist/ui/gui/api.d.ts +0 -1
  244. package/dist/ui/gui/api.js.map +1 -1
  245. package/dist/ui/gui/view.d.ts +0 -1
  246. package/dist/ui/gui/view.js.map +1 -1
  247. package/dist/ui/tui/controller.d.ts +0 -1
  248. package/dist/ui/tui/controller.js +70 -24
  249. package/dist/ui/tui/controller.js.map +1 -1
  250. package/dist/ui/tui/menu.d.ts +1 -2
  251. package/dist/ui/tui/menu.js +2 -2
  252. package/dist/ui/tui/menu.js.map +1 -1
  253. package/dist/ui/tui/options.d.ts +0 -1
  254. package/dist/ui/tui/options.js.map +1 -1
  255. package/dist/ui/tui/receipts.d.ts +0 -1
  256. package/dist/ui/tui/receipts.js +4 -1
  257. package/dist/ui/tui/receipts.js.map +1 -1
  258. package/dist/ui/tui/status.d.ts +1 -2
  259. package/dist/ui/tui/status.js +4 -2
  260. package/dist/ui/tui/status.js.map +1 -1
  261. package/dist/ui/tui/tiers.d.ts +0 -1
  262. package/dist/ui/tui/tiers.js.map +1 -1
  263. package/package.json +2 -2
  264. package/dist/adapters/codex-capacity/index.d.ts.map +0 -1
  265. package/dist/adapters/codex-capacity/parse.d.ts.map +0 -1
  266. package/dist/adapters/codex-capacity/reading.d.ts.map +0 -1
  267. package/dist/adapters/codex-capacity/sensor.d.ts.map +0 -1
  268. package/dist/adapters/codex-capacity/types.d.ts.map +0 -1
  269. package/dist/adapters/opencode/escalation-tool.d.ts.map +0 -1
  270. package/dist/adapters/opencode/events.d.ts.map +0 -1
  271. package/dist/adapters/opencode/hooks.d.ts.map +0 -1
  272. package/dist/adapters/opencode/index.d.ts.map +0 -1
  273. package/dist/adapters/opencode/inventory.d.ts.map +0 -1
  274. package/dist/adapters/opencode/report.d.ts.map +0 -1
  275. package/dist/adapters/opencode/session-ops.d.ts.map +0 -1
  276. package/dist/adapters/opencode/storage.d.ts.map +0 -1
  277. package/dist/adapters/opencode/tier-tool.d.ts.map +0 -1
  278. package/dist/adapters/opencode/types.d.ts.map +0 -1
  279. package/dist/core/compatibility/gate.d.ts.map +0 -1
  280. package/dist/core/compatibility/index.d.ts.map +0 -1
  281. package/dist/core/compatibility/types.d.ts.map +0 -1
  282. package/dist/core/scheduler/admit.d.ts.map +0 -1
  283. package/dist/core/scheduler/escalate.d.ts.map +0 -1
  284. package/dist/core/scheduler/index.d.ts.map +0 -1
  285. package/dist/core/scheduler/mode.d.ts.map +0 -1
  286. package/dist/core/scheduler/types.d.ts.map +0 -1
  287. package/dist/core/tier-policy/index.d.ts.map +0 -1
  288. package/dist/core/tier-policy/resolve.d.ts.map +0 -1
  289. package/dist/core/tier-policy/tier-list.d.ts.map +0 -1
  290. package/dist/core/tier-policy/types.d.ts.map +0 -1
  291. package/dist/core/work-unit/index.d.ts.map +0 -1
  292. package/dist/core/work-unit/interruption.d.ts.map +0 -1
  293. package/dist/core/work-unit/tracker.d.ts.map +0 -1
  294. package/dist/core/work-unit/types.d.ts.map +0 -1
  295. package/dist/execution/continuation/execute.d.ts.map +0 -1
  296. package/dist/execution/continuation/index.d.ts.map +0 -1
  297. package/dist/execution/continuation/ledger.d.ts +0 -20
  298. package/dist/execution/continuation/ledger.d.ts.map +0 -1
  299. package/dist/execution/continuation/ledger.js +0 -31
  300. package/dist/execution/continuation/ledger.js.map +0 -1
  301. package/dist/execution/continuation/plan.d.ts.map +0 -1
  302. package/dist/execution/continuation/prompts.d.ts.map +0 -1
  303. package/dist/execution/continuation/types.d.ts.map +0 -1
  304. package/dist/execution/escalation/index.d.ts.map +0 -1
  305. package/dist/execution/escalation/types.d.ts.map +0 -1
  306. package/dist/execution/index.d.ts.map +0 -1
  307. package/dist/execution/parking/index.d.ts.map +0 -1
  308. package/dist/execution/parking/plan.d.ts.map +0 -1
  309. package/dist/execution/recovery/gate.d.ts +0 -20
  310. package/dist/execution/recovery/gate.d.ts.map +0 -1
  311. package/dist/execution/recovery/gate.js +0 -23
  312. package/dist/execution/recovery/gate.js.map +0 -1
  313. package/dist/execution/recovery/index.d.ts +0 -3
  314. package/dist/execution/recovery/index.d.ts.map +0 -1
  315. package/dist/execution/recovery/index.js +0 -2
  316. package/dist/execution/recovery/index.js.map +0 -1
  317. package/dist/execution/retry/decide.d.ts.map +0 -1
  318. package/dist/execution/retry/index.d.ts.map +0 -1
  319. package/dist/execution/retry/types.d.ts.map +0 -1
  320. package/dist/gui.d.ts.map +0 -1
  321. package/dist/health/capacity/index.d.ts.map +0 -1
  322. package/dist/health/capacity/merge.d.ts.map +0 -1
  323. package/dist/health/capacity/registry.d.ts.map +0 -1
  324. package/dist/health/capacity/types.d.ts.map +0 -1
  325. package/dist/health/circuit-breaker/breaker.d.ts.map +0 -1
  326. package/dist/health/circuit-breaker/index.d.ts.map +0 -1
  327. package/dist/health/circuit-breaker/types.d.ts.map +0 -1
  328. package/dist/health/classifier/classify.d.ts.map +0 -1
  329. package/dist/health/classifier/index.d.ts.map +0 -1
  330. package/dist/health/classifier/types.d.ts.map +0 -1
  331. package/dist/health/index.d.ts.map +0 -1
  332. package/dist/health/resource-health/index.d.ts.map +0 -1
  333. package/dist/health/resource-health/key.d.ts.map +0 -1
  334. package/dist/health/resource-health/registry.d.ts.map +0 -1
  335. package/dist/health/resource-health/transitions.d.ts.map +0 -1
  336. package/dist/health/resource-health/types.d.ts.map +0 -1
  337. package/dist/index.d.ts.map +0 -1
  338. package/dist/plugin-id.d.ts.map +0 -1
  339. package/dist/rpc/definition.d.ts.map +0 -1
  340. package/dist/rpc/handlers.d.ts.map +0 -1
  341. package/dist/rpc/status.d.ts.map +0 -1
  342. package/dist/rpc.d.ts.map +0 -1
  343. package/dist/state/capacity/index.d.ts.map +0 -1
  344. package/dist/state/capacity/parse.d.ts.map +0 -1
  345. package/dist/state/capacity/store.d.ts.map +0 -1
  346. package/dist/state/capacity/types.d.ts.map +0 -1
  347. package/dist/state/health/index.d.ts.map +0 -1
  348. package/dist/state/health/parse.d.ts.map +0 -1
  349. package/dist/state/health/store.d.ts.map +0 -1
  350. package/dist/state/health/types.d.ts.map +0 -1
  351. package/dist/state/parked-work/index.d.ts.map +0 -1
  352. package/dist/state/parked-work/parse.d.ts.map +0 -1
  353. package/dist/state/parked-work/store.d.ts.map +0 -1
  354. package/dist/state/parked-work/types.d.ts.map +0 -1
  355. package/dist/state/receipts/bound.d.ts.map +0 -1
  356. package/dist/state/receipts/index.d.ts.map +0 -1
  357. package/dist/state/receipts/parse.d.ts.map +0 -1
  358. package/dist/state/receipts/store.d.ts.map +0 -1
  359. package/dist/state/receipts/types.d.ts.map +0 -1
  360. package/dist/state/session-modes/index.d.ts.map +0 -1
  361. package/dist/state/session-modes/parse.d.ts.map +0 -1
  362. package/dist/state/session-modes/store.d.ts.map +0 -1
  363. package/dist/state/session-modes/types.d.ts.map +0 -1
  364. package/dist/state/settings/index.d.ts.map +0 -1
  365. package/dist/state/settings/parse.d.ts.map +0 -1
  366. package/dist/state/settings/store.d.ts.map +0 -1
  367. package/dist/state/settings/types.d.ts.map +0 -1
  368. package/dist/supervisor/index.d.ts.map +0 -1
  369. package/dist/supervisor/log.d.ts.map +0 -1
  370. package/dist/supervisor/supervisor.d.ts.map +0 -1
  371. package/dist/supervisor/types.d.ts.map +0 -1
  372. package/dist/supervisor/view.d.ts.map +0 -1
  373. package/dist/tui.d.ts.map +0 -1
  374. package/dist/ui/gui/api.d.ts.map +0 -1
  375. package/dist/ui/gui/view.d.ts.map +0 -1
  376. package/dist/ui/tui/controller.d.ts.map +0 -1
  377. package/dist/ui/tui/menu.d.ts.map +0 -1
  378. package/dist/ui/tui/options.d.ts.map +0 -1
  379. package/dist/ui/tui/receipts.d.ts.map +0 -1
  380. package/dist/ui/tui/status.d.ts.map +0 -1
  381. package/dist/ui/tui/tiers.d.ts.map +0 -1
package/README.md CHANGED
@@ -12,14 +12,14 @@ It is set up entirely from the `/adaptive` menu in OpenCode. There are no config
12
12
 
13
13
  **Use cheap models for small work.** Keep separate lists for quick, standard and advanced work. Typo fixes don't need your strongest model.
14
14
 
15
- **Leave long runs unattended.** If every model in a list is blocked when a task is about to start, the task waits and starts when one comes back, even after an OpenCode restart. A `/goal` run is a series of tasks, so it pauses and carries on by itself.
15
+ **Leave long runs unattended.** If a model fails mid-task, work continues on the next ready model in the tier, and the preferred model is used again at the next task — finished tool calls are not repeated, even across an OpenCode restart. A `/goal` run is a series of tasks, so it carries on by itself.
16
16
 
17
17
  ## Features
18
18
 
19
19
  - **Menu setup.** Models, order and mode are set in `/adaptive` with model search. No config files.
20
20
  - **Tiers.** Quick, standard and advanced work each get their own list, and a failure stays inside the tier the work needs. The agent can ask for a tier with the `adaptive_tier` tool. Routing follows fixed rules, not a prompt the model may or may not obey.
21
21
  - **Quota awareness.** It reads usage from provider response headers. When a subscription is nearly used up (about 10% left), new tasks go to the next ready model in the tier, and it is used again after the reset time when the provider reports one.
22
- - **Waiting that survives a restart.** When every model is blocked as a task is about to start, the task is saved and starts when one returns, instead of failing.
22
+ - **Recovery that survives a restart.** If work is interrupted and cannot continue right away because no model in its tier is ready, it is saved and resumes when one returns — even after an OpenCode restart, without repeating finished tool calls.
23
23
  - **Dry run.** In `observe` mode it records what it would have done, with the reason, before it changes anything. A session can have its own mode.
24
24
  - **Escalation on evidence only.** An outage never sends work to a more expensive tier. Moving up needs a context overflow, a policy rejection, or an explicit request from the agent.
25
25
 
@@ -64,8 +64,9 @@ The tier for a task is the first of these that applies:
64
64
  1. A pinned model (`/adaptive` → **Pin**).
65
65
  2. A tier request for the session: the agent can declare one with the `adaptive_tier` tool, or you set it inside a session with `/adaptive` → **Tier**.
66
66
  3. A per-agent tier from the `agentTiers` setting (RPC only).
67
- 4. Background requests such as titles and summaries use `quick`.
68
- 5. `standard`.
67
+ 4. `standard`.
68
+
69
+ Background requests such as titles and summaries are observed but not routed separately in v1 — they keep OpenCode's own model.
69
70
 
70
71
  No language model or keyword matching is involved. A model is skipped if it is unknown or can't fit the context, and the receipt says why. Adaptive only uses models you added.
71
72
 
@@ -73,7 +74,7 @@ No language model or keyword matching is involved. A model is skipped if it is u
73
74
 
74
75
  - **Rate limit, quota, timeout, outage:** if the error is clear-cut and another model in the same tier is ready, the task switches to it and carries on from the current session. Your prompt is not resent and finished tool calls are not repeated. If the error is unclear or no other model is ready, OpenCode's normal retry continues.
75
76
  - **A model fails repeatedly:** it is paused for a cooldown, then tried once. If that works, it is back.
76
- - **Every model in the tier is blocked as a task starts:** the task waits and starts when one returns.
77
+ - **Every model in the tier is blocked as a task starts:** OpenCode's own model runs it, and the decision is recorded as a receipt with the reason. A task that fails to recover is saved and resumes when a model returns.
77
78
  - **You cancel:** nothing is retried or switched.
78
79
  - **Auth error or unknown model:** the model is marked unavailable and skipped.
79
80
 
@@ -81,7 +82,7 @@ An outage never moves work to a stronger tier. Work only moves up on real eviden
81
82
 
82
83
  ## Limits
83
84
 
84
- - No borrowing between tiers. If a tier is exhausted, work waits. To let a model serve two tiers, add it to both.
85
+ - No borrowing between tiers. If a tier is exhausted, the task runs on OpenCode's own model rather than another tier's models. To let a model serve two tiers, add it to both.
85
86
  - A task that moved up a tier stays there. The next task is routed again from scratch.
86
87
  - Usage figures come from response headers and are best effort. Providers that use WebSockets don't expose them.
87
88
  - The browser/desktop settings page is experimental. No released OpenCode loads it yet, so use `/adaptive`.
@@ -90,7 +91,7 @@ An outage never moves work to a stronger tier. Work only moves up on real eviden
90
91
 
91
92
  - **Nothing changes.** You are in `observe` mode. Switch to `active` in `/adaptive` → **Mode**.
92
93
  - **A model is never picked.** Its provider must be connected in OpenCode.
93
- - **A task is waiting to start.** Every model in its tier is blocked. Wait for the cooldown or add another model.
94
+ - **Receipts show `park` on a new task.** Every model in its tier was blocked when the task started, so it ran on OpenCode's own model. The receipt says why; check `/adaptive` → **Status** for cooldowns.
94
95
  - **Why did it pick that model?** `/adaptive` → **Receipts**.
95
96
  - **"Plugin failed" toast.** The plugin didn't load. Update it with `opencode plugin update`, or remove and add it again.
96
97
 
@@ -2,4 +2,3 @@ export * from "./types.js";
2
2
  export * from "./parse.js";
3
3
  export * from "./reading.js";
4
4
  export * from "./sensor.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA","sourcesContent":["export * from \"./types.js\"\nexport * from \"./parse.js\"\nexport * from \"./reading.js\"\nexport * from \"./sensor.js\"\n"]}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Untrusted-header validation. Header values arrive from provider responses
3
3
  * (or relays); every field is parsed defensively and a window is admitted only
4
- * when its usage percentage is trustworthy. Reset fields that fail validation
4
+ * when its usage percentage is trustworthy. A usage above 100% voids the
5
+ * snapshot rather than leaving the other window to speak for it. Reset fields that fail validation
5
6
  * are dropped field-wise — they cannot invalidate a valid percentage.
6
7
  */
7
8
  import type { CodexUsage } from "./types.js";
@@ -25,4 +26,3 @@ export declare function isCodexHeaderName(lowercaseName: string): boolean;
25
26
  * trustworthy usage percentage.
26
27
  */
27
28
  export declare function parseCodexUsage(captured: Readonly<Record<string, string>>): CodexUsage | null;
28
- //# sourceMappingURL=parse.d.ts.map
@@ -27,7 +27,12 @@ function finiteAtLeast(value, min) {
27
27
  return parsed;
28
28
  }
29
29
  function emptyAccumulator() {
30
- return { usedPercent: undefined, resetAfterSeconds: undefined, resetAtSeconds: undefined };
30
+ return {
31
+ usedPercent: undefined,
32
+ overshoot: undefined,
33
+ resetAfterSeconds: undefined,
34
+ resetAtSeconds: undefined,
35
+ };
31
36
  }
32
37
  function takenValue(accumulator, suffix) {
33
38
  switch (suffix) {
@@ -51,9 +56,14 @@ function applyField(accumulator, suffix, value) {
51
56
  // The percentage is the window's existence test: out of range or
52
57
  // unparseable values never admit a window.
53
58
  const usedPercent = finiteAtLeast(value, 0);
54
- if (usedPercent !== undefined && usedPercent <= 100) {
55
- accumulator.usedPercent = usedPercent;
59
+ if (usedPercent === undefined) {
60
+ return;
61
+ }
62
+ if (usedPercent > 100) {
63
+ accumulator.overshoot = true;
64
+ return;
56
65
  }
66
+ accumulator.usedPercent = usedPercent;
57
67
  return;
58
68
  }
59
69
  case "reset-after-seconds": {
@@ -117,6 +127,12 @@ export function parseCodexUsage(captured) {
117
127
  applyField(accumulator, rest.slice(separator + 1), value);
118
128
  accumulators[key] = accumulator;
119
129
  }
130
+ // An overshooting window is exhausted, yet its percentage is not
131
+ // trustworthy: dropping just that window would let the other one present
132
+ // the subscription as usable, so the whole snapshot is void.
133
+ if (accumulators.primary?.overshoot === true || accumulators.secondary?.overshoot === true) {
134
+ return null;
135
+ }
120
136
  const primary = windowOf(accumulators.primary ?? emptyAccumulator());
121
137
  const secondary = windowOf(accumulators.secondary ?? emptyAccumulator());
122
138
  if (primary === undefined && secondary === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/parse.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/C;;;;GAIG;AACH,MAAM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GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;QACrC,IAAI,CAAE,kBAAwC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9D,SAAQ;QACV,CAAC;QACD,MAAM,GAAG,GAAG,IAAuB,CAAA;QACnC,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,gBAAgB,EAAE,CAAA;QAC3D,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;QACzD,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAA;IACjC,CAAC;IACD,iEAAiE;IACjE,yEAAyE;IACzE,6DAA6D;IAC7D,IAAI,YAAY,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,IAAI,YAAY,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,EAAE,CAAC;QAC3F,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC,CAAA;IACpE,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,IAAI,gBAAgB,EAAE,CAAC,CAAA;IACxE,IAAI,OAAO,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO;QACL,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAA;AACH,CAAC","sourcesContent":["/**\n * Untrusted-header validation. Header values arrive from provider responses\n * (or relays); every field is parsed defensively and a window is admitted only\n * when its usage percentage is trustworthy. A usage above 100% voids the\n * snapshot rather than leaving the other window to speak for it. Reset fields that fail validation\n * are dropped field-wise — they cannot invalidate a valid percentage.\n */\nimport type { CodexUsage, CodexWindow, CodexWindowKind } from \"./types.js\"\nimport { CODEX_WINDOW_KINDS } from \"./types.js\"\n\n/**\n * LiteLLM relays Codex headers under a provider prefix, e.g.\n * `llm_provider-x-codex-primary-used-percent`. Matching on the substring keeps\n * the parser independent of which relay prefix is used.\n */\nexport const CODEX_HEADER_MARK = \"x-codex-\"\n\n/**\n * Allowlist predicate for the `http.response` capture option: matches plain\n * and LiteLLM-prefixed Codex telemetry header names (case already lowered by\n * the caller). Only quota telemetry passes — no other response header is ever\n * captured.\n */\nexport function isCodexHeaderName(lowercaseName: string): boolean {\n return lowercaseName.includes(CODEX_HEADER_MARK)\n}\n\ninterface WindowAccumulator {\n usedPercent?: number | undefined\n /** A usage above 100% was reported: the window is exhausted, not absent. */\n overshoot?: boolean | undefined\n resetAfterSeconds?: number | undefined\n resetAtSeconds?: number | undefined\n}\n\nfunction finiteAtLeast(value: string, min: number): number | undefined {\n // An empty (or whitespace-only) value must not fall through Number(\"\") === 0.\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return undefined\n }\n const parsed = Number(trimmed)\n if (!Number.isFinite(parsed) || parsed < min) {\n return undefined\n }\n return parsed\n}\n\nfunction emptyAccumulator(): WindowAccumulator {\n return {\n usedPercent: undefined,\n overshoot: undefined,\n resetAfterSeconds: undefined,\n resetAtSeconds: undefined,\n }\n}\n\nfunction takenValue(accumulator: WindowAccumulator, suffix: string): number | undefined {\n switch (suffix) {\n case \"used-percent\":\n return accumulator.usedPercent\n case \"reset-after-seconds\":\n return accumulator.resetAfterSeconds\n case \"reset-at\":\n return accumulator.resetAtSeconds\n default:\n return undefined\n }\n}\n\nfunction applyField(accumulator: WindowAccumulator, suffix: string, value: string): void {\n // First valid value per field wins; invalid or duplicate values are ignored.\n if (takenValue(accumulator, suffix) !== undefined) {\n return\n }\n switch (suffix) {\n case \"used-percent\": {\n // The percentage is the window's existence test: out of range or\n // unparseable values never admit a window.\n const usedPercent = finiteAtLeast(value, 0)\n if (usedPercent === undefined) {\n return\n }\n if (usedPercent > 100) {\n accumulator.overshoot = true\n return\n }\n accumulator.usedPercent = usedPercent\n return\n }\n case \"reset-after-seconds\": {\n const resetAfterSeconds = finiteAtLeast(value, 0)\n if (resetAfterSeconds !== undefined) {\n accumulator.resetAfterSeconds = resetAfterSeconds\n }\n return\n }\n case \"reset-at\": {\n // Documented wire quirk: reset-at can be an empty string while\n // reset-after-seconds carries the real value. Empty and unparseable\n // values are dropped, never guessed at.\n const resetAtSeconds = finiteAtLeast(value, 0)\n if (resetAtSeconds !== undefined) {\n accumulator.resetAtSeconds = resetAtSeconds\n }\n return\n }\n default:\n // window-minutes and unknown suffixes carry no reading information.\n return\n }\n}\n\nfunction windowOf(accumulator: WindowAccumulator): CodexWindow | undefined {\n const usedPercent = accumulator.usedPercent\n if (usedPercent === undefined) {\n return undefined\n }\n const { resetAfterSeconds, resetAtSeconds } = accumulator\n return {\n usedPercent,\n ...(resetAfterSeconds !== undefined ? { resetAfterSeconds } : {}),\n ...(resetAtSeconds !== undefined ? { resetAtSeconds } : {}),\n }\n}\n\n/**\n * Parse captured response headers into a validated usage snapshot. Header\n * lookup is case-insensitive and accepts LiteLLM-prefixed names; fields\n * accumulate per window in any order. Returns `null` when no window carries a\n * trustworthy usage percentage.\n */\nexport function parseCodexUsage(captured: Readonly<Record<string, string>>): CodexUsage | null {\n const accumulators: Record<CodexWindowKind, WindowAccumulator | undefined> = {\n primary: undefined,\n secondary: undefined,\n }\n for (const [rawName, value] of Object.entries(captured)) {\n const mark = rawName.toLowerCase().indexOf(CODEX_HEADER_MARK)\n if (mark < 0) {\n continue\n }\n const rest = rawName.slice(mark + CODEX_HEADER_MARK.length).toLowerCase()\n const separator = rest.indexOf(\"-\")\n const kind = rest.slice(0, separator)\n if (!(CODEX_WINDOW_KINDS as readonly string[]).includes(kind)) {\n continue\n }\n const key = kind as CodexWindowKind\n const accumulator = accumulators[key] ?? emptyAccumulator()\n applyField(accumulator, rest.slice(separator + 1), value)\n accumulators[key] = accumulator\n }\n // An overshooting window is exhausted, yet its percentage is not\n // trustworthy: dropping just that window would let the other one present\n // the subscription as usable, so the whole snapshot is void.\n if (accumulators.primary?.overshoot === true || accumulators.secondary?.overshoot === true) {\n return null\n }\n const primary = windowOf(accumulators.primary ?? emptyAccumulator())\n const secondary = windowOf(accumulators.secondary ?? emptyAccumulator())\n if (primary === undefined && secondary === undefined) {\n return null\n }\n return {\n ...(primary !== undefined ? { primary } : {}),\n ...(secondary !== undefined ? { secondary } : {}),\n }\n}\n"]}
@@ -7,4 +7,3 @@ export declare const CODEX_EVIDENCE = "x-codex headers";
7
7
  */
8
8
  export declare function bindingWindow(usage: CodexUsage): CodexWindow | undefined;
9
9
  export declare function readingFromUsage(usage: CodexUsage, observedAt: number): CapacityReading;
10
- //# sourceMappingURL=reading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reading.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/reading.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAE/C,SAAS,QAAQ,CAAC,MAAmB;IACnC,OAAO,MAAM,CAAC,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,CAAA;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;IAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;IACjC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,OAAO,SAAS,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,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AC,QAAQ,CAAA;IACnE,OAAO;QACL,SAAS;QACT,cAAc;QACd,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,UAAU;QACV,UAAU;QACV,QAAQ,EAAE,cAAc;KACzB,CAAA;AACH,CAAC","sourcesContent":["/**\n * Codex usage → `CapacityReading` conversion. The binding constraint is the\n * most-consumed window (ties read the primary window, deterministic). Ratios\n * are exact percent/100 fractions; the reset timestamp is anchored to when the\n * headers were observed, preferring the relative `reset-after-seconds` over\n * the absolute `reset-at` epoch-seconds field.\n *\n * Confidence grades telemetry completeness: a binding window with BOTH a\n * usage percentage and a validated reset field is `high` (self-consistent,\n * provider-generated, actionable for draining); a percentage alone is\n * `medium`. An usage snapshot with no window at all yields a no-measurement\n * reading that the capacity merge layer discards as pure noise.\n */\nimport type { Confidence } from \"../../health/capacity/types.js\"\nimport type { CapacityReading } from \"../../health/capacity/types.js\"\nimport type { CodexUsage, CodexWindow } from \"./types.js\"\n\nexport const CODEX_EVIDENCE = \"x-codex headers\"\n\nfunction hasReset(window: CodexWindow): boolean {\n return window.resetAfterSeconds !== undefined || window.resetAtSeconds !== undefined\n}\n\n/**\n * The window whose exhaustion binds first: higher usage wins, ties → primary.\n * Returns `undefined` only for a snapshot with no window at all.\n */\nexport function bindingWindow(usage: CodexUsage): CodexWindow | undefined {\n const primary = usage.primary\n const secondary = usage.secondary\n if (primary === undefined) {\n return secondary\n }\n if (secondary === undefined) {\n return primary\n }\n return secondary.usedPercent > primary.usedPercent ? secondary : primary\n}\n\nexport function readingFromUsage(usage: CodexUsage, observedAt: number): CapacityReading {\n const window = bindingWindow(usage)\n if (window === undefined) {\n // No measured field — the capacity merge layer rejects this as noise.\n return { confidence: \"low\", observedAt, evidence: CODEX_EVIDENCE }\n }\n const usedRatio = window.usedPercent / 100\n const remainingRatio = 1 - usedRatio\n let resetAt: number | undefined\n if (window.resetAfterSeconds !== undefined) {\n resetAt = observedAt + window.resetAfterSeconds * 1000\n } else if (window.resetAtSeconds !== undefined) {\n resetAt = window.resetAtSeconds * 1000\n }\n const confidence: Confidence = hasReset(window) ? \"high\" : \"medium\"\n return {\n usedRatio,\n remainingRatio,\n ...(resetAt !== undefined ? { resetAt } : {}),\n confidence,\n observedAt,\n evidence: CODEX_EVIDENCE,\n }\n}\n"]}
@@ -21,4 +21,3 @@ export declare class CodexCapacitySensor implements CapacitySensor {
21
21
  observe(captured: Readonly<Record<string, string>>, observedAt: number): void;
22
22
  read(): Promise<CapacityReading | null>;
23
23
  }
24
- //# sourceMappingURL=sensor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sensor.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/sensor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,OAAO,mBAAmB;IACrB,EAAE,GAAG,eAAe,CAAA;IACpB,QAAQ,CAAa;IAC9B,MAAM,GAAsB,IAAI,CAAA;IAChC,WAAW,GAAG,CAAC,CAAA;IAEf,YAAY,QAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,QAA0C,EAAE,UAAkB;QACpE,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;QACvC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IACnE,CAAC;CACF"}
1
+ {"version":3,"file":"sensor.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/sensor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,OAAO,mBAAmB;IACrB,EAAE,GAAG,eAAe,CAAA;IACpB,QAAQ,CAAa;IAC9B,MAAM,GAAsB,IAAI,CAAA;IAChC,WAAW,GAAG,CAAC,CAAA;IAEf,YAAY,QAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,QAA0C,EAAE,UAAkB;QACpE,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;QACvC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IACnE,CAAC;CACF","sourcesContent":["/**\n * The passive-header `CapacitySensor` (ADP-020). Holds the latest validated\n * header observation; `read()` converts it to a reading. No polling, no\n * endpoint calls, no credential handling — WebSocket-backed providers bypass\n * the HTTP hook entirely (verified limitation), so this sensor reports\n * `null` (no estimate) whenever no trustworthy headers have been observed.\n * An unparseable observation CLEARS the stored usage: present-but-invalid\n * telemetry is distrust, and a stale quota estimate must never linger.\n */\nimport type { ResourceKey } from \"../../health/resource-health/types.js\"\nimport type { CapacityReading, CapacitySensor } from \"../../health/capacity/types.js\"\nimport { parseCodexUsage } from \"./parse.js\"\nimport { readingFromUsage } from \"./reading.js\"\nimport type { CodexUsage } from \"./types.js\"\nimport { CODEX_SENSOR_ID } from \"./types.js\"\n\nexport class CodexCapacitySensor implements CapacitySensor {\n readonly id = CODEX_SENSOR_ID\n readonly resource: ResourceKey\n #usage: CodexUsage | null = null\n #observedAt = 0\n\n constructor(resource: ResourceKey) {\n this.resource = resource\n }\n\n /**\n * Record one captured-header observation. Unparseable telemetry clears the\n * previous estimate instead of keeping it (present-but-invalid = distrust).\n */\n observe(captured: Readonly<Record<string, string>>, observedAt: number): void {\n this.#usage = parseCodexUsage(captured)\n if (this.#usage !== null) {\n this.#observedAt = observedAt\n }\n }\n\n read(): Promise<CapacityReading | null> {\n const usage = this.#usage\n if (usage === null) {\n return Promise.resolve(null)\n }\n return Promise.resolve(readingFromUsage(usage, this.#observedAt))\n }\n}\n"]}
@@ -12,7 +12,6 @@
12
12
  * Everything is validated; unparseable telemetry produces no estimate rather
13
13
  * than a guess.
14
14
  */
15
- import type { CapacityReading } from "../../health/capacity/types.js";
16
15
  export declare const CODEX_SENSOR_ID = "codex-headers";
17
16
  /** The telemetry windows Codex headers report. Primary is the 5h window. */
18
17
  export declare const CODEX_WINDOW_KINDS: readonly ["primary", "secondary"];
@@ -30,6 +29,3 @@ export interface CodexUsage {
30
29
  readonly primary?: CodexWindow | undefined;
31
30
  readonly secondary?: CodexWindow | undefined;
32
31
  }
33
- /** Extract a capacity reading for the binding (most-consumed) window. */
34
- export type CodexReading = CapacityReading;
35
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Passive Codex/ChatGPT capacity telemetry (ADP-020).
3
+ *
4
+ * The only consumed evidence is the `x-codex-*` response-header family
5
+ * (including LiteLLM's `llm_provider-x-codex-*` relay form), captured from the
6
+ * `http.response` hook by the wiring-supplied allowlist. Verified wire facts:
7
+ * `x-codex-primary-used-percent` (5h window), `x-codex-secondary-used-percent`
8
+ * (weekly window), `x-codex-{primary,secondary}-window-minutes`,
9
+ * `x-codex-{primary,secondary}-reset-after-seconds`, and
10
+ * `x-codex-{primary,secondary}-reset-at` — where `reset-at` is documented to
11
+ * sometimes arrive as an EMPTY STRING while `reset-after-seconds` is present.
12
+ * Everything is validated; unparseable telemetry produces no estimate rather
13
+ * than a guess.
14
+ */
1
15
  export const CODEX_SENSOR_ID = "codex-headers";
2
16
  /** The telemetry windows Codex headers report. Primary is the 5h window. */
3
17
  export const CODEX_WINDOW_KINDS = ["primary", "secondary"];
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/types.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAE9C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,WAAW,CAAsC,CAAA"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAE9C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,WAAW,CAAsC,CAAA","sourcesContent":["/**\n * Passive Codex/ChatGPT capacity telemetry (ADP-020).\n *\n * The only consumed evidence is the `x-codex-*` response-header family\n * (including LiteLLM's `llm_provider-x-codex-*` relay form), captured from the\n * `http.response` hook by the wiring-supplied allowlist. Verified wire facts:\n * `x-codex-primary-used-percent` (5h window), `x-codex-secondary-used-percent`\n * (weekly window), `x-codex-{primary,secondary}-window-minutes`,\n * `x-codex-{primary,secondary}-reset-after-seconds`, and\n * `x-codex-{primary,secondary}-reset-at` — where `reset-at` is documented to\n * sometimes arrive as an EMPTY STRING while `reset-after-seconds` is present.\n * Everything is validated; unparseable telemetry produces no estimate rather\n * than a guess.\n */\n\nexport const CODEX_SENSOR_ID = \"codex-headers\"\n\n/** The telemetry windows Codex headers report. Primary is the 5h window. */\nexport const CODEX_WINDOW_KINDS = [\"primary\", \"secondary\"] as const satisfies readonly string[]\n\nexport type CodexWindowKind = (typeof CODEX_WINDOW_KINDS)[number]\n\nexport interface CodexWindow {\n /** Usage percentage in [0, 100] — the window exists only if this is valid. */\n readonly usedPercent: number\n /** Validated finite non-negative seconds until reset, when reported. */\n readonly resetAfterSeconds?: number | undefined\n /** Validated finite non-negative epoch-seconds reset timestamp, when reported. */\n readonly resetAtSeconds?: number | undefined\n}\n\n/** One validated header observation. `null` windows are simply absent. */\nexport interface CodexUsage {\n readonly primary?: CodexWindow | undefined\n readonly secondary?: CodexWindow | undefined\n}\n"]}
@@ -49,4 +49,3 @@ export declare function escalationTool(record: EscalationRecorder): {
49
49
  content: string;
50
50
  }>;
51
51
  };
52
- //# sourceMappingURL=escalation-tool.d.ts.map
@@ -14,9 +14,11 @@
14
14
  import { ESCALATION_TOOL_NAME, parseEscalationRequest } from "../../execution/escalation/index.js";
15
15
  export { ESCALATION_TOOL_NAME };
16
16
  const TOOL_DESCRIPTION = "Request stronger model capability for the current work unit. Provide a short reason and " +
17
- "the concrete evidence (what failed or was blocked). Adaptive records the request and " +
18
- "applies it at the next safe boundary within a finite budget. This is not a planning or " +
19
- "task-management tool.";
17
+ "the concrete evidence (what failed or was blocked). Adaptive records the request as " +
18
+ "structured evidence and weighs it when a failure on this unit is already classified as a " +
19
+ "capability gap (for example context overflow or a content-policy rejection), within a " +
20
+ "finite budget; recording alone does not force a tier escalation. This is not a planning " +
21
+ "or task-management tool.";
20
22
  /** The tool's input schema in JSON Schema form (host-convertible). */
21
23
  const escalationInputSchema = {
22
24
  type: "object",
@@ -1 +1 @@
1
- {"version":3,"file":"escalation-tool.js","sourceRoot":"","sources":["../../../src/adapters/opencode/escalation-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAElG,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAK/B,MAAM,gBAAgB,GACpB,0FAA0F;IAC1F,uFAAuF;IACvF,yFAAyF;IACzF,uBAAuB,CAAA;AAEzB,sEAAsE;AACtE,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,mEAAmE;SACjF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,sEAAsE;SACpF;KACF;IACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;IAChC,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,6EAA6E;AAC7E,MAAM,qBAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAW,CAAA;AAE1D,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,MAA0B;IAOvD,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,gBAAgB;QAC7B,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,CAAC,KAAc,EAAE,OAA8B,EAAE,EAAE;YAC1D,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;YAC7C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAAA;YAC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AAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,CAAC,KAAc,EAAE,OAA8B,EAAE,EAAE;YAC1D,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;YAC7C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAAA;YAC3F,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;YAC5E,OAAO,OAAO,CAAC,OAAO,CACpB,QAAQ;gBACN,CAAC,CAAC,EAAE,OAAO,EAAE,uDAAuD,EAAE;gBACtE,CAAC,CAAC,EAAE,OAAO,EAAE,mDAAmD,EAAE,CACrE,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * The typed escalation tool (T-18, ADP-015): the smallest Adaptive-owned\n * mechanism for an agent to request stronger capability. The input schema is\n * a plain JSON Schema — the host builds the model-facing tool definition by\n * converting the schema, and a Standard Schema implementation is silently\n * dropped (\"Schema vendor does not support JSON Schema conversion\", observed\n * on 2.2.5). The tool also opts out of the host's code-mode bundling: with\n * code mode enabled the host routes codemode-bundled tools through the\n * `execute` tool only, and a direct call fails with \"No tool named ... is\n * currently available\" (observed on 2.2.5). `execute` still re-validates\n * defensively: model-produced JSON is untrusted. The tool is deliberately\n * not a planning or task-management API.\n */\nimport { ESCALATION_TOOL_NAME, parseEscalationRequest } from \"../../execution/escalation/index.js\"\n\nexport { ESCALATION_TOOL_NAME }\n\n/** Records the request against the session's current work unit. */\nexport type EscalationRecorder = (sessionID: string, reason: string, evidence: string) => boolean\n\nconst TOOL_DESCRIPTION =\n \"Request stronger model capability for the current work unit. Provide a short reason and \" +\n \"the concrete evidence (what failed or was blocked). Adaptive records the request as \" +\n \"structured evidence and weighs it when a failure on this unit is already classified as a \" +\n \"capability gap (for example context overflow or a content-policy rejection), within a \" +\n \"finite budget; recording alone does not force a tier escalation. This is not a planning \" +\n \"or task-management tool.\"\n\n/** The tool's input schema in JSON Schema form (host-convertible). */\nconst escalationInputSchema = {\n type: \"object\",\n properties: {\n reason: {\n type: \"string\",\n minLength: 1,\n description: \"Short reason why the current work unit needs stronger capability.\",\n },\n evidence: {\n type: \"string\",\n minLength: 1,\n description: \"Concrete evidence of the capability gap: what failed or was blocked.\",\n },\n },\n required: [\"reason\", \"evidence\"],\n additionalProperties: false,\n}\n\n/** Keeps the tool directly callable when the host's code mode is enabled. */\nconst escalationToolOptions = { codemode: false } as const\n\n/** Build the plugin tool registration for the escalation request surface. */\nexport function escalationTool(record: EscalationRecorder): {\n name: typeof ESCALATION_TOOL_NAME\n description: string\n input: typeof escalationInputSchema\n options: typeof escalationToolOptions\n execute: (input: unknown, context: { sessionID: string }) => Promise<{ content: string }>\n} {\n return {\n name: ESCALATION_TOOL_NAME,\n description: TOOL_DESCRIPTION,\n input: escalationInputSchema,\n options: escalationToolOptions,\n execute: (input: unknown, context: { sessionID: string }) => {\n const request = parseEscalationRequest(input)\n if (request === undefined) {\n return Promise.resolve({ content: \"reason and evidence are required non-empty strings\" })\n }\n const recorded = record(context.sessionID, request.reason, request.evidence)\n return Promise.resolve(\n recorded\n ? { content: \"escalation request recorded for the current work unit\" }\n : { content: \"no active work unit; the request was not recorded\" },\n )\n },\n }\n}\n"]}
@@ -21,4 +21,3 @@ export interface SessionSubscription {
21
21
  export declare function subscribeSessions(events: EventSource, onReport: (report: ExecutionReport) => void, onError: (error: unknown) => void,
22
22
  /** Injectable so tests never wait on real timers. */
23
23
  pause?: (ms: number) => Promise<void>): SessionSubscription;
24
- //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/adapters/opencode/events.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eA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GAAG,CAAC;gBAAE,OAAO,GAAG,aAAa,CAAA;YAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,CAAA;YACpB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,YAAY,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO;QACL,OAAO,EAAE,GAAG,EAAE;YACZ,UAAU,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;QACD,IAAI;KACL,CAAA;AACH,CAAC","sourcesContent":["/**\n * Session event subscription (ADP-001). Subscribes to the lifecycle/\n * selection events, maps them into reports, and pumps them to the supervisor.\n * The pump runs until disposed. A stream error (SSE hiccup, host reconnect)\n * must not permanently silence observation — the pump resubscribes with a\n * bounded backoff and reports each failure to `onError` (wiring decides\n * fail-open behavior — ADP-031). Abort-induced termination is quiet.\n */\nimport type { EventDomain } from \"@opencode/plugin/promise/event\"\n\n/** The event surface the subscription actually uses (structural — fixture-friendly). */\nexport type EventSource = Pick<EventDomain, \"subscribe\">\nimport { mapSessionEvent, type SessionEvent } from \"./report.js\"\nimport type { ExecutionReport } from \"./types.js\"\n\nexport const SESSION_EVENT_TYPES = [\n \"session.execution.started\",\n \"session.execution.succeeded\",\n \"session.execution.failed\",\n \"session.execution.interrupted\",\n \"session.model.selected\",\n] as const satisfies readonly string[]\n\nexport interface SessionSubscription {\n /** Abort the stream; the pump settles quietly. */\n dispose(): void\n /** Settles when the pump ends (disposed or errored). */\n done: Promise<void>\n}\n\nconst RETRY_BASE_MS = 1_000\nconst RETRY_MAX_MS = 30_000\n\nconst defaultPause = (ms: number): Promise<void> =>\n new Promise<void>((resolve) => {\n setTimeout(resolve, ms)\n })\n\n/** Subscribe and pump session lifecycle reports to `onReport`, resubscribing after stream errors. */\nexport function subscribeSessions(\n events: EventSource,\n onReport: (report: ExecutionReport) => void,\n onError: (error: unknown) => void,\n /** Injectable so tests never wait on real timers. */\n pause: (ms: number) => Promise<void> = defaultPause,\n): SessionSubscription {\n const controller = new AbortController()\n // Checked through a function on purpose: TS narrows the `controller.signal`\n // property after the first guard, but `dispose()` flips `aborted` from\n // another context mid-pump, so every re-check below is load-bearing.\n const aborted = (): boolean => controller.signal.aborted\n const done = (async () => {\n let backoff = RETRY_BASE_MS\n for (;;) {\n if (aborted()) return\n // Events delivered since the last failure prove the stream itself\n // works; a fresh failure then starts the backoff climb again.\n let delivered = 0\n try {\n const stream = events.subscribe({\n types: [...SESSION_EVENT_TYPES],\n signal: controller.signal,\n })\n for await (const event of stream as AsyncIterable<SessionEvent>) {\n const report = mapSessionEvent(event)\n if (report !== null) {\n delivered += 1\n onReport(report)\n }\n }\n // A clean stream end is still an observation outage: the host closed\n // the subscription, so fall through to the resubscribe path.\n if (!aborted()) onError(new Error(\"session event stream ended\"))\n } catch (error) {\n if (aborted()) return\n onError(error)\n }\n if (aborted()) return\n if (delivered > 0) backoff = RETRY_BASE_MS\n await pause(backoff)\n backoff = Math.min(backoff * 2, RETRY_MAX_MS)\n }\n })()\n return {\n dispose: () => {\n controller.abort()\n },\n done,\n }\n}\n"]}
@@ -32,4 +32,3 @@ export interface SessionHookOptions {
32
32
  }
33
33
  /** Register supervisor hooks; resolves to all registrations (dispose in order). */
34
34
  export declare function registerSessionHooks(session: SessionHookSource, handlers: SessionHookHandlers, options?: SessionHookOptions): Promise<Registration[]>;
35
- //# sourceMappingURL=hooks.d.ts.map
@@ -1,12 +1,29 @@
1
1
  import { contextModelRequest, hookModelRequest, mapHttpResponse } from "./report.js";
2
2
  /** Register supervisor hooks; resolves to all registrations (dispose in order). */
3
3
  export async function registerSessionHooks(session, handlers, options) {
4
- const retry = await session.hook("retry", (input) => handlers.onRetry(input));
5
- const context = await session.hook("context", (input) => handlers.onModelRequest(contextModelRequest(input)));
6
- const modelRequest = await session.hook("model.request", (input) => handlers.onModelRequest(hookModelRequest(input)));
7
- const httpResponse = await session.hook("http.response", async (input) => handlers.onHttpResponse(await mapHttpResponse(input, options)));
8
- const idle = await session.hook("experimental.idle", (input) => handlers.onIdle({ kind: "idle", sessionID: input.sessionID }));
9
- const prompt = await session.hook("prompt", (input) => handlers.onPrompt({ kind: "prompt", sessionID: input.sessionID }));
10
- return [retry, context, modelRequest, httpResponse, idle, prompt];
4
+ const acquired = [];
5
+ try {
6
+ acquired.push(await session.hook("retry", (input) => handlers.onRetry(input)));
7
+ acquired.push(await session.hook("context", (input) => handlers.onModelRequest(contextModelRequest(input))));
8
+ acquired.push(await session.hook("model.request", (input) => handlers.onModelRequest(hookModelRequest(input))));
9
+ acquired.push(await session.hook("http.response", async (input) => handlers.onHttpResponse(await mapHttpResponse(input, options))));
10
+ acquired.push(await session.hook("experimental.idle", (input) => handlers.onIdle({ kind: "idle", sessionID: input.sessionID })));
11
+ acquired.push(await session.hook("prompt", (input) => handlers.onPrompt({ kind: "prompt", sessionID: input.sessionID })));
12
+ return acquired;
13
+ }
14
+ catch (error) {
15
+ // Partial-failure rollback: every hook already registered on the host must
16
+ // be disposed so a failed setup leaves no half-wired supervisor behind.
17
+ // Disposal failures are swallowed — the registration failure is the cause.
18
+ for (const registration of acquired) {
19
+ try {
20
+ await registration.dispose();
21
+ }
22
+ catch {
23
+ // Disposal failure must not mask the original registration error.
24
+ }
25
+ }
26
+ throw error;
27
+ }
11
28
  }
12
29
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/adapters/opencode/hooks.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAsBpF,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA0B,EAC1B,QAA6B,EAC7B,OAA4B;IAE5B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAA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EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAClE,CACF,CAAA;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2EAA2E;QAC3E,wEAAwE;QACxE,2EAA2E;QAC3E,KAAK,MAAM,YAAY,IAAI,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC;gBACH,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACP,kEAAkE;YACpE,CAAC;QACH,CAAC;QACD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["/**\n * Session hook registration (ADP-012/ADP-013/ADP-027). Registers the hooks the\n * supervisor needs on the host session domain and returns their registrations\n * for cleanup. Hooks MUTATE their inputs on the host — the retry handler owns\n * `input.decision`; the adapter passes the raw input through so wiring can\n * veto (`{ retry: false }`) or leave OpenCode's native retry untouched.\n *\n * Fail-open behavior (ADP-031) is applied by the wiring around these handlers;\n * the adapter itself never swallows errors, so wiring sees every failure.\n */\nimport type { Registration } from \"@opencode/plugin/promise/registration\"\nimport type { SessionDomain, SessionRetry } from \"@opencode/plugin/promise/session\"\n\n/** The session surface the hooks actually use (structural — fixture-friendly). */\nexport type SessionHookSource = Pick<SessionDomain, \"hook\">\nimport { contextModelRequest, hookModelRequest, mapHttpResponse } from \"./report.js\"\nimport type { HttpResponseReport, IdleReport, ModelRequestReport, PromptReport } from \"./types.js\"\n\nexport interface SessionHookHandlers {\n /** Raw retry hook input; wiring decides and mutates `input.decision`. */\n readonly onRetry: (input: SessionRetry) => Promise<void> | void\n readonly onModelRequest: (report: ModelRequestReport) => Promise<void> | void\n readonly onHttpResponse: (report: HttpResponseReport) => Promise<void> | void\n readonly onIdle: (report: IdleReport) => Promise<void> | void\n /** Awaited before the turn's model resolution — the admission boundary. */\n readonly onPrompt: (report: PromptReport) => Promise<void> | void\n}\n\n/** Optional hook behavior supplied by the wiring. */\nexport interface SessionHookOptions {\n /**\n * Allowlist predicate over lowercase response header names selecting the\n * quota telemetry to capture (no other header ever leaves the response).\n */\n readonly capture?: (lowercaseName: string) => boolean\n}\n\n/** Register supervisor hooks; resolves to all registrations (dispose in order). */\nexport async function registerSessionHooks(\n session: SessionHookSource,\n handlers: SessionHookHandlers,\n options?: SessionHookOptions,\n): Promise<Registration[]> {\n const acquired: Registration[] = []\n try {\n acquired.push(await session.hook(\"retry\", (input) => handlers.onRetry(input)))\n acquired.push(\n await session.hook(\"context\", (input) => handlers.onModelRequest(contextModelRequest(input))),\n )\n acquired.push(\n await session.hook(\"model.request\", (input) =>\n handlers.onModelRequest(hookModelRequest(input)),\n ),\n )\n acquired.push(\n await session.hook(\"http.response\", async (input) =>\n handlers.onHttpResponse(await mapHttpResponse(input, options)),\n ),\n )\n acquired.push(\n await session.hook(\"experimental.idle\", (input) =>\n handlers.onIdle({ kind: \"idle\", sessionID: input.sessionID }),\n ),\n )\n acquired.push(\n await session.hook(\"prompt\", (input) =>\n handlers.onPrompt({ kind: \"prompt\", sessionID: input.sessionID }),\n ),\n )\n return acquired\n } catch (error) {\n // Partial-failure rollback: every hook already registered on the host must\n // be disposed so a failed setup leaves no half-wired supervisor behind.\n // Disposal failures are swallowed — the registration failure is the cause.\n for (const registration of acquired) {\n try {\n await registration.dispose()\n } catch {\n // Disposal failure must not mask the original registration error.\n }\n }\n throw error\n }\n}\n"]}
@@ -14,4 +14,3 @@ export type { SessionHookHandlers, SessionHookSource } from "./hooks.js";
14
14
  export { ESCALATION_TOOL_NAME, escalationTool } from "./escalation-tool.js";
15
15
  export { tierTool } from "./tier-tool.js";
16
16
  export type { EscalationRecorder } from "./escalation-tool.js";
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAU/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/opencode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAU/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA","sourcesContent":["export { BODY_EXCERPT_LENGTH, mapHttpResponse, mapSessionEvent, modelRefOf } from \"./report.js\"\nexport type { SessionEvent } from \"./report.js\"\nexport type {\n AdapterStructuredError,\n EventReport,\n ExecutionReport,\n HttpResponseReport,\n IdleReport,\n ModelRequestReport,\n} from \"./types.js\"\nexport { candidateFor, listCandidates, mapModelInfo } from \"./inventory.js\"\nexport type { ModelSource } from \"./inventory.js\"\nexport { sessionOps } from \"./session-ops.js\"\nexport type { SessionOpsHooks, SessionOpsSource } from \"./session-ops.js\"\nexport { storageSeam } from \"./storage.js\"\nexport type { JsonSeam, StorageSource } from \"./storage.js\"\nexport { SESSION_EVENT_TYPES, subscribeSessions } from \"./events.js\"\nexport type { EventSource, SessionSubscription } from \"./events.js\"\nexport { registerSessionHooks } from \"./hooks.js\"\nexport type { SessionHookHandlers, SessionHookSource } from \"./hooks.js\"\nexport { ESCALATION_TOOL_NAME, escalationTool } from \"./escalation-tool.js\"\nexport { tierTool } from \"./tier-tool.js\"\nexport type { EscalationRecorder } from \"./escalation-tool.js\"\n"]}
@@ -28,4 +28,3 @@ export declare function listCandidates(model: ModelSource): Promise<CandidateMod
28
28
  * gate does not reject the very resource the user pinned.
29
29
  */
30
30
  export declare function candidateFor(model: ModelSource, ref: ModelRef): Promise<CandidateModel | undefined>;
31
- //# sourceMappingURL=inventory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../../src/adapters/opencode/inventory.ts"],"names":[],"mappings":"AAmBA,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,OAAO,EAAE,IAAI,CAAC,EAAE;QAChB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE;YACZ,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;YAC9B,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YACnC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;SACtC;QACD,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;KACvC,CAAA;AACH,CAAC;AAED;;gEAEgE;AAChE,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E,CAAC,CAAA;YAClF,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAkB,EAClB,GAAa;IAEb,IAAI,KAAiC,CAAA;IACrC,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;QAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;QAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAM;QACR,CAAC;QACD,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9F,OAAM;QACR,CAAC;QACD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAC/B,KAAK;YACH,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IAChG,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/**\n * Model inventory mapping (ADP-005/ADP-006/ADP-017). Host `Model.Info` records\n * become supervisor `CandidateModel` views for the compatibility gate.\n *\n * `providerEnabled: true` is honest for `editor.list()` output: the verified\n * host contract is that `list()` returns candidates \"from available providers\"\n * (including models disabled by earlier transforms — the per-model `enabled`\n * flag distinguishes those). Pins are verified against the same editor via\n * `candidateFor`, which additionally checks variant existence (a variant the\n * model does not offer must not be switchable-to).\n */\nimport type { Model } from \"@opencode/plugin\"\nimport type { ModelDomain } from \"@opencode/plugin/promise/model\"\nimport type { CandidateModel } from \"../../core/compatibility/types.js\"\nimport type { ModelRef } from \"../../core/work-unit/types.js\"\n\n/** The model surface the inventory actually uses (structural — fixture-friendly). */\nexport type ModelSource = Pick<ModelDomain, \"transform\">\n\n/** Map one host model record into a candidate view. */\nexport function mapModelInfo(info: Model.Info): CandidateModel {\n return {\n providerID: info.providerID,\n modelID: info.id,\n enabled: info.enabled,\n providerEnabled: true,\n capabilities: {\n tools: info.capabilities.tools,\n input: [...info.capabilities.input],\n output: [...info.capabilities.output],\n },\n limit: { context: info.limit.context },\n }\n}\n\n/** All inventory candidates, in host order. Each offered variant is an\n * additional explicit candidate so tier resources pinned to a variant\n * (`provider/model@variant`) are matchable by the scheduler. */\nexport async function listCandidates(model: ModelSource): Promise<CandidateModel[]> {\n const out: CandidateModel[] = []\n await model.transform((editor) => {\n for (const info of editor.list()) {\n out.push(mapModelInfo(info))\n for (const variant of info.variants) {\n out.push({ ...mapModelInfo(info), variant: variant.id, variantAvailable: true })\n }\n }\n })\n return out\n}\n\n/**\n * Resolve one exact resource reference (a pin) to its candidate, or `undefined`\n * when the model is not in the host inventory or the requested variant does\n * not exist. A resolved variant is reported as available so the compatibility\n * gate does not reject the very resource the user pinned.\n */\nexport async function candidateFor(\n model: ModelSource,\n ref: ModelRef,\n): Promise<CandidateModel | undefined> {\n let found: CandidateModel | undefined\n await model.transform((editor) => {\n const info = editor.get(ref.providerID, ref.id)\n if (info === undefined) {\n return\n }\n if (ref.variant !== undefined && !info.variants.some((variant) => variant.id === ref.variant)) {\n return\n }\n const base = mapModelInfo(info)\n found =\n ref.variant !== undefined ? { ...base, variant: ref.variant, variantAvailable: true } : base\n })\n return found\n}\n"]}
@@ -89,4 +89,3 @@ export declare function hookModelRequest(input: {
89
89
  export declare function mapHttpResponse(input: SessionHttpResponse, options?: {
90
90
  capture?: (lowercaseName: string) => boolean;
91
91
  }): Promise<HttpResponseReport>;
92
- //# sourceMappingURL=report.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AAI,CAAC,QAAQ,CAAC,CAAC,MAAM,IAAI,oBAAoB,EAAE,CAAC;gBACzD,MAAK;YACP,CAAC;YACD,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACxC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAA;YAC5D,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,eAAe,GAAG,QAAQ,CAAA;QAC5B,CAAC;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;QAC7B,GAAG,CAAC,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAA;AACH,CAAC","sourcesContent":["/**\n * Event/hook → report mappers. Pure observation, no policy: the adapter\n * normalizes verified host payloads into `EventReport` shapes the supervisor\n * consumes. Timestamps come from the host event envelope (`created`, epoch\n * milliseconds) — work units are clock-free.\n */\nimport type { Model } from \"@opencode/plugin\"\nimport type { SessionHttpResponse } from \"@opencode/plugin/promise/session\"\nimport type { ModelRef } from \"../../core/work-unit/types.js\"\nimport type {\n AdapterStructuredError,\n ExecutionReport,\n HttpResponseReport,\n ModelRequestReport,\n} from \"./types.js\"\n\n/**\n * Response bodies are bounded here (and bounded again by the classifier) so a\n * hostile provider payload can never inflate memory or receipts. The excerpt\n * is read with a streaming reader and the stream is cancelled once the cap is\n * reached — a multi-megabyte body never materializes in memory.\n */\nexport const BODY_EXCERPT_LENGTH = 512\n\n/**\n * Reads at most `BODY_EXCERPT_LENGTH` characters from the response body via a\n * streaming reader, cancelling the underlying stream when the cap is reached.\n * Returns `undefined` for missing or empty bodies.\n */\nasync function readBodyExcerpt(response: Response): Promise<string | undefined> {\n const reader = response.body?.getReader()\n if (reader === undefined) return undefined\n const decoder = new TextDecoder()\n let text = \"\"\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n text += decoder.decode(value, { stream: true })\n if (text.length >= BODY_EXCERPT_LENGTH) {\n // Fire-and-forget: cancellation failure must not fail the observation.\n void reader.cancel().catch(() => undefined)\n break\n }\n }\n text = text.slice(0, BODY_EXCERPT_LENGTH)\n return text === \"\" ? undefined : text\n}\n\n/** Capture bounds for wiring-selected telemetry headers. */\nexport const MAX_CAPTURED_HEADERS = 16\nexport const MAX_CAPTURED_VALUE_LENGTH = 64\n\n/** Convert a host `Model.Ref` into the supervisor's `ModelRef` shape. */\nexport function modelRefOf(ref: Model.Ref): ModelRef {\n return {\n providerID: ref.providerID,\n id: ref.id,\n ...(ref.variant !== undefined ? { variant: ref.variant } : {}),\n }\n}\n\n/** Structural session event the mapper accepts (host payloads are assignable). */\nexport type SessionEvent =\n | { type: \"session.execution.started\"; created: number; data: { sessionID: string } }\n | { type: \"session.execution.succeeded\"; created: number; data: { sessionID: string } }\n | {\n type: \"session.execution.failed\"\n created: number\n data: { sessionID: string; error: AdapterStructuredError }\n }\n | {\n type: \"session.execution.interrupted\"\n created: number\n data: { sessionID: string; reason: string }\n }\n | {\n type: \"session.model.selected\"\n created: number\n data: { sessionID: string; model: Model.Ref }\n }\n\n/**\n * Map one subscribed session event into its report. Returns `null` for event\n * types the supervisor does not consume (defensive — the subscription filters\n * types, so this branch only fires if the host ever widens the stream).\n */\nexport function mapSessionEvent(event: SessionEvent): ExecutionReport | null {\n switch (event.type) {\n case \"session.execution.started\":\n return { kind: \"execution-started\", sessionID: event.data.sessionID, at: event.created }\n case \"session.execution.succeeded\":\n return { kind: \"execution-succeeded\", sessionID: event.data.sessionID, at: event.created }\n case \"session.execution.failed\":\n return {\n kind: \"execution-failed\",\n sessionID: event.data.sessionID,\n at: event.created,\n error: event.data.error,\n }\n case \"session.execution.interrupted\":\n return {\n kind: \"execution-interrupted\",\n sessionID: event.data.sessionID,\n at: event.created,\n reason: event.data.reason,\n }\n case \"session.model.selected\":\n return {\n kind: \"model-selected\",\n sessionID: event.data.sessionID,\n at: event.created,\n model: modelRefOf(event.data.model),\n }\n default:\n return null\n }\n}\n\n/** Model request report from the `context` hook — the agent loop is `primary`. */\nexport function contextModelRequest(input: {\n sessionID: string\n model: Model.Ref\n agent?: string\n}): ModelRequestReport {\n return {\n kind: \"model-request\",\n sessionID: input.sessionID,\n model: modelRefOf(input.model),\n requestKind: \"primary\",\n ...(input.agent !== undefined ? { agent: input.agent } : {}),\n }\n}\n\n/** Model request report from the `model.request` hook (carries the request kind). */\nexport function hookModelRequest(input: {\n sessionID: string\n model: Model.Ref\n kind: \"primary\" | \"compaction\" | \"title\" | \"generate\"\n agent?: string\n}): ModelRequestReport {\n return {\n kind: \"model-request\",\n sessionID: input.sessionID,\n model: modelRefOf(input.model),\n requestKind: input.kind,\n ...(input.agent !== undefined ? { agent: input.agent } : {}),\n }\n}\n\n/**\n * Map an `http.response` hook input. The response body is cloned EXACTLY ONCE\n * and only the bounded excerpt of the clone is read — the original body stays\n * untouched for the host (verified one-shot body limitation). If the body\n * cannot be cloned (already consumed, streaming error), the report degrades\n * to status/header evidence.\n *\n * `capture` is an optional allowlist predicate over lowercase header names\n * (quota telemetry only — never `authorization`, cookies, or any other\n * credential-bearing header). Captured entries are bounded in count and value\n * length; capture never throws.\n */\nexport async function mapHttpResponse(\n input: SessionHttpResponse,\n options?: { capture?: (lowercaseName: string) => boolean },\n): Promise<HttpResponseReport> {\n const retryAfterHeader = input.response.headers.get(\"retry-after\")\n let bodyExcerpt: string | undefined\n try {\n bodyExcerpt = await readBodyExcerpt(input.response.clone())\n } catch {\n // Body unreadable — status + headers evidence remains available.\n }\n let capturedHeaders: Record<string, string> | undefined\n if (options?.capture !== undefined) {\n const captured: Record<string, string> = {}\n for (const [name, value] of input.response.headers) {\n if (Object.keys(captured).length >= MAX_CAPTURED_HEADERS) {\n break\n }\n if (options.capture(name.toLowerCase())) {\n captured[name] = value.slice(0, MAX_CAPTURED_VALUE_LENGTH)\n }\n }\n if (Object.keys(captured).length > 0) {\n capturedHeaders = captured\n }\n }\n return {\n kind: \"http-response\",\n sessionID: input.sessionID,\n status: input.response.status,\n ...(retryAfterHeader !== null ? { retryAfterHeader } : {}),\n ...(bodyExcerpt !== undefined ? { bodyExcerpt } : {}),\n ...(capturedHeaders !== undefined ? { capturedHeaders } : {}),\n }\n}\n"]}
@@ -37,4 +37,3 @@ export interface SessionOpsHooks {
37
37
  }
38
38
  /** Build the supervisor's continuation ops on top of the host session domain. */
39
39
  export declare function sessionOps(session: SessionOpsSource, hooks?: SessionOpsHooks): ContinuationOps;
40
- //# sourceMappingURL=session-ops.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-ops.js","sourceRoot":"","sources":["../../../src/adapters/opencode/session-ops.ts"],"names":[],"mappings":"AAwCA,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,OAAyB,EAAE,KAAuB;IAC3E,OAAO;QACL,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;QAClD,WAAW,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YAChC,KAAK,EAAE,YAAY,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;YACvC,OAAO,OAAO,CAAC,WAAW,CAAC;gBACzB,SAAS;gBACT,KAAK,EAAE;oBACL,UAAU,EAAE,KAAK,CAAC,UAAU;o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KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACnE;aACF,CAAC,CAAA;QACJ,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;YAChC,KAAK,EAAE,YAAY,EAAE,CAAC,SAAS,CAAC,CAAA;YAChC,IAAI,SAAS,GAAG,KAAK,CAAA;YACrB,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;gBACzC,SAAS,GAAG,IAAI,CAAA;YAClB,CAAC;oBAAS,CAAC;gBACT,mEAAmE;gBACnE,mEAAmE;gBACnE,2DAA2D;gBAC3D,KAAK,EAAE,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;YAC5C,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Session operations seam (ADP-013/ADP-014/ADP-023/ADP-028). Implements the\n * supervisor's `ContinuationOps` on the host session domain: settle on the\n * host's experimental wait, switch model, deliver a prompt. Never replays a\n * failed request — prompting after a failure starts a NEW execution that\n * continues from session state (prompt strategy chosen by the supervisor).\n *\n * Switch self-tagging (verified limitation: `session.model.selected` fires for\n * manual AND plugin switches): `beforeSwitch` is invoked BEFORE the host\n * switch so the supervisor can record its own pending attribution note; the\n * resulting selection event is then attributed to Adaptive, never to the user.\n */\nimport type { SessionDomain } from \"@opencode/plugin/promise/session\"\n\n/** The session surface the ops actually use (structural — fixture-friendly). */\nexport type SessionOpsSource = Pick<SessionDomain, \"wait\" | \"switchModel\" | \"prompt\">\nimport type { ContinuationOps } from \"../../execution/continuation/types.js\"\nimport type { ModelRef } from \"../../core/work-unit/types.js\"\n\nexport interface SessionOpsHooks {\n /**\n * Called before every host `switchModel` this adapter performs, so wiring\n * can tag the switch as Adaptive's own (`noteOwnSwitch`).\n */\n readonly beforeSwitch?: (sessionID: string, model: ModelRef) => void\n /**\n * Called before the adapter prompts a continuation, so wiring can mark the\n * upcoming prompt-hook admission as owned (the continuation belongs to the\n * active unit and must not re-admit).\n */\n readonly beforePrompt?: (sessionID: string) => void\n /**\n * Called when the prompted call settles (success or failure), whether or\n * not the prompt hook fired — the counterpart that bounds the ownership\n * mark's lifetime. `delivered` is false exactly when the host prompt\n * rejected, so the hook can never fire for it.\n */\n readonly afterPrompt?: (sessionID: string, delivered: boolean) => void\n}\n\n/** Build the supervisor's continuation ops on top of the host session domain. */\nexport function sessionOps(session: SessionOpsSource, hooks?: SessionOpsHooks): ContinuationOps {\n return {\n settle: (sessionID) => session.wait({ sessionID }),\n switchModel: (sessionID, model) => {\n hooks?.beforeSwitch?.(sessionID, model)\n return session.switchModel({\n sessionID,\n model: {\n providerID: model.providerID,\n id: model.id,\n ...(model.variant !== undefined ? { variant: model.variant } : {}),\n },\n })\n },\n prompt: async (sessionID, text) => {\n hooks?.beforePrompt?.(sessionID)\n let delivered = false\n try {\n await session.prompt({ sessionID, text })\n delivered = true\n } finally {\n // The ownership mark is consumed by the prompt hook; if the prompt\n // never reaches the hook (session gone, host error), the mark must\n // not outlive the attempt and swallow a later user prompt.\n hooks?.afterPrompt?.(sessionID, delivered)\n }\n },\n }\n}\n"]}
@@ -13,4 +13,3 @@ export interface JsonSeam {
13
13
  }
14
14
  /** Bind a storage key to the supervisor seam shape. */
15
15
  export declare function storageSeam(key: string, storage: StorageSource): JsonSeam;
16
- //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/adapters/opencode/storage.ts"],"names":[],"mappings":"AAgBA,uDAAuD;AACvD,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAAsB;IAC7D,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAA0C,CAAC;KAC/E,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/adapters/opencode/storage.ts"],"names":[],"mappings":"AAgBA,uDAAuD;AACvD,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAAsB;IAC7D,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAA0C,CAAC;KAC/E,CAAA;AACH,CAAC","sourcesContent":["/**\n * Storage seam binding (ADP-030/ADP-031). The supervisor's state stores depend\n * on a minimal `{ read, write }` seam; this module binds that seam to the\n * host's `ctx.storage` under the fixed `coool.adaptive/...` keys. Values are\n * JSON-serializable state payloads (settings/receipts/parked work).\n */\nimport type { StorageDomain } from \"@opencode/plugin/promise/storage\"\n\n/** The storage surface the seam actually uses (structural — fixture-friendly). */\nexport type StorageSource = Pick<StorageDomain, \"get\" | \"set\">\n\nexport interface JsonSeam {\n read(): Promise<unknown>\n write(value: unknown): Promise<void>\n}\n\n/** Bind a storage key to the supervisor seam shape. */\nexport function storageSeam(key: string, storage: StorageSource): JsonSeam {\n return {\n read: () => storage.get(key),\n write: (value) => storage.set(key, value as Parameters<typeof storage.set>[1]),\n }\n}\n"]}
@@ -35,4 +35,3 @@ export declare function tierTool(record: TierRequestRecorder): {
35
35
  }[];
36
36
  }>;
37
37
  };
38
- //# sourceMappingURL=tier-tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tier-tool.js","sourceRoot":"","sources":["../../../src/adapters/opencode/tier-tool.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,MAA2B;IAClD,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,kEAAkE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A;YAChD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,OAAO,CAAC,OAAO,CAAC;oBACrB,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,4DAA4D;yBACnE;qBACF;iBACF,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC;gBACrB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,0BAA0B,IAAI,2DAA2D;qBAChG;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAC5D,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAA;IAC/C,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAA;IAC/E,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { TierName } from \"../../core/tier-policy/types.js\"\n\n/** Records the agent's tier declaration; false = not accepted. */\nexport type TierRequestRecorder = (sessionID: string, tier: TierName) => boolean\n\n/**\n * The agent-declared tier tool: a typed sibling of adaptive_escalate. The\n * agent declares the tier of the task it is starting (\"this task is quick\")\n * and the declaration steers the session's next admissions until cleared —\n * one tier per task, not per unit. Plain JSON Schema: the host converts it,\n * and a Standard Schema vendor is silently dropped on 2.2.5.\n */\nexport function tierTool(record: TierRequestRecorder) {\n return {\n name: \"adaptive_tier\",\n description:\n \"Declare the capability tier of the task you are starting: quick \" +\n \"(routine edits, mechanical steps), standard (the default), or \" +\n \"advanced (multi-step design, broad refactors, hard debugging). \" +\n \"The declaration stays in force for this session until you declare \" +\n \"a different tier. Only declare when the task's tier differs from \" +\n \"the default; never use this to work around unavailability.\",\n input: {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n type: \"object\",\n properties: {\n tier: {\n description: \"The tier the current task needs.\",\n enum: [\"quick\", \"standard\", \"advanced\"],\n },\n },\n required: [\"tier\"],\n additionalProperties: false,\n } as const,\n options: { codemode: false } as const,\n execute: (\n input: unknown,\n context: { sessionID: string },\n ): Promise<{ content: { type: \"text\"; text: string }[] }> => {\n const tier = readTier(input)\n if (tier === null) {\n return Promise.resolve({\n content: [\n {\n type: \"text\" as const,\n text: \"adaptive_tier rejected: tier must be quick, standard, or advanced.\",\n },\n ],\n })\n }\n const accepted = record(context.sessionID, tier)\n if (!accepted) {\n return Promise.resolve({\n content: [\n {\n type: \"text\" as const,\n text: \"adaptive_tier rejected: the tier request was not accepted.\",\n },\n ],\n })\n }\n return Promise.resolve({\n content: [\n {\n type: \"text\" as const,\n text: `Tier request recorded: ${tier}. It steers this session's next admissions until cleared.`,\n },\n ],\n })\n },\n }\n}\n\nfunction readTier(input: unknown): TierName | null {\n if (typeof input !== \"object\" || input === null) return null\n const tier = (input as { tier?: unknown }).tier\n if (tier !== \"quick\" && tier !== \"standard\" && tier !== \"advanced\") return null\n return tier\n}\n"]}
@@ -99,4 +99,3 @@ export interface PromptReport {
99
99
  }
100
100
  /** Everything the adapter forwards to the supervisor. */
101
101
  export type EventReport = ExecutionReport | ModelRequestReport | HttpResponseReport | IdleReport | PromptReport;
102
- //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/opencode/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/opencode/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Adapter report types (ADP-025..ADP-031). The OpenCode adapter's only job is\n * to observe host events and hooks and forward them as plain reports; every\n * policy decision lives in the supervisor wiring. Report shapes mirror the\n * verified `@opencode/plugin@2.2.5` surfaces structurally, so the adapter\n * stays testable against typed fixtures without importing host internals\n * beyond types.\n */\nimport type { ModelRef } from \"../../core/work-unit/types.js\"\nimport type { RequestKind } from \"../../core/tier-policy/types.js\"\n\n/**\n * Structural mirror of the wire `Session.StructuredError` (also the classifier\n * evidence source). Declared locally because `SessionError.Error` is not\n * re-exported by `@opencode/plugin` — the host payloads are assignable to\n * this shape.\n */\nexport interface AdapterStructuredError {\n readonly type: string\n readonly message: string\n readonly status?: number | undefined\n readonly response?: { readonly body: string } | undefined\n readonly retryAfterMs?: number | undefined\n}\n\n/** Work-unit lifecycle reports forwarded from `session.execution.*` events. */\nexport type ExecutionReport =\n | { kind: \"execution-started\"; sessionID: string; at: number }\n | { kind: \"execution-succeeded\"; sessionID: string; at: number }\n | { kind: \"execution-failed\"; sessionID: string; at: number; error: AdapterStructuredError }\n | { kind: \"execution-interrupted\"; sessionID: string; at: number; reason: string }\n | { kind: \"model-selected\"; sessionID: string; at: number; model: ModelRef }\n\n/**\n * Model request reports from the `context` hook (the agent loop, always\n * `primary`) and the `model.request` hook (which carries the request kind for\n * auxiliary requests — ADP-027).\n */\nexport interface ModelRequestReport {\n kind: \"model-request\"\n sessionID: string\n model: ModelRef\n requestKind: RequestKind\n /** The agent the request runs under (ADP-002 role-hint routing evidence). */\n agent?: string\n}\n\n/**\n * HTTP response evidence from the `http.response` hook. The response body is\n * cloned exactly once and only a bounded excerpt is kept — the original body\n * stays untouched for the host. WebSocket-backed providers bypass this hook\n * entirely (verified limitation), so this evidence is never load-bearing.\n */\nexport interface HttpResponseReport {\n kind: \"http-response\"\n sessionID: string\n status: number\n /** Raw `Retry-After` header value; the supervisor parses it, not the adapter. */\n retryAfterHeader?: string | undefined\n bodyExcerpt?: string | undefined\n /**\n * Captured quota-telemetry headers selected by the wiring-supplied capture\n * predicate (an allowlist — no other header ever leaves the response, so\n * credentials and cookies cannot leak). Bounded in count and value length.\n */\n capturedHeaders?: Readonly<Record<string, string>> | undefined\n}\n\n/** Idle-boundary report from the `experimental.idle` hook (safe boundary). */\nexport interface IdleReport {\n kind: \"idle\"\n sessionID: string\n}\n\n/**\n * User-prompt report from the `session.hook(\"prompt\")` hook. The hook is\n * awaited BEFORE the turn's model resolution, so admission performed here\n * lands on the very turn that triggered it — the event pump's\n * execution-started report is asynchronous and races the turn (empirically\n * verified on opencode 2.2.5).\n */\nexport interface PromptReport {\n kind: \"prompt\"\n sessionID: string\n}\n\n/** Everything the adapter forwards to the supervisor. */\nexport type EventReport =\n ExecutionReport | ModelRequestReport | HttpResponseReport | IdleReport | PromptReport\n"]}
@@ -5,6 +5,3 @@ import type { CandidateModel, Demand, Verdict } from "./types.js";
5
5
  * satisfies a stated requirement.
6
6
  */
7
7
  export declare function checkCompatibility(candidate: CandidateModel, demand: Demand): Verdict;
8
- /** Order-preserving convenience filter for the scheduler. */
9
- export declare function filterCompatible<T extends CandidateModel>(candidates: readonly T[], demand: Demand): T[];
10
- //# sourceMappingURL=gate.d.ts.map
@@ -48,8 +48,4 @@ export function checkCompatibility(candidate, demand) {
48
48
  }
49
49
  return { compatible: reasons.length === 0, reasons };
50
50
  }
51
- /** Order-preserving convenience filter for the scheduler. */
52
- export function filterCompatible(candidates, demand) {
53
- return candidates.filter((candidate) => checkCompatibility(candidate, demand).compatible);
54
- }
55
51
  //# sourceMappingURL=gate.js.map