omnicell-router 0.8.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -7
- package/README.zh-CN.md +18 -5
- package/backend/dist/capture/recorder.d.ts +4 -10
- package/backend/dist/capture/recorder.js +6 -58
- package/backend/dist/cli/clients/base.d.ts +36 -11
- package/backend/dist/cli/clients/base.js +31 -15
- package/backend/dist/cli/clients/claude.d.ts +9 -0
- package/backend/dist/cli/clients/claude.js +6 -0
- package/backend/dist/cli/clients/codex.d.ts +8 -0
- package/backend/dist/cli/clients/codex.js +5 -0
- package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
- package/backend/dist/cli/clients/core-adapters.js +1 -1
- package/backend/dist/cli/clients/dsh.d.ts +8 -0
- package/backend/dist/cli/clients/dsh.js +5 -0
- package/backend/dist/cli/clients/grok.d.ts +15 -1
- package/backend/dist/cli/clients/grok.js +16 -2
- package/backend/dist/cli/clients/index.d.ts +13 -1
- package/backend/dist/cli/clients/index.js +97 -19
- package/backend/dist/cli/clients/kimi.d.ts +6 -0
- package/backend/dist/cli/clients/kimi.js +3 -0
- package/backend/dist/cli/clients/launcher.d.ts +1 -1
- package/backend/dist/cli/clients/model-meta.js +6 -3
- package/backend/dist/cli/clients/omp.d.ts +6 -0
- package/backend/dist/cli/clients/omp.js +3 -0
- package/backend/dist/cli/clients/openclaw.d.ts +6 -0
- package/backend/dist/cli/clients/openclaw.js +3 -0
- package/backend/dist/cli/clients/opencode.d.ts +8 -0
- package/backend/dist/cli/clients/opencode.js +5 -0
- package/backend/dist/cli/clients/pi.d.ts +6 -0
- package/backend/dist/cli/clients/pi.js +3 -0
- package/backend/dist/cli/clients/update-check.d.ts +37 -0
- package/backend/dist/cli/clients/update-check.js +309 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
- package/backend/dist/cli/clients/workbuddy.js +66 -0
- package/backend/dist/cli/index.js +5 -4
- package/backend/dist/cli/paths.js +8 -0
- package/backend/dist/cli/types.d.ts +92 -16
- package/backend/dist/config/comments-en.js +31 -26
- package/backend/dist/config/comments-zh.js +29 -24
- package/backend/dist/config/defaults.d.ts +194 -33
- package/backend/dist/config/defaults.js +193 -32
- package/backend/dist/config/env.d.ts +10 -0
- package/backend/dist/config/env.js +3 -2
- package/backend/dist/config/index.d.ts +7 -0
- package/backend/dist/config/index.js +184 -43
- package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
- package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
- package/backend/dist/config/migrations/v10-to-v11.js +43 -0
- package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
- package/backend/dist/config/migrations/v6-to-v7.js +97 -0
- package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
- package/backend/dist/config/migrations/v7-to-v8.js +43 -0
- package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
- package/backend/dist/config/migrations/v8-to-v9.js +43 -0
- package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
- package/backend/dist/config/migrations/v9-to-v10.js +71 -0
- package/backend/dist/config/runtime.js +1 -1
- package/backend/dist/config/schema.d.ts +3 -3
- package/backend/dist/config/schema.js +14 -4
- package/backend/dist/config/types.d.ts +167 -38
- package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
- package/backend/dist/egress-proxy/asset-download.js +420 -0
- package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
- package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
- package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
- package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/egress-proxy/mihomo-client.js +308 -0
- package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/egress-proxy/mihomo-config.js +161 -0
- package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
- package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
- package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
- package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
- package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
- package/backend/dist/forward-proxy/egress.d.ts +50 -11
- package/backend/dist/forward-proxy/egress.js +50 -17
- package/backend/dist/forward-proxy/h2-forward.js +36 -10
- package/backend/dist/forward-proxy/index.d.ts +11 -8
- package/backend/dist/forward-proxy/index.js +22 -60
- package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
- package/backend/dist/forward-proxy/interceptor.js +4 -4
- package/backend/dist/forward-proxy/relay.js +3 -3
- package/backend/dist/forward-proxy/rules.d.ts +4 -4
- package/backend/dist/forward-proxy/rules.js +25 -4
- package/backend/dist/forward-proxy/server.d.ts +0 -16
- package/backend/dist/forward-proxy/server.js +124 -156
- package/backend/dist/harness/host/hosts.js +3 -2
- package/backend/dist/index.js +53 -18
- package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
- package/backend/dist/ingress-proxy/access-log.js +774 -0
- package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
- package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
- package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
- package/backend/dist/ingress-proxy/ca-trust.js +315 -0
- package/backend/dist/ingress-proxy/ca.d.ts +104 -0
- package/backend/dist/ingress-proxy/ca.js +273 -0
- package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
- package/backend/dist/ingress-proxy/data-dir.js +45 -0
- package/backend/dist/ingress-proxy/egress.d.ts +151 -0
- package/backend/dist/ingress-proxy/egress.js +364 -0
- package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/ingress-proxy/h2-forward.js +561 -0
- package/backend/dist/ingress-proxy/index.d.ts +24 -0
- package/backend/dist/ingress-proxy/index.js +144 -0
- package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
- package/backend/dist/ingress-proxy/interceptor.js +52 -0
- package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
- package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
- package/backend/dist/ingress-proxy/relay.d.ts +54 -0
- package/backend/dist/ingress-proxy/relay.js +188 -0
- package/backend/dist/ingress-proxy/rules.d.ts +195 -0
- package/backend/dist/ingress-proxy/rules.js +348 -0
- package/backend/dist/ingress-proxy/server.d.ts +153 -0
- package/backend/dist/ingress-proxy/server.js +2065 -0
- package/backend/dist/ingress-proxy/sni.d.ts +35 -0
- package/backend/dist/ingress-proxy/sni.js +124 -0
- package/backend/dist/ingress-proxy/status.d.ts +32 -0
- package/backend/dist/ingress-proxy/status.js +15 -0
- package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
- package/backend/dist/ingress-proxy/system-proxy.js +481 -0
- package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
- package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
- package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
- package/backend/dist/ingress-proxy/traffic-files.js +10 -0
- package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
- package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/ingress-proxy/ws-frames.js +153 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
- package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
- package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
- package/backend/dist/ir/adapters/google-gemini.js +5 -2
- package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
- package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
- package/backend/dist/ir/adapters/openai-chat.js +45 -3
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
- package/backend/dist/ir/adapters/openai-responses.d.ts +82 -24
- package/backend/dist/ir/adapters/openai-responses.js +146 -37
- package/backend/dist/ir/media.d.ts +20 -0
- package/backend/dist/ir/media.js +41 -0
- package/backend/dist/ir/tool-identity.d.ts +35 -0
- package/backend/dist/ir/tool-identity.js +40 -0
- package/backend/dist/ir/types.d.ts +9 -1
- package/backend/dist/local/build-jobs.d.ts +66 -0
- package/backend/dist/local/build-jobs.js +243 -0
- package/backend/dist/local/detect.d.ts +32 -0
- package/backend/dist/local/detect.js +145 -0
- package/backend/dist/local/draft-match.d.ts +58 -0
- package/backend/dist/local/draft-match.js +124 -0
- package/backend/dist/local/engine-runtime.d.ts +522 -0
- package/backend/dist/local/engine-runtime.js +1 -0
- package/backend/dist/local/engines.d.ts +241 -0
- package/backend/dist/local/engines.js +651 -0
- package/backend/dist/local/gguf.d.ts +35 -0
- package/backend/dist/local/gguf.js +314 -0
- package/backend/dist/local/hf.d.ts +120 -0
- package/backend/dist/local/hf.js +304 -0
- package/backend/dist/local/install.d.ts +90 -0
- package/backend/dist/local/install.js +421 -0
- package/backend/dist/local/llamacpp.d.ts +55 -0
- package/backend/dist/local/llamacpp.js +177 -0
- package/backend/dist/local/local-provider.d.ts +81 -0
- package/backend/dist/local/local-provider.js +301 -0
- package/backend/dist/local/machine-stats.d.ts +87 -0
- package/backend/dist/local/machine-stats.js +332 -0
- package/backend/dist/local/model-store.d.ts +347 -0
- package/backend/dist/local/model-store.js +1215 -0
- package/backend/dist/local/part-sweep.d.ts +32 -0
- package/backend/dist/local/part-sweep.js +156 -0
- package/backend/dist/local/plan.d.ts +65 -0
- package/backend/dist/local/plan.js +146 -0
- package/backend/dist/local/resources.d.ts +49 -0
- package/backend/dist/local/resources.js +64 -0
- package/backend/dist/local/run-stats.d.ts +95 -0
- package/backend/dist/local/run-stats.js +195 -0
- package/backend/dist/local/runner.d.ts +235 -0
- package/backend/dist/local/runner.js +1392 -0
- package/backend/dist/local/settings.d.ts +79 -0
- package/backend/dist/local/settings.js +180 -0
- package/backend/dist/local/strata-catalog.d.ts +30 -0
- package/backend/dist/local/strata-catalog.js +511 -0
- package/backend/dist/local/strata-drafting.d.ts +46 -0
- package/backend/dist/local/strata-drafting.js +265 -0
- package/backend/dist/local/strata.d.ts +278 -0
- package/backend/dist/local/strata.js +1392 -0
- package/backend/dist/local/tar.d.ts +20 -0
- package/backend/dist/local/tar.js +367 -0
- package/backend/dist/local/transport.d.ts +35 -0
- package/backend/dist/local/transport.js +89 -0
- package/backend/dist/local/tune.d.ts +58 -0
- package/backend/dist/local/tune.js +324 -0
- package/backend/dist/observability/http-exchange.d.ts +2 -2
- package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
- package/backend/dist/opencode/catalog/auto-pull.js +276 -70
- package/backend/dist/opencode/catalog/ocr-store.js +3 -1
- package/backend/dist/opencode/catalog/overrides-store.d.ts +10 -1
- package/backend/dist/opencode/catalog/overrides-store.js +6 -0
- package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
- package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
- package/backend/dist/opencode/catalog/repository.js +25 -2
- package/backend/dist/opencode/catalog/sources/models-dev.js +13 -3
- package/backend/dist/opencode/catalog/types.d.ts +35 -3
- package/backend/dist/opencode/catalog/types.js +38 -1
- package/backend/dist/opencode/credentials/ocr-store.js +11 -2
- package/backend/dist/opencode/credentials/sync.js +12 -3
- package/backend/dist/opencode/credentials/types.d.ts +31 -4
- package/backend/dist/opencode/credentials/types.js +25 -0
- package/backend/dist/opencode/probe.d.ts +21 -4
- package/backend/dist/opencode/probe.js +34 -10
- package/backend/dist/pipeline/directives.d.ts +9 -4
- package/backend/dist/pipeline/directives.js +14 -10
- package/backend/dist/pipeline/orchestrator.d.ts +42 -13
- package/backend/dist/pipeline/orchestrator.js +497 -165
- package/backend/dist/plugins/environment-ack.d.ts +51 -0
- package/backend/dist/plugins/environment-ack.js +81 -0
- package/backend/dist/plugins/gateways.d.ts +6 -6
- package/backend/dist/plugins/gateways.js +2 -2
- package/backend/dist/plugins/host.d.ts +98 -14
- package/backend/dist/plugins/host.js +622 -87
- package/backend/dist/plugins/install-run.d.ts +27 -0
- package/backend/dist/plugins/install-run.js +99 -0
- package/backend/dist/plugins/manifest.d.ts +84 -32
- package/backend/dist/plugins/manifest.js +149 -45
- package/backend/dist/plugins/market-install.d.ts +18 -0
- package/backend/dist/plugins/market-install.js +111 -0
- package/backend/dist/plugins/market-source.d.ts +100 -0
- package/backend/dist/plugins/market-source.js +449 -0
- package/backend/dist/plugins/market-updates.d.ts +70 -0
- package/backend/dist/plugins/market-updates.js +97 -0
- package/backend/dist/plugins/market.d.ts +677 -0
- package/backend/dist/plugins/market.js +2113 -0
- package/backend/dist/plugins/source-index.d.ts +155 -0
- package/backend/dist/plugins/source-index.js +217 -0
- package/backend/dist/plugins/types.d.ts +402 -37
- package/backend/dist/projects/worktrees.d.ts +88 -0
- package/backend/dist/projects/worktrees.js +220 -0
- package/backend/dist/providers/boot-direct.d.ts +41 -7
- package/backend/dist/providers/boot-direct.js +252 -36
- package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
- package/backend/dist/providers/executors/dispatch.d.ts +17 -7
- package/backend/dist/providers/executors/dispatch.js +28 -9
- package/backend/dist/providers/executors/openai-chat.js +14 -2
- package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
- package/backend/dist/providers/executors/plugin-adapter.js +59 -3
- package/backend/dist/providers/member-match.d.ts +32 -9
- package/backend/dist/providers/member-match.js +65 -21
- package/backend/dist/providers/model-resolution.d.ts +62 -0
- package/backend/dist/providers/model-resolution.js +62 -0
- package/backend/dist/providers/price-order.d.ts +51 -0
- package/backend/dist/providers/price-order.js +54 -0
- package/backend/dist/providers/provider-takedown.d.ts +5 -2
- package/backend/dist/providers/registry.d.ts +84 -25
- package/backend/dist/providers/registry.js +209 -114
- package/backend/dist/providers/selection.d.ts +91 -0
- package/backend/dist/providers/selection.js +158 -0
- package/backend/dist/providers/virtual-meta.d.ts +33 -2
- package/backend/dist/providers/virtual-meta.js +74 -18
- package/backend/dist/quota/cli-login.d.ts +25 -4
- package/backend/dist/quota/cli-login.js +35 -5
- package/backend/dist/quota/coverage-generation.d.ts +24 -0
- package/backend/dist/quota/coverage-generation.js +29 -0
- package/backend/dist/quota/declarations.js +8 -4
- package/backend/dist/quota/engine.js +2 -2
- package/backend/dist/quota/prober.d.ts +43 -2
- package/backend/dist/quota/prober.js +97 -22
- package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
- package/backend/dist/resilience/error-classifier.js +29 -0
- package/backend/dist/router/index.d.ts +1 -1
- package/backend/dist/router/index.js +17 -1
- package/backend/dist/router/layer2-decision.d.ts +1 -1
- package/backend/dist/router/layer2-decision.js +2 -2
- package/backend/dist/routes/console.js +928 -310
- package/backend/dist/routes/environments.js +1 -1
- package/backend/dist/routes/local-models.d.ts +2 -0
- package/backend/dist/routes/local-models.js +1414 -0
- package/backend/dist/routes/mihomo.d.ts +2 -2
- package/backend/dist/routes/mihomo.js +20 -11
- package/backend/dist/routes/projects.js +121 -0
- package/backend/dist/server.js +318 -13
- package/backend/dist/session/session-manager.d.ts +42 -5
- package/backend/dist/session/session-manager.js +64 -11
- package/backend/dist/session/session-row.d.ts +29 -8
- package/backend/dist/session/session-row.js +18 -13
- package/backend/dist/snapshot/bundle.d.ts +40 -0
- package/backend/dist/snapshot/bundle.js +177 -0
- package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
- package/backend/dist/snapshot/handoff/compress.js +77 -0
- package/backend/dist/snapshot/handoff/index.d.ts +119 -0
- package/backend/dist/snapshot/handoff/index.js +160 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
- package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
- package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
- package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
- package/backend/dist/snapshot/handoff/summarize.js +118 -0
- package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
- package/backend/dist/snapshot/handoff/transcript.js +167 -0
- package/backend/dist/snapshot/media-fs.d.ts +10 -0
- package/backend/dist/snapshot/media-fs.js +50 -0
- package/backend/dist/snapshot/media.d.ts +32 -0
- package/backend/dist/snapshot/media.js +87 -0
- package/backend/dist/snapshot/store.d.ts +226 -0
- package/backend/dist/snapshot/store.js +887 -0
- package/backend/dist/snapshot/tree.d.ts +112 -0
- package/backend/dist/snapshot/tree.js +207 -0
- package/backend/dist/snapshot/types.d.ts +212 -0
- package/backend/dist/snapshot/types.js +14 -0
- package/backend/dist/snapshot/view.d.ts +19 -0
- package/backend/dist/snapshot/view.js +57 -0
- package/backend/dist/snapshot/write-worker.d.ts +67 -0
- package/backend/dist/snapshot/write-worker.js +129 -0
- package/backend/dist/surfaces/body-admission.d.ts +67 -2
- package/backend/dist/surfaces/body-admission.js +218 -13
- package/backend/dist/surfaces/chat-pipeline.js +8 -0
- package/backend/dist/surfaces/decision-pipeline.js +10 -7
- package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
- package/backend/dist/surfaces/gateway-catalog.js +202 -0
- package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
- package/backend/dist/surfaces/gateway-chat.js +50 -12
- package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
- package/backend/dist/surfaces/ocr-headers.js +11 -7
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/transport-fastify.js +32 -5
- package/backend/dist/surfaces/transport-node-http.d.ts +9 -3
- package/backend/dist/surfaces/transport-node-http.js +6 -19
- package/backend/dist/surfaces/types.d.ts +11 -3
- package/backend/dist/trace/persist.js +21 -1
- package/backend/dist/trace/tracker.d.ts +35 -3
- package/backend/dist/trace/tracker.js +23 -0
- package/backend/dist/types/openai.d.ts +8 -0
- package/backend/dist/types/router.d.ts +17 -6
- package/backend/dist/types/router.js +14 -2
- package/backend/dist/utils/client-families.d.ts +66 -0
- package/backend/dist/utils/client-families.js +127 -0
- package/backend/dist/utils/event-ring.d.ts +1 -1
- package/backend/dist/utils/event-ring.js +1 -1
- package/backend/dist/utils/proxy-node.js +1 -1
- package/backend/dist/utils/proxy.d.ts +135 -11
- package/backend/dist/utils/proxy.js +144 -29
- package/backend/dist/utils/run-command.d.ts +21 -1
- package/backend/dist/utils/run-command.js +64 -4
- package/backend/dist/utils/server-liveness.d.ts +3 -2
- package/backend/dist/utils/server-liveness.js +3 -2
- package/backend/dist/utils/session-file.d.ts +28 -0
- package/backend/dist/utils/session-file.js +34 -0
- package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
- package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
- package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
- package/frontend/dist/assets/{index-KI1OW5x6.css → index-CqDSOPQ0.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +3 -1
- package/frontend/dist/assets/index-Dk76uc7e.js +0 -1522
|
@@ -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
|
*/
|
|
@@ -16,7 +16,7 @@ import http from 'node:http';
|
|
|
16
16
|
import tls from 'node:tls';
|
|
17
17
|
import zlib from 'node:zlib';
|
|
18
18
|
import { Readable, PassThrough } from 'node:stream';
|
|
19
|
-
import { openViaProxy, parseProxy, upstreamServernameOption } from '../
|
|
19
|
+
import { openViaProxy, parseProxy, upstreamServernameOption } from '../ingress-proxy/egress.js';
|
|
20
20
|
import { isLoopbackUrl } from './proxy.js';
|
|
21
21
|
const MAX_REDIRECTS = 5;
|
|
22
22
|
const HEADER_LIMIT = 64 * 1024;
|
|
@@ -6,24 +6,127 @@ export declare function isLoopbackUrl(url: string): boolean;
|
|
|
6
6
|
/** True when this process's fetch understands the Bun `proxy` option. */
|
|
7
7
|
export declare function isBunRuntime(): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* The outbound proxy
|
|
10
|
-
*
|
|
9
|
+
* The outbound proxy endpoint with NO provider/model gating — `proxy.enabled` +
|
|
10
|
+
* the effective endpoint, nothing else.
|
|
11
11
|
*
|
|
12
|
-
* `
|
|
12
|
+
* `resolveEgress` answers "which leg for THIS provider/model" (includes /
|
|
13
13
|
* excludes). Callers that already decided the egress themselves — the
|
|
14
|
-
*
|
|
14
|
+
* ingress-proxy transit legs after the egress table (ADR-0018) — must not be
|
|
15
15
|
* re-gated by a list that was never about hosts.
|
|
16
|
+
*
|
|
17
|
+
* Named `egress` (not `outbound`): "outbound" is the HOST SDK's axis
|
|
18
|
+
* (`egressProxyFor`, ADR-0022), while this answers the core's own question —
|
|
19
|
+
* where this machine's egress proxy is. It is the single place that turns
|
|
20
|
+
* `proxy.enabled` + the endpoint into a dialable string; nothing else should
|
|
21
|
+
* re-derive it.
|
|
16
22
|
*/
|
|
17
|
-
export declare function
|
|
23
|
+
export declare function egressEndpointUrl(): string | undefined;
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
25
|
+
* Why a target resolved DIRECT. Six values, not one `undefined`: a caller that
|
|
26
|
+
* cannot tell "the proxy is off" from "your rule excluded me" cannot report an
|
|
27
|
+
* honest egress, and the ONE spelling of absence (`undefined` = direct) is the
|
|
28
|
+
* silent trap this union closes.
|
|
29
|
+
*
|
|
30
|
+
* - `disabled` — `proxy.enabled` is not true; nothing is proxied at all.
|
|
31
|
+
* - `loopback` — a local target is never proxied (cycle safety).
|
|
32
|
+
* - `exclude` — an `proxy.excludes` pattern matched this caller.
|
|
33
|
+
* - `no-target` — the caller supplied no `{ provider, model }` to test.
|
|
34
|
+
* - `unlisted` — the includes allowlist does not cover this caller (no list
|
|
35
|
+
* configured, or no pattern matched). The caller goes direct either way and
|
|
36
|
+
* the operator's fix is the same — add a matching include — so the two are
|
|
37
|
+
* deliberately NOT split into a second value.
|
|
38
|
+
* - `no-endpoint` — an include DID name this caller (or the plugin asked for the
|
|
39
|
+
* proxy) and there is nothing usable to dial: `proxy.url` is missing/invalid,
|
|
40
|
+
* no valid `mihomo.mixedPort`, or `proxy.enabled` is off while the demand
|
|
41
|
+
* stands. This is a REFUSAL, not a fallback: `proxiedFetch` throws
|
|
42
|
+
* {@link OUTBOUND_REFUSED_MESSAGE} (502) instead of dialing direct, because a
|
|
43
|
+
* direct dial would put the operator's real address on traffic they
|
|
44
|
+
* explicitly asked to proxy — the silent leak the host axle already refuses.
|
|
45
|
+
* Remove the include (or fix the endpoint) to go direct deliberately.
|
|
46
|
+
* - `plugin` — no list decided this leg; the plugin-level switch or the
|
|
47
|
+
* package's own request did (ADR-0022 amendment). "My split did not apply" and
|
|
48
|
+
* "the plugin asked for direct" are different operator fixes, so they are not
|
|
49
|
+
* the same value.
|
|
50
|
+
*
|
|
51
|
+
* Each remaining value is a different operator fix, which is why they are not
|
|
52
|
+
* collapsed into one `undefined`.
|
|
53
|
+
*/
|
|
54
|
+
export type EgressDirectReason = 'disabled' | 'loopback' | 'exclude' | 'no-target' | 'unlisted' | 'no-endpoint' | 'plugin';
|
|
55
|
+
/**
|
|
56
|
+
* A plugin's own answer about the outbound leg, passed through `host.fetch` and
|
|
57
|
+
* `host.egressProxyFor` (ADR-0022 amendment).
|
|
58
|
+
*
|
|
59
|
+
* Named `Egress` rather than `Proxy` on purpose: `ProxyMode` / `proxy.mode` is
|
|
60
|
+
* already taken in this repo for "manual URL or mihomo core" (the ENDPOINT
|
|
61
|
+
* choice, `config/types.ts`), while this is the LEG choice — through the
|
|
62
|
+
* outbound proxy, around it, or whatever the provider/model split says.
|
|
63
|
+
*
|
|
64
|
+
* `'inherit'` — the default, and what an omitted argument means — states the
|
|
65
|
+
* package has no opinion: the operator's plugin-level switch decides, then the
|
|
66
|
+
* provider/model split, exactly as before this mode existed. `'proxy'` names the
|
|
67
|
+
* operator's outbound proxy (the same endpoint an `includes` hit resolves to,
|
|
68
|
+
* never an address); `'direct'` states the package needs no proxy.
|
|
69
|
+
*/
|
|
70
|
+
export type PluginEgressMode = 'inherit' | 'proxy' | 'direct';
|
|
71
|
+
/**
|
|
72
|
+
* The egress verdict for ONE target — the single resolution point for the
|
|
73
|
+
* provider/model axis (ADR-0018 / ADR-0022). Explicit by construction: a caller
|
|
74
|
+
* reads `mode`, never the absence of a field.
|
|
75
|
+
*
|
|
76
|
+
* A proxied verdict carries BOTH names for its endpoint, because they have
|
|
77
|
+
* different audiences: `url` is dialable (userinfo included) and `origin` is
|
|
78
|
+
* display-safe (userinfo stripped). A caller that renders or reports takes
|
|
79
|
+
* `origin`; only a caller that DIALS may read `url`, and it must never persist
|
|
80
|
+
* or forward it.
|
|
81
|
+
*
|
|
82
|
+
* `wantsProxy` is the INTENT, kept separate from `mode` for one case only:
|
|
83
|
+
* `no-endpoint` means "this caller was demanded to use the proxy and there is
|
|
84
|
+
* nothing to dial". The dialing helper refuses it, but a caller that only REPORTS
|
|
85
|
+
* must not render that as a direct dial — nothing was dialed. Read `mode` for the
|
|
86
|
+
* leg, `wantsProxy` for what the operator asked for.
|
|
87
|
+
*
|
|
88
|
+
* `reason: 'plugin'` says the plugin-level answer decided this leg rather than
|
|
89
|
+
* the provider/model split.
|
|
90
|
+
*/
|
|
91
|
+
export type EgressVerdict = {
|
|
92
|
+
mode: 'direct';
|
|
93
|
+
reason: EgressDirectReason;
|
|
94
|
+
wantsProxy?: boolean;
|
|
95
|
+
} | {
|
|
96
|
+
mode: 'proxy';
|
|
97
|
+
url: string;
|
|
98
|
+
origin: string;
|
|
99
|
+
reason: 'include' | 'plugin';
|
|
100
|
+
};
|
|
101
|
+
/** Resolve the egress for a target. `match` identifies the logical caller
|
|
102
|
+
* ({ provider, model }) for list evaluation; omit it for unlisted infra calls.
|
|
103
|
+
*
|
|
104
|
+
* `egress` is the plugin-level answer (ADR-0022 amendment), already folded by
|
|
105
|
+
* the host SDK so the operator's switch and the package's own request never
|
|
106
|
+
* both speak. Its ladder, and nothing more:
|
|
107
|
+
*
|
|
108
|
+
* 1. loopback stays direct — cycle safety is not a setting;
|
|
109
|
+
* 2. `'proxy'` names the operator's endpoint, and a missing one is
|
|
110
|
+
* `no-endpoint` (a refusal), never a silent direct dial;
|
|
111
|
+
* 3. `'direct'` goes direct, reported as `plugin`;
|
|
112
|
+
* 4. `'inherit'` (or omitted) is the untouched default: the provider/model
|
|
113
|
+
* split decides exactly as it did before this argument existed.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveEgress(targetUrl: string, match?: {
|
|
116
|
+
provider?: string;
|
|
117
|
+
model?: string;
|
|
118
|
+
}, egress?: PluginEgressMode): EgressVerdict;
|
|
119
|
+
/**
|
|
120
|
+
* The proxy URL for a target, or `undefined` for direct — the PROJECTION of
|
|
121
|
+
* {@link resolveEgress} that every dial site consumes. New seams take the
|
|
122
|
+
* verdict; this stays because handing a string to `fetch({ proxy })` is what
|
|
123
|
+
* the transport needs. Never re-derive the lists here: one resolver, one
|
|
124
|
+
* answer.
|
|
22
125
|
*/
|
|
23
126
|
export declare function resolveProxyUrl(targetUrl: string, match?: {
|
|
24
127
|
provider?: string;
|
|
25
128
|
model?: string;
|
|
26
|
-
}): string | undefined;
|
|
129
|
+
}, egress?: PluginEgressMode): string | undefined;
|
|
27
130
|
/**
|
|
28
131
|
* Redact a proxy URL to its origin (`scheme://host:port`). Proxy URLs may
|
|
29
132
|
* embed credentials (`http://user:pass@host:8080`) — capture must never
|
|
@@ -31,11 +134,32 @@ export declare function resolveProxyUrl(targetUrl: string, match?: {
|
|
|
31
134
|
* did this request take".
|
|
32
135
|
*/
|
|
33
136
|
export declare function redactProxyUrl(url: string): string;
|
|
34
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* The provider axle's refusal when the operator DEMANDED the proxy and the
|
|
139
|
+
* machine has no usable endpoint (`no-endpoint`: `proxy.enabled` is on, an
|
|
140
|
+
* include matched this provider/model, but the endpoint is missing or
|
|
141
|
+
* unparseable). This is NOT a fallback candidate: dialing direct here would put
|
|
142
|
+
* the operator's real IP on a request they explicitly asked to route through
|
|
143
|
+
* their proxy — the exact silent leak the host axle already refuses with
|
|
144
|
+
* {@link EGRESS_UNAVAILABLE_MESSAGE}. Spelled once, mirrored from that message so
|
|
145
|
+
* both axles name the same fix.
|
|
146
|
+
*/
|
|
147
|
+
export declare const OUTBOUND_REFUSED_MESSAGE: string;
|
|
148
|
+
/** The error a refused provider dial throws. Status 502 so every surface maps it
|
|
149
|
+
* to a gateway failure instead of a 499/abort, and `errorBody` carries the
|
|
150
|
+
* operator fix. */
|
|
151
|
+
export declare class OutboundEgressRefusedError extends Error {
|
|
152
|
+
status: number;
|
|
153
|
+
code: string;
|
|
154
|
+
errorBody: string;
|
|
155
|
+
constructor(target: string);
|
|
156
|
+
}
|
|
157
|
+
/** fetch wrapper honoring proxy.url + includes/excludes matching. `egress` is
|
|
158
|
+
* the plugin-level answer folded by the host SDK (see {@link PluginEgressMode}). */
|
|
35
159
|
export declare function proxiedFetch(url: string, init?: RequestInit, match?: {
|
|
36
160
|
provider?: string;
|
|
37
161
|
model?: string;
|
|
38
|
-
}): Promise<Response>;
|
|
162
|
+
}, egress?: PluginEgressMode): Promise<Response>;
|
|
39
163
|
/**
|
|
40
164
|
* fetch through an EXPLICIT proxy endpoint, bypassing the `proxy.enabled` /
|
|
41
165
|
* include-exclude policy. Callers that already decided the egress themselves
|