@coool/opencode-adaptive 0.0.0-stage → 1.0.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 (440) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -2
  3. package/dist/adapters/codex-capacity/index.d.ts +5 -0
  4. package/dist/adapters/codex-capacity/index.d.ts.map +1 -0
  5. package/dist/adapters/codex-capacity/index.js +5 -0
  6. package/dist/adapters/codex-capacity/index.js.map +1 -0
  7. package/dist/adapters/codex-capacity/parse.d.ts +28 -0
  8. package/dist/adapters/codex-capacity/parse.d.ts.map +1 -0
  9. package/dist/adapters/codex-capacity/parse.js +130 -0
  10. package/dist/adapters/codex-capacity/parse.js.map +1 -0
  11. package/dist/adapters/codex-capacity/reading.d.ts +10 -0
  12. package/dist/adapters/codex-capacity/reading.d.ts.map +1 -0
  13. package/dist/adapters/codex-capacity/reading.js +45 -0
  14. package/dist/adapters/codex-capacity/reading.js.map +1 -0
  15. package/dist/adapters/codex-capacity/sensor.d.ts +24 -0
  16. package/dist/adapters/codex-capacity/sensor.d.ts.map +1 -0
  17. package/dist/adapters/codex-capacity/sensor.js +30 -0
  18. package/dist/adapters/codex-capacity/sensor.js.map +1 -0
  19. package/dist/adapters/codex-capacity/types.d.ts +35 -0
  20. package/dist/adapters/codex-capacity/types.d.ts.map +1 -0
  21. package/dist/adapters/codex-capacity/types.js +4 -0
  22. package/dist/adapters/codex-capacity/types.js.map +1 -0
  23. package/dist/adapters/opencode/escalation-tool.d.ts +52 -0
  24. package/dist/adapters/opencode/escalation-tool.d.ts.map +1 -0
  25. package/dist/adapters/opencode/escalation-tool.js +59 -0
  26. package/dist/adapters/opencode/escalation-tool.js.map +1 -0
  27. package/dist/adapters/opencode/events.d.ts +24 -0
  28. package/dist/adapters/opencode/events.d.ts.map +1 -0
  29. package/dist/adapters/opencode/events.js +68 -0
  30. package/dist/adapters/opencode/events.js.map +1 -0
  31. package/dist/adapters/opencode/hooks.d.ts +35 -0
  32. package/dist/adapters/opencode/hooks.d.ts.map +1 -0
  33. package/dist/adapters/opencode/hooks.js +12 -0
  34. package/dist/adapters/opencode/hooks.js.map +1 -0
  35. package/dist/adapters/opencode/index.d.ts +17 -0
  36. package/dist/adapters/opencode/index.d.ts.map +1 -0
  37. package/dist/adapters/opencode/index.js +9 -0
  38. package/dist/adapters/opencode/index.js.map +1 -0
  39. package/dist/adapters/opencode/inventory.d.ts +31 -0
  40. package/dist/adapters/opencode/inventory.d.ts.map +1 -0
  41. package/dist/adapters/opencode/inventory.js +53 -0
  42. package/dist/adapters/opencode/inventory.js.map +1 -0
  43. package/dist/adapters/opencode/report.d.ts +92 -0
  44. package/dist/adapters/opencode/report.d.ts.map +1 -0
  45. package/dist/adapters/opencode/report.js +145 -0
  46. package/dist/adapters/opencode/report.js.map +1 -0
  47. package/dist/adapters/opencode/session-ops.d.ts +40 -0
  48. package/dist/adapters/opencode/session-ops.d.ts.map +1 -0
  49. package/dist/adapters/opencode/session-ops.js +32 -0
  50. package/dist/adapters/opencode/session-ops.js.map +1 -0
  51. package/dist/adapters/opencode/storage.d.ts +16 -0
  52. package/dist/adapters/opencode/storage.d.ts.map +1 -0
  53. package/dist/adapters/opencode/storage.js +8 -0
  54. package/dist/adapters/opencode/storage.js.map +1 -0
  55. package/dist/adapters/opencode/tier-tool.d.ts +38 -0
  56. package/dist/adapters/opencode/tier-tool.d.ts.map +1 -0
  57. package/dist/adapters/opencode/tier-tool.js +72 -0
  58. package/dist/adapters/opencode/tier-tool.js.map +1 -0
  59. package/dist/adapters/opencode/types.d.ts +102 -0
  60. package/dist/adapters/opencode/types.d.ts.map +1 -0
  61. package/dist/adapters/opencode/types.js +2 -0
  62. package/dist/adapters/opencode/types.js.map +1 -0
  63. package/dist/core/compatibility/gate.d.ts +10 -0
  64. package/dist/core/compatibility/gate.d.ts.map +1 -0
  65. package/dist/core/compatibility/gate.js +55 -0
  66. package/dist/core/compatibility/gate.js.map +1 -0
  67. package/dist/core/compatibility/index.d.ts +3 -0
  68. package/dist/core/compatibility/index.d.ts.map +1 -0
  69. package/dist/core/compatibility/index.js +3 -0
  70. package/dist/core/compatibility/index.js.map +1 -0
  71. package/dist/core/compatibility/types.d.ts +54 -0
  72. package/dist/core/compatibility/types.d.ts.map +1 -0
  73. package/dist/core/compatibility/types.js +27 -0
  74. package/dist/core/compatibility/types.js.map +1 -0
  75. package/dist/core/scheduler/admit.d.ts +7 -0
  76. package/dist/core/scheduler/admit.d.ts.map +1 -0
  77. package/dist/core/scheduler/admit.js +153 -0
  78. package/dist/core/scheduler/admit.js.map +1 -0
  79. package/dist/core/scheduler/escalate.d.ts +7 -0
  80. package/dist/core/scheduler/escalate.d.ts.map +1 -0
  81. package/dist/core/scheduler/escalate.js +56 -0
  82. package/dist/core/scheduler/escalate.js.map +1 -0
  83. package/dist/core/scheduler/index.d.ts +5 -0
  84. package/dist/core/scheduler/index.d.ts.map +1 -0
  85. package/dist/core/scheduler/index.js +5 -0
  86. package/dist/core/scheduler/index.js.map +1 -0
  87. package/dist/core/scheduler/mode.d.ts +9 -0
  88. package/dist/core/scheduler/mode.d.ts.map +1 -0
  89. package/dist/core/scheduler/mode.js +10 -0
  90. package/dist/core/scheduler/mode.js.map +1 -0
  91. package/dist/core/scheduler/types.d.ts +143 -0
  92. package/dist/core/scheduler/types.d.ts.map +1 -0
  93. package/dist/core/scheduler/types.js +74 -0
  94. package/dist/core/scheduler/types.js.map +1 -0
  95. package/dist/core/tier-policy/index.d.ts +4 -0
  96. package/dist/core/tier-policy/index.d.ts.map +1 -0
  97. package/dist/core/tier-policy/index.js +4 -0
  98. package/dist/core/tier-policy/index.js.map +1 -0
  99. package/dist/core/tier-policy/resolve.d.ts +19 -0
  100. package/dist/core/tier-policy/resolve.d.ts.map +1 -0
  101. package/dist/core/tier-policy/resolve.js +52 -0
  102. package/dist/core/tier-policy/resolve.js.map +1 -0
  103. package/dist/core/tier-policy/tier-list.d.ts +11 -0
  104. package/dist/core/tier-policy/tier-list.d.ts.map +1 -0
  105. package/dist/core/tier-policy/tier-list.js +23 -0
  106. package/dist/core/tier-policy/tier-list.js.map +1 -0
  107. package/dist/core/tier-policy/types.d.ts +85 -0
  108. package/dist/core/tier-policy/types.d.ts.map +1 -0
  109. package/dist/core/tier-policy/types.js +45 -0
  110. package/dist/core/tier-policy/types.js.map +1 -0
  111. package/dist/core/work-unit/index.d.ts +4 -0
  112. package/dist/core/work-unit/index.d.ts.map +1 -0
  113. package/dist/core/work-unit/index.js +4 -0
  114. package/dist/core/work-unit/index.js.map +1 -0
  115. package/dist/core/work-unit/interruption.d.ts +8 -0
  116. package/dist/core/work-unit/interruption.d.ts.map +1 -0
  117. package/dist/core/work-unit/interruption.js +12 -0
  118. package/dist/core/work-unit/interruption.js.map +1 -0
  119. package/dist/core/work-unit/tracker.d.ts +46 -0
  120. package/dist/core/work-unit/tracker.d.ts.map +1 -0
  121. package/dist/core/work-unit/tracker.js +136 -0
  122. package/dist/core/work-unit/tracker.js.map +1 -0
  123. package/dist/core/work-unit/types.d.ts +146 -0
  124. package/dist/core/work-unit/types.d.ts.map +1 -0
  125. package/dist/core/work-unit/types.js +23 -0
  126. package/dist/core/work-unit/types.js.map +1 -0
  127. package/dist/execution/continuation/execute.d.ts +19 -0
  128. package/dist/execution/continuation/execute.d.ts.map +1 -0
  129. package/dist/execution/continuation/execute.js +31 -0
  130. package/dist/execution/continuation/execute.js.map +1 -0
  131. package/dist/execution/continuation/index.d.ts +6 -0
  132. package/dist/execution/continuation/index.d.ts.map +1 -0
  133. package/dist/execution/continuation/index.js +5 -0
  134. package/dist/execution/continuation/index.js.map +1 -0
  135. package/dist/execution/continuation/ledger.d.ts +20 -0
  136. package/dist/execution/continuation/ledger.d.ts.map +1 -0
  137. package/dist/execution/continuation/ledger.js +31 -0
  138. package/dist/execution/continuation/ledger.js.map +1 -0
  139. package/dist/execution/continuation/plan.d.ts +13 -0
  140. package/dist/execution/continuation/plan.d.ts.map +1 -0
  141. package/dist/execution/continuation/plan.js +20 -0
  142. package/dist/execution/continuation/plan.js.map +1 -0
  143. package/dist/execution/continuation/prompts.d.ts +8 -0
  144. package/dist/execution/continuation/prompts.d.ts.map +1 -0
  145. package/dist/execution/continuation/prompts.js +8 -0
  146. package/dist/execution/continuation/prompts.js.map +1 -0
  147. package/dist/execution/continuation/types.d.ts +70 -0
  148. package/dist/execution/continuation/types.d.ts.map +1 -0
  149. package/dist/execution/continuation/types.js +15 -0
  150. package/dist/execution/continuation/types.js.map +1 -0
  151. package/dist/execution/escalation/index.d.ts +2 -0
  152. package/dist/execution/escalation/index.d.ts.map +1 -0
  153. package/dist/execution/escalation/index.js +2 -0
  154. package/dist/execution/escalation/index.js.map +1 -0
  155. package/dist/execution/escalation/types.d.ts +31 -0
  156. package/dist/execution/escalation/types.d.ts.map +1 -0
  157. package/dist/execution/escalation/types.js +49 -0
  158. package/dist/execution/escalation/types.js.map +1 -0
  159. package/dist/execution/index.d.ts +5 -0
  160. package/dist/execution/index.d.ts.map +1 -0
  161. package/dist/execution/index.js +5 -0
  162. package/dist/execution/index.js.map +1 -0
  163. package/dist/execution/parking/index.d.ts +3 -0
  164. package/dist/execution/parking/index.d.ts.map +1 -0
  165. package/dist/execution/parking/index.js +2 -0
  166. package/dist/execution/parking/index.js.map +1 -0
  167. package/dist/execution/parking/plan.d.ts +40 -0
  168. package/dist/execution/parking/plan.d.ts.map +1 -0
  169. package/dist/execution/parking/plan.js +34 -0
  170. package/dist/execution/parking/plan.js.map +1 -0
  171. package/dist/execution/recovery/gate.d.ts +20 -0
  172. package/dist/execution/recovery/gate.d.ts.map +1 -0
  173. package/dist/execution/recovery/gate.js +23 -0
  174. package/dist/execution/recovery/gate.js.map +1 -0
  175. package/dist/execution/recovery/index.d.ts +3 -0
  176. package/dist/execution/recovery/index.d.ts.map +1 -0
  177. package/dist/execution/recovery/index.js +2 -0
  178. package/dist/execution/recovery/index.js.map +1 -0
  179. package/dist/execution/retry/decide.d.ts +30 -0
  180. package/dist/execution/retry/decide.d.ts.map +1 -0
  181. package/dist/execution/retry/decide.js +76 -0
  182. package/dist/execution/retry/decide.js.map +1 -0
  183. package/dist/execution/retry/index.d.ts +3 -0
  184. package/dist/execution/retry/index.d.ts.map +1 -0
  185. package/dist/execution/retry/index.js +3 -0
  186. package/dist/execution/retry/index.js.map +1 -0
  187. package/dist/execution/retry/types.d.ts +66 -0
  188. package/dist/execution/retry/types.d.ts.map +1 -0
  189. package/dist/execution/retry/types.js +9 -0
  190. package/dist/execution/retry/types.js.map +1 -0
  191. package/dist/gui-experimental.cjs +1 -0
  192. package/dist/gui.d.ts +17 -0
  193. package/dist/gui.d.ts.map +1 -0
  194. package/dist/gui.js +70 -0
  195. package/dist/gui.js.map +1 -0
  196. package/dist/health/capacity/index.d.ts +4 -0
  197. package/dist/health/capacity/index.d.ts.map +1 -0
  198. package/dist/health/capacity/index.js +4 -0
  199. package/dist/health/capacity/index.js.map +1 -0
  200. package/dist/health/capacity/merge.d.ts +58 -0
  201. package/dist/health/capacity/merge.d.ts.map +1 -0
  202. package/dist/health/capacity/merge.js +154 -0
  203. package/dist/health/capacity/merge.js.map +1 -0
  204. package/dist/health/capacity/registry.d.ts +41 -0
  205. package/dist/health/capacity/registry.d.ts.map +1 -0
  206. package/dist/health/capacity/registry.js +106 -0
  207. package/dist/health/capacity/registry.js.map +1 -0
  208. package/dist/health/capacity/types.d.ts +74 -0
  209. package/dist/health/capacity/types.d.ts.map +1 -0
  210. package/dist/health/capacity/types.js +6 -0
  211. package/dist/health/capacity/types.js.map +1 -0
  212. package/dist/health/circuit-breaker/breaker.d.ts +84 -0
  213. package/dist/health/circuit-breaker/breaker.d.ts.map +1 -0
  214. package/dist/health/circuit-breaker/breaker.js +132 -0
  215. package/dist/health/circuit-breaker/breaker.js.map +1 -0
  216. package/dist/health/circuit-breaker/index.d.ts +3 -0
  217. package/dist/health/circuit-breaker/index.d.ts.map +1 -0
  218. package/dist/health/circuit-breaker/index.js +3 -0
  219. package/dist/health/circuit-breaker/index.js.map +1 -0
  220. package/dist/health/circuit-breaker/types.d.ts +53 -0
  221. package/dist/health/circuit-breaker/types.d.ts.map +1 -0
  222. package/dist/health/circuit-breaker/types.js +13 -0
  223. package/dist/health/circuit-breaker/types.js.map +1 -0
  224. package/dist/health/classifier/classify.d.ts +9 -0
  225. package/dist/health/classifier/classify.d.ts.map +1 -0
  226. package/dist/health/classifier/classify.js +245 -0
  227. package/dist/health/classifier/classify.js.map +1 -0
  228. package/dist/health/classifier/index.d.ts +3 -0
  229. package/dist/health/classifier/index.d.ts.map +1 -0
  230. package/dist/health/classifier/index.js +3 -0
  231. package/dist/health/classifier/index.js.map +1 -0
  232. package/dist/health/classifier/types.d.ts +72 -0
  233. package/dist/health/classifier/types.d.ts.map +1 -0
  234. package/dist/health/classifier/types.js +27 -0
  235. package/dist/health/classifier/types.js.map +1 -0
  236. package/dist/health/index.d.ts +5 -0
  237. package/dist/health/index.d.ts.map +1 -0
  238. package/dist/health/index.js +5 -0
  239. package/dist/health/index.js.map +1 -0
  240. package/dist/health/resource-health/index.d.ts +5 -0
  241. package/dist/health/resource-health/index.d.ts.map +1 -0
  242. package/dist/health/resource-health/index.js +5 -0
  243. package/dist/health/resource-health/index.js.map +1 -0
  244. package/dist/health/resource-health/key.d.ts +19 -0
  245. package/dist/health/resource-health/key.d.ts.map +1 -0
  246. package/dist/health/resource-health/key.js +54 -0
  247. package/dist/health/resource-health/key.js.map +1 -0
  248. package/dist/health/resource-health/registry.d.ts +41 -0
  249. package/dist/health/resource-health/registry.d.ts.map +1 -0
  250. package/dist/health/resource-health/registry.js +258 -0
  251. package/dist/health/resource-health/registry.js.map +1 -0
  252. package/dist/health/resource-health/transitions.d.ts +11 -0
  253. package/dist/health/resource-health/transitions.d.ts.map +1 -0
  254. package/dist/health/resource-health/transitions.js +165 -0
  255. package/dist/health/resource-health/transitions.js.map +1 -0
  256. package/dist/health/resource-health/types.d.ts +116 -0
  257. package/dist/health/resource-health/types.d.ts.map +1 -0
  258. package/dist/health/resource-health/types.js +43 -0
  259. package/dist/health/resource-health/types.js.map +1 -0
  260. package/dist/index.d.ts +17 -0
  261. package/dist/index.d.ts.map +1 -0
  262. package/dist/index.js +80 -0
  263. package/dist/index.js.map +1 -0
  264. package/dist/plugin-id.d.ts +3 -0
  265. package/dist/plugin-id.d.ts.map +1 -0
  266. package/dist/plugin-id.js +3 -0
  267. package/dist/plugin-id.js.map +1 -0
  268. package/dist/rpc/definition.d.ts +100 -0
  269. package/dist/rpc/definition.d.ts.map +1 -0
  270. package/dist/rpc/definition.js +104 -0
  271. package/dist/rpc/definition.js.map +1 -0
  272. package/dist/rpc/handlers.d.ts +65 -0
  273. package/dist/rpc/handlers.d.ts.map +1 -0
  274. package/dist/rpc/handlers.js +111 -0
  275. package/dist/rpc/handlers.js.map +1 -0
  276. package/dist/rpc/status.d.ts +43 -0
  277. package/dist/rpc/status.d.ts.map +1 -0
  278. package/dist/rpc/status.js +45 -0
  279. package/dist/rpc/status.js.map +1 -0
  280. package/dist/rpc.d.ts +11 -0
  281. package/dist/rpc.d.ts.map +1 -0
  282. package/dist/rpc.js +8 -0
  283. package/dist/rpc.js.map +1 -0
  284. package/dist/state/capacity/index.d.ts +4 -0
  285. package/dist/state/capacity/index.d.ts.map +1 -0
  286. package/dist/state/capacity/index.js +4 -0
  287. package/dist/state/capacity/index.js.map +1 -0
  288. package/dist/state/capacity/parse.d.ts +3 -0
  289. package/dist/state/capacity/parse.d.ts.map +1 -0
  290. package/dist/state/capacity/parse.js +110 -0
  291. package/dist/state/capacity/parse.js.map +1 -0
  292. package/dist/state/capacity/store.d.ts +19 -0
  293. package/dist/state/capacity/store.d.ts.map +1 -0
  294. package/dist/state/capacity/store.js +64 -0
  295. package/dist/state/capacity/store.js.map +1 -0
  296. package/dist/state/capacity/types.d.ts +38 -0
  297. package/dist/state/capacity/types.d.ts.map +1 -0
  298. package/dist/state/capacity/types.js +11 -0
  299. package/dist/state/capacity/types.js.map +1 -0
  300. package/dist/state/health/index.d.ts +5 -0
  301. package/dist/state/health/index.d.ts.map +1 -0
  302. package/dist/state/health/index.js +4 -0
  303. package/dist/state/health/index.js.map +1 -0
  304. package/dist/state/health/parse.d.ts +3 -0
  305. package/dist/state/health/parse.d.ts.map +1 -0
  306. package/dist/state/health/parse.js +121 -0
  307. package/dist/state/health/parse.js.map +1 -0
  308. package/dist/state/health/store.d.ts +18 -0
  309. package/dist/state/health/store.d.ts.map +1 -0
  310. package/dist/state/health/store.js +55 -0
  311. package/dist/state/health/store.js.map +1 -0
  312. package/dist/state/health/types.d.ts +24 -0
  313. package/dist/state/health/types.d.ts.map +1 -0
  314. package/dist/state/health/types.js +5 -0
  315. package/dist/state/health/types.js.map +1 -0
  316. package/dist/state/parked-work/index.d.ts +5 -0
  317. package/dist/state/parked-work/index.d.ts.map +1 -0
  318. package/dist/state/parked-work/index.js +4 -0
  319. package/dist/state/parked-work/index.js.map +1 -0
  320. package/dist/state/parked-work/parse.d.ts +7 -0
  321. package/dist/state/parked-work/parse.d.ts.map +1 -0
  322. package/dist/state/parked-work/parse.js +83 -0
  323. package/dist/state/parked-work/parse.js.map +1 -0
  324. package/dist/state/parked-work/store.d.ts +18 -0
  325. package/dist/state/parked-work/store.d.ts.map +1 -0
  326. package/dist/state/parked-work/store.js +81 -0
  327. package/dist/state/parked-work/store.js.map +1 -0
  328. package/dist/state/parked-work/types.d.ts +42 -0
  329. package/dist/state/parked-work/types.d.ts.map +1 -0
  330. package/dist/state/parked-work/types.js +7 -0
  331. package/dist/state/parked-work/types.js.map +1 -0
  332. package/dist/state/receipts/bound.d.ts +15 -0
  333. package/dist/state/receipts/bound.d.ts.map +1 -0
  334. package/dist/state/receipts/bound.js +77 -0
  335. package/dist/state/receipts/bound.js.map +1 -0
  336. package/dist/state/receipts/index.d.ts +7 -0
  337. package/dist/state/receipts/index.d.ts.map +1 -0
  338. package/dist/state/receipts/index.js +5 -0
  339. package/dist/state/receipts/index.js.map +1 -0
  340. package/dist/state/receipts/parse.d.ts +7 -0
  341. package/dist/state/receipts/parse.d.ts.map +1 -0
  342. package/dist/state/receipts/parse.js +226 -0
  343. package/dist/state/receipts/parse.js.map +1 -0
  344. package/dist/state/receipts/store.d.ts +35 -0
  345. package/dist/state/receipts/store.d.ts.map +1 -0
  346. package/dist/state/receipts/store.js +128 -0
  347. package/dist/state/receipts/store.js.map +1 -0
  348. package/dist/state/receipts/types.d.ts +62 -0
  349. package/dist/state/receipts/types.d.ts.map +1 -0
  350. package/dist/state/receipts/types.js +12 -0
  351. package/dist/state/receipts/types.js.map +1 -0
  352. package/dist/state/session-modes/index.d.ts +5 -0
  353. package/dist/state/session-modes/index.d.ts.map +1 -0
  354. package/dist/state/session-modes/index.js +4 -0
  355. package/dist/state/session-modes/index.js.map +1 -0
  356. package/dist/state/session-modes/parse.d.ts +9 -0
  357. package/dist/state/session-modes/parse.d.ts.map +1 -0
  358. package/dist/state/session-modes/parse.js +62 -0
  359. package/dist/state/session-modes/parse.js.map +1 -0
  360. package/dist/state/session-modes/store.d.ts +21 -0
  361. package/dist/state/session-modes/store.d.ts.map +1 -0
  362. package/dist/state/session-modes/store.js +73 -0
  363. package/dist/state/session-modes/store.js.map +1 -0
  364. package/dist/state/session-modes/types.d.ts +42 -0
  365. package/dist/state/session-modes/types.d.ts.map +1 -0
  366. package/dist/state/session-modes/types.js +7 -0
  367. package/dist/state/session-modes/types.js.map +1 -0
  368. package/dist/state/settings/index.d.ts +5 -0
  369. package/dist/state/settings/index.d.ts.map +1 -0
  370. package/dist/state/settings/index.js +4 -0
  371. package/dist/state/settings/index.js.map +1 -0
  372. package/dist/state/settings/parse.d.ts +34 -0
  373. package/dist/state/settings/parse.d.ts.map +1 -0
  374. package/dist/state/settings/parse.js +261 -0
  375. package/dist/state/settings/parse.js.map +1 -0
  376. package/dist/state/settings/store.d.ts +22 -0
  377. package/dist/state/settings/store.d.ts.map +1 -0
  378. package/dist/state/settings/store.js +57 -0
  379. package/dist/state/settings/store.js.map +1 -0
  380. package/dist/state/settings/types.d.ts +63 -0
  381. package/dist/state/settings/types.d.ts.map +1 -0
  382. package/dist/state/settings/types.js +12 -0
  383. package/dist/state/settings/types.js.map +1 -0
  384. package/dist/supervisor/index.d.ts +5 -0
  385. package/dist/supervisor/index.d.ts.map +1 -0
  386. package/dist/supervisor/index.js +4 -0
  387. package/dist/supervisor/index.js.map +1 -0
  388. package/dist/supervisor/log.d.ts +11 -0
  389. package/dist/supervisor/log.d.ts.map +1 -0
  390. package/dist/supervisor/log.js +14 -0
  391. package/dist/supervisor/log.js.map +1 -0
  392. package/dist/supervisor/supervisor.d.ts +69 -0
  393. package/dist/supervisor/supervisor.d.ts.map +1 -0
  394. package/dist/supervisor/supervisor.js +1343 -0
  395. package/dist/supervisor/supervisor.js.map +1 -0
  396. package/dist/supervisor/types.d.ts +50 -0
  397. package/dist/supervisor/types.d.ts.map +1 -0
  398. package/dist/supervisor/types.js +3 -0
  399. package/dist/supervisor/types.js.map +1 -0
  400. package/dist/supervisor/view.d.ts +4 -0
  401. package/dist/supervisor/view.d.ts.map +1 -0
  402. package/dist/supervisor/view.js +4 -0
  403. package/dist/supervisor/view.js.map +1 -0
  404. package/dist/tui.d.ts +16 -0
  405. package/dist/tui.d.ts.map +1 -0
  406. package/dist/tui.js +252 -0
  407. package/dist/tui.js.map +1 -0
  408. package/dist/ui/gui/api.d.ts +18 -0
  409. package/dist/ui/gui/api.d.ts.map +1 -0
  410. package/dist/ui/gui/api.js +21 -0
  411. package/dist/ui/gui/api.js.map +1 -0
  412. package/dist/ui/gui/view.d.ts +27 -0
  413. package/dist/ui/gui/view.d.ts.map +1 -0
  414. package/dist/ui/gui/view.js +49 -0
  415. package/dist/ui/gui/view.js.map +1 -0
  416. package/dist/ui/tui/controller.d.ts +98 -0
  417. package/dist/ui/tui/controller.d.ts.map +1 -0
  418. package/dist/ui/tui/controller.js +399 -0
  419. package/dist/ui/tui/controller.js.map +1 -0
  420. package/dist/ui/tui/menu.d.ts +56 -0
  421. package/dist/ui/tui/menu.d.ts.map +1 -0
  422. package/dist/ui/tui/menu.js +176 -0
  423. package/dist/ui/tui/menu.js.map +1 -0
  424. package/dist/ui/tui/options.d.ts +20 -0
  425. package/dist/ui/tui/options.d.ts.map +1 -0
  426. package/dist/ui/tui/options.js +17 -0
  427. package/dist/ui/tui/options.js.map +1 -0
  428. package/dist/ui/tui/receipts.d.ts +22 -0
  429. package/dist/ui/tui/receipts.d.ts.map +1 -0
  430. package/dist/ui/tui/receipts.js +109 -0
  431. package/dist/ui/tui/receipts.js.map +1 -0
  432. package/dist/ui/tui/status.d.ts +23 -0
  433. package/dist/ui/tui/status.d.ts.map +1 -0
  434. package/dist/ui/tui/status.js +90 -0
  435. package/dist/ui/tui/status.js.map +1 -0
  436. package/dist/ui/tui/tiers.d.ts +52 -0
  437. package/dist/ui/tui/tiers.d.ts.map +1 -0
  438. package/dist/ui/tui/tiers.js +108 -0
  439. package/dist/ui/tui/tiers.js.map +1 -0
  440. package/package.json +85 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 @coool
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # @coool/opencode-adaptive
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Automatic model fallback and routing for [OpenCode](https://opencode.ai).
4
+
5
+ You list your models in order of preference. Adaptive runs each task on the first one that works. When a model hits a quota, rate limit or outage, work moves to the next one. When the preferred model is back, it is used again.
6
+
7
+ It is set up entirely from the `/adaptive` menu in OpenCode. There are no config files to edit and no model IDs to type.
8
+
9
+ ## What you can do with it
10
+
11
+ **Use subscriptions first, pay-as-you-go second.** Put your subscription models at the top of the list and an API provider such as OpenRouter at the bottom. You get the most out of what you already pay for. The API only takes over when the subscriptions are out of quota, and the subscriptions are used again as soon as they reset.
12
+
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
+
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.
16
+
17
+ ## Features
18
+
19
+ - **Menu setup.** Models, order and mode are set in `/adaptive` with model search. No config files.
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
+ - **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.
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
+ - **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
+
26
+ ## Install
27
+
28
+ ```sh
29
+ opencode plugin add @coool/opencode-adaptive
30
+ ```
31
+
32
+ Needs OpenCode 2.2.1 or newer.
33
+
34
+ ## Set up
35
+
36
+ 1. Start OpenCode and run `/adaptive`.
37
+ 2. Open **Models**, pick a tier, and choose **Add model…**. Search for a model and select it. Repeat, best first. If the tier a task needs is empty, OpenCode's own model runs it.
38
+ 3. Open **Mode** and choose `active`.
39
+
40
+ New installs start in `observe` mode: Adaptive records what it would do but changes nothing. Look at **Receipts** to check its decisions, then switch to `active`.
41
+
42
+ | Mode | What happens |
43
+ | --------- | ---------------------------------------------------------------------- |
44
+ | `off` | Nothing. |
45
+ | `observe` | Decisions are recorded, not applied. This is the default. |
46
+ | `active` | Decisions are applied. A task changes model only when its model fails. |
47
+
48
+ Any session can override the global mode: open `/adaptive` inside the session and choose **This session…**.
49
+
50
+ To reorder or remove a model, select it in the tier list. **Status** shows each model's state, including subscription usage (`used 72%, resets 18:42`) when the provider reports it.
51
+
52
+ ## Tiers
53
+
54
+ A tier is an ordered list of models. The order is your policy, and Adaptive never changes it.
55
+
56
+ - **Quick** for small, mechanical work.
57
+ - **Standard** for everything else. This is the default.
58
+ - **Advanced** for hard work.
59
+
60
+ A model can be in more than one tier.
61
+
62
+ The tier for a task is the first of these that applies:
63
+
64
+ 1. A pinned model (`/adaptive` → **Pin**).
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
+ 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`.
69
+
70
+ 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
+ ## When a model fails
73
+
74
+ - **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
+ - **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
+ - **You cancel:** nothing is retried or switched.
78
+ - **Auth error or unknown model:** the model is marked unavailable and skipped.
79
+
80
+ An outage never moves work to a stronger tier. Work only moves up on real evidence: a context overflow, a content-policy rejection, or the agent calling `adaptive_escalate` with a reason and evidence. This happens at most twice per task.
81
+
82
+ ## Limits
83
+
84
+ - No borrowing between tiers. If a tier is exhausted, work waits. To let a model serve two tiers, add it to both.
85
+ - A task that moved up a tier stays there. The next task is routed again from scratch.
86
+ - Usage figures come from response headers and are best effort. Providers that use WebSockets don't expose them.
87
+ - The browser/desktop settings page is experimental. No released OpenCode loads it yet, so use `/adaptive`.
88
+
89
+ ## Troubleshooting
90
+
91
+ - **Nothing changes.** You are in `observe` mode. Switch to `active` in `/adaptive` → **Mode**.
92
+ - **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
+ - **Why did it pick that model?** `/adaptive` → **Receipts**.
95
+ - **"Plugin failed" toast.** The plugin didn't load. Update it with `opencode plugin update`, or remove and add it again.
96
+
97
+ ## Privacy
98
+
99
+ Nothing leaves your machine. No telemetry, no network calls of its own, no secrets in settings, receipts or logs. Receipts keep the newest 200 entries and are never added to prompts.
@@ -0,0 +1,5 @@
1
+ export * from "./types.js";
2
+ export * from "./parse.js";
3
+ export * from "./reading.js";
4
+ export * from "./sensor.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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"}
@@ -0,0 +1,5 @@
1
+ export * from "./types.js";
2
+ export * from "./parse.js";
3
+ export * from "./reading.js";
4
+ export * from "./sensor.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Untrusted-header validation. Header values arrive from provider responses
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
5
+ * are dropped field-wise — they cannot invalidate a valid percentage.
6
+ */
7
+ import type { CodexUsage } from "./types.js";
8
+ /**
9
+ * LiteLLM relays Codex headers under a provider prefix, e.g.
10
+ * `llm_provider-x-codex-primary-used-percent`. Matching on the substring keeps
11
+ * the parser independent of which relay prefix is used.
12
+ */
13
+ export declare const CODEX_HEADER_MARK = "x-codex-";
14
+ /**
15
+ * Allowlist predicate for the `http.response` capture option: matches plain
16
+ * and LiteLLM-prefixed Codex telemetry header names (case already lowered by
17
+ * the caller). Only quota telemetry passes — no other response header is ever
18
+ * captured.
19
+ */
20
+ export declare function isCodexHeaderName(lowercaseName: string): boolean;
21
+ /**
22
+ * Parse captured response headers into a validated usage snapshot. Header
23
+ * lookup is case-insensitive and accepts LiteLLM-prefixed names; fields
24
+ * accumulate per window in any order. Returns `null` when no window carries a
25
+ * trustworthy usage percentage.
26
+ */
27
+ export declare function parseCodexUsage(captured: Readonly<Record<string, string>>): CodexUsage | null;
28
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/parse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAgC,MAAM,YAAY,CAAA;AAG1E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,aAAa,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAEhE;AAyFD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,UAAU,GAAG,IAAI,CA8B7F"}
@@ -0,0 +1,130 @@
1
+ import { CODEX_WINDOW_KINDS } from "./types.js";
2
+ /**
3
+ * LiteLLM relays Codex headers under a provider prefix, e.g.
4
+ * `llm_provider-x-codex-primary-used-percent`. Matching on the substring keeps
5
+ * the parser independent of which relay prefix is used.
6
+ */
7
+ export const CODEX_HEADER_MARK = "x-codex-";
8
+ /**
9
+ * Allowlist predicate for the `http.response` capture option: matches plain
10
+ * and LiteLLM-prefixed Codex telemetry header names (case already lowered by
11
+ * the caller). Only quota telemetry passes — no other response header is ever
12
+ * captured.
13
+ */
14
+ export function isCodexHeaderName(lowercaseName) {
15
+ return lowercaseName.includes(CODEX_HEADER_MARK);
16
+ }
17
+ function finiteAtLeast(value, min) {
18
+ // An empty (or whitespace-only) value must not fall through Number("") === 0.
19
+ const trimmed = value.trim();
20
+ if (trimmed === "") {
21
+ return undefined;
22
+ }
23
+ const parsed = Number(trimmed);
24
+ if (!Number.isFinite(parsed) || parsed < min) {
25
+ return undefined;
26
+ }
27
+ return parsed;
28
+ }
29
+ function emptyAccumulator() {
30
+ return { usedPercent: undefined, resetAfterSeconds: undefined, resetAtSeconds: undefined };
31
+ }
32
+ function takenValue(accumulator, suffix) {
33
+ switch (suffix) {
34
+ case "used-percent":
35
+ return accumulator.usedPercent;
36
+ case "reset-after-seconds":
37
+ return accumulator.resetAfterSeconds;
38
+ case "reset-at":
39
+ return accumulator.resetAtSeconds;
40
+ default:
41
+ return undefined;
42
+ }
43
+ }
44
+ function applyField(accumulator, suffix, value) {
45
+ // First valid value per field wins; invalid or duplicate values are ignored.
46
+ if (takenValue(accumulator, suffix) !== undefined) {
47
+ return;
48
+ }
49
+ switch (suffix) {
50
+ case "used-percent": {
51
+ // The percentage is the window's existence test: out of range or
52
+ // unparseable values never admit a window.
53
+ const usedPercent = finiteAtLeast(value, 0);
54
+ if (usedPercent !== undefined && usedPercent <= 100) {
55
+ accumulator.usedPercent = usedPercent;
56
+ }
57
+ return;
58
+ }
59
+ case "reset-after-seconds": {
60
+ const resetAfterSeconds = finiteAtLeast(value, 0);
61
+ if (resetAfterSeconds !== undefined) {
62
+ accumulator.resetAfterSeconds = resetAfterSeconds;
63
+ }
64
+ return;
65
+ }
66
+ case "reset-at": {
67
+ // Documented wire quirk: reset-at can be an empty string while
68
+ // reset-after-seconds carries the real value. Empty and unparseable
69
+ // values are dropped, never guessed at.
70
+ const resetAtSeconds = finiteAtLeast(value, 0);
71
+ if (resetAtSeconds !== undefined) {
72
+ accumulator.resetAtSeconds = resetAtSeconds;
73
+ }
74
+ return;
75
+ }
76
+ default:
77
+ // window-minutes and unknown suffixes carry no reading information.
78
+ return;
79
+ }
80
+ }
81
+ function windowOf(accumulator) {
82
+ const usedPercent = accumulator.usedPercent;
83
+ if (usedPercent === undefined) {
84
+ return undefined;
85
+ }
86
+ const { resetAfterSeconds, resetAtSeconds } = accumulator;
87
+ return {
88
+ usedPercent,
89
+ ...(resetAfterSeconds !== undefined ? { resetAfterSeconds } : {}),
90
+ ...(resetAtSeconds !== undefined ? { resetAtSeconds } : {}),
91
+ };
92
+ }
93
+ /**
94
+ * Parse captured response headers into a validated usage snapshot. Header
95
+ * lookup is case-insensitive and accepts LiteLLM-prefixed names; fields
96
+ * accumulate per window in any order. Returns `null` when no window carries a
97
+ * trustworthy usage percentage.
98
+ */
99
+ export function parseCodexUsage(captured) {
100
+ const accumulators = {
101
+ primary: undefined,
102
+ secondary: undefined,
103
+ };
104
+ for (const [rawName, value] of Object.entries(captured)) {
105
+ const mark = rawName.toLowerCase().indexOf(CODEX_HEADER_MARK);
106
+ if (mark < 0) {
107
+ continue;
108
+ }
109
+ const rest = rawName.slice(mark + CODEX_HEADER_MARK.length).toLowerCase();
110
+ const separator = rest.indexOf("-");
111
+ const kind = rest.slice(0, separator);
112
+ if (!CODEX_WINDOW_KINDS.includes(kind)) {
113
+ continue;
114
+ }
115
+ const key = kind;
116
+ const accumulator = accumulators[key] ?? emptyAccumulator();
117
+ applyField(accumulator, rest.slice(separator + 1), value);
118
+ accumulators[key] = accumulator;
119
+ }
120
+ const primary = windowOf(accumulators.primary ?? emptyAccumulator());
121
+ const secondary = windowOf(accumulators.secondary ?? emptyAccumulator());
122
+ if (primary === undefined && secondary === undefined) {
123
+ return null;
124
+ }
125
+ return {
126
+ ...(primary !== undefined ? { primary } : {}),
127
+ ...(secondary !== undefined ? { secondary } : {}),
128
+ };
129
+ }
130
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/parse.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import type { CapacityReading } from "../../health/capacity/types.js";
2
+ import type { CodexUsage, CodexWindow } from "./types.js";
3
+ export declare const CODEX_EVIDENCE = "x-codex headers";
4
+ /**
5
+ * The window whose exhaustion binds first: higher usage wins, ties → primary.
6
+ * Returns `undefined` only for a snapshot with no window at all.
7
+ */
8
+ export declare function bindingWindow(usage: CodexUsage): CodexWindow | undefined;
9
+ export declare function readingFromUsage(usage: CodexUsage, observedAt: number): CapacityReading;
10
+ //# sourceMappingURL=reading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/reading.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEzD,eAAO,MAAM,cAAc,oBAAoB,CAAA;AAM/C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAUxE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAuBvF"}
@@ -0,0 +1,45 @@
1
+ export const CODEX_EVIDENCE = "x-codex headers";
2
+ function hasReset(window) {
3
+ return window.resetAfterSeconds !== undefined || window.resetAtSeconds !== undefined;
4
+ }
5
+ /**
6
+ * The window whose exhaustion binds first: higher usage wins, ties → primary.
7
+ * Returns `undefined` only for a snapshot with no window at all.
8
+ */
9
+ export function bindingWindow(usage) {
10
+ const primary = usage.primary;
11
+ const secondary = usage.secondary;
12
+ if (primary === undefined) {
13
+ return secondary;
14
+ }
15
+ if (secondary === undefined) {
16
+ return primary;
17
+ }
18
+ return secondary.usedPercent > primary.usedPercent ? secondary : primary;
19
+ }
20
+ export function readingFromUsage(usage, observedAt) {
21
+ const window = bindingWindow(usage);
22
+ if (window === undefined) {
23
+ // No measured field — the capacity merge layer rejects this as noise.
24
+ return { confidence: "low", observedAt, evidence: CODEX_EVIDENCE };
25
+ }
26
+ const usedRatio = window.usedPercent / 100;
27
+ const remainingRatio = 1 - usedRatio;
28
+ let resetAt;
29
+ if (window.resetAfterSeconds !== undefined) {
30
+ resetAt = observedAt + window.resetAfterSeconds * 1000;
31
+ }
32
+ else if (window.resetAtSeconds !== undefined) {
33
+ resetAt = window.resetAtSeconds * 1000;
34
+ }
35
+ const confidence = hasReset(window) ? "high" : "medium";
36
+ return {
37
+ usedRatio,
38
+ remainingRatio,
39
+ ...(resetAt !== undefined ? { resetAt } : {}),
40
+ confidence,
41
+ observedAt,
42
+ evidence: CODEX_EVIDENCE,
43
+ };
44
+ }
45
+ //# sourceMappingURL=reading.js.map
@@ -0,0 +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,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAiB,EAAE,UAAkB;IACpE,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACnC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,sEAAsE;QACtE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;IACpE,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,GAAG,GAAG,CAAA;IAC1C,MAAM,cAAc,GAAG,CAAC,GAAG,SAAS,CAAA;IACpC,IAAI,OAA2B,CAAA;IAC/B,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAA;IACxD,CAAC;SAAM,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/C,OAAO,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;IACxC,CAAC;IACD,MAAM,UAAU,GAAe,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,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"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The passive-header `CapacitySensor` (ADP-020). Holds the latest validated
3
+ * header observation; `read()` converts it to a reading. No polling, no
4
+ * endpoint calls, no credential handling — WebSocket-backed providers bypass
5
+ * the HTTP hook entirely (verified limitation), so this sensor reports
6
+ * `null` (no estimate) whenever no trustworthy headers have been observed.
7
+ * An unparseable observation CLEARS the stored usage: present-but-invalid
8
+ * telemetry is distrust, and a stale quota estimate must never linger.
9
+ */
10
+ import type { ResourceKey } from "../../health/resource-health/types.js";
11
+ import type { CapacityReading, CapacitySensor } from "../../health/capacity/types.js";
12
+ export declare class CodexCapacitySensor implements CapacitySensor {
13
+ #private;
14
+ readonly id = "codex-headers";
15
+ readonly resource: ResourceKey;
16
+ constructor(resource: ResourceKey);
17
+ /**
18
+ * Record one captured-header observation. Unparseable telemetry clears the
19
+ * previous estimate instead of keeping it (present-but-invalid = distrust).
20
+ */
21
+ observe(captured: Readonly<Record<string, string>>, observedAt: number): void;
22
+ read(): Promise<CapacityReading | null>;
23
+ }
24
+ //# sourceMappingURL=sensor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensor.d.ts","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/sensor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAMrF,qBAAa,mBAAoB,YAAW,cAAc;;IACxD,QAAQ,CAAC,EAAE,mBAAkB;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;gBAIlB,QAAQ,EAAE,WAAW;IAIjC;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAO7E,IAAI,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;CAOxC"}
@@ -0,0 +1,30 @@
1
+ import { parseCodexUsage } from "./parse.js";
2
+ import { readingFromUsage } from "./reading.js";
3
+ import { CODEX_SENSOR_ID } from "./types.js";
4
+ export class CodexCapacitySensor {
5
+ id = CODEX_SENSOR_ID;
6
+ resource;
7
+ #usage = null;
8
+ #observedAt = 0;
9
+ constructor(resource) {
10
+ this.resource = resource;
11
+ }
12
+ /**
13
+ * Record one captured-header observation. Unparseable telemetry clears the
14
+ * previous estimate instead of keeping it (present-but-invalid = distrust).
15
+ */
16
+ observe(captured, observedAt) {
17
+ this.#usage = parseCodexUsage(captured);
18
+ if (this.#usage !== null) {
19
+ this.#observedAt = observedAt;
20
+ }
21
+ }
22
+ read() {
23
+ const usage = this.#usage;
24
+ if (usage === null) {
25
+ return Promise.resolve(null);
26
+ }
27
+ return Promise.resolve(readingFromUsage(usage, this.#observedAt));
28
+ }
29
+ }
30
+ //# sourceMappingURL=sensor.js.map
@@ -0,0 +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"}
@@ -0,0 +1,35 @@
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
+ */
15
+ import type { CapacityReading } from "../../health/capacity/types.js";
16
+ export declare const CODEX_SENSOR_ID = "codex-headers";
17
+ /** The telemetry windows Codex headers report. Primary is the 5h window. */
18
+ export declare const CODEX_WINDOW_KINDS: readonly ["primary", "secondary"];
19
+ export type CodexWindowKind = (typeof CODEX_WINDOW_KINDS)[number];
20
+ export interface CodexWindow {
21
+ /** Usage percentage in [0, 100] — the window exists only if this is valid. */
22
+ readonly usedPercent: number;
23
+ /** Validated finite non-negative seconds until reset, when reported. */
24
+ readonly resetAfterSeconds?: number | undefined;
25
+ /** Validated finite non-negative epoch-seconds reset timestamp, when reported. */
26
+ readonly resetAtSeconds?: number | undefined;
27
+ }
28
+ /** One validated header observation. `null` windows are simply absent. */
29
+ export interface CodexUsage {
30
+ readonly primary?: CodexWindow | undefined;
31
+ readonly secondary?: CodexWindow | undefined;
32
+ }
33
+ /** Extract a capacity reading for the binding (most-consumed) window. */
34
+ export type CodexReading = CapacityReading;
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/codex-capacity/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAErE,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,mCAAgE,CAAA;AAE/F,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjE,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/C,kFAAkF;IAClF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7C;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;CAC7C;AAED,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,eAAe,CAAA"}
@@ -0,0 +1,4 @@
1
+ export const CODEX_SENSOR_ID = "codex-headers";
2
+ /** The telemetry windows Codex headers report. Primary is the 5h window. */
3
+ export const CODEX_WINDOW_KINDS = ["primary", "secondary"];
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The typed escalation tool (T-18, ADP-015): the smallest Adaptive-owned
3
+ * mechanism for an agent to request stronger capability. The input schema is
4
+ * a plain JSON Schema — the host builds the model-facing tool definition by
5
+ * converting the schema, and a Standard Schema implementation is silently
6
+ * dropped ("Schema vendor does not support JSON Schema conversion", observed
7
+ * on 2.2.5). The tool also opts out of the host's code-mode bundling: with
8
+ * code mode enabled the host routes codemode-bundled tools through the
9
+ * `execute` tool only, and a direct call fails with "No tool named ... is
10
+ * currently available" (observed on 2.2.5). `execute` still re-validates
11
+ * defensively: model-produced JSON is untrusted. The tool is deliberately
12
+ * not a planning or task-management API.
13
+ */
14
+ import { ESCALATION_TOOL_NAME } from "../../execution/escalation/index.js";
15
+ export { ESCALATION_TOOL_NAME };
16
+ /** Records the request against the session's current work unit. */
17
+ export type EscalationRecorder = (sessionID: string, reason: string, evidence: string) => boolean;
18
+ /** The tool's input schema in JSON Schema form (host-convertible). */
19
+ declare const escalationInputSchema: {
20
+ type: string;
21
+ properties: {
22
+ reason: {
23
+ type: string;
24
+ minLength: number;
25
+ description: string;
26
+ };
27
+ evidence: {
28
+ type: string;
29
+ minLength: number;
30
+ description: string;
31
+ };
32
+ };
33
+ required: string[];
34
+ additionalProperties: boolean;
35
+ };
36
+ /** Keeps the tool directly callable when the host's code mode is enabled. */
37
+ declare const escalationToolOptions: {
38
+ readonly codemode: false;
39
+ };
40
+ /** Build the plugin tool registration for the escalation request surface. */
41
+ export declare function escalationTool(record: EscalationRecorder): {
42
+ name: typeof ESCALATION_TOOL_NAME;
43
+ description: string;
44
+ input: typeof escalationInputSchema;
45
+ options: typeof escalationToolOptions;
46
+ execute: (input: unknown, context: {
47
+ sessionID: string;
48
+ }) => Promise<{
49
+ content: string;
50
+ }>;
51
+ };
52
+ //# sourceMappingURL=escalation-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escalation-tool.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/escalation-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qCAAqC,CAAA;AAElG,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAE/B,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAA;AAQjG,sEAAsE;AACtE,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;CAgB1B,CAAA;AAED,6EAA6E;AAC7E,QAAA,MAAM,qBAAqB;;CAA+B,CAAA;AAE1D,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG;IAC1D,IAAI,EAAE,OAAO,oBAAoB,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,qBAAqB,CAAA;IACnC,OAAO,EAAE,OAAO,qBAAqB,CAAA;IACrC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC1F,CAmBA"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The typed escalation tool (T-18, ADP-015): the smallest Adaptive-owned
3
+ * mechanism for an agent to request stronger capability. The input schema is
4
+ * a plain JSON Schema — the host builds the model-facing tool definition by
5
+ * converting the schema, and a Standard Schema implementation is silently
6
+ * dropped ("Schema vendor does not support JSON Schema conversion", observed
7
+ * on 2.2.5). The tool also opts out of the host's code-mode bundling: with
8
+ * code mode enabled the host routes codemode-bundled tools through the
9
+ * `execute` tool only, and a direct call fails with "No tool named ... is
10
+ * currently available" (observed on 2.2.5). `execute` still re-validates
11
+ * defensively: model-produced JSON is untrusted. The tool is deliberately
12
+ * not a planning or task-management API.
13
+ */
14
+ import { ESCALATION_TOOL_NAME, parseEscalationRequest } from "../../execution/escalation/index.js";
15
+ export { ESCALATION_TOOL_NAME };
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.";
20
+ /** The tool's input schema in JSON Schema form (host-convertible). */
21
+ const escalationInputSchema = {
22
+ type: "object",
23
+ properties: {
24
+ reason: {
25
+ type: "string",
26
+ minLength: 1,
27
+ description: "Short reason why the current work unit needs stronger capability.",
28
+ },
29
+ evidence: {
30
+ type: "string",
31
+ minLength: 1,
32
+ description: "Concrete evidence of the capability gap: what failed or was blocked.",
33
+ },
34
+ },
35
+ required: ["reason", "evidence"],
36
+ additionalProperties: false,
37
+ };
38
+ /** Keeps the tool directly callable when the host's code mode is enabled. */
39
+ const escalationToolOptions = { codemode: false };
40
+ /** Build the plugin tool registration for the escalation request surface. */
41
+ export function escalationTool(record) {
42
+ return {
43
+ name: ESCALATION_TOOL_NAME,
44
+ description: TOOL_DESCRIPTION,
45
+ input: escalationInputSchema,
46
+ options: escalationToolOptions,
47
+ execute: (input, context) => {
48
+ const request = parseEscalationRequest(input);
49
+ if (request === undefined) {
50
+ return Promise.resolve({ content: "reason and evidence are required non-empty strings" });
51
+ }
52
+ const recorded = record(context.sessionID, request.reason, request.evidence);
53
+ return Promise.resolve(recorded
54
+ ? { content: "escalation request recorded for the current work unit" }
55
+ : { content: "no active work unit; the request was not recorded" });
56
+ },
57
+ };
58
+ }
59
+ //# sourceMappingURL=escalation-tool.js.map
@@ -0,0 +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;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"}