omnicell-router 0.8.4 → 0.10.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 (363) hide show
  1. package/README.md +26 -7
  2. package/README.zh-CN.md +18 -5
  3. package/backend/dist/capture/recorder.d.ts +4 -10
  4. package/backend/dist/capture/recorder.js +6 -58
  5. package/backend/dist/cli/clients/base.d.ts +36 -11
  6. package/backend/dist/cli/clients/base.js +31 -15
  7. package/backend/dist/cli/clients/claude.d.ts +9 -0
  8. package/backend/dist/cli/clients/claude.js +6 -0
  9. package/backend/dist/cli/clients/codex.d.ts +8 -0
  10. package/backend/dist/cli/clients/codex.js +5 -0
  11. package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
  12. package/backend/dist/cli/clients/core-adapters.js +1 -1
  13. package/backend/dist/cli/clients/dsh.d.ts +8 -0
  14. package/backend/dist/cli/clients/dsh.js +5 -0
  15. package/backend/dist/cli/clients/grok.d.ts +15 -1
  16. package/backend/dist/cli/clients/grok.js +16 -2
  17. package/backend/dist/cli/clients/index.d.ts +13 -1
  18. package/backend/dist/cli/clients/index.js +97 -19
  19. package/backend/dist/cli/clients/kimi.d.ts +6 -0
  20. package/backend/dist/cli/clients/kimi.js +3 -0
  21. package/backend/dist/cli/clients/launcher.d.ts +1 -1
  22. package/backend/dist/cli/clients/model-meta.js +6 -3
  23. package/backend/dist/cli/clients/omp.d.ts +6 -0
  24. package/backend/dist/cli/clients/omp.js +3 -0
  25. package/backend/dist/cli/clients/openclaw.d.ts +6 -0
  26. package/backend/dist/cli/clients/openclaw.js +3 -0
  27. package/backend/dist/cli/clients/opencode.d.ts +8 -0
  28. package/backend/dist/cli/clients/opencode.js +5 -0
  29. package/backend/dist/cli/clients/pi.d.ts +6 -0
  30. package/backend/dist/cli/clients/pi.js +3 -0
  31. package/backend/dist/cli/clients/update-check.d.ts +37 -0
  32. package/backend/dist/cli/clients/update-check.js +309 -0
  33. package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
  34. package/backend/dist/cli/clients/workbuddy.js +66 -0
  35. package/backend/dist/cli/index.js +5 -4
  36. package/backend/dist/cli/paths.js +8 -0
  37. package/backend/dist/cli/types.d.ts +92 -16
  38. package/backend/dist/config/comments-en.js +31 -26
  39. package/backend/dist/config/comments-zh.js +29 -24
  40. package/backend/dist/config/defaults.d.ts +194 -33
  41. package/backend/dist/config/defaults.js +193 -32
  42. package/backend/dist/config/env.d.ts +10 -0
  43. package/backend/dist/config/env.js +3 -2
  44. package/backend/dist/config/index.d.ts +7 -0
  45. package/backend/dist/config/index.js +184 -43
  46. package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
  47. package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
  48. package/backend/dist/config/migrations/v10-to-v11.js +43 -0
  49. package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
  50. package/backend/dist/config/migrations/v6-to-v7.js +97 -0
  51. package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
  52. package/backend/dist/config/migrations/v7-to-v8.js +43 -0
  53. package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
  54. package/backend/dist/config/migrations/v8-to-v9.js +43 -0
  55. package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
  56. package/backend/dist/config/migrations/v9-to-v10.js +71 -0
  57. package/backend/dist/config/runtime.js +1 -1
  58. package/backend/dist/config/schema.d.ts +3 -3
  59. package/backend/dist/config/schema.js +14 -4
  60. package/backend/dist/config/types.d.ts +167 -38
  61. package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
  62. package/backend/dist/egress-proxy/asset-download.js +420 -0
  63. package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
  64. package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
  65. package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
  66. package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
  67. package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
  68. package/backend/dist/egress-proxy/mihomo-client.js +308 -0
  69. package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
  70. package/backend/dist/egress-proxy/mihomo-config.js +161 -0
  71. package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
  72. package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
  73. package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
  74. package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
  75. package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
  76. package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
  77. package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
  78. package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
  79. package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
  80. package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
  81. package/backend/dist/forward-proxy/egress.d.ts +50 -11
  82. package/backend/dist/forward-proxy/egress.js +50 -17
  83. package/backend/dist/forward-proxy/h2-forward.js +36 -10
  84. package/backend/dist/forward-proxy/index.d.ts +11 -8
  85. package/backend/dist/forward-proxy/index.js +22 -60
  86. package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
  87. package/backend/dist/forward-proxy/interceptor.js +4 -4
  88. package/backend/dist/forward-proxy/relay.js +3 -3
  89. package/backend/dist/forward-proxy/rules.d.ts +4 -4
  90. package/backend/dist/forward-proxy/rules.js +25 -4
  91. package/backend/dist/forward-proxy/server.d.ts +0 -16
  92. package/backend/dist/forward-proxy/server.js +124 -156
  93. package/backend/dist/harness/host/hosts.js +3 -2
  94. package/backend/dist/index.js +53 -18
  95. package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
  96. package/backend/dist/ingress-proxy/access-log.js +774 -0
  97. package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
  98. package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
  99. package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
  100. package/backend/dist/ingress-proxy/ca-trust.js +315 -0
  101. package/backend/dist/ingress-proxy/ca.d.ts +104 -0
  102. package/backend/dist/ingress-proxy/ca.js +273 -0
  103. package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
  104. package/backend/dist/ingress-proxy/data-dir.js +45 -0
  105. package/backend/dist/ingress-proxy/egress.d.ts +151 -0
  106. package/backend/dist/ingress-proxy/egress.js +364 -0
  107. package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
  108. package/backend/dist/ingress-proxy/h2-forward.js +561 -0
  109. package/backend/dist/ingress-proxy/index.d.ts +24 -0
  110. package/backend/dist/ingress-proxy/index.js +144 -0
  111. package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
  112. package/backend/dist/ingress-proxy/interceptor.js +52 -0
  113. package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
  114. package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
  115. package/backend/dist/ingress-proxy/relay.d.ts +54 -0
  116. package/backend/dist/ingress-proxy/relay.js +188 -0
  117. package/backend/dist/ingress-proxy/rules.d.ts +195 -0
  118. package/backend/dist/ingress-proxy/rules.js +348 -0
  119. package/backend/dist/ingress-proxy/server.d.ts +153 -0
  120. package/backend/dist/ingress-proxy/server.js +2065 -0
  121. package/backend/dist/ingress-proxy/sni.d.ts +35 -0
  122. package/backend/dist/ingress-proxy/sni.js +124 -0
  123. package/backend/dist/ingress-proxy/status.d.ts +32 -0
  124. package/backend/dist/ingress-proxy/status.js +15 -0
  125. package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
  126. package/backend/dist/ingress-proxy/system-proxy.js +481 -0
  127. package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
  128. package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
  129. package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
  130. package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
  131. package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
  132. package/backend/dist/ingress-proxy/traffic-files.js +10 -0
  133. package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
  134. package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
  135. package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
  136. package/backend/dist/ingress-proxy/ws-frames.js +153 -0
  137. package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
  138. package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
  139. package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
  140. package/backend/dist/ir/adapters/google-gemini.js +5 -2
  141. package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
  142. package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
  143. package/backend/dist/ir/adapters/openai-chat.js +45 -3
  144. package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
  145. package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
  146. package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
  147. package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
  148. package/backend/dist/ir/adapters/openai-responses.d.ts +82 -24
  149. package/backend/dist/ir/adapters/openai-responses.js +146 -37
  150. package/backend/dist/ir/media.d.ts +20 -0
  151. package/backend/dist/ir/media.js +41 -0
  152. package/backend/dist/ir/tool-identity.d.ts +35 -0
  153. package/backend/dist/ir/tool-identity.js +40 -0
  154. package/backend/dist/ir/types.d.ts +9 -1
  155. package/backend/dist/local/build-jobs.d.ts +66 -0
  156. package/backend/dist/local/build-jobs.js +243 -0
  157. package/backend/dist/local/detect.d.ts +32 -0
  158. package/backend/dist/local/detect.js +145 -0
  159. package/backend/dist/local/draft-match.d.ts +58 -0
  160. package/backend/dist/local/draft-match.js +124 -0
  161. package/backend/dist/local/engine-runtime.d.ts +522 -0
  162. package/backend/dist/local/engine-runtime.js +1 -0
  163. package/backend/dist/local/engines.d.ts +241 -0
  164. package/backend/dist/local/engines.js +651 -0
  165. package/backend/dist/local/gguf.d.ts +35 -0
  166. package/backend/dist/local/gguf.js +314 -0
  167. package/backend/dist/local/hf.d.ts +120 -0
  168. package/backend/dist/local/hf.js +304 -0
  169. package/backend/dist/local/install.d.ts +90 -0
  170. package/backend/dist/local/install.js +421 -0
  171. package/backend/dist/local/llamacpp.d.ts +55 -0
  172. package/backend/dist/local/llamacpp.js +177 -0
  173. package/backend/dist/local/local-provider.d.ts +81 -0
  174. package/backend/dist/local/local-provider.js +301 -0
  175. package/backend/dist/local/machine-stats.d.ts +87 -0
  176. package/backend/dist/local/machine-stats.js +332 -0
  177. package/backend/dist/local/model-store.d.ts +347 -0
  178. package/backend/dist/local/model-store.js +1215 -0
  179. package/backend/dist/local/part-sweep.d.ts +32 -0
  180. package/backend/dist/local/part-sweep.js +156 -0
  181. package/backend/dist/local/plan.d.ts +65 -0
  182. package/backend/dist/local/plan.js +146 -0
  183. package/backend/dist/local/resources.d.ts +49 -0
  184. package/backend/dist/local/resources.js +64 -0
  185. package/backend/dist/local/run-stats.d.ts +95 -0
  186. package/backend/dist/local/run-stats.js +195 -0
  187. package/backend/dist/local/runner.d.ts +235 -0
  188. package/backend/dist/local/runner.js +1392 -0
  189. package/backend/dist/local/settings.d.ts +79 -0
  190. package/backend/dist/local/settings.js +180 -0
  191. package/backend/dist/local/strata-catalog.d.ts +30 -0
  192. package/backend/dist/local/strata-catalog.js +511 -0
  193. package/backend/dist/local/strata-drafting.d.ts +46 -0
  194. package/backend/dist/local/strata-drafting.js +265 -0
  195. package/backend/dist/local/strata.d.ts +278 -0
  196. package/backend/dist/local/strata.js +1392 -0
  197. package/backend/dist/local/tar.d.ts +20 -0
  198. package/backend/dist/local/tar.js +367 -0
  199. package/backend/dist/local/transport.d.ts +35 -0
  200. package/backend/dist/local/transport.js +89 -0
  201. package/backend/dist/local/tune.d.ts +58 -0
  202. package/backend/dist/local/tune.js +324 -0
  203. package/backend/dist/observability/http-exchange.d.ts +2 -2
  204. package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
  205. package/backend/dist/opencode/catalog/auto-pull.js +276 -70
  206. package/backend/dist/opencode/catalog/ocr-store.js +3 -1
  207. package/backend/dist/opencode/catalog/overrides-store.d.ts +10 -1
  208. package/backend/dist/opencode/catalog/overrides-store.js +6 -0
  209. package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
  210. package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
  211. package/backend/dist/opencode/catalog/repository.js +25 -2
  212. package/backend/dist/opencode/catalog/sources/models-dev.js +13 -3
  213. package/backend/dist/opencode/catalog/types.d.ts +35 -3
  214. package/backend/dist/opencode/catalog/types.js +38 -1
  215. package/backend/dist/opencode/credentials/ocr-store.js +11 -2
  216. package/backend/dist/opencode/credentials/sync.js +12 -3
  217. package/backend/dist/opencode/credentials/types.d.ts +31 -4
  218. package/backend/dist/opencode/credentials/types.js +25 -0
  219. package/backend/dist/opencode/probe.d.ts +21 -4
  220. package/backend/dist/opencode/probe.js +34 -10
  221. package/backend/dist/pipeline/directives.d.ts +9 -4
  222. package/backend/dist/pipeline/directives.js +14 -10
  223. package/backend/dist/pipeline/orchestrator.d.ts +42 -13
  224. package/backend/dist/pipeline/orchestrator.js +497 -165
  225. package/backend/dist/plugins/environment-ack.d.ts +51 -0
  226. package/backend/dist/plugins/environment-ack.js +81 -0
  227. package/backend/dist/plugins/gateways.d.ts +6 -6
  228. package/backend/dist/plugins/gateways.js +2 -2
  229. package/backend/dist/plugins/host.d.ts +98 -14
  230. package/backend/dist/plugins/host.js +622 -87
  231. package/backend/dist/plugins/install-run.d.ts +27 -0
  232. package/backend/dist/plugins/install-run.js +99 -0
  233. package/backend/dist/plugins/manifest.d.ts +84 -32
  234. package/backend/dist/plugins/manifest.js +149 -45
  235. package/backend/dist/plugins/market-install.d.ts +18 -0
  236. package/backend/dist/plugins/market-install.js +111 -0
  237. package/backend/dist/plugins/market-source.d.ts +100 -0
  238. package/backend/dist/plugins/market-source.js +449 -0
  239. package/backend/dist/plugins/market-updates.d.ts +70 -0
  240. package/backend/dist/plugins/market-updates.js +97 -0
  241. package/backend/dist/plugins/market.d.ts +677 -0
  242. package/backend/dist/plugins/market.js +2113 -0
  243. package/backend/dist/plugins/source-index.d.ts +155 -0
  244. package/backend/dist/plugins/source-index.js +217 -0
  245. package/backend/dist/plugins/types.d.ts +402 -37
  246. package/backend/dist/projects/worktrees.d.ts +88 -0
  247. package/backend/dist/projects/worktrees.js +220 -0
  248. package/backend/dist/providers/boot-direct.d.ts +41 -7
  249. package/backend/dist/providers/boot-direct.js +252 -36
  250. package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
  251. package/backend/dist/providers/executors/dispatch.d.ts +17 -7
  252. package/backend/dist/providers/executors/dispatch.js +28 -9
  253. package/backend/dist/providers/executors/openai-chat.js +14 -2
  254. package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
  255. package/backend/dist/providers/executors/plugin-adapter.js +59 -3
  256. package/backend/dist/providers/member-match.d.ts +32 -9
  257. package/backend/dist/providers/member-match.js +65 -21
  258. package/backend/dist/providers/model-resolution.d.ts +62 -0
  259. package/backend/dist/providers/model-resolution.js +62 -0
  260. package/backend/dist/providers/price-order.d.ts +51 -0
  261. package/backend/dist/providers/price-order.js +54 -0
  262. package/backend/dist/providers/provider-takedown.d.ts +5 -2
  263. package/backend/dist/providers/registry.d.ts +84 -25
  264. package/backend/dist/providers/registry.js +209 -114
  265. package/backend/dist/providers/selection.d.ts +91 -0
  266. package/backend/dist/providers/selection.js +158 -0
  267. package/backend/dist/providers/virtual-meta.d.ts +33 -2
  268. package/backend/dist/providers/virtual-meta.js +74 -18
  269. package/backend/dist/quota/cli-login.d.ts +25 -4
  270. package/backend/dist/quota/cli-login.js +35 -5
  271. package/backend/dist/quota/coverage-generation.d.ts +24 -0
  272. package/backend/dist/quota/coverage-generation.js +29 -0
  273. package/backend/dist/quota/declarations.js +8 -4
  274. package/backend/dist/quota/engine.js +2 -2
  275. package/backend/dist/quota/prober.d.ts +43 -2
  276. package/backend/dist/quota/prober.js +97 -22
  277. package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
  278. package/backend/dist/resilience/error-classifier.js +29 -0
  279. package/backend/dist/router/index.d.ts +1 -1
  280. package/backend/dist/router/index.js +17 -1
  281. package/backend/dist/router/layer2-decision.d.ts +1 -1
  282. package/backend/dist/router/layer2-decision.js +2 -2
  283. package/backend/dist/routes/console.js +928 -310
  284. package/backend/dist/routes/environments.js +1 -1
  285. package/backend/dist/routes/local-models.d.ts +2 -0
  286. package/backend/dist/routes/local-models.js +1414 -0
  287. package/backend/dist/routes/mihomo.d.ts +2 -2
  288. package/backend/dist/routes/mihomo.js +20 -11
  289. package/backend/dist/routes/projects.js +121 -0
  290. package/backend/dist/server.js +318 -13
  291. package/backend/dist/session/session-manager.d.ts +42 -5
  292. package/backend/dist/session/session-manager.js +64 -11
  293. package/backend/dist/session/session-row.d.ts +29 -8
  294. package/backend/dist/session/session-row.js +18 -13
  295. package/backend/dist/snapshot/bundle.d.ts +40 -0
  296. package/backend/dist/snapshot/bundle.js +177 -0
  297. package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
  298. package/backend/dist/snapshot/handoff/compress.js +77 -0
  299. package/backend/dist/snapshot/handoff/index.d.ts +119 -0
  300. package/backend/dist/snapshot/handoff/index.js +160 -0
  301. package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
  302. package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
  303. package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
  304. package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
  305. package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
  306. package/backend/dist/snapshot/handoff/summarize.js +118 -0
  307. package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
  308. package/backend/dist/snapshot/handoff/transcript.js +167 -0
  309. package/backend/dist/snapshot/media-fs.d.ts +10 -0
  310. package/backend/dist/snapshot/media-fs.js +50 -0
  311. package/backend/dist/snapshot/media.d.ts +32 -0
  312. package/backend/dist/snapshot/media.js +87 -0
  313. package/backend/dist/snapshot/store.d.ts +226 -0
  314. package/backend/dist/snapshot/store.js +887 -0
  315. package/backend/dist/snapshot/tree.d.ts +112 -0
  316. package/backend/dist/snapshot/tree.js +207 -0
  317. package/backend/dist/snapshot/types.d.ts +212 -0
  318. package/backend/dist/snapshot/types.js +14 -0
  319. package/backend/dist/snapshot/view.d.ts +19 -0
  320. package/backend/dist/snapshot/view.js +57 -0
  321. package/backend/dist/snapshot/write-worker.d.ts +67 -0
  322. package/backend/dist/snapshot/write-worker.js +129 -0
  323. package/backend/dist/surfaces/body-admission.d.ts +67 -2
  324. package/backend/dist/surfaces/body-admission.js +218 -13
  325. package/backend/dist/surfaces/chat-pipeline.js +8 -0
  326. package/backend/dist/surfaces/decision-pipeline.js +10 -7
  327. package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
  328. package/backend/dist/surfaces/gateway-catalog.js +202 -0
  329. package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
  330. package/backend/dist/surfaces/gateway-chat.js +50 -12
  331. package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
  332. package/backend/dist/surfaces/ocr-headers.js +11 -7
  333. package/backend/dist/surfaces/systemone.js +1 -1
  334. package/backend/dist/surfaces/transport-fastify.js +32 -5
  335. package/backend/dist/surfaces/transport-node-http.d.ts +9 -3
  336. package/backend/dist/surfaces/transport-node-http.js +6 -19
  337. package/backend/dist/surfaces/types.d.ts +11 -3
  338. package/backend/dist/trace/persist.js +21 -1
  339. package/backend/dist/trace/tracker.d.ts +35 -3
  340. package/backend/dist/trace/tracker.js +23 -0
  341. package/backend/dist/types/openai.d.ts +8 -0
  342. package/backend/dist/types/router.d.ts +17 -6
  343. package/backend/dist/types/router.js +14 -2
  344. package/backend/dist/utils/client-families.d.ts +66 -0
  345. package/backend/dist/utils/client-families.js +127 -0
  346. package/backend/dist/utils/event-ring.d.ts +1 -1
  347. package/backend/dist/utils/event-ring.js +1 -1
  348. package/backend/dist/utils/proxy-node.js +1 -1
  349. package/backend/dist/utils/proxy.d.ts +135 -11
  350. package/backend/dist/utils/proxy.js +144 -29
  351. package/backend/dist/utils/run-command.d.ts +21 -1
  352. package/backend/dist/utils/run-command.js +64 -4
  353. package/backend/dist/utils/server-liveness.d.ts +3 -2
  354. package/backend/dist/utils/server-liveness.js +3 -2
  355. package/backend/dist/utils/session-file.d.ts +28 -0
  356. package/backend/dist/utils/session-file.js +34 -0
  357. package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
  358. package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
  359. package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
  360. package/frontend/dist/assets/{index-KI1OW5x6.css → index-CqDSOPQ0.css} +1 -1
  361. package/frontend/dist/index.html +2 -2
  362. package/package.json +3 -1
  363. package/frontend/dist/assets/index-Dk76uc7e.js +0 -1522
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Primary-pick selection for tier pools and combos — ONE algorithm family, ONE
3
+ * vocabulary shared by both surfaces.
4
+ *
5
+ * Strategies (the industry-standard trio):
6
+ * - `priority` — the chain head (config/rule order, weight desc)
7
+ * serves; failover walks the rest of the chain.
8
+ * This is the failover axis, not a load-balancing
9
+ * algorithm.
10
+ * - `weighted_round_robin` — smooth WEIGHTED round-robin (SWRR): every member
11
+ * is served in proportion to its weight, with the
12
+ * turns spread evenly (this replaced the retired
13
+ * weighted-RANDOM draw).
14
+ * - `round_robin` — plain (sequential) round-robin: members take
15
+ * turns equally; weights are ignored.
16
+ *
17
+ * `weighted_round_robin` and `round_robin` run through the SAME smooth
18
+ * round-robin core; they differ only in the weight policy (declared share vs
19
+ * uniform 1). There is NO legacy spelling: a value that names none of the
20
+ * three strategies resolves to the default (`priority`).
21
+ */
22
+ /**
23
+ * Hard ceiling for a member weight. The smooth core accumulates credit in a JS
24
+ * number, so an unbounded value (`Infinity` from YAML `.inf` / `1e309`, or a
25
+ * float near the maximum added twice) overflows the accumulator to `Infinity`
26
+ * and then poisons the cursor with `NaN`. Clamping here keeps every weight
27
+ * finite while leaving realistic rotation shares untouched.
28
+ */
29
+ export const MAX_MEMBER_WEIGHT = 1_000_000;
30
+ /** Resolve a member weight: NaN and sub-1 values mean 1; a non-finite
31
+ * (Infinity from YAML `.inf` / `1e309`) or overflowing value is clamped to
32
+ * `MAX_MEMBER_WEIGHT` — the intent `as heavy as possible` stays honoured and
33
+ * the accumulator stays finite. */
34
+ export function normalizeMemberWeight(value) {
35
+ const n = Number(value);
36
+ if (Number.isNaN(n) || n < 1)
37
+ return 1;
38
+ return Math.min(n, MAX_MEMBER_WEIGHT);
39
+ }
40
+ /**
41
+ * Normalize a stored strategy value. The three known strategies pass through;
42
+ * everything else — absent, unknown, or the retired `weighted` spelling of the
43
+ * old weighted-RANDOM draw — falls back to the default `priority`.
44
+ */
45
+ export function normalizeSelectionStrategy(value) {
46
+ return value === 'weighted_round_robin' || value === 'round_robin' ? value : 'priority';
47
+ }
48
+ /** Plain-object guard for the config fragments this helper walks. */
49
+ function isPlainObject(value) {
50
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
51
+ }
52
+ /**
53
+ * Canonicalize every PRESENT `selection` value in a config-shaped container:
54
+ * `tiers.<tier>.selection` and `combos[].selection` (the runtime flat shape and
55
+ * the disk `routing.*` shape share this layout, so one walker serves both).
56
+ *
57
+ * Called at every config boundary — the runtime read (loadConfig), the visual
58
+ * save (saveConfig) and the raw-YAML save (saveRawConfig) — so runtime consumers
59
+ * only ever see one of the three strategies and no write path can persist an
60
+ * unknown or retired spelling.
61
+ *
62
+ * An ABSENT `selection` is left absent (it already means the default); only a
63
+ * present value is rewritten. `normalizeSelectionStrategy` owns the mapping —
64
+ * unknown / retired spellings become `priority`.
65
+ *
66
+ * @returns true when at least one value changed.
67
+ */
68
+ export function canonicalizeSelectionValues(container) {
69
+ if (!isPlainObject(container))
70
+ return false;
71
+ let changed = false;
72
+ const canonicalizeEntry = (entry) => {
73
+ if (!isPlainObject(entry) || !('selection' in entry))
74
+ return;
75
+ const canonical = normalizeSelectionStrategy(entry.selection);
76
+ if (entry.selection !== canonical) {
77
+ entry.selection = canonical;
78
+ changed = true;
79
+ }
80
+ };
81
+ const tiers = container.tiers;
82
+ if (isPlainObject(tiers)) {
83
+ for (const entry of Object.values(tiers))
84
+ canonicalizeEntry(entry);
85
+ }
86
+ const combos = container.combos;
87
+ if (Array.isArray(combos)) {
88
+ for (const entry of combos)
89
+ canonicalizeEntry(entry);
90
+ }
91
+ return changed;
92
+ }
93
+ /**
94
+ * Smooth round-robin core (the nginx SWRR algorithm), shared by tier pools and
95
+ * combos so both surfaces rotate identically.
96
+ *
97
+ * Each pick adds every member's weight to its running credit, serves the
98
+ * highest credit and debits the pool's total weight from it. With weighted
99
+ * members each is served exactly `weight` times per cycle, interleaved as
100
+ * evenly as the weights allow (weights 5:1:1 → a, a, b, a, c, a, a — a
101
+ * burst-free rotation); with uniform weights it degenerates to plain
102
+ * round-robin (a, b, c, a, …).
103
+ *
104
+ * O(n) time and O(n) state per pool: unlike the retired "expand each member
105
+ * into `weight` consecutive slots" table, a six-digit weight costs nothing and
106
+ * every pool read stays linear in the member count.
107
+ *
108
+ * State is scoped by a caller-chosen key (tier + strategy / combo id +
109
+ * strategy). A pool whose member sequence OR declared weights change starts a
110
+ * fresh vector on the next pick, so a stale credit vector can never steer a
111
+ * new composition — and a pool shrunk to one member resets here too (the
112
+ * recovered pool must not resume credit accumulated before the shrink).
113
+ */
114
+ export class WeightedRoundRobin {
115
+ state = new Map();
116
+ /**
117
+ * One draw over `entries`. `idOf` identifies a member (pool identity) and
118
+ * `weightOf` returns its rotation weight (values below 1 / non-numeric
119
+ * degrade to 1, a non-finite value clamps to MAX_MEMBER_WEIGHT — matching
120
+ * the config contract); pass `() => 1` for plain round-robin.
121
+ */
122
+ pick(key, entries, idOf, weightOf) {
123
+ if (entries.length === 0)
124
+ throw new Error('WeightedRoundRobin.pick: empty pool');
125
+ const ids = entries.map(idOf);
126
+ const weights = entries.map((entry) => normalizeMemberWeight(weightOf(entry)));
127
+ let cursor = this.state.get(key);
128
+ if (!cursor ||
129
+ cursor.ids.length !== ids.length ||
130
+ cursor.ids.some((id, i) => id !== ids[i]) ||
131
+ cursor.weights.some((w, i) => w !== weights[i])) {
132
+ cursor = { ids, weights, current: ids.map(() => 0) };
133
+ this.state.set(key, cursor);
134
+ }
135
+ // One member: its credit nets to zero every pick (add its weight, then
136
+ // debit the same total), so serve it without advancing the vector. The
137
+ // identity check above still reset a stale vector when the pool shrank.
138
+ if (entries.length === 1)
139
+ return entries[0];
140
+ let total = 0;
141
+ let best = 0;
142
+ for (let i = 0; i < entries.length; i++) {
143
+ cursor.current[i] += weights[i];
144
+ total += weights[i];
145
+ if (cursor.current[i] > cursor.current[best])
146
+ best = i;
147
+ }
148
+ cursor.current[best] -= total;
149
+ return entries[best];
150
+ }
151
+ /** Drop one pool's cursor (membership/order changed) or every cursor. */
152
+ reset(key) {
153
+ if (key === undefined)
154
+ this.state.clear();
155
+ else
156
+ this.state.delete(key);
157
+ }
158
+ }
@@ -8,8 +8,11 @@ import { type ModelPricing, type TierLevel } from '../types/router.js';
8
8
  * and the `/v1/models` `metadata` block. A virtual ref has no single physical
