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
@@ -2,8 +2,142 @@ import { catalogModelToDef } from '../provider-defs.js';
2
2
  import { loadConfig } from '../../config/index.js';
3
3
  import { assertAllowedUpstream, UpstreamUrlError } from '../../utils/upstream-url-guard.js';
4
4
  import { redactUpstreamBody } from '../../observability/upstream-body-redaction.js';
5
- import { wireFor } from '../../providers/wire.js';
5
+ import { proxiedFetch } from '../../utils/proxy.js';
6
+ import { setHeaderCaseInsensitive } from '../../providers/executors/http-json.js';
7
+ import { normalizeOpenAICompatible } from './sources/registry.js';
8
+ import { anthropicMessagesUrl, baseForWire, wireFor } from '../../providers/wire.js';
6
9
  import { isPluginWire } from '../../providers/plugin-wires.js';
10
+ import { isMachineLoginValue } from '../credentials/types.js';
11
+ /** Bound for model-list pagination — a broken upstream must never loop. */
12
+ const MAX_MODEL_LIST_PAGES = 10;
13
+ const MODEL_LIST_PAGE_SIZE = '1000';
14
+ /** The def's wire, resolved the same way the executors resolve it. */
15
+ async function defWire(def) {
16
+ const { primaryProtocol, normalizeProtocols } = await import('../../providers/protocols-field.js');
17
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
18
+ return protocols.length > 0 ? wireFor(primaryProtocol(protocols)) : 'openai-chat';
19
+ }
20
+ /** Where a wire's model list lives: Anthropic's /v1/models mount (same base
21
+ * normalization the /messages executor applies), /models everywhere else. */
22
+ function liveModelsUrl(wire, baseURL) {
23
+ const base = baseForWire(wire, String(baseURL).replace(/\/+$/, ''));
24
+ if (wire === 'anthropic-messages') {
25
+ return anthropicMessagesUrl(base).replace(/\/messages$/, '/models');
26
+ }
27
+ return `${base}/models`;
28
+ }
29
+ /** The credential carrier each wire actually accepts — NOT Bearer for all. */
30
+ function liveAuthHeaders(wire, key) {
31
+ if (wire === 'anthropic-messages')
32
+ return { 'x-api-key': key, 'anthropic-version': '2023-06-01' };
33
+ if (wire === 'google-gemini')
34
+ return { 'x-goog-api-key': key };
35
+ return { Authorization: `Bearer ${key}` };
36
+ }
37
+ function withQuery(url, params) {
38
+ const u = new URL(url);
39
+ for (const [k, v] of Object.entries(params))
40
+ u.searchParams.set(k, v);
41
+ return u.toString();
42
+ }
43
+ /** One list page → models (+ the query params that fetch the next page). */
44
+ function normalizeModelListPage(raw, wire) {
45
+ if (wire === 'google-gemini') {
46
+ const list = Array.isArray(raw?.models) ? raw.models : [];
47
+ const models = list
48
+ .map((m) => {
49
+ const rawName = String(m?.name ?? '');
50
+ // Gemini names entries `models/<id>`; the def id the executor addresses
51
+ // is the bare one.
52
+ const id = rawName.startsWith('models/') ? rawName.slice('models/'.length) : rawName;
53
+ return { id, name: m?.displayName || undefined, source: 'openai-compatible' };
54
+ })
55
+ .filter((m) => m.id);
56
+ const token = typeof raw?.nextPageToken === 'string' && raw.nextPageToken ? raw.nextPageToken : undefined;
57
+ return { models, ...(token ? { next: { pageToken: token, pageSize: MODEL_LIST_PAGE_SIZE } } : {}) };
58
+ }
59
+ // OpenAI-compatible family ({data:[…]}). Anthropic answers the same shape but
60
+ // names the model in `display_name` and paginates on has_more/last_id.
61
+ const models = normalizeOpenAICompatible(raw).map((m) => {
62
+ if (wire !== 'anthropic-messages')
63
+ return m;
64
+ const match = Array.isArray(raw?.data) ? raw.data.find((r) => String(r?.id) === m.id) : undefined;
65
+ const display = match?.display_name;
66
+ return display && !m.name ? { ...m, name: String(display) } : m;
67
+ });
68
+ const lastId = raw?.has_more === true && typeof raw?.last_id === 'string' ? raw.last_id : undefined;
69
+ return { models, ...(lastId ? { next: { limit: MODEL_LIST_PAGE_SIZE, after_id: lastId } } : {}) };
70
+ }
71
+ /**
72
+ * The ONE live model-list request, shared by the manual/connect pull and the
73
+ * periodic sweep so the two can never drift. Wire-aware auth + URL + response
74
+ * shape + pagination; operator-declared def headers win over the wire defaults;
75
+ * the dial honours the egress proxy (a model-less call matches `provider/*`).
76
+ */
77
+ async function fetchLiveModelList(opts) {
78
+ const url = liveModelsUrl(opts.wire, opts.baseURL);
79
+ let pageUrl = opts.wire === 'anthropic-messages'
80
+ ? withQuery(url, { limit: MODEL_LIST_PAGE_SIZE })
81
+ : opts.wire === 'google-gemini'
82
+ ? withQuery(url, { pageSize: MODEL_LIST_PAGE_SIZE })
83
+ : url;
84
+ const models = [];
85
+ for (let page = 0; page < MAX_MODEL_LIST_PAGES; page++) {
86
+ const headers = liveAuthHeaders(opts.wire, opts.key);
87
+ for (const [k, v] of Object.entries(opts.headers ?? {})) {
88
+ if (typeof v === 'string')
89
+ setHeaderCaseInsensitive(headers, k, v);
90
+ }
91
+ let res;
92
+ try {
93
+ res = await proxiedFetch(pageUrl, { headers, redirect: 'manual', signal: AbortSignal.timeout(15000) }, { provider: opts.providerId });
94
+ }
95
+ catch (err) {
96
+ const cause = err?.cause?.code || err?.cause?.message || err?.message;
97
+ return {
98
+ ok: false,
99
+ models,
100
+ url,
101
+ reasonCode: 'pull_unreachable',
102
+ cause: cause ? String(cause) : undefined,
103
+ error: `cannot reach ${url}${cause ? ` (${String(cause)})` : ''}`,
104
+ };
105
+ }
106
+ if (res.status >= 300 && res.status < 400) {
107
+ return {
108
+ ok: false,
109
+ models,
110
+ url,
111
+ reasonCode: 'pull_redirect',
112
+ error: `Upstream redirected (${res.status}); credentialed pulls do not follow redirects.`,
113
+ };
114
+ }
115
+ if (!res.ok) {
116
+ const rawBody = await res.text().catch(() => '');
117
+ const text = redactUpstreamBody(rawBody, headers);
118
+ return {
119
+ ok: false,
120
+ models,
121
+ url,
122
+ reasonCode: 'pull_http',
123
+ httpStatus: res.status,
124
+ upstreamBody: text || undefined,
125
+ authHint: res.status === 401 || res.status === 403,
126
+ error: `Upstream answered HTTP ${res.status} for ${url}${text ? `: ${text}` : ''}`,
127
+ };
128
+ }
129
+ const raw = await res.json().catch(() => null);
130
+ if (!raw) {
131
+ return { ok: false, models, url, reasonCode: 'pull_non_json', error: `Upstream answered non-JSON for ${url}` };
132
+ }
133
+ const parsed = normalizeModelListPage(raw, opts.wire);
134
+ models.push(...parsed.models);
135
+ if (!parsed.next)
136
+ break;
137
+ pageUrl = withQuery(pageUrl, parsed.next);
138
+ }
139
+ return { ok: true, models, url };
140
+ }
7
141
  export async function pullLiveModels(id, opts) {
8
142
  const { getProviderNodeById, getProviderModelDefs, upsertProviderModel, matchesGlobPattern, expandEnvTemplate } = await import('../user-config.js');
9
143
  const def = getProviderNodeById(id);
@@ -29,7 +163,12 @@ export async function pullLiveModels(id, opts) {
29
163
  const { getCredentialStore } = await import('../credentials/index.js');
30
164
  const store = await getCredentialStore();
31
165
  const inlineKey = expandEnvTemplate(def?.options?.apiKey);
32
- const key = inlineKey || store.resolveKey(id)?.key;
166
+ // The machine-login marker (`ocr:machine`) is not a secret: sending it as a
167
+ // Bearer token would guarantee a 401 on a provider whose real door is the CLI
168
+ // login it stands for. Treat it as "no key" so the caller takes the door that
169
+ // owns the login instead of the /models route that cannot use one.
170
+ const stored = store.resolveKey(id)?.key;
171
+ const key = inlineKey || (isMachineLoginValue(stored) ? undefined : stored);
33
172
  if (!key) {
34
173
  return {
35
174
  httpStatus: 400,
@@ -40,49 +179,36 @@ export async function pullLiveModels(id, opts) {
40
179
  },
41
180
  };
42
181
  }
43
- const url = `${String(baseURL).replace(/\/+$/, '')}/models`;
44
- let res;
45
- try {
46
- res = await fetch(url, {
47
- headers: { Authorization: `Bearer ${key}` },
48
- redirect: 'manual',
49
- signal: AbortSignal.timeout(15000),
50
- });
51
- }
52
- catch (err) {
53
- const cause = err?.cause?.code || err?.cause?.message || err?.message;
54
- return { httpStatus: 502, body: { success: false, reasonCode: 'pull_unreachable', url, cause: cause ? String(cause) : undefined } };
55
- }
56
- if (res.status >= 300 && res.status < 400) {
57
- return {
58
- httpStatus: 502,
59
- body: { success: false, reasonCode: 'pull_redirect', url, error: `Upstream redirected (${res.status}); credentialed pulls do not follow redirects.` },
60
- };
61
- }
62
- if (!res.ok) {
63
- const raw = await res.text().catch(() => '');
64
- const text = redactUpstreamBody(raw, { Authorization: `Bearer ${key}` });
182
+ // Wire-aware request: the wire decides the URL mount, the credential carrier
183
+ // and the response shape; the def's own headers ride along (they win).
184
+ const live = await fetchLiveModelList({
185
+ providerId: id,
186
+ baseURL: String(baseURL),
187
+ wire: await defWire(def),
188
+ key,
189
+ headers: def?.options?.headers ?? def?.headers,
190
+ });
191
+ if (!live.ok) {
65
192
  return {
66
- httpStatus: res.status === 401 || res.status === 403 ? 401 : 502,
193
+ httpStatus: live.reasonCode === 'pull_http' ? (live.httpStatus === 401 || live.httpStatus === 403 ? 401 : 502) : 502,
67
194
  body: {
68
195
  success: false,
69
- reasonCode: 'pull_http',
70
- authHint: res.status === 401 || res.status === 403,
71
- url,
72
- httpStatus: res.status,
73
- upstreamBody: text || undefined,
196
+ reasonCode: live.reasonCode,
197
+ url: live.url,
198
+ // Always present: the connect-time fill and the console pull surface
199
+ // this sentence, and a generic "auto-fill failed" hides the operator's
200
+ // actual fix (wrong key vs wrong endpoint).
201
+ error: live.error,
202
+ ...(live.httpStatus !== undefined ? { httpStatus: live.httpStatus } : {}),
203
+ ...(live.upstreamBody ? { upstreamBody: live.upstreamBody } : {}),
204
+ ...(live.cause ? { cause: live.cause } : {}),
205
+ ...(live.authHint ? { authHint: live.authHint } : {}),
74
206
  },
75
207
  };
76
208
  }
77
- const raw = await res.json().catch(() => null);
78
- if (!raw) {
79
- return { httpStatus: 502, body: { success: false, reasonCode: 'pull_non_json', url } };
80
- }
81
- const { normalizeOpenAICompatible } = await import('./sources/registry.js');
82
- const models = normalizeOpenAICompatible(raw);
83
209
  // Auto-enrich from the aggregated catalog (pricing/limits/modalities for the
84
210
  // same ids) BEFORE writing — fill-missing-only, own entries excluded.
85
- const enriched = await enrichFromCatalog(models, id);
211
+ const enriched = await enrichFromCatalog(live.models, id);
86
212
  const pattern = opts.pattern?.trim();
87
213
  // Explicit id selection (console pull-preview click-to-select) narrows the
88
214
  // matched set on TOP of the pattern; ids not matched are simply absent.
@@ -267,6 +393,36 @@ export async function autoPullProviderModels() {
267
393
  const def = getProviderNodeById(v.id);
268
394
  if (!def)
269
395
  return { id: v.id, mode: 'skipped', models: [] };
396
+ // Plugin-provided model-service wire: the model source is the plugin's
397
+ // own pullModels() — a /models GET cannot exist on this transport class
398
+ // (qoder's exchange host answers 404 by design; its catalog lives on the
399
+ // signed /algo gateway). Same dispatch as autoPullProvider (console pull,
400
+ // connect-time fill); the fetch itself runs in Phase 2 because a plugin
401
+ // pull writes as it goes and writes must stay serial.
402
+ const { primaryProtocol, normalizeProtocols } = await import('../../providers/protocols-field.js');
403
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
404
+ const wire = protocols.length > 0 ? wireFor(primaryProtocol(protocols)) : 'unroutable';
405
+ if (isPluginWire(wire)) {
406
+ // Same rule as the live path below: inline template first, then the
407
+ // store's active row. A plugin that can run credentialless treats an
408
+ // absent key as "this machine's own login"; one that cannot answers
409
+ // with its own refusal, which the sweep reports as data.
410
+ //
411
+ // The machine-login marker is NOT a secret: handing `ocr:machine` to a
412
+ // plugin as `apiKey` would sign the vendor request with the literal
413
+ // marker and earn a guaranteed 401. Absent is the honest answer.
414
+ const storedKey = credStore.resolveKey(v.id)?.key;
415
+ const pluginKey = expandEnvTemplate(def?.options?.apiKey) ||
416
+ (storedKey && !isMachineLoginValue(storedKey) ? storedKey : undefined);
417
+ return {
418
+ id: v.id,
419
+ mode: 'plugin',
420
+ models: [],
421
+ pluginWire: wire,
422
+ pattern,
423
+ ...(pluginKey ? { apiKey: pluginKey } : {}),
424
+ };
425
+ }
270
426
  const baseURL = expandEnvTemplate(def?.options?.baseURL);
271
427
  if (baseURL) {
272
428
  try {
@@ -282,36 +438,26 @@ export async function autoPullProviderModels() {
282
438
  }
283
439
  }
284
440
  const inlineKey = expandEnvTemplate(def?.options?.apiKey);
285
- const key = inlineKey || credStore.resolveKey(v.id)?.key;
441
+ // Same marker rule as `pullLiveModels`: a machine-login row carries no
442
+ // token, so it must not become a Bearer header here either.
443
+ const storedKey = credStore.resolveKey(v.id)?.key;
444
+ const key = inlineKey || (isMachineLoginValue(storedKey) ? undefined : storedKey);
286
445
  if (baseURL && key) {
287
446
  // Builtin (first-party catalog) providers merge: the static catalog is
288
447
  // the metadata-authoritative base, the live list only tops up ids the
289
448
  // catalog does not know yet (dedup by id, catalog entries win).
290
- let liveModels;
291
- let liveError;
292
- try {
293
- const res = await fetch(`${String(baseURL).replace(/\/+$/, '')}/models`, {
294
- headers: { Authorization: `Bearer ${key}` },
295
- redirect: 'manual',
296
- signal: AbortSignal.timeout(15000),
297
- });
298
- if (res.status >= 300 && res.status < 400)
299
- liveError = `redirect ${res.status}`;
300
- else if (!res.ok)
301
- liveError = `HTTP ${res.status}`;
302
- else {
303
- const raw = await res.json().catch(() => null);
304
- if (!raw)
305
- liveError = 'non-JSON payload';
306
- else {
307
- const { normalizeOpenAICompatible } = await import('./sources/registry.js');
308
- liveModels = normalizeOpenAICompatible(raw).filter((m) => matchesGlobPattern(pattern, m.id));
309
- }
310
- }
311
- }
312
- catch (err) {
313
- liveError = err?.message || String(err);
314
- }
449
+ // Same wire-aware request as the manual/connect pull (one engine, no
450
+ // drift): the sweep used to assume Bearer + /models, which silently
451
+ // failed for every Anthropic/Gemini def.
452
+ const live = await fetchLiveModelList({
453
+ providerId: v.id,
454
+ baseURL: String(baseURL),
455
+ wire,
456
+ key,
457
+ headers: def?.options?.headers ?? def?.headers,
458
+ });
459
+ const liveModels = live.ok ? live.models.filter((m) => matchesGlobPattern(pattern, m.id)) : undefined;
460
+ const liveError = live.ok ? undefined : live.error;
315
461
  if (await isBuiltinCatalogProvider(v.id)) {
316
462
  const { catalogRepository } = await import('./repository.js');
317
463
  const provider = await catalogRepository.getProvider(v.id);
@@ -351,6 +497,47 @@ export async function autoPullProviderModels() {
351
497
  out.push({ providerId: job.id, mode: 'skipped', pulled: 0, ...(job.error ? { error: job.error } : {}) });
352
498
  continue;
353
499
  }
500
+ if (job.mode === 'plugin') {
501
+ // Serial like every other write: a plugin pull fetches AND upserts, and
502
+ // defs writes must never interleave. ADD-ONLY still holds — the plugin's
503
+ // pullModels skips ids already defined in the defs file. A missing
504
+ // plugin surfaces as data; the sweep never throws.
505
+ const { getModelServicePlugin } = await import('../../plugins/host.js');
506
+ const plugin = job.pluginWire ? getModelServicePlugin(job.pluginWire) : undefined;
507
+ if (!plugin?.pullModels) {
508
+ out.push({
509
+ providerId: job.id,
510
+ mode: 'plugin',
511
+ pulled: 0,
512
+ error: `the ${job.pluginWire} plugin is not installed (console /plugins)`,
513
+ });
514
+ continue;
515
+ }
516
+ try {
517
+ const res = await plugin.pullModels(job.id, { pattern: job.pattern, ...(job.apiKey ? { apiKey: job.apiKey } : {}) });
518
+ const body = res.body;
519
+ const failed = body?.success === false || res.httpStatus >= 400;
520
+ const cleared = Number(body?.cleared ?? 0);
521
+ out.push({
522
+ providerId: job.id,
523
+ mode: 'plugin',
524
+ pulled: failed ? 0 : Number(body?.pulled ?? 0),
525
+ ...(!failed && cleared > 0 ? { cleared } : {}),
526
+ ...(failed
527
+ ? { error: String(body?.error ?? body?.reasonCode ?? `HTTP ${res.httpStatus}`) }
528
+ : { skipped: Number(body?.skipped ?? 0) }),
529
+ });
530
+ }
531
+ catch (err) {
532
+ out.push({
533
+ providerId: job.id,
534
+ mode: 'plugin',
535
+ pulled: 0,
536
+ error: err instanceof Error ? err.message : String(err),
537
+ });
538
+ }
539
+ continue;
540
+ }
354
541
  if (job.error) {
355
542
  out.push({ providerId: job.id, mode: job.mode, pulled: 0, error: job.error });
356
543
  continue;
@@ -459,8 +646,9 @@ export async function autoPullProvider(id, opts = {}) {
459
646
  const def = getProviderNodeById(id);
460
647
  // Plugin-provided model-service wire: the model source is the plugin's own
461
648
  // pullModels() — a plain /models GET cannot exist on this transport class.
462
- const npm = def?.npm || def?.package || '';
463
- const npmWire = npm ? wireFor(npm) : 'unroutable';
649
+ const { primaryProtocol, normalizeProtocols } = await import('../../providers/protocols-field.js');
650
+ const protocols = normalizeProtocols(def?.protocols ?? def?.package ?? def?.npm);
651
+ const npmWire = protocols.length > 0 ? wireFor(primaryProtocol(protocols)) : 'unroutable';
464
652
  if (isPluginWire(npmWire)) {
465
653
  // The executor's wire id is also the protocol id a plugin labels its own
466
654
  // model list with, so the message names the wire the def resolved to.
@@ -469,7 +657,18 @@ export async function autoPullProvider(id, opts = {}) {
469
657
  if (!plugin?.pullModels) {
470
658
  return { httpStatus: 400, body: { success: false, error: `the ${npmWire} plugin is not installed (console /plugins)` } };
471
659
  }
472
- return plugin.pullModels(id, opts);
660
+ // A plugin pull IS a credential-bearing call: it asks the vendor for the
661
+ // model list, and that list belongs to whichever account is active. Without
662
+ // the key here, a provider authorized only in the console could never fill
663
+ // its own catalog. Same rule as the sweep and the live pull: inline template
664
+ // first, then the store's active row. The machine-login marker is not a
665
+ // secret (it would sign the request with `ocr:machine` and 401), so it is
666
+ // treated as "no key" here exactly as in the sweep and the live pull.
667
+ const pullStore = await getCredentialStore();
668
+ const storedPullKey = pullStore.resolveKey(id)?.key;
669
+ const pullKey = expandEnvTemplate(def?.options?.apiKey) ||
670
+ (storedPullKey && !isMachineLoginValue(storedPullKey) ? storedPullKey : undefined);
671
+ return plugin.pullModels(id, { ...opts, ...(pullKey ? { apiKey: pullKey } : {}) });
473
672
  }
474
673
  // B4: live capability keyed on the BOUND store (pullLiveModels resolves the
475
674
  // same way — one source, no live/catalog branch mismatch). P3-5: capability
@@ -516,14 +715,14 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
516
715
  // (node absent, or present-but-baseless) — an operator-owned node needs no
517
716
  // network on this path.
518
717
  let catalogName;
519
- let catalogNpm;
718
+ let catalogProtocols;
520
719
  let catalogBase;
521
720
  if ((!existing || !existing.options?.baseURL) && !opts.baseURL) {
522
721
  try {
523
722
  const { catalogRepository } = await import('./repository.js');
524
723
  const rec = await catalogRepository.getProvider(id);
525
724
  catalogName = rec?.name;
526
- catalogNpm = rec?.npm;
725
+ catalogProtocols = rec?.protocols;
527
726
  catalogBase = rec?.baseURL || rec?.api;
528
727
  }
529
728
  catch {
@@ -531,21 +730,21 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
531
730
  }
532
731
  }
533
732
  if (!existing) {
534
- const up = upsertProviderDef({ id, name: catalogName, npm: catalogNpm, baseURL: opts.baseURL || catalogBase });
733
+ const up = upsertProviderDef({ id, name: catalogName, protocols: catalogProtocols, baseURL: opts.baseURL || catalogBase });
535
734
  if (!up.success)
536
735
  return { nodeCreated: false, pulled: 0, fillError: up.error };
537
736
  nodeCreated = true;
538
737
  }
539
738
  else if (!existing.options?.baseURL) {
540
739
  // Baseless node (the bind sweep's shape). Merging, not rebuilding: every
541
- // other slot the operator owns (name/npm/headers/models/env/canonical/body)
740
+ // other slot the operator owns (name/protocols/headers/models/env/canonical/body)
542
741
  // rides through untouched.
543
742
  const baseURL = opts.baseURL || catalogBase;
544
743
  if (baseURL) {
545
744
  const up = upsertProviderDef({
546
745
  id,
547
746
  name: existing.name,
548
- npm: existing.npm,
747
+ protocols: existing.protocols,
549
748
  baseURL,
550
749
  headers: existing.options?.headers,
551
750
  models: existing.models,
@@ -563,11 +762,19 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
563
762
  }
564
763
  let res = await autoPullProvider(id, {});
565
764
  if (!res.body?.success) {
566
- res = await pullCatalogModels(id, {}); // static catalog fallback (live fetch failed)
765
+ // The static catalog is a FALLBACK, not a success. Keeping its `pulled: 0`
766
+ // and dropping the live error would report "connected, 0 models, no problem"
767
+ // for a lane that actually answered 401 — the operator would have no idea the
768
+ // account was rejected. The live failure stays primary; a fallback that found
769
+ // nothing is reported as that failure, not as an empty-but-happy result.
770
+ const liveError = String(res.body?.error ?? 'model auto-fill failed');
771
+ const fallback = await pullCatalogModels(id, {});
772
+ const fallbackPulled = fallback.body?.pulled ?? 0;
773
+ return {
774
+ nodeCreated,
775
+ pulled: fallbackPulled,
776
+ ...(fallbackPulled > 0 ? {} : { fillError: liveError }),
777
+ };
567
778
  }
568
- return {
569
- nodeCreated,
570
- pulled: res.body?.pulled ?? 0,
571
- ...(res.body?.success ? {} : { fillError: String(res.body?.error ?? 'model auto-fill failed') }),
572
- };
779
+ return { nodeCreated, pulled: res.body?.pulled ?? 0 };
573
780
  }
@@ -13,12 +13,13 @@ export interface OcrCatalogStore {
13
13
  /** Bump to invalidate every on-disk snapshot when the aggregation semantics
14
14
  * change in code (the signature only covers defs/config mtimes + source
15
15
  * defs + locked ids — code-level changes cannot drift it). Monotonic only —
16
- * never reuse or step back: 1–4 are burned (2 was the pre-rename snapshot
17
- * with `builtin` source ids; 3 the custom-store 'custom' source, retired
18
- * when model books unified into providers.json; 4 still stored SDK package
19
- * strings in the `npm` slot). A stale 1–4 file stays invalid forever and
20
- * the next semantic change goes to 6. */
21
- version: 5;
16
+ * never reuse or step back: 1–5 are burned (2 was the pre-rename snapshot
17
+ * with `builtin` source ids; 3 the custom-store 'custom' source, retired
18
+ * when model books unified into providers.json; 4 still stored SDK package
19
+ * strings in the `npm` slot; 5 stored singular protocol ids under `npm`).
20
+ * Version 6 stores `protocols: string[]` (ADR-0010). A stale 1–5 file stays
21
+ * invalid forever. */
22
+ version: 6;
22
23
  /** aggregation signature — defs/config.yaml mtimes + source defs + locked ids */
23
24
  sig: string;
24
25
  /** when this snapshot was aggregated (epoch ms) */
@@ -14,7 +14,9 @@ export function readOcrStore() {
14
14
  if (!fs.existsSync(file))
15
15
  return null;
16
16
  const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
17
- if (parsed?.version !== 5 || typeof parsed.sig !== 'string' || typeof parsed.builtAt !== 'number')
17
+ if (parsed?.version !== 6)
18
+ return null;
19
+ if (typeof parsed.sig !== 'string' || typeof parsed.builtAt !== 'number')
18
20
  return null;
19
21
  if (!Array.isArray(parsed.providers))
20
22
  return null;
@@ -28,7 +30,7 @@ export function writeOcrStore(sig, providers) {
28
30
  try {
29
31
  const file = getOcrStorePath();
30
32
  fs.mkdirSync(path.dirname(file), { recursive: true });
31
- const store = { version: 5, sig, builtAt: Date.now(), providers };
33
+ const store = { version: 6, sig, builtAt: Date.now(), providers };
32
34
  const tmp = `${file}.tmp.${process.pid}.${Date.now()}`;
33
35
  fs.writeFileSync(tmp, JSON.stringify(store), 'utf8');
34
36
  renameWithRetry(tmp, file);
@@ -1,4 +1,4 @@
1
- import type { CatalogCost, CatalogLimit, CatalogModalities } from './types.js';
1
+ import type { CatalogCost, CatalogLimit, CatalogModalities, CatalogModelType } from './types.js';
2
2
  import type { ReasoningEffort } from '../../types/router.js';
3
3
  /**
4
4
  * Aggregate override store (~/.omnicell-router/catalog/overrides.json).
@@ -7,6 +7,8 @@ import type { ReasoningEffort } from '../../types/router.js';
7
7
  * this is the landing spot for edits made in the OCR Catalog viewer, which
8
8
  * targets the AGGREGATION (not the defs-file nodes themselves).
9
9
  * Key is `${providerId}||${modelId}` (model ids may contain '/').
10
+ *
11
+ * Schema version 2: protocol slot is `protocols: string[]` only (ADR-0010).
10
12
  */
11
13
  export interface OverrideEntry {
12
14
  name?: string;
@@ -43,16 +45,25 @@ export interface OverrideEntry {
43
45
  reasoningEfforts?: ReasoningEffort[];
44
46
  /** Model-default thinking level; `null` clears the override (follow the catalog/def). */
45
47
  defaultEffort?: ReasoningEffort | null;
46
- /** Model-level protocol id. Retired SDK package strings are translated on read. */
47
- npm?: string;
48
+ /** Model-level outbound protocol set (ordered). */
49
+ protocols?: string[];
48
50
  /** Named thinking-level variants (UI short shape `{id, effort}` — materialized to the def shape at aggregation). */
49
51
  variants?: {
50
52
  id: string;
51
53
  effort: string;
52
54
  }[];
55
+ /**
56
+ * Manual correction of the model's `type` (see `CatalogModelType`). The
57
+ * catalog source publishes one type; a reseller row whose type the source gets
58
+ * wrong — or a genuinely dual-use model (a Gemini `*-image` that also answers
59
+ * text) the operator wants in the TEXT pool — is fixed HERE, because the
60
+ * routing admission reads the type and there is no other editing plane. `null`
61
+ * clears the override (follow the catalog/def).
62
+ */
63
+ type?: CatalogModelType | null;
53
64
  }
54
65
  export interface OverrideStore {
55
- version: 1;
66
+ version: 2;
56
67
  updated: number;
57
68
  models: Record<string, OverrideEntry>;
58
69
  }
@@ -1,8 +1,10 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { getOcrStorePath } from './ocr-store.js';
4
- import { protocolIdFromNpm } from '../provider-package.js';
5
4
  import { renameWithRetry } from '../../utils/atomic-write.js';
5
+ import { migrateOverridesFile, OVERRIDES_SCHEMA } from '../migrate/engine.js';
6
+ import { normalizeProtocols } from '../../providers/protocols-field.js';
7
+ import { protocolIdFromNpm } from '../provider-package.js';
6
8
  export const overrideKey = (providerId, modelId) => `${providerId}||${modelId}`;
7
9
  export function getOverridesStorePath() {
8
10
  return path.join(path.dirname(getOcrStorePath()), 'overrides.json');
@@ -12,33 +14,32 @@ export function readOverridesStore() {
12
14
  const file = getOverridesStorePath();
13
15
  if (!fs.existsSync(file))
14
16
  return null;
17
+ migrateOverridesFile(file);
15
18
  const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
16
- if (parsed?.version !== 1 || typeof parsed.models !== 'object' || parsed.models === null)
19
+ if (parsed?.version !== OVERRIDES_SCHEMA || typeof parsed.models !== 'object' || parsed.models === null)
17
20
  return null;
18
21
  const models = {};
19
22
  for (const [key, entry] of Object.entries(parsed.models)) {
20
- models[key] = translateOverrideNpm(entry);
23
+ models[key] = normalizeOverrideEntry(entry);
21
24
  }
22
- return { ...parsed, models };
25
+ return { ...parsed, version: 2, models };
23
26
  }
24
27
  catch {
25
28
  return null;
26
29
  }
27
30
  }
28
- /** Read view only. The file is not rewritten here; the next override write
29
- * persists the translated id because it round-trips this view. */
30
- function translateOverrideNpm(entry) {
31
- if (!entry || typeof entry.npm !== 'string')
31
+ function normalizeOverrideEntry(entry) {
32
+ if (!entry)
32
33
  return entry;
33
- const npm = protocolIdFromNpm(entry.npm);
34
- if (npm === entry.npm)
34
+ if (entry.protocols === undefined)
35
35
  return entry;
36
- if (npm === undefined) {
36
+ const list = normalizeProtocols(entry.protocols);
37
+ if (list.length === 0) {
37
38
  const rest = { ...entry };
38
- delete rest.npm;
39
+ delete rest.protocols;
39
40
  return rest;
40
41
  }
41
- return { ...entry, npm };
42
+ return { ...entry, protocols: list };
42
43
  }
43
44
  export function getOverride(providerId, modelId) {
44
45
  return readOverridesStore()?.models[overrideKey(providerId, modelId)];
@@ -46,6 +47,7 @@ export function getOverride(providerId, modelId) {
46
47
  function persist(store) {
47
48
  const file = getOverridesStorePath();
48
49
  store.updated = Date.now();
50
+ store.version = 2;
49
51
  fs.mkdirSync(path.dirname(file), { recursive: true });
50
52
  const tmp = `${file}.tmp.${process.pid}.${Date.now()}`;
51
53
  fs.writeFileSync(tmp, JSON.stringify(store), 'utf8');
@@ -53,7 +55,7 @@ function persist(store) {
53
55
  }
54
56
  export function upsertOverride(providerId, modelId, entry) {
55
57
  try {
56
- const store = readOverridesStore() ?? { version: 1, updated: 0, models: {} };
58
+ const store = readOverridesStore() ?? { version: 2, updated: 0, models: {} };
57
59
  const merged = { ...(store.models[overrideKey(providerId, modelId)] ?? {}) };
58
60
  if (entry.name !== undefined)
59
61
  merged.name = entry.name;
@@ -75,12 +77,13 @@ export function upsertOverride(providerId, modelId, entry) {
75
77
  merged.disabled = entry.disabled;
76
78
  if (entry.reasoningEfforts !== undefined)
77
79
  merged.reasoningEfforts = entry.reasoningEfforts;
78
- if (entry.npm !== undefined) {
79
- const npm = protocolIdFromNpm(entry.npm);
80
- if (npm === undefined)
81
- delete merged.npm;
80
+ if (entry.protocols !== undefined) {
81
+ // Console may still post a singular SDK string via a one-element list.
82
+ const list = normalizeProtocols(entry.protocols.map((p) => protocolIdFromNpm(p) ?? p));
83
+ if (list.length === 0)
84
+ delete merged.protocols;
82
85
  else
83
- merged.npm = npm;
86
+ merged.protocols = list;
84
87
  }
85
88
  if (entry.defaultEffort !== undefined) {
86
89
  if (entry.defaultEffort === null)
@@ -90,6 +93,12 @@ export function upsertOverride(providerId, modelId, entry) {
90
93
  }
91
94
  if (entry.variants !== undefined)
92
95
  merged.variants = entry.variants;
96
+ if (entry.type !== undefined) {
97
+ if (entry.type === null)
98
+ delete merged.type;
99
+ else
100
+ merged.type = entry.type;
101
+ }
93
102
  store.models[overrideKey(providerId, modelId)] = merged;
94
103
  persist(store);
95
104
  return { success: true };