omnicell-router 0.8.2 → 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 (400) hide show
  1. package/README.md +26 -7
  2. package/README.zh-CN.md +18 -5
  3. package/backend/dist/auth/api-keys.js +11 -0
  4. package/backend/dist/auth/key-models.d.ts +36 -0
  5. package/backend/dist/auth/key-models.js +99 -0
  6. package/backend/dist/capture/recorder.d.ts +4 -10
  7. package/backend/dist/capture/recorder.js +6 -58
  8. package/backend/dist/cli/clients/activity.js +2 -0
  9. package/backend/dist/cli/clients/base.d.ts +36 -11
  10. package/backend/dist/cli/clients/base.js +31 -15
  11. package/backend/dist/cli/clients/claude.d.ts +9 -0
  12. package/backend/dist/cli/clients/claude.js +6 -0
  13. package/backend/dist/cli/clients/codex.d.ts +78 -0
  14. package/backend/dist/cli/clients/codex.js +475 -57
  15. package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
  16. package/backend/dist/cli/clients/core-adapters.js +1 -1
  17. package/backend/dist/cli/clients/dsh.d.ts +8 -0
  18. package/backend/dist/cli/clients/dsh.js +5 -0
  19. package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
  20. package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
  21. package/backend/dist/cli/clients/grok.d.ts +15 -1
  22. package/backend/dist/cli/clients/grok.js +16 -2
  23. package/backend/dist/cli/clients/index.d.ts +13 -1
  24. package/backend/dist/cli/clients/index.js +97 -19
  25. package/backend/dist/cli/clients/kimi.d.ts +6 -0
  26. package/backend/dist/cli/clients/kimi.js +3 -0
  27. package/backend/dist/cli/clients/launcher.d.ts +1 -1
  28. package/backend/dist/cli/clients/model-meta.js +6 -3
  29. package/backend/dist/cli/clients/omp.d.ts +6 -0
  30. package/backend/dist/cli/clients/omp.js +3 -0
  31. package/backend/dist/cli/clients/openclaw.d.ts +6 -0
  32. package/backend/dist/cli/clients/openclaw.js +3 -0
  33. package/backend/dist/cli/clients/opencode.d.ts +8 -0
  34. package/backend/dist/cli/clients/opencode.js +8 -2
  35. package/backend/dist/cli/clients/pi.d.ts +6 -0
  36. package/backend/dist/cli/clients/pi.js +3 -0
  37. package/backend/dist/cli/clients/reserved.js +2 -0
  38. package/backend/dist/cli/clients/update-check.d.ts +37 -0
  39. package/backend/dist/cli/clients/update-check.js +309 -0
  40. package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
  41. package/backend/dist/cli/clients/workbuddy.js +66 -0
  42. package/backend/dist/cli/index.js +5 -4
  43. package/backend/dist/cli/paths.js +8 -0
  44. package/backend/dist/cli/types.d.ts +101 -16
  45. package/backend/dist/config/comments-en.js +34 -25
  46. package/backend/dist/config/comments-zh.js +33 -24
  47. package/backend/dist/config/defaults.d.ts +280 -22
  48. package/backend/dist/config/defaults.js +279 -21
  49. package/backend/dist/config/env.d.ts +10 -0
  50. package/backend/dist/config/env.js +3 -2
  51. package/backend/dist/config/index.d.ts +22 -1
  52. package/backend/dist/config/index.js +218 -43
  53. package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
  54. package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
  55. package/backend/dist/config/migrations/v10-to-v11.js +43 -0
  56. package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
  57. package/backend/dist/config/migrations/v4-to-v5.js +42 -0
  58. package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
  59. package/backend/dist/config/migrations/v5-to-v6.js +29 -0
  60. package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
  61. package/backend/dist/config/migrations/v6-to-v7.js +97 -0
  62. package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
  63. package/backend/dist/config/migrations/v7-to-v8.js +43 -0
  64. package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
  65. package/backend/dist/config/migrations/v8-to-v9.js +43 -0
  66. package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
  67. package/backend/dist/config/migrations/v9-to-v10.js +71 -0
  68. package/backend/dist/config/runtime.js +1 -1
  69. package/backend/dist/config/schema.d.ts +3 -3
  70. package/backend/dist/config/schema.js +18 -4
  71. package/backend/dist/config/types.d.ts +221 -41
  72. package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
  73. package/backend/dist/egress-proxy/asset-download.js +420 -0
  74. package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
  75. package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
  76. package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
  77. package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
  78. package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
  79. package/backend/dist/egress-proxy/mihomo-client.js +308 -0
  80. package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
  81. package/backend/dist/egress-proxy/mihomo-config.js +161 -0
  82. package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
  83. package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
  84. package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
  85. package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
  86. package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
  87. package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
  88. package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
  89. package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
  90. package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
  91. package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
  92. package/backend/dist/forward-proxy/egress.d.ts +50 -11
  93. package/backend/dist/forward-proxy/egress.js +63 -17
  94. package/backend/dist/forward-proxy/h2-forward.js +42 -15
  95. package/backend/dist/forward-proxy/index.d.ts +11 -8
  96. package/backend/dist/forward-proxy/index.js +27 -60
  97. package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
  98. package/backend/dist/forward-proxy/interceptor.js +4 -4
  99. package/backend/dist/forward-proxy/relay.js +3 -3
  100. package/backend/dist/forward-proxy/rules.d.ts +4 -4
  101. package/backend/dist/forward-proxy/rules.js +25 -4
  102. package/backend/dist/forward-proxy/server.d.ts +12 -16
  103. package/backend/dist/forward-proxy/server.js +237 -171
  104. package/backend/dist/harness/host/hosts.js +3 -2
  105. package/backend/dist/index.js +59 -19
  106. package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
  107. package/backend/dist/ingress-proxy/access-log.js +774 -0
  108. package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
  109. package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
  110. package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
  111. package/backend/dist/ingress-proxy/ca-trust.js +315 -0
  112. package/backend/dist/ingress-proxy/ca.d.ts +104 -0
  113. package/backend/dist/ingress-proxy/ca.js +273 -0
  114. package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
  115. package/backend/dist/ingress-proxy/data-dir.js +45 -0
  116. package/backend/dist/ingress-proxy/egress.d.ts +151 -0
  117. package/backend/dist/ingress-proxy/egress.js +364 -0
  118. package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
  119. package/backend/dist/ingress-proxy/h2-forward.js +561 -0
  120. package/backend/dist/ingress-proxy/index.d.ts +24 -0
  121. package/backend/dist/ingress-proxy/index.js +144 -0
  122. package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
  123. package/backend/dist/ingress-proxy/interceptor.js +52 -0
  124. package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
  125. package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
  126. package/backend/dist/ingress-proxy/relay.d.ts +54 -0
  127. package/backend/dist/ingress-proxy/relay.js +188 -0
  128. package/backend/dist/ingress-proxy/rules.d.ts +195 -0
  129. package/backend/dist/ingress-proxy/rules.js +348 -0
  130. package/backend/dist/ingress-proxy/server.d.ts +153 -0
  131. package/backend/dist/ingress-proxy/server.js +2065 -0
  132. package/backend/dist/ingress-proxy/sni.d.ts +35 -0
  133. package/backend/dist/ingress-proxy/sni.js +124 -0
  134. package/backend/dist/ingress-proxy/status.d.ts +32 -0
  135. package/backend/dist/ingress-proxy/status.js +15 -0
  136. package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
  137. package/backend/dist/ingress-proxy/system-proxy.js +481 -0
  138. package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
  139. package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
  140. package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
  141. package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
  142. package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
  143. package/backend/dist/ingress-proxy/traffic-files.js +10 -0
  144. package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
  145. package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
  146. package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
  147. package/backend/dist/ingress-proxy/ws-frames.js +153 -0
  148. package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
  149. package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
  150. package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
  151. package/backend/dist/ir/adapters/google-gemini.js +5 -2
  152. package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
  153. package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
  154. package/backend/dist/ir/adapters/openai-chat.js +50 -6
  155. package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
  156. package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
  157. package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
  158. package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
  159. package/backend/dist/ir/adapters/openai-responses.d.ts +92 -1
  160. package/backend/dist/ir/adapters/openai-responses.js +163 -12
  161. package/backend/dist/ir/capabilities.js +4 -0
  162. package/backend/dist/ir/media.d.ts +20 -0
  163. package/backend/dist/ir/media.js +41 -0
  164. package/backend/dist/ir/tool-identity.d.ts +35 -0
  165. package/backend/dist/ir/tool-identity.js +40 -0
  166. package/backend/dist/ir/types.d.ts +9 -1
  167. package/backend/dist/ir/validate.d.ts +24 -0
  168. package/backend/dist/ir/validate.js +113 -63
  169. package/backend/dist/local/build-jobs.d.ts +66 -0
  170. package/backend/dist/local/build-jobs.js +243 -0
  171. package/backend/dist/local/detect.d.ts +32 -0
  172. package/backend/dist/local/detect.js +145 -0
  173. package/backend/dist/local/draft-match.d.ts +58 -0
  174. package/backend/dist/local/draft-match.js +124 -0
  175. package/backend/dist/local/engine-runtime.d.ts +522 -0
  176. package/backend/dist/local/engine-runtime.js +1 -0
  177. package/backend/dist/local/engines.d.ts +241 -0
  178. package/backend/dist/local/engines.js +651 -0
  179. package/backend/dist/local/gguf.d.ts +35 -0
  180. package/backend/dist/local/gguf.js +314 -0
  181. package/backend/dist/local/hf.d.ts +120 -0
  182. package/backend/dist/local/hf.js +304 -0
  183. package/backend/dist/local/install.d.ts +90 -0
  184. package/backend/dist/local/install.js +421 -0
  185. package/backend/dist/local/llamacpp.d.ts +55 -0
  186. package/backend/dist/local/llamacpp.js +177 -0
  187. package/backend/dist/local/local-provider.d.ts +81 -0
  188. package/backend/dist/local/local-provider.js +301 -0
  189. package/backend/dist/local/machine-stats.d.ts +87 -0
  190. package/backend/dist/local/machine-stats.js +332 -0
  191. package/backend/dist/local/model-store.d.ts +347 -0
  192. package/backend/dist/local/model-store.js +1215 -0
  193. package/backend/dist/local/part-sweep.d.ts +32 -0
  194. package/backend/dist/local/part-sweep.js +156 -0
  195. package/backend/dist/local/plan.d.ts +65 -0
  196. package/backend/dist/local/plan.js +146 -0
  197. package/backend/dist/local/resources.d.ts +49 -0
  198. package/backend/dist/local/resources.js +64 -0
  199. package/backend/dist/local/run-stats.d.ts +95 -0
  200. package/backend/dist/local/run-stats.js +195 -0
  201. package/backend/dist/local/runner.d.ts +235 -0
  202. package/backend/dist/local/runner.js +1392 -0
  203. package/backend/dist/local/settings.d.ts +79 -0
  204. package/backend/dist/local/settings.js +180 -0
  205. package/backend/dist/local/strata-catalog.d.ts +30 -0
  206. package/backend/dist/local/strata-catalog.js +511 -0
  207. package/backend/dist/local/strata-drafting.d.ts +46 -0
  208. package/backend/dist/local/strata-drafting.js +265 -0
  209. package/backend/dist/local/strata.d.ts +278 -0
  210. package/backend/dist/local/strata.js +1392 -0
  211. package/backend/dist/local/tar.d.ts +20 -0
  212. package/backend/dist/local/tar.js +367 -0
  213. package/backend/dist/local/transport.d.ts +35 -0
  214. package/backend/dist/local/transport.js +89 -0
  215. package/backend/dist/local/tune.d.ts +58 -0
  216. package/backend/dist/local/tune.js +324 -0
  217. package/backend/dist/observability/http-exchange.d.ts +2 -2
  218. package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
  219. package/backend/dist/opencode/catalog/auto-pull.js +284 -77
  220. package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
  221. package/backend/dist/opencode/catalog/ocr-store.js +4 -2
  222. package/backend/dist/opencode/catalog/overrides-store.d.ts +15 -4
  223. package/backend/dist/opencode/catalog/overrides-store.js +28 -19
  224. package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
  225. package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
  226. package/backend/dist/opencode/catalog/repository.js +28 -5
  227. package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
  228. package/backend/dist/opencode/catalog/sources/models-dev.js +42 -14
  229. package/backend/dist/opencode/catalog/types.d.ts +42 -12
  230. package/backend/dist/opencode/catalog/types.js +38 -1
  231. package/backend/dist/opencode/credentials/def-materialize.js +27 -21
  232. package/backend/dist/opencode/credentials/ocr-store.js +11 -2
  233. package/backend/dist/opencode/credentials/sync.js +12 -3
  234. package/backend/dist/opencode/credentials/types.d.ts +31 -4
  235. package/backend/dist/opencode/credentials/types.js +25 -0
  236. package/backend/dist/opencode/migrate/engine.d.ts +20 -0
  237. package/backend/dist/opencode/migrate/engine.js +71 -0
  238. package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
  239. package/backend/dist/opencode/migrate/migrator.js +6 -0
  240. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
  241. package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
  242. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
  243. package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
  244. package/backend/dist/opencode/probe.d.ts +21 -4
  245. package/backend/dist/opencode/probe.js +34 -10
  246. package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
  247. package/backend/dist/opencode/provider-def-adapters.js +43 -27
  248. package/backend/dist/opencode/provider-defs.d.ts +10 -16
  249. package/backend/dist/opencode/provider-defs.js +45 -45
  250. package/backend/dist/opencode/user-config.d.ts +23 -26
  251. package/backend/dist/opencode/user-config.js +95 -77
  252. package/backend/dist/pipeline/directives.d.ts +9 -4
  253. package/backend/dist/pipeline/directives.js +14 -10
  254. package/backend/dist/pipeline/orchestrator.d.ts +42 -13
  255. package/backend/dist/pipeline/orchestrator.js +514 -172
  256. package/backend/dist/plugins/builtin/model-gateway.js +38 -12
  257. package/backend/dist/plugins/environment-ack.d.ts +51 -0
  258. package/backend/dist/plugins/environment-ack.js +81 -0
  259. package/backend/dist/plugins/gateways.d.ts +6 -6
  260. package/backend/dist/plugins/gateways.js +2 -2
  261. package/backend/dist/plugins/host.d.ts +100 -16
  262. package/backend/dist/plugins/host.js +637 -99
  263. package/backend/dist/plugins/install-run.d.ts +27 -0
  264. package/backend/dist/plugins/install-run.js +99 -0
  265. package/backend/dist/plugins/manifest.d.ts +84 -32
  266. package/backend/dist/plugins/manifest.js +149 -45
  267. package/backend/dist/plugins/market-install.d.ts +18 -0
  268. package/backend/dist/plugins/market-install.js +111 -0
  269. package/backend/dist/plugins/market-source.d.ts +100 -0
  270. package/backend/dist/plugins/market-source.js +449 -0
  271. package/backend/dist/plugins/market-updates.d.ts +70 -0
  272. package/backend/dist/plugins/market-updates.js +97 -0
  273. package/backend/dist/plugins/market.d.ts +677 -0
  274. package/backend/dist/plugins/market.js +2113 -0
  275. package/backend/dist/plugins/source-index.d.ts +155 -0
  276. package/backend/dist/plugins/source-index.js +217 -0
  277. package/backend/dist/plugins/types.d.ts +402 -37
  278. package/backend/dist/projects/worktrees.d.ts +88 -0
  279. package/backend/dist/projects/worktrees.js +220 -0
  280. package/backend/dist/providers/boot-direct.d.ts +41 -7
  281. package/backend/dist/providers/boot-direct.js +284 -44
  282. package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
  283. package/backend/dist/providers/dial-wire.d.ts +17 -0
  284. package/backend/dist/providers/dial-wire.js +49 -0
  285. package/backend/dist/providers/executors/dispatch.d.ts +17 -7
  286. package/backend/dist/providers/executors/dispatch.js +28 -9
  287. package/backend/dist/providers/executors/openai-chat.js +14 -2
  288. package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
  289. package/backend/dist/providers/executors/plugin-adapter.js +59 -3
  290. package/backend/dist/providers/member-match.d.ts +32 -9
  291. package/backend/dist/providers/member-match.js +65 -21
  292. package/backend/dist/providers/model-resolution.d.ts +62 -0
  293. package/backend/dist/providers/model-resolution.js +62 -0
  294. package/backend/dist/providers/price-order.d.ts +51 -0
  295. package/backend/dist/providers/price-order.js +54 -0
  296. package/backend/dist/providers/protocols-field.d.ts +24 -0
  297. package/backend/dist/providers/protocols-field.js +66 -0
  298. package/backend/dist/providers/provider-takedown.d.ts +5 -2
  299. package/backend/dist/providers/registry.d.ts +87 -26
  300. package/backend/dist/providers/registry.js +232 -121
  301. package/backend/dist/providers/selection.d.ts +91 -0
  302. package/backend/dist/providers/selection.js +158 -0
  303. package/backend/dist/providers/virtual-meta.d.ts +33 -2
  304. package/backend/dist/providers/virtual-meta.js +74 -18
  305. package/backend/dist/quota/cli-login.d.ts +25 -4
  306. package/backend/dist/quota/cli-login.js +38 -6
  307. package/backend/dist/quota/coverage-generation.d.ts +24 -0
  308. package/backend/dist/quota/coverage-generation.js +29 -0
  309. package/backend/dist/quota/declarations.js +8 -4
  310. package/backend/dist/quota/engine.js +2 -2
  311. package/backend/dist/quota/prober.d.ts +43 -2
  312. package/backend/dist/quota/prober.js +97 -22
  313. package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
  314. package/backend/dist/resilience/error-classifier.js +29 -0
  315. package/backend/dist/router/index.d.ts +1 -1
  316. package/backend/dist/router/index.js +17 -1
  317. package/backend/dist/router/layer2-decision.d.ts +1 -1
  318. package/backend/dist/router/layer2-decision.js +2 -2
  319. package/backend/dist/routes/console.js +1043 -405
  320. package/backend/dist/routes/environments.js +1 -1
  321. package/backend/dist/routes/local-models.d.ts +2 -0
  322. package/backend/dist/routes/local-models.js +1414 -0
  323. package/backend/dist/routes/mihomo.d.ts +2 -2
  324. package/backend/dist/routes/mihomo.js +20 -11
  325. package/backend/dist/routes/projects.js +121 -0
  326. package/backend/dist/server.js +409 -15
  327. package/backend/dist/session/session-manager.d.ts +42 -5
  328. package/backend/dist/session/session-manager.js +64 -11
  329. package/backend/dist/session/session-row.d.ts +29 -8
  330. package/backend/dist/session/session-row.js +18 -13
  331. package/backend/dist/snapshot/bundle.d.ts +40 -0
  332. package/backend/dist/snapshot/bundle.js +177 -0
  333. package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
  334. package/backend/dist/snapshot/handoff/compress.js +77 -0
  335. package/backend/dist/snapshot/handoff/index.d.ts +119 -0
  336. package/backend/dist/snapshot/handoff/index.js +160 -0
  337. package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
  338. package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
  339. package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
  340. package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
  341. package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
  342. package/backend/dist/snapshot/handoff/summarize.js +118 -0
  343. package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
  344. package/backend/dist/snapshot/handoff/transcript.js +167 -0
  345. package/backend/dist/snapshot/media-fs.d.ts +10 -0
  346. package/backend/dist/snapshot/media-fs.js +50 -0
  347. package/backend/dist/snapshot/media.d.ts +32 -0
  348. package/backend/dist/snapshot/media.js +87 -0
  349. package/backend/dist/snapshot/store.d.ts +226 -0
  350. package/backend/dist/snapshot/store.js +887 -0
  351. package/backend/dist/snapshot/tree.d.ts +112 -0
  352. package/backend/dist/snapshot/tree.js +207 -0
  353. package/backend/dist/snapshot/types.d.ts +212 -0
  354. package/backend/dist/snapshot/types.js +14 -0
  355. package/backend/dist/snapshot/view.d.ts +19 -0
  356. package/backend/dist/snapshot/view.js +57 -0
  357. package/backend/dist/snapshot/write-worker.d.ts +67 -0
  358. package/backend/dist/snapshot/write-worker.js +129 -0
  359. package/backend/dist/surfaces/anthropic.js +4 -1
  360. package/backend/dist/surfaces/body-admission.d.ts +344 -0
  361. package/backend/dist/surfaces/body-admission.js +818 -0
  362. package/backend/dist/surfaces/chat-pipeline.js +8 -0
  363. package/backend/dist/surfaces/decision-pipeline.js +10 -7
  364. package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
  365. package/backend/dist/surfaces/gateway-catalog.js +202 -0
  366. package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
  367. package/backend/dist/surfaces/gateway-chat.js +50 -12
  368. package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
  369. package/backend/dist/surfaces/ocr-headers.js +11 -7
  370. package/backend/dist/surfaces/systemone.js +1 -1
  371. package/backend/dist/surfaces/transport-fastify.js +32 -5
  372. package/backend/dist/surfaces/transport-node-http.d.ts +51 -6
  373. package/backend/dist/surfaces/transport-node-http.js +76 -16
  374. package/backend/dist/surfaces/types.d.ts +11 -3
  375. package/backend/dist/trace/persist.js +21 -1
  376. package/backend/dist/trace/tracker.d.ts +35 -3
  377. package/backend/dist/trace/tracker.js +23 -0
  378. package/backend/dist/types/openai.d.ts +8 -0
  379. package/backend/dist/types/router.d.ts +17 -6
  380. package/backend/dist/types/router.js +14 -2
  381. package/backend/dist/utils/client-families.d.ts +66 -0
  382. package/backend/dist/utils/client-families.js +127 -0
  383. package/backend/dist/utils/event-ring.d.ts +1 -1
  384. package/backend/dist/utils/event-ring.js +1 -1
  385. package/backend/dist/utils/proxy-node.js +1 -1
  386. package/backend/dist/utils/proxy.d.ts +135 -11
  387. package/backend/dist/utils/proxy.js +144 -29
  388. package/backend/dist/utils/run-command.d.ts +21 -1
  389. package/backend/dist/utils/run-command.js +64 -4
  390. package/backend/dist/utils/server-liveness.d.ts +28 -0
  391. package/backend/dist/utils/server-liveness.js +32 -0
  392. package/backend/dist/utils/session-file.d.ts +28 -0
  393. package/backend/dist/utils/session-file.js +34 -0
  394. package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
  395. package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
  396. package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
  397. package/frontend/dist/assets/{index-DxZ9MHKB.css → index-CqDSOPQ0.css} +1 -1
  398. package/frontend/dist/index.html +2 -2
  399. package/package.json +3 -1
  400. package/frontend/dist/assets/index-55VVwfFQ.js +0 -1521
