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
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { pickDialWire } from './dial-wire.js';
|
|
1
2
|
import { OpenAIChatProvider } from './executors/openai-chat.js';
|
|
2
3
|
import { AnthropicMessagesProvider } from './executors/anthropic-messages.js';
|
|
3
4
|
import { OpenAIResponsesProvider } from './executors/openai-responses.js';
|
|
4
5
|
import { GoogleGeminiProvider } from './executors/google-gemini.js';
|
|
5
6
|
import { getModelServicePlugin } from '../plugins/host.js';
|
|
6
|
-
import { EFFORT_LADDER, downgradeReasoning, modelSupportsEfforts } from '../types/router.js';
|
|
7
|
+
import { TIER_RANK, COST_MODE_TIER_CEILING, EFFORT_LADDER, downgradeReasoning, modelSupportsEfforts } from '../types/router.js';
|
|
8
|
+
import { IrUnsupportedError } from '../ir/errors.js';
|
|
9
|
+
import { withDialContext } from '../ir/validate.js';
|
|
7
10
|
import { createEventAccumulator } from '../ir/stream.js';
|
|
8
11
|
import { createToolMarkupScanner, detectToolMarkupLeak } from './compat/tool-markup-leak.js';
|
|
9
12
|
import { createToolMarkupStreamRecovery, recoverToolMarkupInResponse, toolMarkupRecoveryFor } from './compat/tool-markup-recovery.js';
|
|
@@ -14,8 +17,10 @@ import { canonicalProtocol } from './protocol.js';
|
|
|
14
17
|
import { CircuitBreakerManager, UpstreamError } from '../resilience/index.js';
|
|
15
18
|
import { globMatchAny } from '../utils/glob.js';
|
|
16
19
|
import { loadConfig } from '../config/index.js';
|
|
17
|
-
import {
|
|
18
|
-
import { resolveTierMembers, claimModel, claimInTier, matchingTiers, applyEffortMap, MEMBER_TIER_ORDER, TIER_DESCENDING_ORDER, comboMemberRefsOf, expandComboRefs, RESERVED_IDS } from './member-match.js';
|
|
20
|
+
import { resolveEgress } from '../utils/proxy.js';
|
|
21
|
+
import { resolveTierMembers, claimModel, claimInTier, matchingTiers, applyEffortMap, markExactFullIds, MEMBER_TIER_ORDER, TIER_DESCENDING_ORDER, comboMemberRefsOf, expandComboRefs, RESERVED_IDS } from './member-match.js';
|
|
22
|
+
import { WeightedRoundRobin, normalizeSelectionStrategy, normalizeMemberWeight } from './selection.js';
|
|
23
|
+
import { comparePriceBucket, comparePriceThenId, samePriceBucket } from './price-order.js';
|
|
19
24
|
/**
|
|
20
25
|
* Normalize a client-supplied upstream host for provider matching: lowercase,
|
|
21
26
|
* strip IPv6 brackets and a trailing :port. Returns undefined for empty or
|
|
@@ -81,9 +86,11 @@ export class ProviderRegistry {
|
|
|
81
86
|
* so what routing sees is always exactly what was last committed.
|
|
82
87
|
*/
|
|
83
88
|
committedMembers = { lite: [], plus: [], pro: [], ultra: [] };
|
|
84
|
-
|
|
89
|
+
/** Smooth weighted round-robin cursors — one per tier pool. */
|
|
90
|
+
tierRr = new WeightedRoundRobin();
|
|
85
91
|
combos = new Map();
|
|
86
|
-
|
|
92
|
+
/** Smooth weighted round-robin cursors — one per combo pool. */
|
|
93
|
+
comboRr = new WeightedRoundRobin();
|
|
87
94
|
/** Fingerprint of the combo section last applied by applyCombos — lets the
|
|
88
95
|
* lazy hand-edit safety net skip no-op replays instead of resetting
|
|
89
96
|
* round-robin cursors and re-logging skip warnings every TTL window. */
|
|
@@ -397,7 +404,7 @@ export class ProviderRegistry {
|
|
|
397
404
|
* containing `/` are rejected (those are full-id lookups, not bare names).
|
|
398
405
|
*
|
|
399
406
|
* `upstreamHost` (the proxy-interception target host, when the request
|
|
400
|
-
* arrived through the MITM
|
|
407
|
+
* arrived through the MITM ingress proxy) disambiguates same-name models:
|
|
401
408
|
* candidates whose provider baseUrl hostname matches the host win; when
|
|
402
409
|
* nothing matches (hooked clients hit the gateway itself, unknown hosts)
|
|
403
410
|
* the full hit list applies. Empty result = no registered model carries
|
|
@@ -414,15 +421,13 @@ export class ProviderRegistry {
|
|
|
414
421
|
// Locale-independent tiebreak: strict code-unit order, not localeCompare.
|
|
415
422
|
// Unpriced models sort last: an unknown price cannot claim to be the
|
|
416
423
|
// cheapest, and `Infinity` keeps that ordering without inventing a number.
|
|
417
|
-
const byPrice = (a, b) => (a.pricing?.input ?? Infinity) - (b.pricing?.input ?? Infinity) ||
|
|
418
|
-
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
419
424
|
const host = normalizeHostHeader(upstreamHost);
|
|
420
425
|
if (host) {
|
|
421
426
|
const scoped = hits.filter((m) => this.providerHosts.get(m.provider) === host);
|
|
422
427
|
if (scoped.length > 0)
|
|
423
|
-
return scoped.sort(
|
|
428
|
+
return scoped.sort(comparePriceThenId);
|
|
424
429
|
}
|
|
425
|
-
return hits.sort(
|
|
430
|
+
return hits.sort(comparePriceThenId);
|
|
426
431
|
}
|
|
427
432
|
/** Raw provider config (any type) — used for provider baseUrl/apiKey
|
|
428
433
|
* lookup (e.g. boot-time provider registration). */
|
|
@@ -462,54 +467,74 @@ export class ProviderRegistry {
|
|
|
462
467
|
* a weight per pool), default 1. */
|
|
463
468
|
weightFor(tier, modelId) {
|
|
464
469
|
const claim = claimInTier(tier, modelId, this.committedMembers);
|
|
465
|
-
return claim ?
|
|
470
|
+
return claim ? normalizeMemberWeight(claim.rule.weight) : 1;
|
|
466
471
|
}
|
|
467
|
-
/** Effective selection strategy: explicit config wins
|
|
472
|
+
/** Effective selection strategy: explicit config wins, default priority. */
|
|
468
473
|
selectionStrategy(tier) {
|
|
469
|
-
return this.tierPolicies?.[tier]?.selection
|
|
470
|
-
}
|
|
471
|
-
/** Weighted round-robin: each model occupies `weight` consecutive slots per cycle. */
|
|
472
|
-
pickRoundRobin(models, tier) {
|
|
473
|
-
const slots = [];
|
|
474
|
-
for (const m of models) {
|
|
475
|
-
const w = this.weightFor(tier, m.id);
|
|
476
|
-
for (let i = 0; i < w; i++)
|
|
477
|
-
slots.push(m);
|
|
478
|
-
}
|
|
479
|
-
if (slots.length === 0)
|
|
480
|
-
return models[0];
|
|
481
|
-
const prev = this.rrCursor.get(tier) ?? 0;
|
|
482
|
-
this.rrCursor.set(tier, prev + 1);
|
|
483
|
-
return slots[prev % slots.length];
|
|
474
|
+
return normalizeSelectionStrategy(this.tierPolicies?.[tier]?.selection);
|
|
484
475
|
}
|
|
485
476
|
/**
|
|
486
477
|
* Primary pick inside a tier, driven by the tier's selection strategy:
|
|
487
478
|
* - priority (default): first healthy candidate in chain order (= member
|
|
488
479
|
* list order)
|
|
489
|
-
* -
|
|
490
|
-
* rule's weight
|
|
491
|
-
*
|
|
480
|
+
* - weighted_round_robin: smooth WEIGHTED round-robin — weight = the
|
|
481
|
+
* claiming member rule's weight (default 1), served in proportion, evenly
|
|
482
|
+
* interleaved
|
|
483
|
+
* - round_robin: plain sequential round-robin — equal turns, weights ignored
|
|
484
|
+
* `weighted_round_robin` and `round_robin` share ONE smooth round-robin core
|
|
485
|
+
* (combos use it too); only the weight policy differs.
|
|
492
486
|
* The failover chain order is strategy-independent (buildTierPoolEntries:
|
|
493
487
|
* rule weight desc, then rule list order).
|
|
494
488
|
*/
|
|
495
|
-
pickPrimary(models, tier) {
|
|
496
|
-
if (models.length <= 1)
|
|
497
|
-
return models[0];
|
|
489
|
+
pickPrimary(models, tier, costOrder = false) {
|
|
498
490
|
const strategy = this.selectionStrategy(tier);
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
491
|
+
// Cost mode (ADR-0001 §2): restrict the pool to the CHEAPEST price bucket
|
|
492
|
+
// BEFORE the strategy runs, so a pricier member is never selected ahead of
|
|
493
|
+
// a cheaper one — under `priority` too. `priority` returns a head, and a
|
|
494
|
+
// caller list (widened access pool, model-access expansion) is not
|
|
495
|
+
// guaranteed to be price-sorted, so the bucket anchor is the
|
|
496
|
+
// lexicographically CHEAPEST member rather than `models[0]`. Equal-priced
|
|
497
|
+
// members keep sharing turns (rotation draws inside the bucket).
|
|
498
|
+
let pool = models;
|
|
499
|
+
if (costOrder && models.length > 1) {
|
|
500
|
+
const cheapest = models.reduce((best, m) => (comparePriceBucket(m, best) < 0 ? m : best), models[0]);
|
|
501
|
+
const bucket = models.filter((m) => samePriceBucket(m, cheapest));
|
|
502
|
+
if (bucket.length > 0)
|
|
503
|
+
pool = bucket;
|
|
511
504
|
}
|
|
512
|
-
|
|
505
|
+
// `priority` never touches a cursor. The rotation strategies ALWAYS go
|
|
506
|
+
// through the core — including a single-member pool, whose identity check
|
|
507
|
+
// resets a stale vector after a shrink (a short-circuit here would strand
|
|
508
|
+
// credit accumulated before it).
|
|
509
|
+
if (strategy === 'priority')
|
|
510
|
+
return pool[0];
|
|
511
|
+
const weightOf = strategy === 'weighted_round_robin' ? (m) => this.weightFor(tier, m.id) : () => 1;
|
|
512
|
+
// The price projection keeps its OWN cursor: `routing.mode` is hot-reloaded
|
|
513
|
+
// (config/runtime.ts `syncRuntimeAuthView`), so a cost bucket draw and a
|
|
514
|
+
// full-pool draw of this tier can alternate inside one process. A shared
|
|
515
|
+
// key would reset the other projection's credit vector on every toggle.
|
|
516
|
+
return this.tierRr.pick(`${tier}:${strategy}${costOrder ? ':cost' : ''}`, pool, (m) => m.id, weightOf);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Strategy-aware leader over an ALREADY-FILTERED candidate list. `getModelForTier`
|
|
520
|
+
* assembles the pool (health, denylist, cross-tier fallback) and then picks;
|
|
521
|
+
* this is the pure pick for a chain whose pool was filtered elsewhere
|
|
522
|
+
* (model access, widening) — the serving chain must lead with this model.
|
|
523
|
+
*/
|
|
524
|
+
pickLeader(tier, candidates, costOrder = false) {
|
|
525
|
+
return this.pickPrimary(candidates, tier, costOrder);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Chain order for a ready candidate list: the strategy-selected leader first,
|
|
529
|
+
* then the remaining members in their existing order. `priority` leaves the
|
|
530
|
+
* list untouched (its head already leads); only the rotation strategies
|
|
531
|
+
* reorder, and the failover walk after the head is unchanged.
|
|
532
|
+
*/
|
|
533
|
+
orderChain(tier, candidates, costOrder = false) {
|
|
534
|
+
if (candidates.length === 0)
|
|
535
|
+
return candidates;
|
|
536
|
+
const leader = this.pickPrimary(candidates, tier, costOrder);
|
|
537
|
+
return [leader, ...candidates.filter((m) => m.id !== leader.id)];
|
|
513
538
|
}
|
|
514
539
|
/**
|
|
515
540
|
* Per-tier pool construction — the ONE membership read for a single tier.
|
|
@@ -524,7 +549,7 @@ export class ProviderRegistry {
|
|
|
524
549
|
* weight and effortMap — the translation that applies when the model
|
|
525
550
|
* serves from THIS pool.
|
|
526
551
|
*/
|
|
527
|
-
buildTierPoolEntries(tier, members) {
|
|
552
|
+
buildTierPoolEntries(tier, members, order = 'declared') {
|
|
528
553
|
const entries = [];
|
|
529
554
|
for (const m of this.models.values()) {
|
|
530
555
|
if (!m.autoTier) {
|
|
@@ -534,7 +559,7 @@ export class ProviderRegistry {
|
|
|
534
559
|
const claim = claimInTier(tier, m.id, members);
|
|
535
560
|
entries.push({
|
|
536
561
|
model: m,
|
|
537
|
-
weight: claim ?
|
|
562
|
+
weight: claim ? normalizeMemberWeight(claim.rule.weight) : 1,
|
|
538
563
|
effortMap: m.effortMap,
|
|
539
564
|
rank: m.isDefaultInTier ? 0 : m.priority ?? 10,
|
|
540
565
|
});
|
|
@@ -545,12 +570,17 @@ export class ProviderRegistry {
|
|
|
545
570
|
continue;
|
|
546
571
|
entries.push({
|
|
547
572
|
model: m,
|
|
548
|
-
weight:
|
|
573
|
+
weight: normalizeMemberWeight(claim.rule.weight),
|
|
549
574
|
effortMap: claim.rule.effortMap,
|
|
550
575
|
rank: claim.index,
|
|
551
576
|
});
|
|
552
577
|
}
|
|
553
|
-
|
|
578
|
+
// `declared` = weight desc then rule-list order (the operator's own chain).
|
|
579
|
+
// `cheapest` = price first, then the declared order INSIDE a price bucket
|
|
580
|
+
// (cost mode only, ADR-0001 §2; see providers/price-order.ts).
|
|
581
|
+
entries.sort((a, b) => (order === 'cheapest' ? comparePriceBucket(a.model, b.model) : 0) ||
|
|
582
|
+
b.weight - a.weight ||
|
|
583
|
+
a.rank - b.rank);
|
|
554
584
|
return entries;
|
|
555
585
|
}
|
|
556
586
|
/**
|
|
@@ -620,22 +650,40 @@ export class ProviderRegistry {
|
|
|
620
650
|
this.autoRefreshMembers = on;
|
|
621
651
|
}
|
|
622
652
|
/** Registered member refs of one combo (config order, deduped, unregistered
|
|
623
|
-
dropped) — null when the ref is dead:
|
|
624
|
-
shadowed by a registered model. */
|
|
653
|
+
dropped), each carrying its OWN effortMap — null when the ref is dead:
|
|
654
|
+
unknown id, operator-disabled, or shadowed by a registered model. */
|
|
625
655
|
comboMemberRefs(comboId) {
|
|
626
656
|
const combo = this.combos.get(comboId);
|
|
627
657
|
if (!combo || combo.disabled === true || this.models.has(comboId))
|
|
628
658
|
return null;
|
|
629
|
-
return comboMemberRefsOf(combo, (id) => this.models.has(id));
|
|
659
|
+
return { members: comboMemberRefsOf(combo, (id) => this.models.has(id)) };
|
|
660
|
+
}
|
|
661
|
+
/** Per-member thinking-level translations of one combo, keyed by member id
|
|
662
|
+
(ADR-0003). Consumed by the directly-addressed combo path, which has no
|
|
663
|
+
pool context to re-derive from. Empty when the combo is unknown/dead or
|
|
664
|
+
declares no member tables. */
|
|
665
|
+
comboEffortMaps(comboId) {
|
|
666
|
+
const out = new Map();
|
|
667
|
+
for (const member of this.comboMemberRefs(comboId)?.members ?? []) {
|
|
668
|
+
if (member.effortMap)
|
|
669
|
+
out.set(member.id, member.effortMap);
|
|
670
|
+
}
|
|
671
|
+
return out;
|
|
630
672
|
}
|
|
631
673
|
/**
|
|
632
674
|
* The ONE member-rule read view: `tiers.<t>.members` with `combo:<id>` refs
|
|
633
|
-
* expanded in place
|
|
634
|
-
* boot, save checks) must read through this
|
|
635
|
-
* lists while config keeps the operator's
|
|
675
|
+
* expanded in place and hand-written FULL ids pinned exact. Every membership
|
|
676
|
+
* consumer (claims, weights, pools, boot, save checks) must read through this
|
|
677
|
+
* so pools stay physical-model lists while config keeps the operator's
|
|
678
|
+
* declared references. Exact pinning is a PROJECTION concern, not a config
|
|
679
|
+
* write: the stored `tiers` keeps the operator's plain pattern.
|
|
636
680
|
*/
|
|
637
681
|
expandedMemberRules(policies) {
|
|
638
|
-
|
|
682
|
+
const expanded = expandComboRefs(resolveTierMembers(policies).tiers, (id) => this.comboMemberRefs(id));
|
|
683
|
+
const registered = new Set();
|
|
684
|
+
for (const id of this.models.keys())
|
|
685
|
+
registered.add(id.toLowerCase());
|
|
686
|
+
return { dead: expanded.dead, tiers: markExactFullIds(expanded.tiers, (id) => registered.has(id.toLowerCase())) };
|
|
639
687
|
}
|
|
640
688
|
/**
|
|
641
689
|
* COMMIT path — the only one that rewrites live pool membership. Called on
|
|
@@ -725,37 +773,66 @@ export class ProviderRegistry {
|
|
|
725
773
|
* pool (one whose supported set sits above the requested level) is
|
|
726
774
|
* NOT a valid match — we'd rather let the orchestrator pick a
|
|
727
775
|
* different route than silently drop to `none`.
|
|
776
|
+
*
|
|
777
|
+
* `maxTier` bounds Pass 2 (the cross-tier search): no tier ranked above it
|
|
778
|
+
* may serve. Cost mode passes COST_MODE_TIER_CEILING so an effort the lite
|
|
779
|
+
* pool cannot satisfy can never spend a pro/ultra model (ADR-0001 §28).
|
|
780
|
+
* Defaulting to undefined keeps the unrestricted cross-tier search for
|
|
781
|
+
* smart/quality and for direct registry callers.
|
|
782
|
+
*
|
|
783
|
+
* `sameTierOnly` disables Pass 2 entirely: the request is served from THIS
|
|
784
|
+
* tier or not at all. A `same_tier_only` failover policy and a client-forced
|
|
785
|
+
* tier both demand it — a forced lite must never be widened onto a plus/pro
|
|
786
|
+
* model by an effort-aware pick (ADR-0014).
|
|
728
787
|
*/
|
|
729
|
-
pickModelForEffort(tier, requested, healthyOnly = true) {
|
|
788
|
+
pickModelForEffort(tier, requested, healthyOnly = true, costOrder = false, maxTier, sameTierOnly = false) {
|
|
730
789
|
if (requested === 'none') {
|
|
731
790
|
// No thinking requested. Legacy pass-through (any model) UNLESS a
|
|
732
791
|
// member rule maps `none` to a real level (e.g. none→high):
|
|
733
792
|
// then the mapped candidates compete and the mapped level is served.
|
|
734
|
-
const entries = this.tierPoolEntries(tier, healthyOnly);
|
|
793
|
+
const entries = this.tierPoolEntries(tier, healthyOnly, { costOrder });
|
|
735
794
|
if (entries.some((e) => applyEffortMap(e.effortMap, 'none') !== 'none')) {
|
|
736
795
|
const mapped = this.bestEffortMatch(entries, requested);
|
|
737
796
|
if (mapped)
|
|
738
797
|
return mapped;
|
|
739
798
|
}
|
|
740
|
-
|
|
799
|
+
// Pass-through head is NOT a selection: the caller's per-request chain
|
|
800
|
+
// head is the one real pick, so reading the rotation cursor here would
|
|
801
|
+
// advance it twice per request and serve every second draw. The pool
|
|
802
|
+
// head (all health levels, never drawn) is the same model the chain
|
|
803
|
+
// would lead with.
|
|
804
|
+
const head = entries[0]?.model ?? this.getCandidateModelsForTier(tier, false, { costOrder })[0];
|
|
805
|
+
if (head)
|
|
806
|
+
return { model: head, actualEffort: 'none', degraded: false };
|
|
807
|
+
// Pool empty at every health level: keep the getter's cross-tier /
|
|
808
|
+
// throw contract. No rotation draw can happen here — a pool with no
|
|
809
|
+
// candidate has nothing for pickPrimary to advance.
|
|
810
|
+
const m = this.getModelForTier(tier, healthyOnly, costOrder);
|
|
741
811
|
if (m)
|
|
742
812
|
return { model: m, actualEffort: 'none', degraded: false };
|
|
743
813
|
return null;
|
|
744
814
|
}
|
|
745
815
|
// Pass 1: pick from the requested tier (each candidate is first translated
|
|
746
816
|
// by ITS pool's effortMap, then capability-clamped — see bestEffortMatch).
|
|
747
|
-
const tierPick = this.bestEffortMatch(this.tierPoolEntries(tier, healthyOnly), requested);
|
|
817
|
+
const tierPick = this.bestEffortMatch(this.tierPoolEntries(tier, healthyOnly, { costOrder }), requested);
|
|
748
818
|
if (tierPick)
|
|
749
819
|
return tierPick;
|
|
750
820
|
// Pass 2: cross-tier fallback — search all tiers in tier-rank order
|
|
751
821
|
// (highest first) for any healthy thinking-capable model. Per design
|
|
752
822
|
// decision 2026-10: cross-tier mixing is allowed; the actual model is
|
|
753
|
-
// still reported in the response so the caller sees the truth.
|
|
823
|
+
// still reported in the response so the caller sees the truth. `maxTier`
|
|
824
|
+
// caps that walk (cost mode must never spend above its ceiling).
|
|
825
|
+
// `sameTierOnly` refuses the walk outright — the tier is a hard bound, not
|
|
826
|
+
// a preference (same_tier_only policy / a client-forced tier).
|
|
827
|
+
if (sameTierOnly)
|
|
828
|
+
return null;
|
|
754
829
|
const tierOrder = TIER_DESCENDING_ORDER;
|
|
755
830
|
for (const t of tierOrder) {
|
|
756
831
|
if (t === tier)
|
|
757
832
|
continue;
|
|
758
|
-
|
|
833
|
+
if (maxTier !== undefined && TIER_RANK[t] > TIER_RANK[maxTier])
|
|
834
|
+
continue;
|
|
835
|
+
const pick = this.bestEffortMatch(this.tierPoolEntries(t, healthyOnly, { costOrder }), requested);
|
|
759
836
|
if (pick)
|
|
760
837
|
return pick;
|
|
761
838
|
}
|
|
@@ -770,7 +847,7 @@ export class ProviderRegistry {
|
|
|
770
847
|
* upstream for the gateway's own wire mismatch; the decision surface
|
|
771
848
|
* passes `decisionSurface: true` to see them. */
|
|
772
849
|
tierPoolEntries(tier, healthyOnly, opts) {
|
|
773
|
-
return this.buildTierPoolEntries(tier, this.committedMembers)
|
|
850
|
+
return this.buildTierPoolEntries(tier, this.committedMembers, opts?.costOrder ? 'cheapest' : 'declared')
|
|
774
851
|
.filter(({ model }) => opts?.decisionSurface === true || model.wire !== 'systemone')
|
|
775
852
|
.filter(({ model }) => !this.policyRejectionReason(this.tierPolicies, model))
|
|
776
853
|
.filter(({ model }) => !healthyOnly || this.modelAvailable(model).available);
|
|
@@ -818,33 +895,53 @@ export class ProviderRegistry {
|
|
|
818
895
|
return null;
|
|
819
896
|
return { model: best.model, actualEffort: best.actualEffort, degraded: best.gap > 0 };
|
|
820
897
|
}
|
|
821
|
-
getModelForTier(tier, healthyOnly = true) {
|
|
822
|
-
const candidates = this.getCandidateModelsForTier(tier, healthyOnly);
|
|
898
|
+
getModelForTier(tier, healthyOnly = true, costOrder = false) {
|
|
899
|
+
const candidates = this.getCandidateModelsForTier(tier, healthyOnly, { costOrder });
|
|
823
900
|
if (candidates.length > 0) {
|
|
824
|
-
return this.pickPrimary(candidates, tier);
|
|
901
|
+
return this.pickPrimary(candidates, tier, costOrder);
|
|
825
902
|
}
|
|
826
903
|
// If healthyOnly was true and no healthy models found, fallback to any model in tier
|
|
827
904
|
if (healthyOnly) {
|
|
828
|
-
const anyCandidate = this.getCandidateModelsForTier(tier, false);
|
|
905
|
+
const anyCandidate = this.getCandidateModelsForTier(tier, false, { costOrder });
|
|
829
906
|
if (anyCandidate.length > 0) {
|
|
830
|
-
return this.pickPrimary(anyCandidate, tier);
|
|
907
|
+
return this.pickPrimary(anyCandidate, tier, costOrder);
|
|
831
908
|
}
|
|
832
909
|
}
|
|
833
910
|
// the requested tier is EMPTY (a real possibility now that there
|
|
834
911
|
// is no residual catch-all). Degradation is still possible — routing must
|
|
835
912
|
// not hard-fail on a config the user can legitimately write — but it is
|
|
836
913
|
// NEVER silent: the cross-tier step is logged with the reason.
|
|
837
|
-
|
|
914
|
+
//
|
|
915
|
+
// COST MODE (ADR-0001 §2) bounds the walk: `costOrder` clamps every
|
|
916
|
+
// landing to COST_MODE_TIER_CEILING, and a 'never' costEscalation policy
|
|
917
|
+
// pins the walk to tiers at or below the requested one — a cost pin must
|
|
918
|
+
// never be repaired onto pro/ultra money just because lite is empty.
|
|
919
|
+
const cfg = this.tierPolicies ? loadConfig() : undefined;
|
|
920
|
+
const escalate = cfg?.fallback?.escalateTier ?? 'plus';
|
|
921
|
+
const hardPin = costOrder && cfg?.routing?.costEscalation === 'never';
|
|
922
|
+
const maxRank = !costOrder
|
|
923
|
+
? Number.POSITIVE_INFINITY
|
|
924
|
+
: hardPin
|
|
925
|
+
? TIER_RANK[tier]
|
|
926
|
+
: TIER_RANK[COST_MODE_TIER_CEILING];
|
|
838
927
|
const order = [escalate, 'plus', 'lite', 'pro', 'ultra'];
|
|
839
|
-
const chain = order.filter((t, i, all) => t !== tier && all.indexOf(t) === i);
|
|
928
|
+
const chain = order.filter((t, i, all) => t !== tier && all.indexOf(t) === i && TIER_RANK[t] <= maxRank);
|
|
840
929
|
for (const step of chain) {
|
|
841
|
-
|
|
930
|
+
// Cost mode prefers the step's CHEAPEST pool head (a peek — never a
|
|
931
|
+
// rotation draw) over the declared-order representative, so the degraded
|
|
932
|
+
// landing honours the price axis the rest of the cost-mode primitives
|
|
933
|
+
// sort by (the tierDefaults table is built in declared order).
|
|
934
|
+
const rep = costOrder
|
|
935
|
+
? this.getCandidateModelsForTier(step, true, { costOrder })[0] ?? this.tierDefaults.get(step)
|
|
936
|
+
: this.tierDefaults.get(step);
|
|
842
937
|
if (rep && rep.tier !== undefined) {
|
|
843
938
|
console.warn(`[Registry] Tier '${tier}' has no candidate model — falling back to '${step}' (${rep.id}), reason=empty-pool`);
|
|
844
939
|
return rep;
|
|
845
940
|
}
|
|
846
941
|
}
|
|
847
|
-
|
|
942
|
+
// Last resort: prefer an in-budget model before a model that would breach
|
|
943
|
+
// the cost ceiling / a hard pin.
|
|
944
|
+
const any = Array.from(this.models.values()).find((m) => m.tier !== undefined && TIER_RANK[m.tier] <= maxRank) ?? Array.from(this.models.values()).find((m) => m.tier !== undefined);
|
|
848
945
|
if (!any) {
|
|
849
946
|
throw new Error(`No routable models registered (no model's tier membership is claimed by any pool).`);
|
|
850
947
|
}
|
|
@@ -939,7 +1036,7 @@ export class ProviderRegistry {
|
|
|
939
1036
|
return;
|
|
940
1037
|
this.combosFingerprint = fingerprint;
|
|
941
1038
|
this.combos.clear();
|
|
942
|
-
this.
|
|
1039
|
+
this.comboRr.reset();
|
|
943
1040
|
for (const combo of combos || []) {
|
|
944
1041
|
if (!combo?.id || !Array.isArray(combo.models) || combo.models.length === 0)
|
|
945
1042
|
continue;
|
|
@@ -974,7 +1071,7 @@ export class ProviderRegistry {
|
|
|
974
1071
|
comboMemberRef(entry) {
|
|
975
1072
|
if (typeof entry === 'string')
|
|
976
1073
|
return { id: entry, weight: 1 };
|
|
977
|
-
return { id: entry.id, weight:
|
|
1074
|
+
return { id: entry.id, weight: normalizeMemberWeight(entry.weight) };
|
|
978
1075
|
}
|
|
979
1076
|
/**
|
|
980
1077
|
* Resolve a combo to its registered member models in config order.
|
|
@@ -1000,16 +1097,27 @@ export class ProviderRegistry {
|
|
|
1000
1097
|
return members;
|
|
1001
1098
|
}
|
|
1002
1099
|
/**
|
|
1003
|
-
* Combo primary pick, mirroring the tier selection strategies:
|
|
1100
|
+
* Combo primary pick, mirroring the tier selection strategies exactly:
|
|
1004
1101
|
* - priority (default): first healthy member in config order
|
|
1005
|
-
* -
|
|
1006
|
-
*
|
|
1102
|
+
* - weighted_round_robin: smooth WEIGHTED round-robin — weight = the member
|
|
1103
|
+
* entry's weight (default 1)
|
|
1104
|
+
* - round_robin: plain sequential round-robin — equal turns, weights ignored
|
|
1105
|
+
* The same smooth round-robin core serves the tier pools; cursors are
|
|
1106
|
+
* combo-scoped (and strategy-scoped).
|
|
1007
1107
|
* Falls back to the full member list when every member is tripped.
|
|
1108
|
+
*
|
|
1109
|
+
* An EMPTY member list is a caller bug (the combo either does not exist or
|
|
1110
|
+
* has no registered member) and throws — the same contract as the rotation
|
|
1111
|
+
* core. Callers check `resolveCombo(...)` first; `undefined` from the old
|
|
1112
|
+
* `members[0]` return was never part of this signature.
|
|
1008
1113
|
*/
|
|
1009
1114
|
pickComboLeader(comboId, members) {
|
|
1010
|
-
if (members.length
|
|
1011
|
-
|
|
1012
|
-
|
|
1115
|
+
if (members.length === 0) {
|
|
1116
|
+
throw new Error(`pickComboLeader: combo '${comboId}' has no resolved members`);
|
|
1117
|
+
}
|
|
1118
|
+
// Single-member combos still go through the rotation core on rotation
|
|
1119
|
+
// strategies so a shrunk pool resets its cursor (same rule as the tiers).
|
|
1120
|
+
const strategy = normalizeSelectionStrategy(this.combos.get(comboId)?.selection);
|
|
1013
1121
|
// Decision 6 aggregate (same rule as the tier pools): a member whose every
|
|
1014
1122
|
// credential is out must not lead a combo.
|
|
1015
1123
|
const healthy = members.filter((m) => this.modelAvailable(m).available);
|
|
@@ -1020,31 +1128,10 @@ export class ProviderRegistry {
|
|
|
1020
1128
|
if (!weights.has(ref.id))
|
|
1021
1129
|
weights.set(ref.id, ref.weight);
|
|
1022
1130
|
}
|
|
1023
|
-
if (strategy === '
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
for (let i = 0; i < w; i++)
|
|
1028
|
-
slots.push(m);
|
|
1029
|
-
}
|
|
1030
|
-
if (slots.length === 0)
|
|
1031
|
-
return pool[0];
|
|
1032
|
-
const prev = this.comboRrCursor.get(comboId) ?? 0;
|
|
1033
|
-
this.comboRrCursor.set(comboId, prev + 1);
|
|
1034
|
-
return slots[prev % slots.length];
|
|
1035
|
-
}
|
|
1036
|
-
if (strategy === 'weighted') {
|
|
1037
|
-
const ws = pool.map(m => weights.get(m.id) ?? 1);
|
|
1038
|
-
const total = ws.reduce((a, b) => a + b, 0);
|
|
1039
|
-
let r = Math.random() * total;
|
|
1040
|
-
for (let i = 0; i < pool.length; i++) {
|
|
1041
|
-
r -= ws[i];
|
|
1042
|
-
if (r < 0)
|
|
1043
|
-
return pool[i];
|
|
1044
|
-
}
|
|
1045
|
-
return pool[pool.length - 1];
|
|
1046
|
-
}
|
|
1047
|
-
return pool[0];
|
|
1131
|
+
if (strategy === 'priority')
|
|
1132
|
+
return pool[0];
|
|
1133
|
+
const weightOf = strategy === 'weighted_round_robin' ? (m) => weights.get(m.id) ?? 1 : () => 1;
|
|
1134
|
+
return this.comboRr.pick(`${comboId}:${strategy}`, pool, (m) => m.id, weightOf);
|
|
1048
1135
|
}
|
|
1049
1136
|
/**
|
|
1050
1137
|
* Introspection for the console resolve a tier's effective
|
|
@@ -1090,13 +1177,19 @@ export class ProviderRegistry {
|
|
|
1090
1177
|
}
|
|
1091
1178
|
/**
|
|
1092
1179
|
* Outbound egress the CORE transport will take for `model`, resolved from
|
|
1093
|
-
* the same `
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1180
|
+
* the same `resolveEgress` the executors dial with (ADR-0018 / ADR-0022).
|
|
1181
|
+
* Call this IMMEDIATELY before `execute()` and keep the value with the
|
|
1182
|
+
* attempt: the proxy config hot-applies, so a read after a long stream can
|
|
1183
|
+
* describe a different dial.
|
|
1097
1184
|
*
|
|
1098
|
-
* `undefined` = UNKNOWN, never direct: nothing was dialed (mock mode)
|
|
1099
|
-
*
|
|
1185
|
+
* `undefined` = UNKNOWN, never direct: nothing was dialed (mock mode), the
|
|
1186
|
+
* transport does not report its dial base (plugin-owned executors), OR the
|
|
1187
|
+
* operator demanded the proxy and there was no endpoint to dial
|
|
1188
|
+
* (`no-endpoint`). That last case `proxiedFetch` REFUSES — no socket is
|
|
1189
|
+
* opened — so claiming `direct` would put a "goes direct" stamp on a request
|
|
1190
|
+
* that never left the machine. The connectivity probe reports UNKNOWN for it
|
|
1191
|
+
* for the same reason; this keeps the two honest about one verdict. The
|
|
1192
|
+
* verdict's `origin` is already redacted, so no credential can ride a trace.
|
|
1100
1193
|
*/
|
|
1101
1194
|
egressFor(model) {
|
|
1102
1195
|
if (this.mockMode)
|
|
@@ -1104,8 +1197,13 @@ export class ProviderRegistry {
|
|
|
1104
1197
|
const base = this.providers.get(model.provider)?.dialBaseFor?.(model);
|
|
1105
1198
|
if (!base)
|
|
1106
1199
|
return undefined;
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1200
|
+
const verdict = resolveEgress(base, { provider: model.provider, model: model.id });
|
|
1201
|
+
if (verdict.mode === 'proxy')
|
|
1202
|
+
return { mode: 'proxy', origin: verdict.origin };
|
|
1203
|
+
// A refused dial (no-endpoint) took NO leg — stamp UNKNOWN, not direct.
|
|
1204
|
+
if (verdict.reason === 'no-endpoint')
|
|
1205
|
+
return undefined;
|
|
1206
|
+
return { mode: 'direct', reason: verdict.reason };
|
|
1109
1207
|
}
|
|
1110
1208
|
/**
|
|
1111
1209
|
* Execute one completion. `credentialKeyHashPrefix`
|
|
@@ -1118,7 +1216,9 @@ export class ProviderRegistry {
|
|
|
1118
1216
|
*/
|
|
1119
1217
|
async execute(request, model, upstreamEventContext, credentialKeyHashPrefix, relay,
|
|
1120
1218
|
/** Resolved OCR conversation id. Not a capture field. */
|
|
1121
|
-
sessionId
|
|
1219
|
+
sessionId,
|
|
1220
|
+
/** Inbound client surface protocol — prefer-native dial (ADR-0033). */
|
|
1221
|
+
inboundWire) {
|
|
1122
1222
|
if (this.mockMode) {
|
|
1123
1223
|
relay?.onTransport?.('buffered');
|
|
1124
1224
|
return this.mockExecute(request, model);
|
|
@@ -1126,6 +1226,8 @@ export class ProviderRegistry {
|
|
|
1126
1226
|
const provider = this.providers.get(model.provider);
|
|
1127
1227
|
if (!provider)
|
|
1128
1228
|
throw new Error(`Provider '${model.provider}' not found for model '${model.id}'`);
|
|
1229
|
+
const dialWire = pickDialWire(model.protocols ?? (model.wire ? [model.wire] : undefined), inboundWire, request);
|
|
1230
|
+
const dialModel = dialWire === model.wire ? model : { ...model, wire: dialWire };
|
|
1129
1231
|
const chain = this.credentialChains.get(model.provider);
|
|
1130
1232
|
let credential;
|
|
1131
1233
|
if (credentialKeyHashPrefix !== undefined) {
|
|
@@ -1135,17 +1237,17 @@ export class ProviderRegistry {
|
|
|
1135
1237
|
}
|
|
1136
1238
|
}
|
|
1137
1239
|
try {
|
|
1138
|
-
const recovery = toolMarkupRecoveryFor(request,
|
|
1240
|
+
const recovery = toolMarkupRecoveryFor(request, dialModel, this.providerConfigs.get(model.provider));
|
|
1139
1241
|
if (relay) {
|
|
1140
1242
|
const streams = provider.supportsStreaming
|
|
1141
|
-
? provider.supportsStreaming(
|
|
1243
|
+
? provider.supportsStreaming(dialModel)
|
|
1142
1244
|
: typeof provider.createStream === 'function';
|
|
1143
1245
|
if (streams) {
|
|
1144
1246
|
const accumulate = createEventAccumulator();
|
|
1145
1247
|
const scanner = recovery ? null : createToolMarkupScanner();
|
|
1146
1248
|
const rewrite = recovery ? createToolMarkupStreamRecovery(request) : null;
|
|
1147
1249
|
relay.onTransport?.('sse');
|
|
1148
|
-
const stream = await provider.createStream(request,
|
|
1250
|
+
const stream = await provider.createStream(request, dialModel, upstreamEventContext, credential, sessionId);
|
|
1149
1251
|
// Drain for terminal usage even if the client disconnected. Relay and
|
|
1150
1252
|
// accounting consume the same event objects without history copies.
|
|
1151
1253
|
for await (const event of stream) {
|
|
@@ -1163,17 +1265,17 @@ export class ProviderRegistry {
|
|
|
1163
1265
|
}
|
|
1164
1266
|
const accumulated = accumulate.finish();
|
|
1165
1267
|
const finished = rewrite ? rewrite.finishResponse(accumulated) : accumulated;
|
|
1166
|
-
reportToolMarkupLeak(rewrite ? finished.toolMarkupLeak ?? null : scanner.leak(),
|
|
1268
|
+
reportToolMarkupLeak(rewrite ? finished.toolMarkupLeak ?? null : scanner.leak(), dialModel);
|
|
1167
1269
|
return finished;
|
|
1168
1270
|
}
|
|
1169
1271
|
relay.onTransport?.('buffered');
|
|
1170
1272
|
}
|
|
1171
|
-
const buffered = await provider.createCompletion(request,
|
|
1273
|
+
const buffered = await provider.createCompletion(request, dialModel, upstreamEventContext, credential, sessionId);
|
|
1172
1274
|
const finished = recovery ? recoverToolMarkupInResponse(buffered, request) : buffered;
|
|
1173
1275
|
const leak = recovery ? finished.toolMarkupLeak ?? null : detectToolMarkupLeak(finished);
|
|
1174
1276
|
if (!leak)
|
|
1175
1277
|
return finished;
|
|
1176
|
-
reportToolMarkupLeak(leak,
|
|
1278
|
+
reportToolMarkupLeak(leak, dialModel);
|
|
1177
1279
|
return { ...finished, toolMarkupLeak: leak };
|
|
1178
1280
|
}
|
|
1179
1281
|
catch (err) {
|
|
@@ -1181,6 +1283,15 @@ export class ProviderRegistry {
|
|
|
1181
1283
|
if (used && err && (typeof err === 'object' || typeof err === 'function')) {
|
|
1182
1284
|
err.usedCredentialKeyHashPrefix = used.keyHashPrefix;
|
|
1183
1285
|
}
|
|
1286
|
+
// Layer model + declared protocols onto IR refusals so the client sees
|
|
1287
|
+
// which dial was incompatible — not only the bare protocol id.
|
|
1288
|
+
if (err instanceof IrUnsupportedError) {
|
|
1289
|
+
throw withDialContext(err, {
|
|
1290
|
+
modelId: dialModel.id,
|
|
1291
|
+
dialWire: dialWire,
|
|
1292
|
+
protocols: dialModel.protocols ?? (dialModel.wire ? [dialModel.wire] : undefined),
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1184
1295
|
throw err;
|
|
1185
1296
|
}
|
|
1186
1297
|
}
|