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,7 +1,9 @@
|
|
|
1
1
|
import { appendClientResponseChunk, markClientResponseStreamStart, emitClientResponse, } from '../observability/http-exchange.js';
|
|
2
|
+
import { bodyLimitFor, payloadTooLarge, requestBodyTimeout, writeRefusalAnswer } from './body-admission.js';
|
|
3
|
+
import { REQUEST_BODY_IDLE_TIMEOUT_MS } from '../config/defaults.js';
|
|
2
4
|
import { createClientLegWatchdog, writeWithBackpressure } from './transport-backpressure.js';
|
|
3
5
|
/**
|
|
4
|
-
* Raw node:http transport (the MITM
|
|
6
|
+
* Raw node:http transport (the MITM ingress-proxy leg) — the second
|
|
5
7
|
* implementation of the frozen TransportContext terminal-send discipline
|
|
6
8
|
* (contract §1.5). The interceptor reads the body, hands this transport to
|
|
7
9
|
* dispatchSurface, and the SAME chat pipelines then run byte-comparable on
|
|
@@ -17,27 +19,79 @@ import { createClientLegWatchdog, writeWithBackpressure } from './transport-back
|
|
|
17
19
|
* "fix" this by inventing key headers the caller cannot send.
|
|
18
20
|
* (Authoritative text — interceptor.ts keeps only a pointer here.)
|
|
19
21
|
*/
|
|
20
|
-
const MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
21
22
|
/**
|
|
22
|
-
* Read the request body with
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Read the request body with the gateway's hard cap (`bodyLimitFor('gateway')` —
|
|
24
|
+
* the SAME number the native Fastify routes pass as bodyLimit, so one admission
|
|
25
|
+
* ceiling covers both legs; `client.bodyLimits.maxBytes` moves it for both at the
|
|
26
|
+
* next boot). Oversized bodies reject with a BodyAdmissionError
|
|
27
|
+
* that already carries the 413 status, the `payload_too_large` code and the
|
|
28
|
+
* client-facing sentence; the caller only has to answer with it.
|
|
29
|
+
*
|
|
30
|
+
* The cap is measured on the WIRE here (this leg buffers before decoding), and
|
|
31
|
+
* `model-gateway.ts` re-checks after `decompressBody`, so a compressed body
|
|
32
|
+
* cannot slip past the ceiling that the native leg applies to its inflated
|
|
33
|
+
* stream.
|
|
34
|
+
*
|
|
35
|
+
* A STALLED body is refused too, with 408 (see `requestBodyTimeout`). The
|
|
36
|
+
* server-level `requestTimeout` cannot express it: that clock covers the whole
|
|
37
|
+
* request, so one byte per minute never trips it — and on Bun no such clock is
|
|
38
|
+
* armed at all. This timer is re-armed on every chunk, so liveness is measured on
|
|
39
|
+
* the axis that actually fails in practice: progress, not elapsed time.
|
|
40
|
+
*
|
|
41
|
+
* `idleMs` is a seam (a test cannot wait a minute, and a later config knob needs
|
|
42
|
+
* one call site); production callers pass nothing and get the single-source default.
|
|
25
43
|
*/
|
|
26
|
-
export function readRequestBody(req) {
|
|
44
|
+
export function readRequestBody(req, idleMs = REQUEST_BODY_IDLE_TIMEOUT_MS) {
|
|
27
45
|
return new Promise((resolve, reject) => {
|
|
28
46
|
const chunks = [];
|
|
47
|
+
const capBytes = bodyLimitFor('gateway');
|
|
29
48
|
let total = 0;
|
|
49
|
+
let idle;
|
|
50
|
+
const clearIdle = () => {
|
|
51
|
+
if (idle)
|
|
52
|
+
clearTimeout(idle);
|
|
53
|
+
idle = undefined;
|
|
54
|
+
};
|
|
55
|
+
const armIdle = () => {
|
|
56
|
+
clearIdle();
|
|
57
|
+
idle = setTimeout(() => {
|
|
58
|
+
idle = undefined;
|
|
59
|
+
// Same shape as the size overflow: stop consuming, let the caller answer,
|
|
60
|
+
// and let `sendPreDispatchError` close the connection.
|
|
61
|
+
req.pause();
|
|
62
|
+
reject(requestBodyTimeout());
|
|
63
|
+
}, idleMs);
|
|
64
|
+
// Never hold the event loop open for a client that has stopped talking.
|
|
65
|
+
idle.unref?.();
|
|
66
|
+
};
|
|
30
67
|
req.on('data', (d) => {
|
|
68
|
+
armIdle();
|
|
31
69
|
total += d.length;
|
|
32
|
-
if (total >
|
|
33
|
-
|
|
34
|
-
|
|
70
|
+
if (total > capBytes) {
|
|
71
|
+
clearIdle();
|
|
72
|
+
// RFC 9110 15.5.14: an oversized payload is refused with a 413 — an
|
|
73
|
+
// ANSWER, not a reset. Destroying the request here tore the socket down
|
|
74
|
+
// before the caller could write the status, so the client saw a bare
|
|
75
|
+
// ECONNRESET with no code at all (verified on bun and node). Pause
|
|
76
|
+
// instead — the ceiling is already crossed, so stop consuming and let
|
|
77
|
+
// `sendPreDispatchError` answer, flush and close.
|
|
78
|
+
req.pause();
|
|
79
|
+
reject(payloadTooLarge(capBytes));
|
|
35
80
|
return;
|
|
36
81
|
}
|
|
37
82
|
chunks.push(d);
|
|
38
83
|
});
|
|
39
|
-
req.on('end', () =>
|
|
40
|
-
|
|
84
|
+
req.on('end', () => {
|
|
85
|
+
clearIdle();
|
|
86
|
+
resolve(Buffer.concat(chunks));
|
|
87
|
+
});
|
|
88
|
+
// A client that hangs up mid-body is not a stalled body: no 408 answer to send,
|
|
89
|
+
// just stop the clock.
|
|
90
|
+
req.on('close', clearIdle);
|
|
91
|
+
req.on('error', (err) => {
|
|
92
|
+
clearIdle();
|
|
93
|
+
reject(err);
|
|
94
|
+
});
|
|
41
95
|
});
|
|
42
96
|
}
|
|
43
97
|
/**
|
|
@@ -46,18 +100,24 @@ export function readRequestBody(req) {
|
|
|
46
100
|
* capture events exist on this path on either leg (contract §4: 400/403
|
|
47
101
|
* precede process). Adapters never throw — write failures are logged loud.
|
|
48
102
|
*/
|
|
49
|
-
export function sendPreDispatchError(res, surface, status, message
|
|
103
|
+
export function sendPreDispatchError(res, surface, status, message, code,
|
|
104
|
+
/** The rejection's negotiation headers (`Accept-Encoding` for a refused coding,
|
|
105
|
+
* `Accept` for a refused media type). Carried through so the MITM leg advertises
|
|
106
|
+
* exactly what the native leg does — a client that only reads the headers learns
|
|
107
|
+
* the fix on neither leg if they are dropped here. */
|
|
108
|
+
headers) {
|
|
50
109
|
let serialized;
|
|
51
110
|
try {
|
|
52
|
-
serialized = JSON.stringify(surface.errorBody(status, message));
|
|
111
|
+
serialized = JSON.stringify(surface.errorBody(status, message, code));
|
|
53
112
|
}
|
|
54
113
|
catch (err) {
|
|
55
114
|
logWriteError(err, 'node-http pre-dispatch error body serialization failed');
|
|
56
115
|
return;
|
|
57
116
|
}
|
|
58
117
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
118
|
+
// ONE writer for every refusal (see `writeRefusalAnswer`): answer first,
|
|
119
|
+
// declare `content-length`, then drain the refused body (bounded) and close.
|
|
120
|
+
writeRefusalAnswer(res, status, serialized, { headers });
|
|
61
121
|
}
|
|
62
122
|
catch (err) {
|
|
63
123
|
logWriteError(err, 'node-http pre-dispatch error write failed');
|
|
@@ -67,7 +127,7 @@ function logWriteError(err, message) {
|
|
|
67
127
|
// R-3: loud-not-silent. Bun's socket layer can surface write errors as
|
|
68
128
|
// 'ERR_STREAM_DESTROYED'-style throws on dead peers; they must reach the
|
|
69
129
|
// operator log, never an empty catch.
|
|
70
|
-
console.error(`[
|
|
130
|
+
console.error(`[ingress-proxy] ${message}`, err);
|
|
71
131
|
}
|
|
72
132
|
/**
|
|
73
133
|
* Build the MITM-leg transport. `captureEnabled` is the SURFACE capture
|
|
@@ -16,7 +16,7 @@ import type { ExecutionResult } from '../types/router.js';
|
|
|
16
16
|
* makeModelAccessGuard(registry)(req, reply, model); a denial
|
|
17
17
|
* has ALREADY been written as a 403 by the guard, callers only
|
|
18
18
|
* check the boolean and must NOT send another response.
|
|
19
|
-
* - 'exempt' — POLICY EXEMPTION (MITM
|
|
19
|
+
* - 'exempt' — POLICY EXEMPTION (MITM ingress-proxy leg): the tunnel peer is
|
|
20
20
|
* authenticated by the CONNECT/TLS layer, not an API key, so
|
|
21
21
|
* every model passes and the capture's inbound request headers
|
|
22
22
|
* carry no key identity. `keyName`/`policy` pin the empty view
|
|
@@ -80,12 +80,20 @@ export interface TransportContext {
|
|
|
80
80
|
endSse(): void;
|
|
81
81
|
/**
|
|
82
82
|
* Client-abort detection. Bun never fires req 'res''close'/'aborted'
|
|
83
|
-
* reliably after the body is read (
|
|
83
|
+
* reliably after the body is read (ingress-proxy.test.ts:360 documents the
|
|
84
84
|
* verified runtime behavior) — adapters combine their own close-flag with
|
|
85
85
|
* the socket's destroyed state; the pipeline uses this only as a fallback
|
|
86
86
|
* signal, the terminal send itself is what finalizes capture.
|
|
87
87
|
*/
|
|
88
88
|
isClientGone(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* STICKY "did the client leave during this turn" (ADR-0040). Unlike
|
|
91
|
+
* `isClientGone` — which reports the CURRENT socket state and is read at the
|
|
92
|
+
* terminal send — this must still answer YES after the upstream drained into a
|
|
93
|
+
* socket the peer abandoned, so an interrupted turn is recorded as `aborted`
|
|
94
|
+
* rather than `completed`. Optional: a transport with no such signal omits it.
|
|
95
|
+
*/
|
|
96
|
+
didClientLeave?(): boolean;
|
|
89
97
|
logError(err: unknown, message: string): void;
|
|
90
98
|
}
|
|
91
99
|
/**
|
|
@@ -203,7 +211,7 @@ export interface ChatSurface {
|
|
|
203
211
|
* conversion call, per the model's resolved wire — ADR-0008 §7;
|
|
204
212
|
* no purpose tag — unambiguous within its own turn). FinOps/trace stay
|
|
205
213
|
* excluded; the default-off path is
|
|
206
|
-
* pinned zero-event by
|
|
214
|
+
* pinned zero-event by ingress-proxy-systemone.test.ts.
|
|
207
215
|
*/
|
|
208
216
|
export interface DecisionSurface {
|
|
209
217
|
readonly wire: 'systemone';
|
|
@@ -52,7 +52,17 @@ function normalizeReplayedTrace(raw) {
|
|
|
52
52
|
delete fin.cachedPromptTokens;
|
|
53
53
|
}
|
|
54
54
|
delete fin.savedCostUsd;
|
|
55
|
-
|
|
55
|
+
// `costUsd` is OPTIONAL — absent means the price was unknown at request
|
|
56
|
+
// time, and every aggregate counts it as an unpriced turn. Coerce only a
|
|
57
|
+
// value that IS present: `Number(undefined) || 0` laundered an unpriced
|
|
58
|
+
// turn into a confident $0 the next time the process booted.
|
|
59
|
+
if (fin.costUsd !== undefined) {
|
|
60
|
+
const cost = Number(fin.costUsd);
|
|
61
|
+
if (Number.isFinite(cost))
|
|
62
|
+
fin.costUsd = cost;
|
|
63
|
+
else
|
|
64
|
+
delete fin.costUsd;
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
const req = record.request;
|
|
58
68
|
if (req && typeof req === 'object') {
|
|
@@ -86,6 +96,13 @@ async function tryOpenTraceStore(dir) {
|
|
|
86
96
|
// stores (each with its own handle), so contend politely and keep the
|
|
87
97
|
// schema switch atomic.
|
|
88
98
|
db.run('PRAGMA busy_timeout = 5000;');
|
|
99
|
+
// The write-through path fires once per completed request, so the default
|
|
100
|
+
// FULL (an fsync per commit) sits on the inference hot path. WAL + NORMAL
|
|
101
|
+
// keeps the file crash-consistent and only risks losing the most recent
|
|
102
|
+
// commits on power loss — acceptable for observability, which fails open
|
|
103
|
+
// by contract. `synchronous` is per-connection: every hot-path handle sets
|
|
104
|
+
// its own (see openFinOpsStore).
|
|
105
|
+
db.run('PRAGMA synchronous = NORMAL;');
|
|
89
106
|
const version = Number(db.query('PRAGMA user_version').get()?.user_version ?? 0);
|
|
90
107
|
// `user_version` is FILE-wide (SQLite has no per-table version): this store
|
|
91
108
|
// is its sole owner — every other store on the file only runs
|
|
@@ -307,6 +324,9 @@ export async function openFinOpsStore(dir) {
|
|
|
307
324
|
fs.mkdirSync(dir, { recursive: true });
|
|
308
325
|
db = new Database(path.join(dir, 'traces.db'), { create: true });
|
|
309
326
|
db.run('PRAGMA journal_mode = WAL;');
|
|
327
|
+
// Same hot-path rationale as tryOpenTraceStore: one counter transaction per
|
|
328
|
+
// completed request must not pay an fsync.
|
|
329
|
+
db.run('PRAGMA synchronous = NORMAL;');
|
|
310
330
|
db.run(`CREATE TABLE IF NOT EXISTS finops_totals (
|
|
311
331
|
key TEXT PRIMARY KEY,
|
|
312
332
|
value REAL NOT NULL
|
|
@@ -98,6 +98,14 @@ export interface ExecutionTrace {
|
|
|
98
98
|
userAgent?: string;
|
|
99
99
|
acceptLanguage?: string;
|
|
100
100
|
clientRequestId?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Self-declared client id from `x-ocr-client`, e.g.
|
|
103
|
+
* `OmniCellRouter-Playground/0.8.5`. PREFERRED over `userAgent` when the
|
|
104
|
+
* console classifies this trace's client family, because a browser
|
|
105
|
+
* webview strips a script-set `User-Agent` on `fetch` (it sends its own
|
|
106
|
+
* instead). Display-only, never an identity or routing input (ADR-0002).
|
|
107
|
+
*/
|
|
108
|
+
clientHint?: string;
|
|
101
109
|
};
|
|
102
110
|
/**
|
|
103
111
|
* Client-minted conversation id this turn carried (Cursor's agent-wire
|
|
@@ -217,9 +225,11 @@ export interface ExecutionTrace {
|
|
|
217
225
|
outputTokens: number;
|
|
218
226
|
cachedTokens: number;
|
|
219
227
|
/**
|
|
220
|
-
* Actual USD cost of this request,
|
|
221
|
-
*
|
|
222
|
-
*
|
|
228
|
+
* Actual USD cost of this request, booked at request time: the
|
|
229
|
+
* vendor-reported committed cost when the wire reports one (plugin wires
|
|
230
|
+
* whose upstream bills itself, e.g. qoder credits), otherwise the catalog
|
|
231
|
+
* pricing that was current then. The only cost figure stored — derived
|
|
232
|
+
* comparisons (baseline/savings) are intentionally not recorded.
|
|
223
233
|
*
|
|
224
234
|
* Absent when the serving model had NO known price: an unpriced model must
|
|
225
235
|
* stay unpriceable all the way to the console, because writing 0 here would
|
|
@@ -286,6 +296,22 @@ export interface UsageStatsSummary {
|
|
|
286
296
|
};
|
|
287
297
|
keys: KeyUsageRow[];
|
|
288
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Per-model slice of one session's recorded spend, as a trace-derived view —
|
|
301
|
+
* never routing state. Emitted only when a session was served by MORE THAN ONE
|
|
302
|
+
* model: a single-model session's total already says everything, and the
|
|
303
|
+
* sessions list is polled, so the common case must not grow the payload.
|
|
304
|
+
*/
|
|
305
|
+
export interface SessionModelCostRow {
|
|
306
|
+
/** Registered id exactly as served (`provider/model`, or a bare id for a hand-configured model). */
|
|
307
|
+
model: string;
|
|
308
|
+
/** Exchanges served by this model. */
|
|
309
|
+
requests: number;
|
|
310
|
+
/** Cost of this model's requests that could be priced; see {@link unpricedRequests}. */
|
|
311
|
+
costUsd: number;
|
|
312
|
+
/** Requests on this model whose price was unknown — excluded from `costUsd`. */
|
|
313
|
+
unpricedRequests: number;
|
|
314
|
+
}
|
|
289
315
|
export declare class TraceTracker {
|
|
290
316
|
private traces;
|
|
291
317
|
/** sessionId -> requestId[] — one entry per RECORD. */
|
|
@@ -405,6 +431,12 @@ export declare class TraceTracker {
|
|
|
405
431
|
* Non-zero means the total is a floor, not the session's real spend.
|
|
406
432
|
*/
|
|
407
433
|
unpricedTurns: number;
|
|
434
|
+
/**
|
|
435
|
+
* Per-model split of `requests` / `costUsd`, priced cost descending.
|
|
436
|
+
* Present ONLY when the session served more than one model — a
|
|
437
|
+
* single-model session omits it so the polled sessions list stays lean.
|
|
438
|
+
*/
|
|
439
|
+
byModel?: SessionModelCostRow[];
|
|
408
440
|
totalLatencyMs: number;
|
|
409
441
|
genOutputTokens: number;
|
|
410
442
|
genMsSum: number;
|
|
@@ -339,6 +339,7 @@ export class TraceTracker {
|
|
|
339
339
|
let stalledMsSum = 0;
|
|
340
340
|
let stallWindowMs = 0;
|
|
341
341
|
const ttftSamples = [];
|
|
342
|
+
const byModelRows = new Map();
|
|
342
343
|
let prevModel = null;
|
|
343
344
|
for (const t of traces) {
|
|
344
345
|
if (prevModel !== null && t.execution.modelUsed !== prevModel)
|
|
@@ -351,6 +352,19 @@ export class TraceTracker {
|
|
|
351
352
|
costUsd += t.finops.costUsd;
|
|
352
353
|
else
|
|
353
354
|
unpricedTurns++;
|
|
355
|
+
let modelRow = byModelRows.get(t.execution.modelUsed);
|
|
356
|
+
if (!modelRow) {
|
|
357
|
+
modelRow = { model: t.execution.modelUsed, requests: 0, costUsd: 0, unpricedRequests: 0 };
|
|
358
|
+
byModelRows.set(t.execution.modelUsed, modelRow);
|
|
359
|
+
}
|
|
360
|
+
modelRow.requests++;
|
|
361
|
+
// Same skip-and-count semantics as the session total: an unpriced
|
|
362
|
+
// request is excluded from the model's sum and counted, so neither
|
|
363
|
+
// figure silently reads as confident.
|
|
364
|
+
if (t.finops.costUsd !== undefined)
|
|
365
|
+
modelRow.costUsd += t.finops.costUsd;
|
|
366
|
+
else
|
|
367
|
+
modelRow.unpricedRequests++;
|
|
354
368
|
totalLatencyMs += t.execution.latencyMs;
|
|
355
369
|
if (typeof t.execution.genMs === 'number') {
|
|
356
370
|
genOutputTokens += t.finops.outputTokens;
|
|
@@ -364,6 +378,14 @@ export class TraceTracker {
|
|
|
364
378
|
}
|
|
365
379
|
}
|
|
366
380
|
const last = traces[traces.length - 1];
|
|
381
|
+
const byModel = byModelRows.size > 1
|
|
382
|
+
? [...byModelRows.values()]
|
|
383
|
+
.map((r) => ({ ...r, costUsd: Number(r.costUsd.toFixed(6)) }))
|
|
384
|
+
// Priced cost descending — "who ate the bill" order. Unpriced
|
|
385
|
+
// models carry cost 0 and land last; ties break on the model id
|
|
386
|
+
// by code unit (localeCompare collation varies by ICU build).
|
|
387
|
+
.sort((a, b) => b.costUsd - a.costUsd || (a.model < b.model ? -1 : a.model > b.model ? 1 : 0))
|
|
388
|
+
: undefined;
|
|
367
389
|
return {
|
|
368
390
|
traceCount: traces.length,
|
|
369
391
|
switchCount,
|
|
@@ -372,6 +394,7 @@ export class TraceTracker {
|
|
|
372
394
|
cachedTokens,
|
|
373
395
|
costUsd: Number(costUsd.toFixed(6)),
|
|
374
396
|
unpricedTurns,
|
|
397
|
+
byModel,
|
|
375
398
|
totalLatencyMs,
|
|
376
399
|
genOutputTokens,
|
|
377
400
|
genMsSum,
|
|
@@ -167,6 +167,14 @@ export interface Usage {
|
|
|
167
167
|
accepted_prediction_tokens?: number;
|
|
168
168
|
rejected_prediction_tokens?: number;
|
|
169
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Vendor-reported committed cost of THIS exchange in USD (gateway extension,
|
|
172
|
+
* stamped by the model-service plugin from the upstream's own billing — e.g.
|
|
173
|
+
* qoder reports `credits`, converted at the operator's USD/credit rate).
|
|
174
|
+
* `usageToIR` maps it to `vendorCostUsd`, where it wins over catalog
|
|
175
|
+
* pricing for every booking; it is NEVER re-emitted on a client-facing wire.
|
|
176
|
+
*/
|
|
177
|
+
cost_usd?: number;
|
|
170
178
|
}
|
|
171
179
|
export interface ChatCompletionChoice {
|
|
172
180
|
index: number;
|
|
@@ -22,11 +22,21 @@ export type TierLevel = 'lite' | 'plus' | 'pro' | 'ultra';
|
|
|
22
22
|
export type PoolMembership = TierLevel | 'unclassified';
|
|
23
23
|
export declare const TIER_RANK: Record<TierLevel, number>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Cost mode means "the cheapest tier that still WORKS", so a lite-lead
|
|
26
|
+
* request may escalate after a failure but never above this ceiling. One
|
|
27
|
+
* constant shared by every escalation site keeps a cost pin from silently
|
|
28
|
+
* spending pro/ultra money (ADR-0001 §1).
|
|
29
|
+
*/
|
|
30
|
+
export declare const COST_MODE_TIER_CEILING: TierLevel;
|
|
31
|
+
/** The lower of `tier` and `cap` by TIER_RANK — a ceiling applied to a tier. */
|
|
32
|
+
export declare function clampTierToCeiling(tier: TierLevel, cap: TierLevel): TierLevel;
|
|
33
|
+
/**
|
|
34
|
+
* Thinking-effort vocabulary, aligned with OpenCode's 7-level ladder
|
|
26
35
|
* (lowest → highest). `EFFORT_LADDER.indexOf(effort)` IS the rank —
|
|
27
36
|
* weaker levels have smaller index.
|
|
28
37
|
* none — no reasoning (the lowest tier; client sends this
|
|
29
38
|
* explicitly to mean "do not think", not as a default)
|
|
39
|
+
* minimal — the lightest active reasoning level (above none)
|
|
30
40
|
* low / medium / high — shared by every wire (OpenAI, Anthropic,
|
|
31
41
|
* Google, OpenAI Responses)
|
|
32
42
|
* xhigh — OpenAI / OpenAI-compatible top tier (GPT-5+)
|
|
@@ -40,7 +50,7 @@ export declare const TIER_RANK: Record<TierLevel, number>;
|
|
|
40
50
|
* served.
|
|
41
51
|
*
|
|
42
52
|
* Default `supportedReasoningEfforts` for a thinking-capable model is
|
|
43
|
-
* the full
|
|
53
|
+
* the full 7-level ladder — there is no reduced "thinking" subset.
|
|
44
54
|
*/
|
|
45
55
|
export declare const EFFORT_LADDER: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
46
56
|
export type ReasoningEffort = (typeof EFFORT_LADDER)[number];
|
|
@@ -153,9 +163,10 @@ export type SessionLookupType = 'explicit_header' | 'embedded_user_id' | 'reques
|
|
|
153
163
|
/**
|
|
154
164
|
* Machine-readable routing-reason vocabulary carried alongside the English
|
|
155
165
|
* `reason` on every decision and trace. Producers emit a code from the locked
|
|
156
|
-
* set ('forced', 'default', 'combo', 'l2.*', 'session.*') plus the
|
|
157
|
-
* needed to render it; the console localizes from code+params and falls
|
|
158
|
-
* to the raw `reason` for unknown or legacy values.
|
|
166
|
+
* set ('forced', 'mode', 'default', 'combo', 'l2.*', 'session.*') plus the
|
|
167
|
+
* params needed to render it; the console localizes from code+params and falls
|
|
168
|
+
* back to the raw `reason` for unknown or legacy values. `mode` marks a tier
|
|
169
|
+
* pinned by the global `routing.mode` lever; `forced` stays client-authored.
|
|
159
170
|
*/
|
|
160
171
|
export type ReasonParams = Record<string, string | number | boolean>;
|
|
161
172
|
export interface RoutingDecision {
|
|
@@ -272,7 +283,7 @@ export interface ExecutionResult {
|
|
|
272
283
|
* client sent (or undefined if the client omitted the field).
|
|
273
284
|
* `actualEffort` is what the gateway actually served (may be lower
|
|
274
285
|
* after registry-level downgrade); `reasoningDegraded` flags the
|
|
275
|
-
* discrepancy. Both are full
|
|
286
|
+
* discrepancy. Both are full 7-level `ReasoningEffort` values.
|
|
276
287
|
*/
|
|
277
288
|
requestedEffort?: ReasoningEffort;
|
|
278
289
|
actualEffort?: ReasoningEffort;
|
|
@@ -5,11 +5,23 @@ export const TIER_RANK = {
|
|
|
5
5
|
ultra: 4,
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Cost mode means "the cheapest tier that still WORKS", so a lite-lead
|
|
9
|
+
* request may escalate after a failure but never above this ceiling. One
|
|
10
|
+
* constant shared by every escalation site keeps a cost pin from silently
|
|
11
|
+
* spending pro/ultra money (ADR-0001 §1).
|
|
12
|
+
*/
|
|
13
|
+
export const COST_MODE_TIER_CEILING = 'plus';
|
|
14
|
+
/** The lower of `tier` and `cap` by TIER_RANK — a ceiling applied to a tier. */
|
|
15
|
+
export function clampTierToCeiling(tier, cap) {
|
|
16
|
+
return TIER_RANK[tier] <= TIER_RANK[cap] ? tier : cap;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thinking-effort vocabulary, aligned with OpenCode's 7-level ladder
|
|
9
20
|
* (lowest → highest). `EFFORT_LADDER.indexOf(effort)` IS the rank —
|
|
10
21
|
* weaker levels have smaller index.
|
|
11
22
|
* none — no reasoning (the lowest tier; client sends this
|
|
12
23
|
* explicitly to mean "do not think", not as a default)
|
|
24
|
+
* minimal — the lightest active reasoning level (above none)
|
|
13
25
|
* low / medium / high — shared by every wire (OpenAI, Anthropic,
|
|
14
26
|
* Google, OpenAI Responses)
|
|
15
27
|
* xhigh — OpenAI / OpenAI-compatible top tier (GPT-5+)
|
|
@@ -23,7 +35,7 @@ export const TIER_RANK = {
|
|
|
23
35
|
* served.
|
|
24
36
|
*
|
|
25
37
|
* Default `supportedReasoningEfforts` for a thinking-capable model is
|
|
26
|
-
* the full
|
|
38
|
+
* the full 7-level ladder — there is no reduced "thinking" subset.
|
|
27
39
|
*/
|
|
28
40
|
export const EFFORT_LADDER = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
29
41
|
/** Shared thinking-token budget estimates for protocols that express effort as a token budget. */
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-family classification — the ONE mapping from a client fingerprint (a
|
|
3
|
+
* self-declared `x-ocr-client` hint, else the HTTP User-Agent) to a stable
|
|
4
|
+
* client family for the console.
|
|
5
|
+
*
|
|
6
|
+
* Display-only: both inputs are client-forgeable and are deliberately never
|
|
7
|
+
* identity/routing inputs (ADR-0002 resolves session identity zero-header,
|
|
8
|
+
* anchored on the API-key application). The hint exists because a browser
|
|
9
|
+
* webview strips a script-set `User-Agent` on `fetch` — see
|
|
10
|
+
* `CLIENT_HINT_HEADER`. The family id is the machine key the sessions filter
|
|
11
|
+
* and the console query string use; `label` is an English fallback shown when
|
|
12
|
+
* the console has no localized name for the id. Product names (OpenCode,
|
|
13
|
+
* Cursor, …) are proper nouns and are never translated.
|
|
14
|
+
*/
|
|
15
|
+
export interface ClientFamily {
|
|
16
|
+
/** Stable machine id (`opencode`, `claude-code`, `pi`, …). Never localized. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** English display label / fallback for unknown UAs. */
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
/** Family id for a User-Agent the table does not recognize. */
|
|
22
|
+
export declare const UNKNOWN_CLIENT_FAMILY_ID = "unknown";
|
|
23
|
+
/**
|
|
24
|
+
* Inbound header a client uses to declare its own identity, e.g.
|
|
25
|
+
* `OmniCellRouter-Playground/<version>`.
|
|
26
|
+
*
|
|
27
|
+
* A browser webview strips a script-set `User-Agent` on `fetch` (the browser
|
|
28
|
+
* sends its own instead — verified empirically), so the UA alone cannot carry
|
|
29
|
+
* a self-declared id from a console page. A custom header survives, and it is
|
|
30
|
+
* PREFERRED over the UA for family classification. Display-only, exactly like
|
|
31
|
+
* the UA: forgeable, never an identity or routing input (ADR-0002).
|
|
32
|
+
*/
|
|
33
|
+
export declare const CLIENT_HINT_HEADER = "x-ocr-client";
|
|
34
|
+
/**
|
|
35
|
+
* The identification material ONE request carried: a self-declared hint
|
|
36
|
+
* (`x-ocr-client`) and/or the raw inbound User-Agent. Either may be absent.
|
|
37
|
+
*/
|
|
38
|
+
export interface ClientFingerprint {
|
|
39
|
+
/** Self-declared client id (`x-ocr-client`), e.g. `playground/0.8.5`. */
|
|
40
|
+
hint?: string;
|
|
41
|
+
/** Raw inbound `User-Agent` string. */
|
|
42
|
+
userAgent?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Classify one User-Agent into a client family. Unknown UAs keep their leading
|
|
46
|
+
* whitespace token (capped) as the label so the console never invents a client
|
|
47
|
+
* that isn't there; the full raw UA stays in the chip tooltip.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clientFamilyOf(ua: string): ClientFamily;
|
|
50
|
+
/**
|
|
51
|
+
* One family as a session reports it: the family plus the raw fingerprints
|
|
52
|
+
* that produced it (write order). The fingerprint list exists only so the
|
|
53
|
+
* console chip can keep showing the exact value in its tooltip — it is never
|
|
54
|
+
* an identity or a filter key (the family id is).
|
|
55
|
+
*/
|
|
56
|
+
export interface SessionClientFamily extends ClientFamily {
|
|
57
|
+
/** The identifying strings: a self-declared hint or the raw UA, whichever
|
|
58
|
+
* classified the request (see `clientFamiliesOf`). */
|
|
59
|
+
fingerprints: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Distinct families across a session's per-request fingerprints, in write
|
|
63
|
+
* order (first element = display anchor). Fingerprints of the same family
|
|
64
|
+
* collapse to one entry that keeps every contributing value.
|
|
65
|
+
*/
|
|
66
|
+
export declare function clientFamiliesOf(fingerprints: readonly ClientFingerprint[]): SessionClientFamily[];
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered first-match table. ORDER MATTERS: `pi` is ANCHORED and must be
|
|
3
|
+
* tested before the generic `/anthropic/i` entry — a pi User-Agent embeds no
|
|
4
|
+
* vendor name, but an unanchored `/pi/i` would match "Anthropic/…".
|
|
5
|
+
*/
|
|
6
|
+
const CLIENT_PATTERNS = [
|
|
7
|
+
// The console's own playground page (frontend/src/pages/PlaygroundPage.tsx
|
|
8
|
+
// sends `OmniCellRouter-Playground/<version>`). Before `pi` so the product
|
|
9
|
+
// prefix can never be mistaken for a vendor SDK.
|
|
10
|
+
[/omnicellrouter-playground/i, 'playground', 'Playground'],
|
|
11
|
+
// pi agent — `pi/<version> (<platform>; <runtime>/<ver>; <arch>)` or `pi`.
|
|
12
|
+
[/^pi(\/|\s|$)/i, 'pi', 'pi'],
|
|
13
|
+
// Coding agents / CLIs
|
|
14
|
+
[/opencode/i, 'opencode', 'OpenCode'],
|
|
15
|
+
[/claude-cli|claude-code/i, 'claude-code', 'Claude Code'],
|
|
16
|
+
[/chatgpt/i, 'chatgpt', 'ChatGPT'],
|
|
17
|
+
[/codex/i, 'codex', 'Codex / ChatGPT'],
|
|
18
|
+
[/cline/i, 'cline', 'Cline'],
|
|
19
|
+
[/roo-?code/i, 'roo-code', 'Roo Code'],
|
|
20
|
+
[/kilo-?code/i, 'kilo-code', 'Kilo Code'],
|
|
21
|
+
// Cursor was renamed Grok Build (2026-11-30); the family id stays `cursor`
|
|
22
|
+
// because it is the machine key historical sessions already carry.
|
|
23
|
+
[/cursor/i, 'cursor', 'Grok Build (Cursor)'],
|
|
24
|
+
[/windsurf/i, 'windsurf', 'Windsurf'],
|
|
25
|
+
// Chat frontends
|
|
26
|
+
[/cherrystudio/i, 'cherry-studio', 'Cherry Studio'],
|
|
27
|
+
[/chatbox/i, 'chatbox', 'ChatBox'],
|
|
28
|
+
[/lobe-?chat|lobehub/i, 'lobechat', 'LobeChat'],
|
|
29
|
+
[/nextchat|chatgpt-?next-?web/i, 'nextchat', 'NextChat'],
|
|
30
|
+
[/open-?webui/i, 'open-webui', 'Open WebUI'],
|
|
31
|
+
[/librechat/i, 'librechat', 'LibreChat'],
|
|
32
|
+
[/dify/i, 'dify', 'Dify'],
|
|
33
|
+
[/fastgpt/i, 'fastgpt', 'FastGPT'],
|
|
34
|
+
// IDE / editor integrations
|
|
35
|
+
[/visual-?studio-?code|vscode/i, 'vscode', 'VS Code'],
|
|
36
|
+
[/jetbrains/i, 'jetbrains', 'JetBrains'],
|
|
37
|
+
// Official SDKs
|
|
38
|
+
[/openai\/node/i, 'openai-node', 'OpenAI SDK (Node)'],
|
|
39
|
+
[/openai\/python/i, 'openai-python', 'OpenAI SDK (Python)'],
|
|
40
|
+
[/anthropic/i, 'anthropic-sdk', 'Anthropic SDK'],
|
|
41
|
+
[/google-?genai|generativelanguage/i, 'google-genai', 'Google GenAI SDK'],
|
|
42
|
+
// HTTP libraries (generic fallbacks for home-grown callers)
|
|
43
|
+
[/python-?httpx/i, 'python-httpx', 'Python httpx'],
|
|
44
|
+
[/python-?requests/i, 'python-requests', 'Python requests'],
|
|
45
|
+
[/python-?urllib/i, 'python-urllib', 'Python urllib'],
|
|
46
|
+
[/aiohttp/i, 'python-aiohttp', 'Python aiohttp'],
|
|
47
|
+
[/okhttp/i, 'okhttp', 'OkHttp'],
|
|
48
|
+
[/go-http-client/i, 'go-http', 'Go HTTP'],
|
|
49
|
+
[/guzzle/i, 'guzzle', 'Guzzle'],
|
|
50
|
+
[/\bdart\//i, 'dart', 'Dart'],
|
|
51
|
+
[/axios/i, 'axios', 'Axios'],
|
|
52
|
+
[/undici/i, 'undici', 'Node fetch (undici)'],
|
|
53
|
+
// API tools
|
|
54
|
+
[/postmanruntime/i, 'postman', 'Postman'],
|
|
55
|
+
[/insomnia/i, 'insomnia', 'Insomnia'],
|
|
56
|
+
[/\bcurl\/|libcurl/i, 'curl', 'curl'],
|
|
57
|
+
[/wget/i, 'wget', 'Wget'],
|
|
58
|
+
];
|
|
59
|
+
/** Max length of an unrecognized UA token shown as the label. */
|
|
60
|
+
const UNKNOWN_LABEL_CAP = 32;
|
|
61
|
+
/** Family id for a User-Agent the table does not recognize. */
|
|
62
|
+
export const UNKNOWN_CLIENT_FAMILY_ID = 'unknown';
|
|
63
|
+
/**
|
|
64
|
+
* Inbound header a client uses to declare its own identity, e.g.
|
|
65
|
+
* `OmniCellRouter-Playground/<version>`.
|
|
66
|
+
*
|
|
67
|
+
* A browser webview strips a script-set `User-Agent` on `fetch` (the browser
|
|
68
|
+
* sends its own instead — verified empirically), so the UA alone cannot carry
|
|
69
|
+
* a self-declared id from a console page. A custom header survives, and it is
|
|
70
|
+
* PREFERRED over the UA for family classification. Display-only, exactly like
|
|
71
|
+
* the UA: forgeable, never an identity or routing input (ADR-0002).
|
|
72
|
+
*/
|
|
73
|
+
export const CLIENT_HINT_HEADER = 'x-ocr-client';
|
|
74
|
+
/**
|
|
75
|
+
* Classify one User-Agent into a client family. Unknown UAs keep their leading
|
|
76
|
+
* whitespace token (capped) as the label so the console never invents a client
|
|
77
|
+
* that isn't there; the full raw UA stays in the chip tooltip.
|
|
78
|
+
*/
|
|
79
|
+
export function clientFamilyOf(ua) {
|
|
80
|
+
for (const [pattern, id, label] of CLIENT_PATTERNS) {
|
|
81
|
+
if (pattern.test(ua))
|
|
82
|
+
return { id, label };
|
|
83
|
+
}
|
|
84
|
+
const token = ua.trim().split(/\s+/)[0] ?? '';
|
|
85
|
+
const label = token.length > UNKNOWN_LABEL_CAP ? `${token.slice(0, UNKNOWN_LABEL_CAP)}…` : token || '—';
|
|
86
|
+
return { id: UNKNOWN_CLIENT_FAMILY_ID, label };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Resolve ONE request's family. A self-declared hint wins when it names a
|
|
90
|
+
* known family; otherwise the UA classifies, and an unrecognized hint is the
|
|
91
|
+
* last resort. Returns the raw string that actually classified so the console
|
|
92
|
+
* tooltip shows the value the family came from.
|
|
93
|
+
*/
|
|
94
|
+
function familyOfFingerprint(fp) {
|
|
95
|
+
const hint = fp.hint?.trim();
|
|
96
|
+
const ua = fp.userAgent?.trim();
|
|
97
|
+
if (hint) {
|
|
98
|
+
const declared = clientFamilyOf(hint);
|
|
99
|
+
if (declared.id !== UNKNOWN_CLIENT_FAMILY_ID)
|
|
100
|
+
return { family: declared, raw: hint };
|
|
101
|
+
}
|
|
102
|
+
if (ua)
|
|
103
|
+
return { family: clientFamilyOf(ua), raw: ua };
|
|
104
|
+
if (hint)
|
|
105
|
+
return { family: clientFamilyOf(hint), raw: hint };
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Distinct families across a session's per-request fingerprints, in write
|
|
110
|
+
* order (first element = display anchor). Fingerprints of the same family
|
|
111
|
+
* collapse to one entry that keeps every contributing value.
|
|
112
|
+
*/
|
|
113
|
+
export function clientFamiliesOf(fingerprints) {
|
|
114
|
+
const byId = new Map();
|
|
115
|
+
for (const fp of fingerprints) {
|
|
116
|
+
const resolved = familyOfFingerprint(fp);
|
|
117
|
+
if (!resolved)
|
|
118
|
+
continue;
|
|
119
|
+
const existing = byId.get(resolved.family.id);
|
|
120
|
+
if (existing) {
|
|
121
|
+
existing.fingerprints.push(resolved.raw);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
byId.set(resolved.family.id, { ...resolved.family, fingerprints: [resolved.raw] });
|
|
125
|
+
}
|
|
126
|
+
return [...byId.values()];
|
|
127
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/** Ring capacity (and, mirrored, the durable row budget). */
|
|
9
9
|
export declare const EVENT_RING_CAPACITY = 500;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Ingress-proxy access-log ring capacity — body-bearing rows are heavy, so
|
|
12
12
|
* the fourth ledger carries a smaller ring than the other three (pass to the
|
|
13
13
|
* EventRing constructor; never re-declare per module).
|
|
14
14
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/** Ring capacity (and, mirrored, the durable row budget). */
|
|
9
9
|
export const EVENT_RING_CAPACITY = 500;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Ingress-proxy access-log ring capacity — body-bearing rows are heavy, so
|
|
12
12
|
* the fourth ledger carries a smaller ring than the other three (pass to the
|
|
13
13
|
* EventRing constructor; never re-declare per module).
|
|
14
14
|
*/
|