@@ -0,0 +1,91 @@
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
+ export type SelectionStrategy = 'priority' | 'weighted_round_robin' | 'round_robin';
23
+ /**
24
+ * Hard ceiling for a member weight. The smooth core accumulates credit in a JS
25
+ * number, so an unbounded value (`Infinity` from YAML `.inf` / `1e309`, or a
26
+ * float near the maximum added twice) overflows the accumulator to `Infinity`
27
+ * and then poisons the cursor with `NaN`. Clamping here keeps every weight
28
+ * finite while leaving realistic rotation shares untouched.
29
+ */
30
+ export declare const MAX_MEMBER_WEIGHT = 1000000;
31
+ /** Resolve a member weight: NaN and sub-1 values mean 1; a non-finite
32
+ * (Infinity from YAML `.inf` / `1e309`) or overflowing value is clamped to
33
+ * `MAX_MEMBER_WEIGHT` — the intent `as heavy as possible` stays honoured and
34
+ * the accumulator stays finite. */
35
+ export declare function normalizeMemberWeight(value: unknown): number;
36
+ /**
37
+ * Normalize a stored strategy value. The three known strategies pass through;
38
+ * everything else — absent, unknown, or the retired `weighted` spelling of the
39
+ * old weighted-RANDOM draw — falls back to the default `priority`.
40
+ */
41
+ export declare function normalizeSelectionStrategy(value: unknown): SelectionStrategy;
42
+ /**
43
+ * Canonicalize every PRESENT `selection` value in a config-shaped container:
44
+ * `tiers.<tier>.selection` and `combos[].selection` (the runtime flat shape and
45
+ * the disk `routing.*` shape share this layout, so one walker serves both).
46
+ *
47
+ * Called at every config boundary — the runtime read (loadConfig), the visual
48
+ * save (saveConfig) and the raw-YAML save (saveRawConfig) — so runtime consumers
49
+ * only ever see one of the three strategies and no write path can persist an
50
+ * unknown or retired spelling.
51
+ *
52
+ * An ABSENT `selection` is left absent (it already means the default); only a
53
+ * present value is rewritten. `normalizeSelectionStrategy` owns the mapping —
54
+ * unknown / retired spellings become `priority`.
55
+ *
56
+ * @returns true when at least one value changed.
57
+ */
58
+ export declare function canonicalizeSelectionValues(container: unknown): boolean;
59
+ /**
60
+ * Smooth round-robin core (the nginx SWRR algorithm), shared by tier pools and
61
+ * combos so both surfaces rotate identically.
62
+ *
63
+ * Each pick adds every member's weight to its running credit, serves the
64
+ * highest credit and debits the pool's total weight from it. With weighted
65
+ * members each is served exactly `weight` times per cycle, interleaved as
66
+ * evenly as the weights allow (weights 5:1:1 → a, a, b, a, c, a, a — a
67
+ * burst-free rotation); with uniform weights it degenerates to plain
68
+ * round-robin (a, b, c, a, …).
69
+ *
70
+ * O(n) time and O(n) state per pool: unlike the retired "expand each member
71
+ * into `weight` consecutive slots" table, a six-digit weight costs nothing and
72
+ * every pool read stays linear in the member count.
73
+ *
74
+ * State is scoped by a caller-chosen key (tier + strategy / combo id +
75
+ * strategy). A pool whose member sequence OR declared weights change starts a
76
+ * fresh vector on the next pick, so a stale credit vector can never steer a
77
+ * new composition — and a pool shrunk to one member resets here too (the
78
+ * recovered pool must not resume credit accumulated before the shrink).
79
+ */
80
+ export declare class WeightedRoundRobin {
81
+ private state;
82
+ /**
83
+ * One draw over `entries`. `idOf` identifies a member (pool identity) and
84
+ * `weightOf` returns its rotation weight (values below 1 / non-numeric
85
+ * degrade to 1, a non-finite value clamps to MAX_MEMBER_WEIGHT — matching
86
+ * the config contract); pass `() => 1` for plain round-robin.
87
+ */
88
+ pick<T>(key: string, entries: readonly T[], idOf: (entry: T) => string, weightOf: (entry: T) => number): T;
89
+ /** Drop one pool's cursor (membership/order changed) or every cursor. */
90
+ reset(key?: string): void;
91
+ }
@@ -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,18 +1,50 @@
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
+ import { primaryProtocol, normalizeProtocols } from '../providers/protocols-field.js';
3
4
  import { getProviderNodeById } from '../opencode/user-config.js';
4
5
  /**
5
- * One quota pair for a provider whose plugin owns login (`authTypes: ['none']`).
6
- * There is no OCR key to hash. The prefix is the pair identity the console
7
- * 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.
8
11
  */
9
12
  export const CLI_LOGIN_QUOTA_PREFIX = 'cli-login';
10
- /** 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
+ */
11
21
  export function providerUsesCliLogin(providerId) {
12
22
  const def = getProviderNodeById(providerId);
13
- const npm = typeof def?.npm === 'string' ? def.npm : typeof def?.package === 'string' ? def.package : undefined;
23
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
24
+ const npm = protocols.length > 0 ? primaryProtocol(protocols) : undefined;
14
25
  const options = def?.options;
15
26
  const settings = def?.settings;
16
27
  const base = typeof options?.baseURL === 'string' ? options.baseURL : typeof settings?.baseURL === 'string' ? settings.baseURL : undefined;
17
28
  return pluginDeclinesCredentials(getModelServicePlugin(wireFor(npm, base)));
18
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