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.
- package/README.md +26 -7
- package/README.zh-CN.md +18 -5
- package/backend/dist/auth/api-keys.js +11 -0
- package/backend/dist/auth/key-models.d.ts +36 -0
- package/backend/dist/auth/key-models.js +99 -0
- package/backend/dist/capture/recorder.d.ts +4 -10
- package/backend/dist/capture/recorder.js +6 -58
- package/backend/dist/cli/clients/activity.js +2 -0
- package/backend/dist/cli/clients/base.d.ts +36 -11
- package/backend/dist/cli/clients/base.js +31 -15
- package/backend/dist/cli/clients/claude.d.ts +9 -0
- package/backend/dist/cli/clients/claude.js +6 -0
- package/backend/dist/cli/clients/codex.d.ts +78 -0
- package/backend/dist/cli/clients/codex.js +475 -57
- package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
- package/backend/dist/cli/clients/core-adapters.js +1 -1
- package/backend/dist/cli/clients/dsh.d.ts +8 -0
- package/backend/dist/cli/clients/dsh.js +5 -0
- package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
- package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
- package/backend/dist/cli/clients/grok.d.ts +15 -1
- package/backend/dist/cli/clients/grok.js +16 -2
- package/backend/dist/cli/clients/index.d.ts +13 -1
- package/backend/dist/cli/clients/index.js +97 -19
- package/backend/dist/cli/clients/kimi.d.ts +6 -0
- package/backend/dist/cli/clients/kimi.js +3 -0
- package/backend/dist/cli/clients/launcher.d.ts +1 -1
- package/backend/dist/cli/clients/model-meta.js +6 -3
- package/backend/dist/cli/clients/omp.d.ts +6 -0
- package/backend/dist/cli/clients/omp.js +3 -0
- package/backend/dist/cli/clients/openclaw.d.ts +6 -0
- package/backend/dist/cli/clients/openclaw.js +3 -0
- package/backend/dist/cli/clients/opencode.d.ts +8 -0
- package/backend/dist/cli/clients/opencode.js +8 -2
- package/backend/dist/cli/clients/pi.d.ts +6 -0
- package/backend/dist/cli/clients/pi.js +3 -0
- package/backend/dist/cli/clients/reserved.js +2 -0
- package/backend/dist/cli/clients/update-check.d.ts +37 -0
- package/backend/dist/cli/clients/update-check.js +309 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
- package/backend/dist/cli/clients/workbuddy.js +66 -0
- package/backend/dist/cli/index.js +5 -4
- package/backend/dist/cli/paths.js +8 -0
- package/backend/dist/cli/types.d.ts +101 -16
- package/backend/dist/config/comments-en.js +34 -25
- package/backend/dist/config/comments-zh.js +33 -24
- package/backend/dist/config/defaults.d.ts +280 -22
- package/backend/dist/config/defaults.js +279 -21
- package/backend/dist/config/env.d.ts +10 -0
- package/backend/dist/config/env.js +3 -2
- package/backend/dist/config/index.d.ts +22 -1
- package/backend/dist/config/index.js +218 -43
- package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
- package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
- package/backend/dist/config/migrations/v10-to-v11.js +43 -0
- package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
- package/backend/dist/config/migrations/v4-to-v5.js +42 -0
- package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
- package/backend/dist/config/migrations/v5-to-v6.js +29 -0
- package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
- package/backend/dist/config/migrations/v6-to-v7.js +97 -0
- package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
- package/backend/dist/config/migrations/v7-to-v8.js +43 -0
- package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
- package/backend/dist/config/migrations/v8-to-v9.js +43 -0
- package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
- package/backend/dist/config/migrations/v9-to-v10.js +71 -0
- package/backend/dist/config/runtime.js +1 -1
- package/backend/dist/config/schema.d.ts +3 -3
- package/backend/dist/config/schema.js +18 -4
- package/backend/dist/config/types.d.ts +221 -41
- package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
- package/backend/dist/egress-proxy/asset-download.js +420 -0
- package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
- package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
- package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
- package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/egress-proxy/mihomo-client.js +308 -0
- package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/egress-proxy/mihomo-config.js +161 -0
- package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
- package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
- package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
- package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
- package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
- package/backend/dist/forward-proxy/egress.d.ts +50 -11
- package/backend/dist/forward-proxy/egress.js +63 -17
- package/backend/dist/forward-proxy/h2-forward.js +42 -15
- package/backend/dist/forward-proxy/index.d.ts +11 -8
- package/backend/dist/forward-proxy/index.js +27 -60
- package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
- package/backend/dist/forward-proxy/interceptor.js +4 -4
- package/backend/dist/forward-proxy/relay.js +3 -3
- package/backend/dist/forward-proxy/rules.d.ts +4 -4
- package/backend/dist/forward-proxy/rules.js +25 -4
- package/backend/dist/forward-proxy/server.d.ts +12 -16
- package/backend/dist/forward-proxy/server.js +237 -171
- package/backend/dist/harness/host/hosts.js +3 -2
- package/backend/dist/index.js +59 -19
- package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
- package/backend/dist/ingress-proxy/access-log.js +774 -0
- package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
- package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
- package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
- package/backend/dist/ingress-proxy/ca-trust.js +315 -0
- package/backend/dist/ingress-proxy/ca.d.ts +104 -0
- package/backend/dist/ingress-proxy/ca.js +273 -0
- package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
- package/backend/dist/ingress-proxy/data-dir.js +45 -0
- package/backend/dist/ingress-proxy/egress.d.ts +151 -0
- package/backend/dist/ingress-proxy/egress.js +364 -0
- package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/ingress-proxy/h2-forward.js +561 -0
- package/backend/dist/ingress-proxy/index.d.ts +24 -0
- package/backend/dist/ingress-proxy/index.js +144 -0
- package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
- package/backend/dist/ingress-proxy/interceptor.js +52 -0
- package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
- package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
- package/backend/dist/ingress-proxy/relay.d.ts +54 -0
- package/backend/dist/ingress-proxy/relay.js +188 -0
- package/backend/dist/ingress-proxy/rules.d.ts +195 -0
- package/backend/dist/ingress-proxy/rules.js +348 -0
- package/backend/dist/ingress-proxy/server.d.ts +153 -0
- package/backend/dist/ingress-proxy/server.js +2065 -0
- package/backend/dist/ingress-proxy/sni.d.ts +35 -0
- package/backend/dist/ingress-proxy/sni.js +124 -0
- package/backend/dist/ingress-proxy/status.d.ts +32 -0
- package/backend/dist/ingress-proxy/status.js +15 -0
- package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
- package/backend/dist/ingress-proxy/system-proxy.js +481 -0
- package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
- package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
- package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
- package/backend/dist/ingress-proxy/traffic-files.js +10 -0
- package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
- package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/ingress-proxy/ws-frames.js +153 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
- package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
- package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
- package/backend/dist/ir/adapters/google-gemini.js +5 -2
- package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
- package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
- package/backend/dist/ir/adapters/openai-chat.js +50 -6
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
- package/backend/dist/ir/adapters/openai-responses.d.ts +92 -1
- package/backend/dist/ir/adapters/openai-responses.js +163 -12
- package/backend/dist/ir/capabilities.js +4 -0
- package/backend/dist/ir/media.d.ts +20 -0
- package/backend/dist/ir/media.js +41 -0
- package/backend/dist/ir/tool-identity.d.ts +35 -0
- package/backend/dist/ir/tool-identity.js +40 -0
- package/backend/dist/ir/types.d.ts +9 -1
- package/backend/dist/ir/validate.d.ts +24 -0
- package/backend/dist/ir/validate.js +113 -63
- package/backend/dist/local/build-jobs.d.ts +66 -0
- package/backend/dist/local/build-jobs.js +243 -0
- package/backend/dist/local/detect.d.ts +32 -0
- package/backend/dist/local/detect.js +145 -0
- package/backend/dist/local/draft-match.d.ts +58 -0
- package/backend/dist/local/draft-match.js +124 -0
- package/backend/dist/local/engine-runtime.d.ts +522 -0
- package/backend/dist/local/engine-runtime.js +1 -0
- package/backend/dist/local/engines.d.ts +241 -0
- package/backend/dist/local/engines.js +651 -0
- package/backend/dist/local/gguf.d.ts +35 -0
- package/backend/dist/local/gguf.js +314 -0
- package/backend/dist/local/hf.d.ts +120 -0
- package/backend/dist/local/hf.js +304 -0
- package/backend/dist/local/install.d.ts +90 -0
- package/backend/dist/local/install.js +421 -0
- package/backend/dist/local/llamacpp.d.ts +55 -0
- package/backend/dist/local/llamacpp.js +177 -0
- package/backend/dist/local/local-provider.d.ts +81 -0
- package/backend/dist/local/local-provider.js +301 -0
- package/backend/dist/local/machine-stats.d.ts +87 -0
- package/backend/dist/local/machine-stats.js +332 -0
- package/backend/dist/local/model-store.d.ts +347 -0
- package/backend/dist/local/model-store.js +1215 -0
- package/backend/dist/local/part-sweep.d.ts +32 -0
- package/backend/dist/local/part-sweep.js +156 -0
- package/backend/dist/local/plan.d.ts +65 -0
- package/backend/dist/local/plan.js +146 -0
- package/backend/dist/local/resources.d.ts +49 -0
- package/backend/dist/local/resources.js +64 -0
- package/backend/dist/local/run-stats.d.ts +95 -0
- package/backend/dist/local/run-stats.js +195 -0
- package/backend/dist/local/runner.d.ts +235 -0
- package/backend/dist/local/runner.js +1392 -0
- package/backend/dist/local/settings.d.ts +79 -0
- package/backend/dist/local/settings.js +180 -0
- package/backend/dist/local/strata-catalog.d.ts +30 -0
- package/backend/dist/local/strata-catalog.js +511 -0
- package/backend/dist/local/strata-drafting.d.ts +46 -0
- package/backend/dist/local/strata-drafting.js +265 -0
- package/backend/dist/local/strata.d.ts +278 -0
- package/backend/dist/local/strata.js +1392 -0
- package/backend/dist/local/tar.d.ts +20 -0
- package/backend/dist/local/tar.js +367 -0
- package/backend/dist/local/transport.d.ts +35 -0
- package/backend/dist/local/transport.js +89 -0
- package/backend/dist/local/tune.d.ts +58 -0
- package/backend/dist/local/tune.js +324 -0
- package/backend/dist/observability/http-exchange.d.ts +2 -2
- package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
- package/backend/dist/opencode/catalog/auto-pull.js +284 -77
- package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
- package/backend/dist/opencode/catalog/ocr-store.js +4 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +15 -4
- package/backend/dist/opencode/catalog/overrides-store.js +28 -19
- package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
- package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
- package/backend/dist/opencode/catalog/repository.js +28 -5
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
- package/backend/dist/opencode/catalog/sources/models-dev.js +42 -14
- package/backend/dist/opencode/catalog/types.d.ts +42 -12
- package/backend/dist/opencode/catalog/types.js +38 -1
- package/backend/dist/opencode/credentials/def-materialize.js +27 -21
- package/backend/dist/opencode/credentials/ocr-store.js +11 -2
- package/backend/dist/opencode/credentials/sync.js +12 -3
- package/backend/dist/opencode/credentials/types.d.ts +31 -4
- package/backend/dist/opencode/credentials/types.js +25 -0
- package/backend/dist/opencode/migrate/engine.d.ts +20 -0
- package/backend/dist/opencode/migrate/engine.js +71 -0
- package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
- package/backend/dist/opencode/migrate/migrator.js +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
- package/backend/dist/opencode/probe.d.ts +21 -4
- package/backend/dist/opencode/probe.js +34 -10
- package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
- package/backend/dist/opencode/provider-def-adapters.js +43 -27
- package/backend/dist/opencode/provider-defs.d.ts +10 -16
- package/backend/dist/opencode/provider-defs.js +45 -45
- package/backend/dist/opencode/user-config.d.ts +23 -26
- package/backend/dist/opencode/user-config.js +95 -77
- package/backend/dist/pipeline/directives.d.ts +9 -4
- package/backend/dist/pipeline/directives.js +14 -10
- package/backend/dist/pipeline/orchestrator.d.ts +42 -13
- package/backend/dist/pipeline/orchestrator.js +514 -172
- package/backend/dist/plugins/builtin/model-gateway.js +38 -12
- package/backend/dist/plugins/environment-ack.d.ts +51 -0
- package/backend/dist/plugins/environment-ack.js +81 -0
- package/backend/dist/plugins/gateways.d.ts +6 -6
- package/backend/dist/plugins/gateways.js +2 -2
- package/backend/dist/plugins/host.d.ts +100 -16
- package/backend/dist/plugins/host.js +637 -99
- package/backend/dist/plugins/install-run.d.ts +27 -0
- package/backend/dist/plugins/install-run.js +99 -0
- package/backend/dist/plugins/manifest.d.ts +84 -32
- package/backend/dist/plugins/manifest.js +149 -45
- package/backend/dist/plugins/market-install.d.ts +18 -0
- package/backend/dist/plugins/market-install.js +111 -0
- package/backend/dist/plugins/market-source.d.ts +100 -0
- package/backend/dist/plugins/market-source.js +449 -0
- package/backend/dist/plugins/market-updates.d.ts +70 -0
- package/backend/dist/plugins/market-updates.js +97 -0
- package/backend/dist/plugins/market.d.ts +677 -0
- package/backend/dist/plugins/market.js +2113 -0
- package/backend/dist/plugins/source-index.d.ts +155 -0
- package/backend/dist/plugins/source-index.js +217 -0
- package/backend/dist/plugins/types.d.ts +402 -37
- package/backend/dist/projects/worktrees.d.ts +88 -0
- package/backend/dist/projects/worktrees.js +220 -0
- package/backend/dist/providers/boot-direct.d.ts +41 -7
- package/backend/dist/providers/boot-direct.js +284 -44
- package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
- package/backend/dist/providers/dial-wire.d.ts +17 -0
- package/backend/dist/providers/dial-wire.js +49 -0
- package/backend/dist/providers/executors/dispatch.d.ts +17 -7
- package/backend/dist/providers/executors/dispatch.js +28 -9
- package/backend/dist/providers/executors/openai-chat.js +14 -2
- package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
- package/backend/dist/providers/executors/plugin-adapter.js +59 -3
- package/backend/dist/providers/member-match.d.ts +32 -9
- package/backend/dist/providers/member-match.js +65 -21
- package/backend/dist/providers/model-resolution.d.ts +62 -0
- package/backend/dist/providers/model-resolution.js +62 -0
- package/backend/dist/providers/price-order.d.ts +51 -0
- package/backend/dist/providers/price-order.js +54 -0
- package/backend/dist/providers/protocols-field.d.ts +24 -0
- package/backend/dist/providers/protocols-field.js +66 -0
- package/backend/dist/providers/provider-takedown.d.ts +5 -2
- package/backend/dist/providers/registry.d.ts +87 -26
- package/backend/dist/providers/registry.js +232 -121
- package/backend/dist/providers/selection.d.ts +91 -0
- package/backend/dist/providers/selection.js +158 -0
- package/backend/dist/providers/virtual-meta.d.ts +33 -2
- package/backend/dist/providers/virtual-meta.js +74 -18
- package/backend/dist/quota/cli-login.d.ts +25 -4
- package/backend/dist/quota/cli-login.js +38 -6
- package/backend/dist/quota/coverage-generation.d.ts +24 -0
- package/backend/dist/quota/coverage-generation.js +29 -0
- package/backend/dist/quota/declarations.js +8 -4
- package/backend/dist/quota/engine.js +2 -2
- package/backend/dist/quota/prober.d.ts +43 -2
- package/backend/dist/quota/prober.js +97 -22
- package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
- package/backend/dist/resilience/error-classifier.js +29 -0
- package/backend/dist/router/index.d.ts +1 -1
- package/backend/dist/router/index.js +17 -1
- package/backend/dist/router/layer2-decision.d.ts +1 -1
- package/backend/dist/router/layer2-decision.js +2 -2
- package/backend/dist/routes/console.js +1043 -405
- package/backend/dist/routes/environments.js +1 -1
- package/backend/dist/routes/local-models.d.ts +2 -0
- package/backend/dist/routes/local-models.js +1414 -0
- package/backend/dist/routes/mihomo.d.ts +2 -2
- package/backend/dist/routes/mihomo.js +20 -11
- package/backend/dist/routes/projects.js +121 -0
- package/backend/dist/server.js +409 -15
- package/backend/dist/session/session-manager.d.ts +42 -5
- package/backend/dist/session/session-manager.js +64 -11
- package/backend/dist/session/session-row.d.ts +29 -8
- package/backend/dist/session/session-row.js +18 -13
- package/backend/dist/snapshot/bundle.d.ts +40 -0
- package/backend/dist/snapshot/bundle.js +177 -0
- package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
- package/backend/dist/snapshot/handoff/compress.js +77 -0
- package/backend/dist/snapshot/handoff/index.d.ts +119 -0
- package/backend/dist/snapshot/handoff/index.js +160 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
- package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
- package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
- package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
- package/backend/dist/snapshot/handoff/summarize.js +118 -0
- package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
- package/backend/dist/snapshot/handoff/transcript.js +167 -0
- package/backend/dist/snapshot/media-fs.d.ts +10 -0
- package/backend/dist/snapshot/media-fs.js +50 -0
- package/backend/dist/snapshot/media.d.ts +32 -0
- package/backend/dist/snapshot/media.js +87 -0
- package/backend/dist/snapshot/store.d.ts +226 -0
- package/backend/dist/snapshot/store.js +887 -0
- package/backend/dist/snapshot/tree.d.ts +112 -0
- package/backend/dist/snapshot/tree.js +207 -0
- package/backend/dist/snapshot/types.d.ts +212 -0
- package/backend/dist/snapshot/types.js +14 -0
- package/backend/dist/snapshot/view.d.ts +19 -0
- package/backend/dist/snapshot/view.js +57 -0
- package/backend/dist/snapshot/write-worker.d.ts +67 -0
- package/backend/dist/snapshot/write-worker.js +129 -0
- package/backend/dist/surfaces/anthropic.js +4 -1
- package/backend/dist/surfaces/body-admission.d.ts +344 -0
- package/backend/dist/surfaces/body-admission.js +818 -0
- package/backend/dist/surfaces/chat-pipeline.js +8 -0
- package/backend/dist/surfaces/decision-pipeline.js +10 -7
- package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
- package/backend/dist/surfaces/gateway-catalog.js +202 -0
- package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
- package/backend/dist/surfaces/gateway-chat.js +50 -12
- package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
- package/backend/dist/surfaces/ocr-headers.js +11 -7
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/transport-fastify.js +32 -5
- package/backend/dist/surfaces/transport-node-http.d.ts +51 -6
- package/backend/dist/surfaces/transport-node-http.js +76 -16
- package/backend/dist/surfaces/types.d.ts +11 -3
- package/backend/dist/trace/persist.js +21 -1
- package/backend/dist/trace/tracker.d.ts +35 -3
- package/backend/dist/trace/tracker.js +23 -0
- package/backend/dist/types/openai.d.ts +8 -0
- package/backend/dist/types/router.d.ts +17 -6
- package/backend/dist/types/router.js +14 -2
- package/backend/dist/utils/client-families.d.ts +66 -0
- package/backend/dist/utils/client-families.js +127 -0
- package/backend/dist/utils/event-ring.d.ts +1 -1
- package/backend/dist/utils/event-ring.js +1 -1
- package/backend/dist/utils/proxy-node.js +1 -1
- package/backend/dist/utils/proxy.d.ts +135 -11
- package/backend/dist/utils/proxy.js +144 -29
- package/backend/dist/utils/run-command.d.ts +21 -1
- package/backend/dist/utils/run-command.js +64 -4
- package/backend/dist/utils/server-liveness.d.ts +28 -0
- package/backend/dist/utils/server-liveness.js +32 -0
- package/backend/dist/utils/session-file.d.ts +28 -0
- package/backend/dist/utils/session-file.js +34 -0
- package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
- package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
- package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
- package/frontend/dist/assets/{index-DxZ9MHKB.css → index-CqDSOPQ0.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +3 -1
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
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:
|
|
193
|
+
httpStatus: live.reasonCode === 'pull_http' ? (live.httpStatus === 401 || live.httpStatus === 403 ? 401 : 502) : 502,
|
|
67
194
|
body: {
|
|
68
195
|
success: false,
|
|
69
|
-
reasonCode:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
|
463
|
-
const
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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,
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 !==
|
|
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:
|
|
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
|
|
47
|
-
|
|
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:
|
|
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 !==
|
|
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] =
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
function translateOverrideNpm(entry) {
|
|
31
|
-
if (!entry || typeof entry.npm !== 'string')
|
|
31
|
+
function normalizeOverrideEntry(entry) {
|
|
32
|
+
if (!entry)
|
|
32
33
|
return entry;
|
|
33
|
-
|
|
34
|
-
if (npm === entry.npm)
|
|
34
|
+
if (entry.protocols === undefined)
|
|
35
35
|
return entry;
|
|
36
|
-
|
|
36
|
+
const list = normalizeProtocols(entry.protocols);
|
|
37
|
+
if (list.length === 0) {
|
|
37
38
|
const rest = { ...entry };
|
|
38
|
-
delete rest.
|
|
39
|
+
delete rest.protocols;
|
|
39
40
|
return rest;
|
|
40
41
|
}
|
|
41
|
-
return { ...entry,
|
|
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:
|
|
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.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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.
|
|
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 };
|