9
9
  * truth, but its member set bounds what every request can safely assume, so
10
10
  * the envelope claims LIMITS, never effort truth:
11
- * - compaction limits: MIN across members (any member overflowing breaks
12
- * the request — the safe answer for a failover chain);
11
+ * - compaction limits: for TIER aliases (`lite`/`plus`/`pro`/`ultra`) and
12
+ * `auto` the context window is the DECLARED rung window
13
+ * (`VIRTUAL_CONTEXT_WINDOWS`, ADR-0041) — a property of the rung, not a
14
+ * min over whatever members currently populate it; combos keep the safe
15
+ * MIN across members (any member overflowing breaks the request);
13
16
  * - image input: claimed only when EVERY member declares it (a
14
17
  * vision-incapable failover member would 400 the attachment);
15
18
  * - pricing: the chain-order LEADER (first member of the first tier in
@@ -42,6 +45,13 @@ export interface VirtualEnvelope {
42
45
  * models.dev-shaped capability block for ONE model record (snake_case, aligned
43
46
  * with https://models.opencode.ai/api.json). Fields absent from the record stay
44
47
  * absent — consumers treat missing as unknown, not false.
48
+ *
49
+ * An always-think model is projected onto the models.dev vocabulary the way
50
+ * models.dev itself would spell it: `effort` rows lose `none`, and a row that
51
+ * empties under the strip is dropped. A `toggle` row carried beside a table is
52
+ * dropped too — a toggle MEANS off is available, which is exactly the fact this
53
+ * model denies. With every level row dropped, `reasoning_options: []` is the
54
+ * honest "reasons, but no caller-visible level control".
45
55
  */
46
56
  export declare function modelsDevBlock(cat: CatalogModel): Record<string, unknown>;
47
57
  /**
@@ -53,6 +63,27 @@ export declare function modelsDevBlock(cat: CatalogModel): Record<string, unknow
53
63
  export declare function virtualModelsDevBlock(env: VirtualEnvelope): Record<string, unknown>;
54
64
  /** The tier ladder in escalation order — `auto` spans all of it. */
55
65
  export declare const TIER_LADDER: readonly TierLevel[];
66
+ /**
67
+ * Declared prompt windows for the virtual rows (ADR-0041).
68
+ *
69
+ * A tier's window is a property of the RUNG, not a min over whatever members
70
+ * currently populate it: membership is rule-driven and drifts with every
71
+ * config save, and a safe-min envelope made the advertised window change under
72
+ * clients that had already cached it (one small member collapsed every row to
73
+ * its window). The declared value is the CONTRACT every surface publishes —
74
+ * `/v1/models` `metadata.limit.context`, `/v1/catalog.json`, the plugin
75
+ * catalog capabilities and the Junie profile `maxContextLength`.
76
+ *
77
+ * A member whose real window is SMALLER than its rung's declared window is an
78
+ * operator configuration error (the console flags it on save); the gateway
79
+ * never silently truncates or rewrites the declaration, and an upstream
80
+ * overflow is relayed as the failure it is.
81
+ */
82
+ export declare const VIRTUAL_CONTEXT_WINDOWS: Record<TierLevel, number>;
83
+ /** `auto` may land on any rung, so its declared window is the smallest one. */
84
+ export declare const AUTO_CONTEXT_WINDOW: number;
85
+ /** Declared window for a tier alias or `auto`; undefined for any other id. */
86
+ export declare function virtualContextWindow(alias: string): number | undefined;
56
87
  /**
57
88
  * What each tier is FOR — a FUNCTION label, deliberately not a price or
58
89
  * capability ranking. The distinction matters: an ordering ("lite < plus <
@@ -1,25 +1,38 @@
1
+ import { catalogDisableable } from '../opencode/catalog/reasoning-declaration.js';
1
2
  import { EFFORT_LADDER } from '../types/router.js';
2
- /** Strip `none` from a published effort table when the vendor forbids
3
- * thinking-off (ADR-0035): the public catalog must advertise exactly what
4
- * routing will serve, never a level the gateway withholds. An effort option
5
- * that empties under the strip is dropped, not re-published. */
6
- function stripForbiddenNone(options, disableable) {
7
- if (disableable !== false)
8
- return options;
9
- return options
10
- .map((o) => (o.type === 'effort' && Array.isArray(o.values) ? { ...o, values: o.values.filter((v) => v !== 'none') } : o))
11
- .filter((o) => !(o.type === 'effort' && Array.isArray(o.values) && o.values.length === 0));
12
- }
13
3
  /**
14
4
  * models.dev-shaped capability block for ONE model record (snake_case, aligned
15
5
  * with https://models.opencode.ai/api.json). Fields absent from the record stay
16
6
  * absent — consumers treat missing as unknown, not false.
7
+ *
8
+ * An always-think model is projected onto the models.dev vocabulary the way
9
+ * models.dev itself would spell it: `effort` rows lose `none`, and a row that
10
+ * empties under the strip is dropped. A `toggle` row carried beside a table is
11
+ * dropped too — a toggle MEANS off is available, which is exactly the fact this
12
+ * model denies. With every level row dropped, `reasoning_options: []` is the
13
+ * honest "reasons, but no caller-visible level control".
17
14
  */
18
15
  export function modelsDevBlock(cat) {
16
+ // Derive the always-think fact exactly as routing does — the normalizer never
17
+ // sets `reasoningDisableable`, so reading the field alone left the PUBLISHED
18
+ // block advertising `none` on a no-`none` table while routing omitted it.
19
+ const alwaysThinks = (cat.reasoningDisableable ?? catalogDisableable(cat)) === false;
20
+ // Off allowed / not stated: the declaration is published verbatim. Always-think:
21
+ // drop the `toggle` (it asserts off) and strip `none` from every effort row,
22
+ // dropping a row that empties — `reasoning_options: []` is then the honest
23
+ // "reasons, no caller-visible level control".
24
+ const projected = cat.reasoningOptions
25
+ ? alwaysThinks
26
+ ? cat.reasoningOptions
27
+ .filter((o) => o.type !== 'toggle')
28
+ .map((o) => (o.type === 'effort' && Array.isArray(o.values) ? { ...o, values: o.values.filter((v) => v !== 'none') } : o))
29
+ .filter((o) => !(o.type === 'effort' && Array.isArray(o.values) && o.values.length === 0))
30
+ : cat.reasoningOptions
31
+ : undefined;
19
32
  return {
20
33
  ...(cat.attachment !== undefined ? { attachment: cat.attachment } : {}),
21
34
  ...(cat.reasoning !== undefined ? { reasoning: cat.reasoning } : {}),
22
- ...(cat.reasoningOptions ? { reasoning_options: stripForbiddenNone(cat.reasoningOptions, cat.reasoningDisableable) } : {}),
35
+ ...(projected !== undefined ? { reasoning_options: projected } : {}),
23
36
  ...(cat.tool_call !== undefined ? { tool_call: cat.tool_call } : {}),
24
37
  ...(cat.temperature !== undefined ? { temperature: cat.temperature } : {}),
25
38
  ...(cat.structured_output !== undefined ? { structured_output: cat.structured_output } : {}),
@@ -51,6 +64,36 @@ export function virtualModelsDevBlock(env) {
51
64
  }
52
65
  /** The tier ladder in escalation order — `auto` spans all of it. */
53
66
  export const TIER_LADDER = ['lite', 'plus', 'pro', 'ultra'];
67
+ /**
68
+ * Declared prompt windows for the virtual rows (ADR-0041).
69
+ *
70
+ * A tier's window is a property of the RUNG, not a min over whatever members
71
+ * currently populate it: membership is rule-driven and drifts with every
72
+ * config save, and a safe-min envelope made the advertised window change under
73
+ * clients that had already cached it (one small member collapsed every row to
74
+ * its window). The declared value is the CONTRACT every surface publishes —
75
+ * `/v1/models` `metadata.limit.context`, `/v1/catalog.json`, the plugin
76
+ * catalog capabilities and the Junie profile `maxContextLength`.
77
+ *
78
+ * A member whose real window is SMALLER than its rung's declared window is an
79
+ * operator configuration error (the console flags it on save); the gateway
80
+ * never silently truncates or rewrites the declaration, and an upstream
81
+ * overflow is relayed as the failure it is.
82
+ */
83
+ export const VIRTUAL_CONTEXT_WINDOWS = {
84
+ lite: 128_000,
85
+ plus: 200_000,
86
+ pro: 400_000,
87
+ ultra: 1_000_000,
88
+ };
89
+ /** `auto` may land on any rung, so its declared window is the smallest one. */
90
+ export const AUTO_CONTEXT_WINDOW = Math.min(...TIER_LADDER.map((tier) => VIRTUAL_CONTEXT_WINDOWS[tier]));
91
+ /** Declared window for a tier alias or `auto`; undefined for any other id. */
92
+ export function virtualContextWindow(alias) {
93
+ if (alias === 'auto')
94
+ return AUTO_CONTEXT_WINDOW;
95
+ return VIRTUAL_CONTEXT_WINDOWS[alias];
96
+ }
54
97
  /**
55
98
  * What each tier is FOR — a FUNCTION label, deliberately not a price or
56
99
  * capability ranking. The distinction matters: an ordering ("lite < plus <
@@ -89,8 +132,10 @@ export function pricingFromCost(cost) {
89
132
  ...(cost.cache_write !== undefined ? { cacheWrite: cost.cache_write } : {}),
90
133
  };
91
134
  }
92
- /** Common math: safe-min limits, intersection image, leader pricing/name. */
93
- function envelopeOf(memberCats, leaderCat, leaderPricing, fallbackCount) {
135
+ /** Common math: safe-min limits, intersection image, leader pricing/name.
136
+ * `declaredContextWindow` overrides the safe-min context for refs whose
137
+ * window is a declaration (tier aliases / `auto`, ADR-0041). */
138
+ function envelopeOf(memberCats, leaderCat, leaderPricing, fallbackCount, declaredContextWindow) {
94
139
  const contexts = memberCats.map((c) => c.limit?.context).filter((n) => typeof n === 'number' && n > 0);
95
140
  const outputs = memberCats.map((c) => c.limit?.output).filter((n) => typeof n === 'number' && n > 0);
96
141
  const allImage = memberCats.length > 0 && memberCats.every((c) => Array.isArray(c.modalities?.input) && c.modalities.input.includes('image'));
@@ -102,7 +147,11 @@ function envelopeOf(memberCats, leaderCat, leaderPricing, fallbackCount) {
102
147
  const pricing = leaderPricing ?? pricingFromCost(leaderCat?.cost);
103
148
  return {
104
149
  memberCount: fallbackCount,
105
- ...(contexts.length > 0 ? { contextWindow: Math.min(...contexts) } : {}),
150
+ ...(declaredContextWindow
151
+ ? { contextWindow: declaredContextWindow }
152
+ : contexts.length > 0
153
+ ? { contextWindow: Math.min(...contexts) }
154
+ : {}),
106
155
  ...(outputs.length > 0 ? { maxTokens: Math.min(...outputs) } : {}),
107
156
  ...(allImage ? { imageInput: true } : {}),
108
157
  ...(all((c) => c.tool_call) ? { toolCall: true } : {}),
@@ -180,13 +229,20 @@ export async function tierAliasEnvelope(registry, listCatalog, alias) {
180
229
  if (alias !== 'auto')
181
230
  break;
182
231
  }
183
- if (memberIds.length === 0)
184
- return { memberCount: 0 };
232
+ // A rung with no resolvable members is still ADVERTISED as a row by every
233
+ // surface (`/v1/models` lists it unconditionally), so its declared window
234
+ // must not vanish with the membership: the window is a property of the rung
235
+ // (ADR-0041), and a client caching an empty rung would otherwise see the
236
+ // contract change the moment a member joins.
237
+ const declared = virtualContextWindow(alias);
238
+ if (memberIds.length === 0) {
239
+ return { memberCount: 0, ...(declared ? { contextWindow: declared } : {}) };
240
+ }
185
241
  // A model may join several tiers (ADR-0003 §2) — dedupe so memberCount and
186
242
  // the catalog lookup see each member once.
187
243
  const uniqueMemberIds = [...new Set(memberIds)];
188
244
  const { records, lookup } = await findMemberCatalogRecords(uniqueMemberIds, listCatalog);
189
- return envelopeOf(records, lookup(uniqueMemberIds[0]), leaderPricing, uniqueMemberIds.length);
245
+ return envelopeOf(records, lookup(uniqueMemberIds[0]), leaderPricing, uniqueMemberIds.length, declared);
190
246
  }
191
247
  /**
192
248
  * Envelope for a combo: members are the FIXED config list (no rule drift —
@@ -1,8 +1,29 @@
1
1
  /**
2
- * One quota pair for a provider whose plugin owns login (`authTypes: ['none']`).
3
- * There is no OCR key to hash. The prefix is the pair identity the console
4
- * translates as the machine CLI login.
2
+ * One quota pair for a provider whose plugin owns login (`authTypes` containing
3
+ * `none`). There is no OCR key to hash, so the pair identity is this fixed prefix —
4
+ * the console renders it as the machine CLI login. The same account is emitted only
5
+ * once: a stored machine-login row (`MACHINE_LOGIN_VALUE`) is filtered out of the
6
+ * credential list before pairing rather than becoming a second row.
5
7
  */
6
8
  export declare const CLI_LOGIN_QUOTA_PREFIX = "cli-login";
7
- /** True when the provider's model-service plugin refuses an OCR credential. */
9
+ /**
10
+ * True when the provider's model-service plugin REFUSES an OCR credential (it
11
+ * declares only `none`). The broader sibling is
12
+ * `providerMayUseLocalLogin` (wire-first) / `plugins/host.ts#providerRunsCredentialless`
13
+ * (preset-scoped) — "may also run with no key" — which is the predicate a plugin
14
+ * with two doors satisfies; this one stays the "a stored key means nothing here"
15
+ * question.
16
+ */
8
17
  export declare function providerUsesCliLogin(providerId: string): boolean;
18
+ /**
19
+ * `none` is among the declared methods of whichever plugin serves this provider
20
+ * — the WIRE-FIRST form of `pluginRunsCredentialless`.
21
+ *
22
+ * The preset-only lookup in `plugins/host.ts` cannot see a hand-authored def
23
+ * that names a plugin wire without being one of that plugin's presets, and the
24
+ * two answers only differ there (a console-created provider is a preset, so both
25
+ * resolve to the same plugin). The quota layer and the console's pair rows use
26
+ * this one: a two-door provider's machine login is a real account that no stored
27
+ * key accounts for, so dropping it would hide the row the operator is spending.
28
+ */
29
+ export declare function providerMayUseLocalLogin(providerId: string): boolean;
@@ -1,14 +1,23 @@
1
- import { getModelServicePlugin, pluginDeclinesCredentials } from '../plugins/host.js';
1
+ import { getModelServicePlugin, pluginDeclinesCredentials, pluginRunsCredentialless, providerRunsCredentialless } from '../plugins/host.js';
2
2
  import { wireFor } from '../providers/wire.js';
3
3
  import { primaryProtocol, normalizeProtocols } from '../providers/protocols-field.js';
4
4
  import { getProviderNodeById } from '../opencode/user-config.js';
5
5
  /**
6
- * One quota pair for a provider whose plugin owns login (`authTypes: ['none']`).
7
- * There is no OCR key to hash. The prefix is the pair identity the console
8
- * translates as the machine CLI login.
6
+ * One quota pair for a provider whose plugin owns login (`authTypes` containing
7
+ * `none`). There is no OCR key to hash, so the pair identity is this fixed prefix —
8
+ * the console renders it as the machine CLI login. The same account is emitted only
9
+ * once: a stored machine-login row (`MACHINE_LOGIN_VALUE`) is filtered out of the
10
+ * credential list before pairing rather than becoming a second row.
9
11
  */
10
12
  export const CLI_LOGIN_QUOTA_PREFIX = 'cli-login';
11
- /** True when the provider's model-service plugin refuses an OCR credential. */
13
+ /**
14
+ * True when the provider's model-service plugin REFUSES an OCR credential (it
15
+ * declares only `none`). The broader sibling is
16
+ * `providerMayUseLocalLogin` (wire-first) / `plugins/host.ts#providerRunsCredentialless`
17
+ * (preset-scoped) — "may also run with no key" — which is the predicate a plugin
18
+ * with two doors satisfies; this one stays the "a stored key means nothing here"
19
+ * question.
20
+ */
12
21
  export function providerUsesCliLogin(providerId) {
13
22
  const def = getProviderNodeById(providerId);
14
23
  const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
@@ -18,3 +27,24 @@ export function providerUsesCliLogin(providerId) {
18
27
  const base = typeof options?.baseURL === 'string' ? options.baseURL : typeof settings?.baseURL === 'string' ? settings.baseURL : undefined;
19
28
  return pluginDeclinesCredentials(getModelServicePlugin(wireFor(npm, base)));
20
29
  }
30
+ /**
31
+ * `none` is among the declared methods of whichever plugin serves this provider
32
+ * — the WIRE-FIRST form of `pluginRunsCredentialless`.
33
+ *
34
+ * The preset-only lookup in `plugins/host.ts` cannot see a hand-authored def
35
+ * that names a plugin wire without being one of that plugin's presets, and the
36
+ * two answers only differ there (a console-created provider is a preset, so both
37
+ * resolve to the same plugin). The quota layer and the console's pair rows use
38
+ * this one: a two-door provider's machine login is a real account that no stored
39
+ * key accounts for, so dropping it would hide the row the operator is spending.
40
+ */
41
+ export function providerMayUseLocalLogin(providerId) {
42
+ const def = getProviderNodeById(providerId);
43
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
44
+ const npm = protocols.length > 0 ? primaryProtocol(protocols) : undefined;
45
+ const options = def?.options;
46
+ const settings = def?.settings;
47
+ const base = typeof options?.baseURL === 'string' ? options.baseURL : typeof settings?.baseURL === 'string' ? settings.baseURL : undefined;
48
+ const plugin = getModelServicePlugin(wireFor(npm, base));
49
+ return plugin ? pluginRunsCredentialless(plugin) : providerRunsCredentialless(providerId);
50
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Coverage-generation signal (ADR-0009 §5): the EFFECTIVE quota plan is
3
+ * derived from two mutable universes that keep changing long after boot — the
4
+ * set of LOADED model-service plugins (each may declare `quotaCheck`) and the
5
+ * provider-defs map that resolves a provider id to a wire. Both commit at
6
+ * their own atomic swap points.
7
+ *
8
+ * A plan computed once at construction therefore keeps probing the universe it
9
+ * was born into: a plugin installed, reloaded, or enabled inside the running
10
+ * process never gains coverage, and the console renders its provider as
11
+ * uncovered — no quota row at all, right beside a healthy connection (the
12
+ * production case was a boot-time engine-refused plugin whose contract-matching
13
+ * replacement landed in-process seconds later).
14
+ *
15
+ * So the plan is rebuilt LAZILY, the first time it is read after one of those
16
+ * commit points bumped this counter. Same direction as `claimPluginWires`: the
17
+ * producers PUSH, consumers ASK. Deliberately a leaf module with no imports, so
18
+ * the plugin host and the pool builder can bump it without pulling the quota
19
+ * engine (or anything it imports) into their own load graph.
20
+ */
21
+ /** Record that quota coverage inputs changed (plugin registry or provider defs). */
22
+ export declare function noteQuotaCoverageInputsChanged(): void;
23
+ /** Monotonic stamp a cached plan compares itself against. */
24
+ export declare function quotaCoverageGeneration(): number;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Coverage-generation signal (ADR-0009 §5): the EFFECTIVE quota plan is
3
+ * derived from two mutable universes that keep changing long after boot — the
4
+ * set of LOADED model-service plugins (each may declare `quotaCheck`) and the
5
+ * provider-defs map that resolves a provider id to a wire. Both commit at
6
+ * their own atomic swap points.
7
+ *
8
+ * A plan computed once at construction therefore keeps probing the universe it
9
+ * was born into: a plugin installed, reloaded, or enabled inside the running
10
+ * process never gains coverage, and the console renders its provider as
11
+ * uncovered — no quota row at all, right beside a healthy connection (the
12
+ * production case was a boot-time engine-refused plugin whose contract-matching
13
+ * replacement landed in-process seconds later).
14
+ *
15
+ * So the plan is rebuilt LAZILY, the first time it is read after one of those
16
+ * commit points bumped this counter. Same direction as `claimPluginWires`: the
17
+ * producers PUSH, consumers ASK. Deliberately a leaf module with no imports, so
18
+ * the plugin host and the pool builder can bump it without pulling the quota
19
+ * engine (or anything it imports) into their own load graph.
20
+ */
21
+ let generation = 0;
22
+ /** Record that quota coverage inputs changed (plugin registry or provider defs). */
23
+ export function noteQuotaCoverageInputsChanged() {
24
+ generation += 1;
25
+ }
26
+ /** Monotonic stamp a cached plan compares itself against. */
27
+ export function quotaCoverageGeneration() {
28
+ return generation;
29
+ }
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS } from '../config/defaults.js';
1
2
  /**
2
3
  * Built-in declaration table (L-b) — ships with the release, keyed by the OCR
3
4
  * CATALOG provider id (never another project's id namespace). Coverage here is
@@ -37,6 +38,9 @@ export const BUILTIN_QUOTA_DECLARATIONS = [
37
38
  total: { firstOf: [{ path: 'total_balance' }, { path: 'totalBalance' }] },
38
39
  },
39
40
  },
41
+ // Credit/balance pool — volatile with spend, but upstream balance endpoints
42
+ // are cost-sensitive, so it refreshes on the shorter balance cadence.
43
+ cacheTtlMs: DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS,
40
44
  builtin: true,
41
45
  },
42
46
  {
@@ -58,7 +62,7 @@ export const BUILTIN_QUOTA_DECLARATIONS = [
58
62
  },
59
63
  ],
60
64
  },
61
- cacheTtlMs: 15 * 60_000,
65
+ cacheTtlMs: DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS,
62
66
  builtin: true,
63
67
  },
64
68
  {
@@ -81,7 +85,7 @@ export const BUILTIN_QUOTA_DECLARATIONS = [
81
85
  },
82
86
  ],
83
87
  },
84
- cacheTtlMs: 15 * 60_000,
88
+ cacheTtlMs: DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS,
85
89
  builtin: true,
86
90
  },
87
91
  {
@@ -290,7 +294,7 @@ export const BUILTIN_QUOTA_DECLARATIONS = [
290
294
  },
291
295
  ],
292
296
  },
293
- cacheTtlMs: 15 * 60_000,
297
+ cacheTtlMs: DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS,
294
298
  builtin: true,
295
299
  },
296
300
  {
@@ -311,7 +315,7 @@ export const BUILTIN_QUOTA_DECLARATIONS = [
311
315
  },
312
316
  ],
313
317
  },
314
- cacheTtlMs: 15 * 60_000,
318
+ cacheTtlMs: DEFAULT_QUOTA_BALANCE_CACHE_TTL_MS,
315
319
  builtin: true,
316
320
  },
317
321
  ];
@@ -1,4 +1,4 @@
1
- import { DEFAULT_QUOTA_PROBE_TIMEOUT_MS } from '../config/defaults.js';
1
+ import { DEFAULT_QUOTA_CACHE_TTL_MS, DEFAULT_QUOTA_PROBE_TIMEOUT_MS } from '../config/defaults.js';
2
2
  import { BUILTIN_QUOTA_DECLARATIONS, builtinAdapters } from './declarations.js';
3
3
  import { evalSuccessIf, resolveWindows, validateEntry } from './dsl.js';
4
4
  import { captureBody, resolveVerdict, upstreamCode } from './verdict.js';
@@ -21,7 +21,7 @@ export const QUOTA_TTL_MIN_MS = 60_000;
21
21
  export const QUOTA_TTL_MAX_MS = 24 * 3_600_000;
22
22
  export function clampTtl(ttl) {
23
23
  if (ttl === undefined || !Number.isFinite(ttl))
24
- return 15 * 60_000;
24
+ return DEFAULT_QUOTA_CACHE_TTL_MS;
25
25
  return Math.max(QUOTA_TTL_MIN_MS, Math.min(QUOTA_TTL_MAX_MS, ttl));
26
26
  }
27
27
  /** Display cap for the memory-only last-probe capture: bodies above this many
@@ -53,10 +53,15 @@ export interface QuotaRegistryView {
53
53
  key: string;
54
54
  }[];
55
55
  /**
56
- * The plugin owns login and stores no OCR key (`authTypes: ['none']`).
57
- * Quota still activates: one pair, the machine CLI login.
56
+ * `'none'` is among the plugin's declared methods: this provider may run on the
57
+ * login the plugin owns, so quota carries a machine-login row — beside the OCR
58
+ * keys when the plugin also declares a key door, in place of them when it does
59
+ * not. See `credentiallessOnly`.
58
60
  */
59
61
  credentialless?(name: string): boolean;
62
+ /** The plugin declares ONLY `none` — a stored OCR key means nothing to it, so
63
+ * the machine-login row is that provider's only quota row. */
64
+ credentiallessOnly?(name: string): boolean;
60
65
  }
61
66
  /** Outcome of one manual refresh (the console button). */
62
67
  export interface QuotaRefreshReport {
@@ -71,6 +76,12 @@ export interface QuotaRefreshReport {
71
76
  /** Another cycle (timer tick or a second refresh) held the slot past the
72
77
  * request budget — nothing was probed, the answer is honest, not a hang. */
73
78
  busy: boolean;
79
+ /** A refresh for this scope already ran inside the cooldown window: nothing
80
+ * was probed and the stored snapshot is as fresh as a repeat would make it.
81
+ * Present only when true (an ordinary report omits the key). */
82
+ cooldown?: boolean;
83
+ /** When the cooldown expires (epoch ms), rides with `cooldown`. */
84
+ nextAllowedAt?: number;
74
85
  }
75
86
  export interface QuotaProberDeps {
76
87
  registry: QuotaRegistryView;
@@ -94,15 +105,37 @@ export declare class QuotaProber {
94
105
  /** The one in-flight cycle — the timer tick and a manual refresh share it. */
95
106
  private current;
96
107
  private plan;
108
+ /** Coverage-input stamp the cached plan was built from (see `currentPlan`). */
109
+ private planGeneration;
97
110
  /** Pair key (`provider#prefix`) -> scheduling state. */
98
111
  private state;
99
112
  /** ENGINE-LEVEL 429 gate (global — scheduling is engine-level logic). */
100
113
  private rateLimitedUntilMs;
101
114
  private rateLimitStreak;
115
+ /** Scope key (`*` or `provider#prefix`) -> epoch ms a manual refresh is next
116
+ * allowed. Cleared by `resetScheduling` (tests / config reload storms). */
117
+ private readonly refreshCooldownUntil;
102
118
  constructor(deps: QuotaProberDeps);
103
119
  /** Rebuild the effective entry set (boot + every config save hot path). */
104
120
  reloadConfig(): void;
105
121
  private buildPlan;
122
+ /**
123
+ * The plan, rebuilt on first read after a coverage-input commit.
124
+ *
125
+ * The effective plan is a JOIN of three mutable universes (built-in table,
126
+ * operator config, loaded plugins + the provider defs that resolve a
127
+ * provider id to a wire), and the last two keep changing after boot: a
128
+ * plugin installed / reloaded / enabled in-process, or a provider-def
129
+ * mutation, commits a new universe. `reloadConfig` cannot be the only
130
+ * rebuild point for those — it is called by the config-save seams, which
131
+ * know nothing about a plugin swap — so the commit points PUSH a generation
132
+ * stamp (`quota/coverage-generation.ts`) and the readers below rebuild here.
133
+ *
134
+ * Lazy on purpose: a rebuild runs per console read / per tick, never from
135
+ * the middle of a plugin registry swap (an in-flight probe would otherwise
136
+ * observe a half-committed plugin set).
137
+ */
138
+ private currentPlan;
106
139
  /**
107
140
  * Entries rejected at load (validation failures) — console surfaces them.
108
141
  */
@@ -166,6 +199,14 @@ export declare class QuotaProber {
166
199
  * stay due for the next tick. The 429 rule still wins — an armed global gate
167
200
  * refuses the cycle, and a mid-cycle 429 stops it instead of hammering
168
201
  * shared quota endpoints.
202
+ *
203
+ * Cooldown: a scope that WAS probed by a manual refresh inside
204
+ * `MANUAL_REFRESH_COOLDOWN_MS` answers `cooldown` from the snapshot instead of
205
+ * probing again. Without it the button is an unbounded upstream poller (a
206
+ * script or a stuck click loop would call every pair at request speed);
207
+ * with it, the only way to exceed the tick's own cadence is at most one extra
208
+ * cycle per window. A `disabled`/`rateLimited`/`busy` answer never arms the
209
+ * cooldown, because nothing was probed.
169
210
  */
170
211
  refreshNow(opts?: {
171
212
  providerId?: string;