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
|
@@ -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
|
|
@@ -11,7 +11,9 @@ import { nodeProxiedFetch } from './proxy-node.js';
|
|
|
11
11
|
* 3. includes — the ALLOWLIST: only a matching provider/model is proxied. An
|
|
12
12
|
* empty (or absent) list proxies NOTHING — no rule configured means no
|
|
13
13
|
* outbound proxy (ADR-0022 amendment 2026-12).
|
|
14
|
-
* 4.
|
|
14
|
+
* 4. direct — and the verdict says WHY (`EgressDirectReason`), so a caller can
|
|
15
|
+
* report an honest leg instead of guessing from an absence. Bun fetch still
|
|
16
|
+
* honors HTTP_PROXY/HTTPS_PROXY/NO_PROXY on a direct dial.
|
|
15
17
|
*
|
|
16
18
|
* List patterns match BOTH the composite `provider/modelId` and the bare model id,
|
|
17
19
|
* so one syntax covers both levels: `providerName/asterisk` (slash-star) selects
|
|
@@ -20,6 +22,11 @@ import { nodeProxiedFetch } from './proxy-node.js';
|
|
|
20
22
|
* unlisted: a call with no match target is never proxied, because the empty
|
|
21
23
|
* includes list is direct.
|
|
22
24
|
*
|
|
25
|
+
* Before any of that, a caller may pass a {@link PluginEgressMode} — the operator's
|
|
26
|
+
* plugin-level switch, folded by the host SDK — which this resolver applies as a
|
|
27
|
+
* single decision. Omitting it (`'inherit'`) leaves the provider/model split in
|
|
28
|
+
* charge, which is the default for every core dial.
|
|
29
|
+
*
|
|
23
30
|
* proxiedFetch passes the resolved proxy via Bun's fetch `proxy` option
|
|
24
31
|
* (verified on bun 1.3.14). Node's fetch ignores that option, so the Node
|
|
25
32
|
* path opens the proxy itself (absolute-form HTTP, CONNECT for HTTPS) —
|
|
@@ -83,15 +90,20 @@ export function isBunRuntime() {
|
|
|
83
90
|
* The endpoint `proxy.enabled` actually dials, with no include/exclude gate.
|
|
84
91
|
* `manual` uses `proxy.url`. `mihomo` uses the loopback mixed-port (ADR-0022)
|
|
85
92
|
* and ignores `proxy.url`.
|
|
93
|
+
*
|
|
94
|
+
* Returns BOTH names for the endpoint, because the validation parse has them
|
|
95
|
+
* anyway: `url` is dialable (userinfo included), `origin` is display-safe
|
|
96
|
+
* (`URL.origin` drops userinfo). One parse, no second redaction helper call.
|
|
86
97
|
*/
|
|
87
|
-
function
|
|
98
|
+
function globalProxyEndpoint() {
|
|
88
99
|
const cfg = activeConfig;
|
|
89
100
|
if (cfg?.mode === 'mihomo') {
|
|
90
101
|
const port = cfg.mihomo?.mixedPort;
|
|
91
102
|
const controller = cfg.mihomo?.controllerPort;
|
|
92
103
|
if (!Number.isInteger(port) || port < 1 || port > 65535 || port === controller)
|
|
93
104
|
return undefined;
|
|
94
|
-
|
|
105
|
+
const url = `http://127.0.0.1:${port}`;
|
|
106
|
+
return { url, origin: url };
|
|
95
107
|
}
|
|
96
108
|
const url = (cfg?.url || '').trim();
|
|
97
109
|
if (!url)
|
|
@@ -102,6 +114,7 @@ function globalProxyUrl() {
|
|
|
102
114
|
const parsed = new URL(url);
|
|
103
115
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
104
116
|
throw new Error('scheme');
|
|
117
|
+
return { url, origin: parsed.origin };
|
|
105
118
|
}
|
|
106
119
|
catch {
|
|
107
120
|
if (!warnedInvalidProxyUrl) {
|
|
@@ -110,39 +123,97 @@ function globalProxyUrl() {
|
|
|
110
123
|
}
|
|
111
124
|
return undefined;
|
|
112
125
|
}
|
|
113
|
-
return url;
|
|
114
126
|
}
|
|
115
127
|
/**
|
|
116
|
-
* The outbound proxy
|
|
117
|
-
*
|
|
128
|
+
* The outbound proxy endpoint with NO provider/model gating — `proxy.enabled` +
|
|
129
|
+
* the effective endpoint, nothing else.
|
|
118
130
|
*
|
|
119
|
-
* `
|
|
131
|
+
* `resolveEgress` answers "which leg for THIS provider/model" (includes /
|
|
120
132
|
* excludes). Callers that already decided the egress themselves — the
|
|
121
|
-
*
|
|
133
|
+
* ingress-proxy transit legs after the egress table (ADR-0018) — must not be
|
|
122
134
|
* re-gated by a list that was never about hosts.
|
|
135
|
+
*
|
|
136
|
+
* Named `egress` (not `outbound`): "outbound" is the HOST SDK's axis
|
|
137
|
+
* (`egressProxyFor`, ADR-0022), while this answers the core's own question —
|
|
138
|
+
* where this machine's egress proxy is. It is the single place that turns
|
|
139
|
+
* `proxy.enabled` + the endpoint into a dialable string; nothing else should
|
|
140
|
+
* re-derive it.
|
|
123
141
|
*/
|
|
124
|
-
export function
|
|
142
|
+
export function egressEndpointUrl() {
|
|
125
143
|
const cfg = activeConfig;
|
|
126
144
|
if (!cfg || cfg.enabled !== true)
|
|
127
145
|
return undefined;
|
|
128
|
-
return
|
|
146
|
+
return globalProxyEndpoint()?.url;
|
|
129
147
|
}
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
148
|
+
/** Resolve the egress for a target. `match` identifies the logical caller
|
|
149
|
+
* ({ provider, model }) for list evaluation; omit it for unlisted infra calls.
|
|
150
|
+
*
|
|
151
|
+
* `egress` is the plugin-level answer (ADR-0022 amendment), already folded by
|
|
152
|
+
* the host SDK so the operator's switch and the package's own request never
|
|
153
|
+
* both speak. Its ladder, and nothing more:
|
|
154
|
+
*
|
|
155
|
+
* 1. loopback stays direct — cycle safety is not a setting;
|
|
156
|
+
* 2. `'proxy'` names the operator's endpoint, and a missing one is
|
|
157
|
+
* `no-endpoint` (a refusal), never a silent direct dial;
|
|
158
|
+
* 3. `'direct'` goes direct, reported as `plugin`;
|
|
159
|
+
* 4. `'inherit'` (or omitted) is the untouched default: the provider/model
|
|
160
|
+
* split decides exactly as it did before this argument existed.
|
|
134
161
|
*/
|
|
135
|
-
export function
|
|
162
|
+
export function resolveEgress(targetUrl, match, egress) {
|
|
136
163
|
const cfg = activeConfig;
|
|
137
|
-
if (!cfg || cfg.enabled !== true)
|
|
138
|
-
return undefined; // opt-in: off unless explicitly enabled
|
|
139
164
|
if (isLoopbackUrl(targetUrl))
|
|
140
|
-
return
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
165
|
+
return { mode: 'direct', reason: 'loopback' };
|
|
166
|
+
if (egress === 'proxy') {
|
|
167
|
+
const endpoint = cfg?.enabled === true ? globalProxyEndpoint() : undefined;
|
|
168
|
+
return endpoint
|
|
169
|
+
? { mode: 'proxy', url: endpoint.url, origin: endpoint.origin, reason: 'plugin' }
|
|
170
|
+
: { mode: 'direct', reason: 'no-endpoint', wantsProxy: true };
|
|
171
|
+
}
|
|
172
|
+
if (egress === 'direct')
|
|
173
|
+
return { mode: 'direct', reason: 'plugin' };
|
|
174
|
+
// An EXCLUDE is its own explicit "go direct" demand on this caller, so it is
|
|
175
|
+
// resolved FIRST — before the global switch is read. Otherwise turning
|
|
176
|
+
// `proxy.enabled` off would mask an exclude as `no-endpoint` (refused) and a
|
|
177
|
+
// provider the operator deliberately pinned to direct would start failing.
|
|
178
|
+
// Precedence is the ADR-0022 one: excludes, then the allowlist.
|
|
179
|
+
if (cfg?.excludes?.length && cfg.excludes.some((p) => patternHits(p, match))) {
|
|
180
|
+
return { mode: 'direct', reason: 'exclude' };
|
|
181
|
+
}
|
|
182
|
+
// An EXPLICIT include is the operator's demand for the proxy on this caller,
|
|
183
|
+
// and it outranks the global switch's off state: turning `proxy.enabled` off
|
|
184
|
+
// while an include still names a provider must NOT silently send that
|
|
185
|
+
// provider out over the machine's real address. It resolves to `no-endpoint`
|
|
186
|
+
// (refused at dial time) so the operator either fixes the proxy or removes the
|
|
187
|
+
// include deliberately.
|
|
188
|
+
const included = !!cfg?.includes?.length && !!match && cfg.includes.some((p) => patternHits(p, match));
|
|
189
|
+
if (!cfg || cfg.enabled !== true) {
|
|
190
|
+
return included
|
|
191
|
+
? { mode: 'direct', reason: 'no-endpoint', wantsProxy: true }
|
|
192
|
+
: { mode: 'direct', reason: 'disabled' };
|
|
193
|
+
}
|
|
194
|
+
if (!cfg.includes?.length)
|
|
195
|
+
return { mode: 'direct', reason: 'unlisted' };
|
|
196
|
+
if (!match)
|
|
197
|
+
return { mode: 'direct', reason: 'no-target' };
|
|
198
|
+
// No list, or a list that does not cover this caller: same leg, same operator
|
|
199
|
+
// fix (add a matching include), so ONE reason covers both.
|
|
200
|
+
if (!included)
|
|
201
|
+
return { mode: 'direct', reason: 'unlisted' };
|
|
202
|
+
const endpoint = globalProxyEndpoint();
|
|
203
|
+
return endpoint
|
|
204
|
+
? { mode: 'proxy', url: endpoint.url, origin: endpoint.origin, reason: 'include' }
|
|
205
|
+
: { mode: 'direct', reason: 'no-endpoint', wantsProxy: true };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The proxy URL for a target, or `undefined` for direct — the PROJECTION of
|
|
209
|
+
* {@link resolveEgress} that every dial site consumes. New seams take the
|
|
210
|
+
* verdict; this stays because handing a string to `fetch({ proxy })` is what
|
|
211
|
+
* the transport needs. Never re-derive the lists here: one resolver, one
|
|
212
|
+
* answer.
|
|
213
|
+
*/
|
|
214
|
+
export function resolveProxyUrl(targetUrl, match, egress) {
|
|
215
|
+
const verdict = resolveEgress(targetUrl, match, egress);
|
|
216
|
+
return verdict.mode === 'proxy' ? verdict.url : undefined;
|
|
146
217
|
}
|
|
147
218
|
/**
|
|
148
219
|
* Redact a proxy URL to its origin (`scheme://host:port`). Proxy URLs may
|
|
@@ -158,12 +229,56 @@ export function redactProxyUrl(url) {
|
|
|
158
229
|
return 'invalid-proxy-url';
|
|
159
230
|
}
|
|
160
231
|
}
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
232
|
+
/**
|
|
233
|
+
* The provider axle's refusal when the operator DEMANDED the proxy and the
|
|
234
|
+
* machine has no usable endpoint (`no-endpoint`: `proxy.enabled` is on, an
|
|
235
|
+
* include matched this provider/model, but the endpoint is missing or
|
|
236
|
+
* unparseable). This is NOT a fallback candidate: dialing direct here would put
|
|
237
|
+
* the operator's real IP on a request they explicitly asked to route through
|
|
238
|
+
* their proxy — the exact silent leak the host axle already refuses with
|
|
239
|
+
* {@link EGRESS_UNAVAILABLE_MESSAGE}. Spelled once, mirrored from that message so
|
|
240
|
+
* both axles name the same fix.
|
|
241
|
+
*/
|
|
242
|
+
export const OUTBOUND_REFUSED_MESSAGE = 'Outbound proxy: this call is routed through the proxy (proxy.includes, or the plugin\'s own egress setting), but no usable ' +
|
|
243
|
+
'proxy endpoint is configured — enable `proxy.enabled` with a valid URL (or a mihomo core), fix the endpoint, ' +
|
|
244
|
+
'or remove the include / set the plugin to direct to go direct.';
|
|
245
|
+
/** The error a refused provider dial throws. Status 502 so every surface maps it
|
|
246
|
+
* to a gateway failure instead of a 499/abort, and `errorBody` carries the
|
|
247
|
+
* operator fix. */
|
|
248
|
+
export class OutboundEgressRefusedError extends Error {
|
|
249
|
+
status = 502;
|
|
250
|
+
code = 'outbound_egress_refused';
|
|
251
|
+
errorBody;
|
|
252
|
+
constructor(target) {
|
|
253
|
+
super(OUTBOUND_REFUSED_MESSAGE);
|
|
254
|
+
this.name = 'OutboundEgressRefusedError';
|
|
255
|
+
this.errorBody = OUTBOUND_REFUSED_MESSAGE;
|
|
256
|
+
void target;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** fetch wrapper honoring proxy.url + includes/excludes matching. `egress` is
|
|
260
|
+
* the plugin-level answer folded by the host SDK (see {@link PluginEgressMode}). */
|
|
261
|
+
export async function proxiedFetch(url, init = {}, match, egress) {
|
|
262
|
+
const verdict = resolveEgress(url, match, egress);
|
|
263
|
+
if (verdict.mode === 'proxy')
|
|
264
|
+
return fetchViaProxy(url, init, verdict.url);
|
|
265
|
+
// `no-endpoint` — the operator asked for the proxy on this provider and there
|
|
266
|
+
// is nothing to dial. REFUSE: a direct dial would leak the real IP on exactly
|
|
267
|
+
// the traffic they tried to protect. Every other direct reason (disabled /
|
|
268
|
+
// loopback / exclude / unlisted / no-target) is a genuine "go direct".
|
|
269
|
+
if (verdict.reason === 'no-endpoint')
|
|
270
|
+
throw new OutboundEgressRefusedError(url);
|
|
271
|
+
// A `direct` verdict hands the request to the runtime's own `fetch`, which is
|
|
272
|
+
// NOT necessarily the machine's address: Bun honours `HTTP_PROXY` /
|
|
273
|
+
// `HTTPS_PROXY` from the environment around every call, and `mihomo.ts`
|
|
274
|
+
// documents the same for `node:http`/`node:https`. So an install launched
|
|
275
|
+
// behind a shell export lands its direct verdicts on that proxy's rules. This
|
|
276
|
+
// seam does not scrub the variables (an operator's launch environment is not
|
|
277
|
+
// ours to rewrite), which is why `egress: 'direct'` means "the operator's
|
|
278
|
+
// model-scoped split did not select the proxy" — never a claim about the
|
|
279
|
+
// machine's own IP. A proxy-bypass guarantee needs an explicit `fetchViaProxy`
|
|
280
|
+
// or a scrubbed child, not a direct verdict.
|
|
281
|
+
return fetch(url, init);
|
|
167
282
|
}
|
|
168
283
|
/**
|
|
169
284
|
* fetch through an EXPLICIT proxy endpoint, bypassing the `proxy.enabled` /
|
|
@@ -3,7 +3,27 @@ export interface CommandResult {
|
|
|
3
3
|
ok: boolean;
|
|
4
4
|
stdout: string;
|
|
5
5
|
stderr: string;
|
|
6
|
+
/**
|
|
7
|
+
* Exit status; `null` when the process never started (spawn error) or was
|
|
8
|
+
* killed on our deadline. OPTIONAL so a hand-written `CommandRunner` (the CA
|
|
9
|
+
* trust probes' test doubles) keeps compiling.
|
|
10
|
+
*/
|
|
11
|
+
code?: number | null;
|
|
12
|
+
/**
|
|
13
|
+
* The command itself does not exist on this machine (POSIX `ENOENT`, or the
|
|
14
|
+
* Windows shell's "not recognized" answer). Deliberately distinct from "it
|
|
15
|
+
* ran and failed": only this one may be reported to an operator as NOT
|
|
16
|
+
* INSTALLED — a broken install, a timeout or a non-zero exit must never
|
|
17
|
+
* masquerade as an absent client.
|
|
18
|
+
*/
|
|
19
|
+
notFound?: boolean;
|
|
6
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Would the shell resolve this command name? Locale-independent on purpose (see
|
|
23
|
+
* {@link COMMAND_NOT_FOUND_RE}) and consulted ONLY after a run has already
|
|
24
|
+
* failed, so it can never turn a working command into a "missing" one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function commandResolves(cmd: string): boolean;
|
|
7
27
|
/**
|
|
8
28
|
* Quote ONE argv element for a cmd.exe command line.
|
|
9
29
|
*
|
|
@@ -34,7 +54,7 @@ export declare function quoteWindowsArgs(args: string[]): string[];
|
|
|
34
54
|
* that prompts for input would otherwise wait on a pipe nobody writes.
|
|
35
55
|
*
|
|
36
56
|
* Lives in `utils/` (not a client adapter) because the CA-trust probe in
|
|
37
|
-
* `
|
|
57
|
+
* `ingress-proxy/ca-trust.ts` shells out to platform trust tools too; a second
|
|
38
58
|
* runner there would be a drift twin. The packaged JetBrains plugin keeps a
|
|
39
59
|
* local copy of this contract (`plugins/jetbrains-gateway/exec.ts`) because a
|
|
40
60
|
* plugin bundle must not import backend runtime modules.
|
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
/** Spellings of "there is no such command", in the shells we spawn through.
|
|
5
|
+
* Best-effort only: cmd.exe writes its message in the console OEM codepage, so
|
|
6
|
+
* on a non-UTF-8 Windows it arrives here as mojibake and can never match. The
|
|
7
|
+
* authoritative signal is {@link commandResolves}. */
|
|
8
|
+
const COMMAND_NOT_FOUND_RE = /not recognized as an internal or external command|不是内部或外部命令|command not found|No such file or directory/i;
|
|
9
|
+
const isWin = process.platform === 'win32';
|
|
10
|
+
function isRunnableFile(file) {
|
|
11
|
+
try {
|
|
12
|
+
const stat = fs.statSync(file);
|
|
13
|
+
if (!stat.isFile())
|
|
14
|
+
return false;
|
|
15
|
+
// Windows has no execute bit — a readable file with a runnable extension is
|
|
16
|
+
// runnable; elsewhere the x bit is the answer.
|
|
17
|
+
return isWin ? true : (stat.mode & 0o111) !== 0;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Would the shell resolve this command name? Locale-independent on purpose (see
|
|
25
|
+
* {@link COMMAND_NOT_FOUND_RE}) and consulted ONLY after a run has already
|
|
26
|
+
* failed, so it can never turn a working command into a "missing" one.
|
|
27
|
+
*/
|
|
28
|
+
export function commandResolves(cmd) {
|
|
29
|
+
if (!cmd)
|
|
30
|
+
return false;
|
|
31
|
+
const extensions = isWin
|
|
32
|
+
? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)]
|
|
33
|
+
: [''];
|
|
34
|
+
// A name carrying a separator is a path, not a PATH lookup.
|
|
35
|
+
if (cmd.includes('/') || cmd.includes('\\')) {
|
|
36
|
+
return extensions.some((ext) => isRunnableFile(cmd + ext));
|
|
37
|
+
}
|
|
38
|
+
// cmd.exe also resolves the CURRENT directory before PATH.
|
|
39
|
+
const dirs = [process.cwd(), ...(process.env.PATH ?? '').split(isWin ? ';' : ':').filter(Boolean)];
|
|
40
|
+
for (const dir of dirs) {
|
|
41
|
+
for (const ext of extensions) {
|
|
42
|
+
if (isRunnableFile(path.join(dir, cmd + ext)))
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
2
48
|
/**
|
|
3
49
|
* Quote ONE argv element for a cmd.exe command line.
|
|
4
50
|
*
|
|
@@ -33,13 +79,12 @@ export function quoteWindowsArgs(args) {
|
|
|
33
79
|
* that prompts for input would otherwise wait on a pipe nobody writes.
|
|
34
80
|
*
|
|
35
81
|
* Lives in `utils/` (not a client adapter) because the CA-trust probe in
|
|
36
|
-
* `
|
|
82
|
+
* `ingress-proxy/ca-trust.ts` shells out to platform trust tools too; a second
|
|
37
83
|
* runner there would be a drift twin. The packaged JetBrains plugin keeps a
|
|
38
84
|
* local copy of this contract (`plugins/jetbrains-gateway/exec.ts`) because a
|
|
39
85
|
* plugin bundle must not import backend runtime modules.
|
|
40
86
|
*/
|
|
41
87
|
export async function runCommand(cmd, args, timeoutMs = 5000) {
|
|
42
|
-
const isWin = process.platform === 'win32';
|
|
43
88
|
const finalArgs = isWin ? quoteWindowsArgs(args) : args;
|
|
44
89
|
// `new Promise` (not `Promise.withResolvers`): the backend tsconfig targets a
|
|
45
90
|
// pre-ES2024 lib, and this file is the base every probe imports.
|
|
@@ -47,6 +92,8 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
|
|
|
47
92
|
let stdout = '';
|
|
48
93
|
let stderr = '';
|
|
49
94
|
let settled = false;
|
|
95
|
+
let code = null;
|
|
96
|
+
let spawnEnoent = false;
|
|
50
97
|
// POSIX: a new process group, so the deadline can kill the whole tree (a
|
|
51
98
|
// shim spawns children that keep the pipes open). Windows has no group
|
|
52
99
|
// kill — `taskkill /T` below.
|
|
@@ -61,7 +108,13 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
|
|
|
61
108
|
return;
|
|
62
109
|
settled = true;
|
|
63
110
|
clearTimeout(timer);
|
|
64
|
-
|
|
111
|
+
// "There is no such command" — decided ONLY for a run that already
|
|
112
|
+
// failed, from three independent signals: a spawn-level ENOENT, the
|
|
113
|
+
// shell's own wording (when it survives the codepage), or our own
|
|
114
|
+
// PATH/PATHEXT resolution. A deadline kill leaves `code` null and the
|
|
115
|
+
// command resolvable, so a hung client is never reported as missing.
|
|
116
|
+
const notFound = !ok && (spawnEnoent || code === 9009 || COMMAND_NOT_FOUND_RE.test(stderr) || !commandResolves(cmd));
|
|
117
|
+
resolve({ ok, stdout, stderr, code, notFound });
|
|
65
118
|
};
|
|
66
119
|
const timer = setTimeout(() => {
|
|
67
120
|
stderr += `${stderr ? '\n' : ''}${cmd}: timed out after ${timeoutMs}ms`;
|
|
@@ -86,8 +139,15 @@ export async function runCommand(cmd, args, timeoutMs = 5000) {
|
|
|
86
139
|
proc.stderr?.on('data', (c) => (stderr += String(c)));
|
|
87
140
|
proc.on('error', (err) => {
|
|
88
141
|
stderr += `${stderr ? '\n' : ''}${String(err)}`;
|
|
142
|
+
// Only a spawn-level ENOENT means "no such command"; every other spawn
|
|
143
|
+
// error (EACCES, EMFILE…) is a failure of a command that DOES exist.
|
|
144
|
+
if (err.code === 'ENOENT')
|
|
145
|
+
spawnEnoent = true;
|
|
89
146
|
finish(false);
|
|
90
147
|
});
|
|
91
|
-
proc.on('close', (
|
|
148
|
+
proc.on('close', (c) => {
|
|
149
|
+
code = typeof c === 'number' ? c : null;
|
|
150
|
+
finish(code === 0);
|
|
151
|
+
});
|
|
92
152
|
});
|
|
93
153
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* INBOUND liveness bounds, spelled ONCE for every listener the gateway owns.
|
|
4
|
+
*
|
|
5
|
+
* The numbers live in `config/defaults.ts` (single source); this module only turns
|
|
6
|
+
* them into the two shapes a server needs, so a future fourth listener cannot
|
|
7
|
+
* quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
|
|
8
|
+
* Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
|
|
9
|
+
* socket open forever on one runtime and is reaped on the other. These values
|
|
10
|
+
* align with Node's raw `http` defaults, but Fastify's init defaults differ
|
|
11
|
+
* (requestTimeout 0, headersTimeout 60s, keepAliveTimeout 72s) - so assigning
|
|
12
|
+
* them is a real behavior change on both runtimes, not a no-op on Node.
|
|
13
|
+
*
|
|
14
|
+
* Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
|
|
15
|
+
* express (`requestTimeout` measures the whole request, so a trickling client never
|
|
16
|
+
* trips it): see `REQUEST_BODY_IDLE_TIMEOUT_MS` in
|
|
17
|
+
* `surfaces/transport-node-http.ts`.
|
|
18
|
+
*/
|
|
19
|
+
/** Option-object form — Fastify and `http.createServer` both take these keys.
|
|
20
|
+
* Mutable widened type on purpose: an `as const` object makes Fastify's generic
|
|
21
|
+
* inference pick a different server type and the instance stops typechecking. */
|
|
22
|
+
export declare const INBOUND_LIVENESS_OPTIONS: {
|
|
23
|
+
requestTimeout: number;
|
|
24
|
+
headersTimeout: number;
|
|
25
|
+
keepAliveTimeout: number;
|
|
26
|
+
};
|
|
27
|
+
/** Assignment form — for a server instance that was already constructed. */
|
|
28
|
+
export declare function applyInboundLiveness(server: http.Server): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SERVER_HEADERS_TIMEOUT_MS, SERVER_KEEP_ALIVE_TIMEOUT_MS, SERVER_REQUEST_TIMEOUT_MS, } from '../config/defaults.js';
|
|
2
|
+
/**
|
|
3
|
+
* INBOUND liveness bounds, spelled ONCE for every listener the gateway owns.
|
|
4
|
+
*
|
|
5
|
+
* The numbers live in `config/defaults.ts` (single source); this module only turns
|
|
6
|
+
* them into the two shapes a server needs, so a future fourth listener cannot
|
|
7
|
+
* quietly re-pick its own timeouts. Leaving these to the runtime is not neutral:
|
|
8
|
+
* Node ships 300s / 60s / 5s, Bun ships none, so the same slow client holds a
|
|
9
|
+
* socket open forever on one runtime and is reaped on the other. These values
|
|
10
|
+
* align with Node's raw `http` defaults, but Fastify's init defaults differ
|
|
11
|
+
* (requestTimeout 0, headersTimeout 60s, keepAliveTimeout 72s) - so assigning
|
|
12
|
+
* them is a real behavior change on both runtimes, not a no-op on Node.
|
|
13
|
+
*
|
|
14
|
+
* Per-chunk body progress is a DIFFERENT bound that a server-level clock cannot
|
|
15
|
+
* express (`requestTimeout` measures the whole request, so a trickling client never
|
|
16
|
+
* trips it): see `REQUEST_BODY_IDLE_TIMEOUT_MS` in
|
|
17
|
+
* `surfaces/transport-node-http.ts`.
|
|
18
|
+
*/
|
|
19
|
+
/** Option-object form — Fastify and `http.createServer` both take these keys.
|
|
20
|
+
* Mutable widened type on purpose: an `as const` object makes Fastify's generic
|
|
21
|
+
* inference pick a different server type and the instance stops typechecking. */
|
|
22
|
+
export const INBOUND_LIVENESS_OPTIONS = {
|
|
23
|
+
requestTimeout: SERVER_REQUEST_TIMEOUT_MS,
|
|
24
|
+
headersTimeout: SERVER_HEADERS_TIMEOUT_MS,
|
|
25
|
+
keepAliveTimeout: SERVER_KEEP_ALIVE_TIMEOUT_MS,
|
|
26
|
+
};
|
|
27
|
+
/** Assignment form — for a server instance that was already constructed. */
|
|
28
|
+
export function applyInboundLiveness(server) {
|
|
29
|
+
server.requestTimeout = SERVER_REQUEST_TIMEOUT_MS;
|
|
30
|
+
server.headersTimeout = SERVER_HEADERS_TIMEOUT_MS;
|
|
31
|
+
server.keepAliveTimeout = SERVER_KEEP_ALIVE_TIMEOUT_MS;
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-safe file name for a (client-controlled) session id.
|
|
3
|
+
*
|
|
4
|
+
* ONE spelling, shared by every per-session on-disk store — the capture
|
|
5
|
+
* archive and the session-snapshot store both key a file by the gateway
|
|
6
|
+
* session id, and two divergent sanitizers would let one id name two
|
|
7
|
+
* different files (or two ids collide on one). Read and write call this
|
|
8
|
+
* verbatim, so names match by construction; there is no per-side
|
|
9
|
+
* normalization to keep in sync.
|
|
10
|
+
*
|
|
11
|
+
* An id that is already safe is kept verbatim for browsability; anything
|
|
12
|
+
* else (path traversal, separators, excess length) falls back to a stable
|
|
13
|
+
* content hash. `HASH_NAME_RE` reserves the hash output namespace: an id
|
|
14
|
+
* literally shaped like this function's own digest output goes through the
|
|
15
|
+
* hash branch (hash-of-hash), so a crafted `h_<16hex>` can never alias some
|
|
16
|
+
* other unsafe id's file. Case-insensitive because the verbatim branch
|
|
17
|
+
* accepts uppercase hex, which aliases the lowercase digest on
|
|
18
|
+
* case-insensitive filesystems (Windows/macOS).
|
|
19
|
+
*
|
|
20
|
+
* Migration note (capture): archives written before that guard for a literal
|
|
21
|
+
* `h_<16hex>` id keep their old verbatim name and become read-side orphans
|
|
22
|
+
* (the reader now resolves that id to the hash-of-hash name). They stay
|
|
23
|
+
* visible and deletable through the captures directory browser, and the
|
|
24
|
+
* retention sweep backstops them — existing files are never rewritten.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SAFE_SESSION_RE: RegExp;
|
|
27
|
+
export declare const HASH_NAME_RE: RegExp;
|
|
28
|
+
export declare function sessionFileName(sessionId: string, suffix?: string): string;
|