omnicell-router 0.8.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -7
- package/README.zh-CN.md +18 -5
- package/backend/dist/capture/recorder.d.ts +4 -10
- package/backend/dist/capture/recorder.js +6 -58
- 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 +8 -0
- package/backend/dist/cli/clients/codex.js +5 -0
- 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/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 +5 -0
- package/backend/dist/cli/clients/pi.d.ts +6 -0
- package/backend/dist/cli/clients/pi.js +3 -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 +92 -16
- package/backend/dist/config/comments-en.js +31 -26
- package/backend/dist/config/comments-zh.js +29 -24
- package/backend/dist/config/defaults.d.ts +194 -33
- package/backend/dist/config/defaults.js +193 -32
- package/backend/dist/config/env.d.ts +10 -0
- package/backend/dist/config/env.js +3 -2
- package/backend/dist/config/index.d.ts +7 -0
- package/backend/dist/config/index.js +184 -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/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 +14 -4
- package/backend/dist/config/types.d.ts +167 -38
- 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 +50 -17
- package/backend/dist/forward-proxy/h2-forward.js +36 -10
- package/backend/dist/forward-proxy/index.d.ts +11 -8
- package/backend/dist/forward-proxy/index.js +22 -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 +0 -16
- package/backend/dist/forward-proxy/server.js +124 -156
- package/backend/dist/harness/host/hosts.js +3 -2
- package/backend/dist/index.js +53 -18
- 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 +45 -3
- 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 +82 -24
- package/backend/dist/ir/adapters/openai-responses.js +146 -37
- 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/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 +276 -70
- package/backend/dist/opencode/catalog/ocr-store.js +3 -1
- package/backend/dist/opencode/catalog/overrides-store.d.ts +10 -1
- package/backend/dist/opencode/catalog/overrides-store.js +6 -0
- 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 +25 -2
- package/backend/dist/opencode/catalog/sources/models-dev.js +13 -3
- package/backend/dist/opencode/catalog/types.d.ts +35 -3
- package/backend/dist/opencode/catalog/types.js +38 -1
- 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/probe.d.ts +21 -4
- package/backend/dist/opencode/probe.js +34 -10
- 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 +497 -165
- 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 +98 -14
- package/backend/dist/plugins/host.js +622 -87
- 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 +252 -36
- package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
- 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/provider-takedown.d.ts +5 -2
- package/backend/dist/providers/registry.d.ts +84 -25
- package/backend/dist/providers/registry.js +209 -114
- 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 +35 -5
- 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 +928 -310
- 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 +318 -13
- 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/body-admission.d.ts +67 -2
- package/backend/dist/surfaces/body-admission.js +218 -13
- 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 +9 -3
- package/backend/dist/surfaces/transport-node-http.js +6 -19
- 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 +3 -2
- package/backend/dist/utils/server-liveness.js +3 -2
- 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-KI1OW5x6.css → index-CqDSOPQ0.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +3 -1
- package/frontend/dist/assets/index-Dk76uc7e.js +0 -1522
|
@@ -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;
|
|
@@ -470,7 +657,18 @@ export async function autoPullProvider(id, opts = {}) {
|
|
|
470
657
|
if (!plugin?.pullModels) {
|
|
471
658
|
return { httpStatus: 400, body: { success: false, error: `the ${npmWire} plugin is not installed (console /plugins)` } };
|
|
472
659
|
}
|
|
473
|
-
|
|
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 } : {}) });
|
|
474
672
|
}
|
|
475
673
|
// B4: live capability keyed on the BOUND store (pullLiveModels resolves the
|
|
476
674
|
// same way — one source, no live/catalog branch mismatch). P3-5: capability
|
|
@@ -564,11 +762,19 @@ export async function ensureConnectedProviderBook(id, opts = {}) {
|
|
|
564
762
|
}
|
|
565
763
|
let res = await autoPullProvider(id, {});
|
|
566
764
|
if (!res.body?.success) {
|
|
567
|
-
|
|
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
|
+
};
|
|
568
778
|
}
|
|
569
|
-
return {
|
|
570
|
-
nodeCreated,
|
|
571
|
-
pulled: res.body?.pulled ?? 0,
|
|
572
|
-
...(res.body?.success ? {} : { fillError: String(res.body?.error ?? 'model auto-fill failed') }),
|
|
573
|
-
};
|
|
779
|
+
return { nodeCreated, pulled: res.body?.pulled ?? 0 };
|
|
574
780
|
}
|
|
@@ -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 !== 6
|
|
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;
|
|
@@ -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).
|
|
@@ -52,6 +52,15 @@ export interface OverrideEntry {
|
|
|
52
52
|
id: string;
|
|
53
53
|
effort: string;
|
|
54
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;
|
|
55
64
|
}
|
|
56
65
|
export interface OverrideStore {
|
|
57
66
|
version: 2;
|
|
@@ -93,6 +93,12 @@ export function upsertOverride(providerId, modelId, entry) {
|
|
|
93
93
|
}
|
|
94
94
|
if (entry.variants !== undefined)
|
|
95
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
|
+
}
|
|
96
102
|
store.models[overrideKey(providerId, modelId)] = merged;
|
|
97
103
|
persist(store);
|
|
98
104
|
return { success: true };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CatalogModel } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The catalog's DECLARED on/off fact for a reasoning model — the one reader of
|
|
4
|
+
* "may this model be turned off?", shared by the boot/routing side
|
|
5
|
+
* (`providers/boot-direct.ts`) and the published-capability side
|
|
6
|
+
* (`providers/virtual-meta.ts`).
|
|
7
|
+
*
|
|
8
|
+
* It lives in this neutral module rather than `boot-direct` because both
|
|
9
|
+
* consumers need it and `virtual-meta` is imported by `boot-direct`, so
|
|
10
|
+
* exporting it from `boot-direct` would close a load-time module cycle — the
|
|
11
|
+
* same class of failure as the `surfaces/table.ts` cycle the body-admission ADR
|
|
12
|
+
* documents.
|
|
13
|
+
*
|
|
14
|
+
* models.dev spells "off exists" four ways, and this function reads all four:
|
|
15
|
+
* - a bare `toggle` row (no effort table) — an on/off control, no levels;
|
|
16
|
+
* - an effort table containing `none` — off is spelled as a level;
|
|
17
|
+
* - a `toggle` beside an effort table or budget — off is that toggle;
|
|
18
|
+
* - a budget whose `min` is absent or ≤ 0 — budget ZERO is a legal request.
|
|
19
|
+
*
|
|
20
|
+
* It spells "always thinks" three ways:
|
|
21
|
+
* - an effort table WITHOUT `none` and WITHOUT a `toggle` (2,873 rows — OpenAI
|
|
22
|
+
* `gpt-5` / `gpt-6-astra`, Gemini 3.x). A `budget` beside the table does NOT
|
|
23
|
+
* cancel this: `min: 1024` is a relay's thinking-ON floor, not the off fact,
|
|
24
|
+
* and reading it as "always thinks" clamped real off-asks up to `low` on the
|
|
25
|
+
* 162 claude-opus relay rows — a silent capability LOSS.
|
|
26
|
+
* - an empty `[]` (971 rows — MiniMax M2): always-on, no control at all;
|
|
27
|
+
* - a budget-only row with `min > 0` and no toggle: zero is out of range, so
|
|
28
|
+
* off is inexpressible (87 rows — Anthropic claude `min: 1024`, Gemini 2.5
|
|
29
|
+
* Pro `min: 128`).
|
|
30
|
+
*
|
|
31
|
+
* The `min` of a budget-only row therefore DOES decide (zero legal or not);
|
|
32
|
+
* the `min` beside an effort table does NOT (the table shape decides). Returns
|
|
33
|
+
* `undefined` only when the declaration states no ladder and no budget.
|
|
34
|
+
*/
|
|
35
|
+
export declare function catalogDisableable(catModel: CatalogModel | undefined): boolean | undefined;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalog's DECLARED on/off fact for a reasoning model — the one reader of
|
|
3
|
+
* "may this model be turned off?", shared by the boot/routing side
|
|
4
|
+
* (`providers/boot-direct.ts`) and the published-capability side
|
|
5
|
+
* (`providers/virtual-meta.ts`).
|
|
6
|
+
*
|
|
7
|
+
* It lives in this neutral module rather than `boot-direct` because both
|
|
8
|
+
* consumers need it and `virtual-meta` is imported by `boot-direct`, so
|
|
9
|
+
* exporting it from `boot-direct` would close a load-time module cycle — the
|
|
10
|
+
* same class of failure as the `surfaces/table.ts` cycle the body-admission ADR
|
|
11
|
+
* documents.
|
|
12
|
+
*
|
|
13
|
+
* models.dev spells "off exists" four ways, and this function reads all four:
|
|
14
|
+
* - a bare `toggle` row (no effort table) — an on/off control, no levels;
|
|
15
|
+
* - an effort table containing `none` — off is spelled as a level;
|
|
16
|
+
* - a `toggle` beside an effort table or budget — off is that toggle;
|
|
17
|
+
* - a budget whose `min` is absent or ≤ 0 — budget ZERO is a legal request.
|
|
18
|
+
*
|
|
19
|
+
* It spells "always thinks" three ways:
|
|
20
|
+
* - an effort table WITHOUT `none` and WITHOUT a `toggle` (2,873 rows — OpenAI
|
|
21
|
+
* `gpt-5` / `gpt-6-astra`, Gemini 3.x). A `budget` beside the table does NOT
|
|
22
|
+
* cancel this: `min: 1024` is a relay's thinking-ON floor, not the off fact,
|
|
23
|
+
* and reading it as "always thinks" clamped real off-asks up to `low` on the
|
|
24
|
+
* 162 claude-opus relay rows — a silent capability LOSS.
|
|
25
|
+
* - an empty `[]` (971 rows — MiniMax M2): always-on, no control at all;
|
|
26
|
+
* - a budget-only row with `min > 0` and no toggle: zero is out of range, so
|
|
27
|
+
* off is inexpressible (87 rows — Anthropic claude `min: 1024`, Gemini 2.5
|
|
28
|
+
* Pro `min: 128`).
|
|
29
|
+
*
|
|
30
|
+
* The `min` of a budget-only row therefore DOES decide (zero legal or not);
|
|
31
|
+
* the `min` beside an effort table does NOT (the table shape decides). Returns
|
|
32
|
+
* `undefined` only when the declaration states no ladder and no budget.
|
|
33
|
+
*/
|
|
34
|
+
export function catalogDisableable(catModel) {
|
|
35
|
+
const opts = catModel?.reasoningOptions;
|
|
36
|
+
if (!Array.isArray(opts) || opts.length === 0)
|
|
37
|
+
return undefined;
|
|
38
|
+
const hasToggle = opts.some((o) => o?.type === 'toggle');
|
|
39
|
+
const effort = opts.find((o) => o?.type === 'effort');
|
|
40
|
+
const hasEffortTable = !!(effort && Array.isArray(effort.values) && effort.values.length > 0);
|
|
41
|
+
// A bare toggle (no table to decide against) asserts off on its own.
|
|
42
|
+
if (hasToggle && !hasEffortTable && !opts.some((o) => o?.type === 'budget_tokens'))
|
|
43
|
+
return true;
|
|
44
|
+
if (hasEffortTable) {
|
|
45
|
+
// `none` in the table ⇒ off is a level. Otherwise the TOGGLE decides (a
|
|
46
|
+
// toggle beside the table is off; no toggle ⇒ always-think). A budget
|
|
47
|
+
// beside the table never overrides either way.
|
|
48
|
+
if (effort.values.includes('none'))
|
|
49
|
+
return true;
|
|
50
|
+
return hasToggle ? true : false;
|
|
51
|
+
}
|
|
52
|
+
// A toggle + budget (no table) ⇒ off is the toggle. A budget ZERO is also
|
|
53
|
+
// legal there, but the toggle already answers `true`; keep reading `min`
|
|
54
|
+
// below so a budget-only row is judged by its range.
|
|
55
|
+
const budget = opts.find((o) => o?.type === 'budget_tokens');
|
|
56
|
+
if (budget) {
|
|
57
|
+
if (hasToggle)
|
|
58
|
+
return true;
|
|
59
|
+
// Budget-only: `min > 0` ⇒ zero out of range ⇒ always-think; absent or ≤ 0
|
|
60
|
+
// ⇒ zero legal ⇒ off exists.
|
|
61
|
+
return typeof budget.min === 'number' && budget.min > 0 ? false : true;
|
|
62
|
+
}
|
|
63
|
+
// A toggle with no table and no budget already returned above; anything left
|
|
64
|
+
// states no ladder and no budget: "no control", which withholds nothing.
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
@@ -202,8 +202,16 @@ export class CatalogRepository {
|
|
|
202
202
|
console.log(`[OCR] Catalog store: ${this.ocrLoadOrigin} (${this.ocr?.length ?? 0} providers) — ${getOcrStorePath()}`);
|
|
203
203
|
// Auto-pull models for custom providers in the background (ADD-ONLY,
|
|
204
204
|
// gated by catalog.autoPullModels + the per-provider autoPullPatterns
|
|
205
|
-
// whitelist) — boot completes without waiting for it.
|
|
206
|
-
|
|
205
|
+
// whitelist) — boot completes without waiting for it. The boot fire waits
|
|
206
|
+
// for the plugin host's first load: catalog start precedes
|
|
207
|
+
// loadInstalledPlugins(), and a plugin-owned wire answers the pull through
|
|
208
|
+
// its own pullModels() — sweeping first would read every plugin wire as
|
|
209
|
+
// "plugin is not installed".
|
|
210
|
+
void (async () => {
|
|
211
|
+
const { pluginsReady } = await import('../../plugins/host.js');
|
|
212
|
+
await pluginsReady;
|
|
213
|
+
await this.autoPullSafely();
|
|
214
|
+
})();
|
|
207
215
|
}
|
|
208
216
|
/** Auto-pull sweep with full failure containment (scheduler + boot hook). */
|
|
209
217
|
async autoPullSafely() {
|
|
@@ -217,6 +225,15 @@ export class CatalogRepository {
|
|
|
217
225
|
// are routable (and visible in the matrix) without a restart/console hit.
|
|
218
226
|
requestPoolRefresh();
|
|
219
227
|
}
|
|
228
|
+
// Stale `disabled` flags cleared on defined models change the defs file
|
|
229
|
+
// with no new model — the pool must resync too, or a previously hidden
|
|
230
|
+
// model stays excluded from routing until the next restart.
|
|
231
|
+
const cleared = results.reduce((n, r) => n + (r.cleared ?? 0), 0);
|
|
232
|
+
if (cleared > 0) {
|
|
233
|
+
console.log(`[OCR] Auto model pull: cleared stale hidden flags on ${cleared} model(s)`);
|
|
234
|
+
if (pulled === 0)
|
|
235
|
+
requestPoolRefresh();
|
|
236
|
+
}
|
|
220
237
|
}
|
|
221
238
|
catch {
|
|
222
239
|
// best effort — next sync period retries
|
|
@@ -797,6 +814,12 @@ export class CatalogRepository {
|
|
|
797
814
|
.filter((v) => v.id && v.effort)
|
|
798
815
|
.map((v) => ({ id: v.id, settings: { reasoningEffort: v.effort } }));
|
|
799
816
|
}
|
|
817
|
+
// Operator type correction — the ONLY editing plane for admission, since
|
|
818
|
+
// the routing pool decides on the model's type (e.g. opt a genuinely
|
|
819
|
+
// dual-use image model into the text pool).
|
|
820
|
+
if (entry.type !== undefined && entry.type !== null) {
|
|
821
|
+
model.type = entry.type;
|
|
822
|
+
}
|
|
800
823
|
}
|
|
801
824
|
}
|
|
802
825
|
// 4. live service baseURL hints (effective routing endpoints)
|
|
@@ -37,9 +37,19 @@ export function normalizeModelsDev(raw) {
|
|
|
37
37
|
// false with unknown, leaving the provider layer unable to strip the
|
|
38
38
|
// param (upstream 400 "`temperature` is deprecated").
|
|
39
39
|
temperature: m.temperature === true ? true : m.temperature === false ? false : undefined,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
// `reasoning_options` is required by models.dev whenever
|
|
41
|
+
// `reasoning: true`, and an EMPTY array is a real declaration:
|
|
42
|
+
// "always-on, the caller has no level control". Folding `[]` into
|
|
43
|
+
// `undefined` would erase that and let the legacy boolean expansion
|
|
44
|
+
// advertise all seven levels on 971 always-on rows (ADR-0035 rule 3).
|
|
45
|
+
// Keep the array verbatim (`[]` included); a source that truly omits
|
|
46
|
+
// the field stays `undefined`.
|
|
47
|
+
reasoningOptions: Array.isArray(m.reasoning_options) ? m.reasoning_options : undefined,
|
|
48
|
+
// models.dev publishes the model type as `type` (its `ModelTypeV2`
|
|
49
|
+
// enum: chat/image/embedding/…). OCR stores it under the SAME name —
|
|
50
|
+
// one vocabulary from upstream to the wire. `modalities.output` is NOT
|
|
51
|
+
// a substitute: an embedding or ASR row declares `output: ['text']`.
|
|
52
|
+
type: m.type ? String(m.type) : undefined,
|
|
43
53
|
interleaved: m.interleaved && typeof m.interleaved === 'object' ? m.interleaved : undefined,
|
|
44
54
|
structured_output: m.structured_output === true || undefined,
|
|
45
55
|
status: m.status || undefined,
|