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
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { parse, stringify } from 'yaml';
|
|
4
|
-
import { INTERCEPT_POSTURES, lintRules, normalizeRuleTable } from '../
|
|
4
|
+
import { INTERCEPT_POSTURES, lintRules, normalizeRuleTable } from '../ingress-proxy/rules.js';
|
|
5
5
|
import { DEFAULT_RETRIABLE_CAUSES } from '../resilience/types.js';
|
|
6
6
|
import { DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_MAX_RATE_LIMIT_WAIT_MS } from '../resilience/circuit-breaker.js';
|
|
7
7
|
import { EFFORT_LADDER } from '../types/router.js';
|
|
8
8
|
import { resolveDirectivePrefix } from '../pipeline/directives.js';
|
|
9
|
-
import {
|
|
9
|
+
import { canonicalizeSelectionValues } from '../providers/selection.js';
|
|
10
|
+
import { MEMBER_TIER_ORDER, sanitizeEffortMap } from '../providers/member-match.js';
|
|
11
|
+
import { missingNodeCredential, sanitizeTypedNode } from '../egress-proxy/manual-node-spec.js';
|
|
10
12
|
import { ensureEnvScaffold, getEnvPaths, resolveEnvName } from './env.js';
|
|
11
|
-
import {
|
|
13
|
+
import { DEFAULT_INGRESS_PROXY_PORT, DEFAULT_INGRESS_PROXY_HOST, DEFAULT_INGRESS_PROXY_MAX_CONNECTIONS, DEFAULT_INGRESS_PROXY_RULES, DEFAULT_INGRESS_PROXY_INTERCEPT, INGRESS_PROXY_MAX_CONNECTIONS_MIN, INGRESS_PROXY_MAX_CONNECTIONS_MAX, DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS, PROXY_ACCESS_LOG_PERSIST_DAYS_MIN, PROXY_ACCESS_LOG_PERSIST_DAYS_MAX, DEFAULT_HEADROOM_TIMEOUT_MS, DEFAULT_DIRECTIVE_PREFIX, DEFAULT_HEADROOM_URL, DEFAULT_LAYER2_EFFORT_FLOOR, DEFAULT_LAYER2_TIMEOUT_MS, DEFAULT_MAX_BODY_BYTES, GATEWAY_MAX_BODY_BYTES, ADMIN_MAX_BODY_BYTES, BODY_LIMIT_MIN_BYTES, BODY_LIMIT_MAX_BYTES, DEFAULT_AUTO_RESYNC_FOLLOW_CATALOGS, DEFAULT_ROUTE_ENTRIES_MAX, DEFAULT_GATEWAY_PORT, DEFAULT_MIHOMO_CONTROLLER_PORT, DEFAULT_MIHOMO_GROUP, DEFAULT_MIHOMO_MIXED_PORT, DEFAULT_MIHOMO_SUB_INTERVAL_SEC, MIHOMO_SUB_INTERVAL_MAX_SEC, MIHOMO_SUB_INTERVAL_MIN_SEC, MIHOMO_GROUP_INTERVAL_MAX_SEC, MIHOMO_GROUP_INTERVAL_MIN_SEC, DEFAULT_MIHOMO_GROUP_TOLERANCE_MS, MIHOMO_GROUP_TOLERANCE_MAX_MS, DEFAULT_MIHOMO_TEST_URL, MIHOMO_LAN_DIRECT_RULES, } from './defaults.js';
|
|
12
14
|
import { getRateLimiter } from '../ratelimit/rate-limiter.js';
|
|
13
15
|
import { getQuotaProber } from '../quota/prober.js';
|
|
14
16
|
import { migrateConfig, toDiskConfig, toRuntimeConfig, SCHEMA_VERSION } from './schema.js';
|
|
@@ -44,6 +46,13 @@ export const MAX_GRACE_SLEEPERS = 64;
|
|
|
44
46
|
* debounce).
|
|
45
47
|
*/
|
|
46
48
|
export const RATE_LIMIT_CHECKPOINT_INTERVAL_MS = 30_000;
|
|
49
|
+
/**
|
|
50
|
+
* Upper bound on the snapshot drain during a graceful shutdown. The record is
|
|
51
|
+
* assembled in the write worker, so the exit path must AWAIT it to land the
|
|
52
|
+
* last turn; the bound keeps a stalled disk from turning a restart into a hang
|
|
53
|
+
* (the plane fails open by contract, ADR-0038).
|
|
54
|
+
*/
|
|
55
|
+
export const SNAPSHOT_SHUTDOWN_FLUSH_MS = 2_000;
|
|
47
56
|
const DEFAULT_CONFIG = {
|
|
48
57
|
port: parseInt(process.env.PORT || String(DEFAULT_GATEWAY_PORT), 10),
|
|
49
58
|
host: process.env.HOST || '127.0.0.1',
|
|
@@ -60,7 +69,7 @@ const DEFAULT_CONFIG = {
|
|
|
60
69
|
pro: {},
|
|
61
70
|
ultra: {},
|
|
62
71
|
},
|
|
63
|
-
routing: { mode: 'smart' },
|
|
72
|
+
routing: { mode: 'smart', costEscalation: 'to_fallback_tier' },
|
|
64
73
|
fallback: {
|
|
65
74
|
enabled: true,
|
|
66
75
|
maxRetries: 1,
|
|
@@ -104,19 +113,18 @@ const DEFAULT_CONFIG = {
|
|
|
104
113
|
selectedNodes: {},
|
|
105
114
|
},
|
|
106
115
|
},
|
|
107
|
-
|
|
116
|
+
ingressProxy: {
|
|
108
117
|
enabled: false, // opt-in: full-capture MITM proxy must be enabled consciously
|
|
109
|
-
port:
|
|
110
|
-
host:
|
|
111
|
-
maxConnections:
|
|
112
|
-
requireCredential: false, // opt-in: loopback clients must also present an API key
|
|
118
|
+
port: DEFAULT_INGRESS_PROXY_PORT,
|
|
119
|
+
host: DEFAULT_INGRESS_PROXY_HOST,
|
|
120
|
+
maxConnections: DEFAULT_INGRESS_PROXY_MAX_CONNECTIONS,
|
|
113
121
|
// Rule table (ADR-0018 Revision 4): the fresh-install seed routes everything
|
|
114
122
|
// through the outbound proxy policy as a BLIND TUNNEL. Inert until BOTH this
|
|
115
123
|
// listener and `proxy.enabled` are on, so it costs a fresh install nothing.
|
|
116
|
-
rules:
|
|
124
|
+
rules: DEFAULT_INGRESS_PROXY_RULES,
|
|
117
125
|
// Interception posture: decrypt only what a capability declares (live
|
|
118
126
|
// client-gateway plugin claims + explicit `ingress: intercept` rows).
|
|
119
|
-
intercept:
|
|
127
|
+
intercept: DEFAULT_INGRESS_PROXY_INTERCEPT,
|
|
120
128
|
accessLog: { enabled: true, persist: true, persistDays: DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS },
|
|
121
129
|
// Upstream TLS trust for the origin legs (ADR-0019): system trust store
|
|
122
130
|
// unless the operator names a private CA or disables verification.
|
|
@@ -145,6 +153,19 @@ const DEFAULT_CONFIG = {
|
|
|
145
153
|
retentionDays: 7,
|
|
146
154
|
maxTotalMB: 100,
|
|
147
155
|
},
|
|
156
|
+
sessionSnapshots: {
|
|
157
|
+
// ON by default (ADR-0038 amendment): this plane is the PREREQUISITE for the
|
|
158
|
+
// console's message list/tree view and for handoff to another client — not an
|
|
159
|
+
// optional audit extra. `requestCapture`/`responses.persist` default off
|
|
160
|
+
// because turning them off costs only a log copy; turning THIS off costs the
|
|
161
|
+
// feature. The disk/privacy bound is the 30-day retention + 1 GB cap + 8 MB
|
|
162
|
+
// per-request-record cap below, and an operator who wants nothing on disk
|
|
163
|
+
// turns it off.
|
|
164
|
+
enabled: true,
|
|
165
|
+
retentionDays: 30,
|
|
166
|
+
maxTotalMB: 1024,
|
|
167
|
+
maxTurnMB: 8,
|
|
168
|
+
},
|
|
148
169
|
circuitBreaker: {
|
|
149
170
|
// Global knobs mirror the runtime default exactly once (single source:
|
|
150
171
|
// resilience/circuit-breaker.ts); shadow/persistence/rules below are
|
|
@@ -239,6 +260,39 @@ export function sanitizeWebAuthInput(input) {
|
|
|
239
260
|
delete wa.password;
|
|
240
261
|
return wa;
|
|
241
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Combos sanitizer: each member ref may carry its OWN `effortMap` (per-model
|
|
265
|
+
* translation, ADR-0003), so every member table gets the same trust-boundary
|
|
266
|
+
* clamp as a tier member rule — only EFFORT_LADDER → EFFORT_LADDER pairs
|
|
267
|
+
* survive and an empty result is dropped (`undefined` = passthrough, never
|
|
268
|
+
* `{}`). A combo-level `effortMap` is dropped so the redefined-away
|
|
269
|
+
* block-wide shape never re-persists. Everything else passes through
|
|
270
|
+
* untouched; the registry validates member refs when the combo is applied.
|
|
271
|
+
*/
|
|
272
|
+
function sanitizeCombos(input) {
|
|
273
|
+
if (!Array.isArray(input))
|
|
274
|
+
return [];
|
|
275
|
+
return input.map((entry) => {
|
|
276
|
+
if (entry === null || typeof entry !== 'object' || Array.isArray(entry))
|
|
277
|
+
return entry;
|
|
278
|
+
const combo = { ...entry };
|
|
279
|
+
delete combo.effortMap;
|
|
280
|
+
if (Array.isArray(combo.models)) {
|
|
281
|
+
combo.models = combo.models.map((m) => {
|
|
282
|
+
if (m === null || typeof m !== 'object' || Array.isArray(m))
|
|
283
|
+
return m;
|
|
284
|
+
const ref = { ...m };
|
|
285
|
+
const map = sanitizeEffortMap(ref.effortMap);
|
|
286
|
+
if (map)
|
|
287
|
+
ref.effortMap = map;
|
|
288
|
+
else
|
|
289
|
+
delete ref.effortMap;
|
|
290
|
+
return ref;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return combo;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
242
296
|
/**
|
|
243
297
|
* Layer 2 sanitizer: drops the retired vendor-connection keys (`provider`,
|
|
244
298
|
* `baseUrl`, `apiKey`) left over from the pre-System-One decision layer, which talked
|
|
@@ -332,6 +386,27 @@ function resolveRequestCapture(parsed) {
|
|
|
332
386
|
dir: pick('dir'),
|
|
333
387
|
};
|
|
334
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Resolve the `sessionSnapshots:` tree (ADR-0038). Only known keys are picked,
|
|
391
|
+
* so retired/junk keys never round-trip into a saved config.yaml. Numeric caps
|
|
392
|
+
* are floored at 1 for the same irreversibility reason as `requestCapture`
|
|
393
|
+
* (a zero/negative cap would seal every session at its first turn).
|
|
394
|
+
*/
|
|
395
|
+
function resolveSessionSnapshots(parsed) {
|
|
396
|
+
const base = DEFAULT_CONFIG.sessionSnapshots;
|
|
397
|
+
const raw = (parsed?.sessionSnapshots ?? {});
|
|
398
|
+
const pickPos = (key) => {
|
|
399
|
+
const v = Number(raw[key] ?? base[key]);
|
|
400
|
+
return Number.isFinite(v) ? Math.max(1, Math.round(v)) : base[key];
|
|
401
|
+
};
|
|
402
|
+
return {
|
|
403
|
+
enabled: (raw.enabled ?? base.enabled),
|
|
404
|
+
retentionDays: pickPos('retentionDays'),
|
|
405
|
+
maxTotalMB: pickPos('maxTotalMB'),
|
|
406
|
+
maxTurnMB: pickPos('maxTurnMB'),
|
|
407
|
+
dir: (raw.dir ?? base.dir),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
335
410
|
/**
|
|
336
411
|
* Resolve the `streaming:` tree (ADR-0008 §1). Only the two registered axes
|
|
337
412
|
* are picked, so a retired key (`enabled` before schemaVersion 3 — rewritten
|
|
@@ -353,28 +428,34 @@ function resolveStreamingConfig(raw) {
|
|
|
353
428
|
const STREAMING_CLIENT_MODES = ['allow', 'deny', 'always'];
|
|
354
429
|
const STREAMING_UPSTREAM_MODES = ['follow', 'stream', 'buffered'];
|
|
355
430
|
/**
|
|
356
|
-
* Resolve the whole `
|
|
431
|
+
* Resolve the whole `ingressProxy` section (ADR-0018).
|
|
357
432
|
*/
|
|
358
|
-
function
|
|
433
|
+
function resolveIngressProxyConfig(raw) {
|
|
359
434
|
const rawFp = (raw ?? {});
|
|
360
|
-
const fp = { ...DEFAULT_CONFIG.
|
|
361
|
-
// The section carries exactly the keys `
|
|
435
|
+
const fp = { ...DEFAULT_CONFIG.ingressProxy, ...rawFp };
|
|
436
|
+
// The section carries exactly the keys `IngressProxyConfig` declares. Any
|
|
362
437
|
// other key a hand-edited file still holds — a retired key (`bypassHosts`,
|
|
363
438
|
// `viaOutboundProxy`, `mitmHosts`, the interim `egress` / `egressRules` /
|
|
364
|
-
// `decryptRules` shapes, `authToken`) or a typo — is
|
|
365
|
-
// folded, never translated, never re-persisted on the
|
|
366
|
-
//
|
|
367
|
-
//
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
//
|
|
439
|
+
// `decryptRules` shapes, `authToken`, `requireCredential`) or a typo — is
|
|
440
|
+
// dropped here: never folded, never translated, never re-persisted on the
|
|
441
|
+
// next console save. Retired keys are never translated (ADR-0018 §6).
|
|
442
|
+
//
|
|
443
|
+
// `requireCredential` is the retired key an operator must never lose in
|
|
444
|
+
// silence, but the notice does NOT live here: this resolver only ever sees
|
|
445
|
+
// the whitelisted runtime shape, where the key is already gone. The v9→v10
|
|
446
|
+
// migration step (`config/migrations/v9-to-v10.ts`) removes it from the file
|
|
447
|
+
// and emits the warning — see `migrateConfig`'s `warnings`.
|
|
371
448
|
const declared = {
|
|
372
449
|
enabled: fp.enabled,
|
|
373
450
|
port: fp.port,
|
|
374
|
-
|
|
451
|
+
// The inbound proxy authenticates nobody, so a non-loopback bind would be
|
|
452
|
+
// an unauthenticated full-capture MITM proxy on the LAN. The value is NOT
|
|
453
|
+
// folded here (see `normalizeIngressProxyHost`): the listener refuses such a
|
|
454
|
+
// bind at start and the console shows that failure, so the resolved config
|
|
455
|
+
// keeps saying what the operator actually asked for.
|
|
456
|
+
host: normalizeIngressProxyHost(fp.host),
|
|
375
457
|
caDir: fp.caDir,
|
|
376
458
|
maxConnections: fp.maxConnections,
|
|
377
|
-
requireCredential: fp.requireCredential === true,
|
|
378
459
|
accessLog: fp.accessLog,
|
|
379
460
|
rules: fp.rules,
|
|
380
461
|
/** ADR-0018 Revision 4: only the two declared words survive; anything else
|
|
@@ -395,7 +476,7 @@ function resolveForwardProxyConfig(raw) {
|
|
|
395
476
|
};
|
|
396
477
|
}
|
|
397
478
|
/**
|
|
398
|
-
* Resolve `
|
|
479
|
+
* Resolve `ingressProxy.intercept` (ADR-0018 Revision 4): exactly `'claims'`
|
|
399
480
|
* and `'all'` parse; every other value (a typo, a retired word, a non-string)
|
|
400
481
|
* is ignored and the safe posture applies. Junk must never buy machine-wide
|
|
401
482
|
* decryption.
|
|
@@ -403,10 +484,21 @@ function resolveForwardProxyConfig(raw) {
|
|
|
403
484
|
function normalizeInterceptPosture(raw) {
|
|
404
485
|
return typeof raw === 'string' && INTERCEPT_POSTURES.includes(raw)
|
|
405
486
|
? raw
|
|
406
|
-
:
|
|
487
|
+
: DEFAULT_INGRESS_PROXY_INTERCEPT;
|
|
407
488
|
}
|
|
408
489
|
/**
|
|
409
|
-
*
|
|
490
|
+
* The inbound proxy authenticates NOBODY (ADR-0008 §3), so its bind address is
|
|
491
|
+
* a security property, not a preference: only a literal loopback address can
|
|
492
|
+
* serve it. `0.0.0.0` is deliberately NOT folded into loopback here — the
|
|
493
|
+
* listener refuses such a bind at start (`assertIngressProxyBindSafety`), and
|
|
494
|
+
* silently rewriting the operator's address to 127.0.0.1 would hide that.
|
|
495
|
+
*/
|
|
496
|
+
function normalizeIngressProxyHost(raw) {
|
|
497
|
+
const host = typeof raw === 'string' ? raw.trim() : '';
|
|
498
|
+
return host || DEFAULT_INGRESS_PROXY_HOST;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Resolve `ingressProxy.upstreamTls` (ADR-0019) — same trust boundary as the
|
|
410
502
|
* rest of the section: junk falls back to the system trust store, never to a
|
|
411
503
|
* silently disabled verification. `insecure` is only ever true when the operator
|
|
412
504
|
* literally wrote `true`.
|
|
@@ -417,17 +509,17 @@ function normalizeUpstreamTlsConfig(raw) {
|
|
|
417
509
|
return { ...(caFile ? { caFile } : {}), insecure: r.insecure === true };
|
|
418
510
|
}
|
|
419
511
|
/**
|
|
420
|
-
* Resolve `
|
|
512
|
+
* Resolve `ingressProxy.maxConnections` — junk falls back to the default (no
|
|
421
513
|
* coercion), a real number is floored and clamped to the declared bounds so a
|
|
422
514
|
* typo cannot turn the cap into "unlimited" or "reject everything".
|
|
423
515
|
*/
|
|
424
516
|
function normalizeMaxConnections(raw) {
|
|
425
517
|
if (typeof raw !== 'number' || !Number.isFinite(raw))
|
|
426
|
-
return
|
|
427
|
-
return Math.min(
|
|
518
|
+
return DEFAULT_INGRESS_PROXY_MAX_CONNECTIONS;
|
|
519
|
+
return Math.min(INGRESS_PROXY_MAX_CONNECTIONS_MAX, Math.max(INGRESS_PROXY_MAX_CONNECTIONS_MIN, Math.floor(raw)));
|
|
428
520
|
}
|
|
429
521
|
/**
|
|
430
|
-
* Resolve `
|
|
522
|
+
* Resolve `ingressProxy.accessLog` — same trust boundary as resolveRateLimit:
|
|
431
523
|
* junk values fall back to defaults, not coercion. bodyBytes: absent = the
|
|
432
524
|
* consumer applies DEFAULT_PROXY_ACCESS_LOG_BODY_BYTES (1 MiB, spill-to-file);
|
|
433
525
|
* 0 = headers only; a positive number = per-side inline cap.
|
|
@@ -621,7 +713,7 @@ export function resolveRateLimit(parsed) {
|
|
|
621
713
|
let _schemaVersionWarned = false;
|
|
622
714
|
/** One-shot guard for the schemaVersion-position warning. */
|
|
623
715
|
let _schemaOrderWarned = false;
|
|
624
|
-
/** One-shot guard for the
|
|
716
|
+
/** One-shot guard for the ingress-proxy rule-table lint (ADR-0018). */
|
|
625
717
|
let _rulesLintWarned = false;
|
|
626
718
|
/**
|
|
627
719
|
* The port the config FILE names, captured on the read path. The `PORT` env
|
|
@@ -636,10 +728,10 @@ let _diskPort;
|
|
|
636
728
|
* with translations, but a hand-edited config.yaml never opens the console —
|
|
637
729
|
* one warn per process so a table that cannot do what it says is never silent.
|
|
638
730
|
*
|
|
639
|
-
* Gated on `
|
|
731
|
+
* Gated on `ingressProxy.enabled`: with the listener off the table routes
|
|
640
732
|
* nothing, so warning about it would be noise on every fresh install.
|
|
641
733
|
*/
|
|
642
|
-
function
|
|
734
|
+
function warnIngressProxyRulesOnce(raw, proxyEnabled) {
|
|
643
735
|
if (_rulesLintWarned)
|
|
644
736
|
return;
|
|
645
737
|
const fp = (raw ?? {});
|
|
@@ -650,7 +742,7 @@ function warnForwardProxyRulesOnce(raw, proxyEnabled) {
|
|
|
650
742
|
// the resolver, so a warning's index addresses the row the operator typed.
|
|
651
743
|
for (const w of lintRules(fp.rules, proxyEnabled, normalizeInterceptPosture(fp.intercept))) {
|
|
652
744
|
const at = w.ruleIndex === undefined ? '' : ` rule #${w.ruleIndex + 1}`;
|
|
653
|
-
console.warn(`[Config]
|
|
745
|
+
console.warn(`[Config] ingressProxy.rules${at}: ${w.code}${w.detail ? ` (${w.detail})` : ''}`);
|
|
654
746
|
}
|
|
655
747
|
}
|
|
656
748
|
const SUBSCRIPTION_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -1087,10 +1179,16 @@ export function loadConfig(configPath) {
|
|
|
1087
1179
|
return DEFAULT_CONFIG;
|
|
1088
1180
|
}
|
|
1089
1181
|
const flat = toRuntimeConfig(parsed);
|
|
1182
|
+
// Canonical strategy values at the read boundary: a hand-edited file (or
|
|
1183
|
+
// a config copied in without the boot upgrade) must not leak an unknown
|
|
1184
|
+
// or retired spelling into the runtime object — every consumer, and the
|
|
1185
|
+
// next save, reads one of the three strategies only (anything else is
|
|
1186
|
+
// the default `priority`).
|
|
1187
|
+
canonicalizeSelectionValues(flat);
|
|
1090
1188
|
if (configPath === undefined) {
|
|
1091
1189
|
_diskPort = typeof flat.port === 'number' && Number.isFinite(flat.port) ? flat.port : undefined;
|
|
1092
1190
|
}
|
|
1093
|
-
|
|
1191
|
+
warnIngressProxyRulesOnce(flat.ingressProxy, flat.proxy?.enabled === true);
|
|
1094
1192
|
return {
|
|
1095
1193
|
...DEFAULT_CONFIG,
|
|
1096
1194
|
...flat,
|
|
@@ -1126,7 +1224,7 @@ export function loadConfig(configPath) {
|
|
|
1126
1224
|
routeEntries: sanitizeRouteEntriesInput(flat.routeEntries),
|
|
1127
1225
|
directives: sanitizeDirectivesInput(flat.directives),
|
|
1128
1226
|
proxy: sanitizeProxyConfig(flat.proxy ?? DEFAULT_CONFIG.proxy),
|
|
1129
|
-
|
|
1227
|
+
ingressProxy: resolveIngressProxyConfig(flat.ingressProxy),
|
|
1130
1228
|
compression: {
|
|
1131
1229
|
rtk: { ...DEFAULT_CONFIG.compression?.rtk, ...flat.compression?.rtk },
|
|
1132
1230
|
headroom: { ...DEFAULT_CONFIG.compression?.headroom, ...flat.compression?.headroom },
|
|
@@ -1135,6 +1233,7 @@ export function loadConfig(configPath) {
|
|
|
1135
1233
|
streaming: resolveStreamingConfig(flat.streaming),
|
|
1136
1234
|
requestCapture: resolveRequestCapture(flat),
|
|
1137
1235
|
tracePersist: { ...DEFAULT_CONFIG.tracePersist, ...flat.tracePersist },
|
|
1236
|
+
sessionSnapshots: resolveSessionSnapshots(flat),
|
|
1138
1237
|
circuitBreaker: resolveCircuitBreaker(flat),
|
|
1139
1238
|
rateLimit: resolveRateLimit(flat),
|
|
1140
1239
|
bodyLimits: resolveBodyLimits(flat),
|
|
@@ -1148,7 +1247,7 @@ export function loadConfig(configPath) {
|
|
|
1148
1247
|
// RUNTIME carrier only — the disk value never maps; index.ts
|
|
1149
1248
|
// assigns boot.models over this before registry construction.
|
|
1150
1249
|
models: DEFAULT_CONFIG.models,
|
|
1151
|
-
combos: flat.combos
|
|
1250
|
+
combos: sanitizeCombos(flat.combos),
|
|
1152
1251
|
clientProfileMemory: flat.clientProfileMemory || {},
|
|
1153
1252
|
catalog: flat.catalog,
|
|
1154
1253
|
};
|
|
@@ -1290,6 +1389,11 @@ export function saveRawConfig(yamlContent) {
|
|
|
1290
1389
|
error: `config schemaVersion ${fromVersion} is newer than this build supports (current ${SCHEMA_VERSION}) — upgrade OmniCellRouter`,
|
|
1291
1390
|
};
|
|
1292
1391
|
}
|
|
1392
|
+
// Canonical strategy values at the raw-save boundary: a hand-pasted unknown
|
|
1393
|
+
// or retired spelling on an otherwise current-version draft would otherwise
|
|
1394
|
+
// be written back verbatim (migrateConfig is a no-op for a current-version
|
|
1395
|
+
// file). A change forces the canonical regroup write below.
|
|
1396
|
+
const canonicalizedSelection = canonicalizeSelectionValues(disk.routing);
|
|
1293
1397
|
if (fs.existsSync(configPath)) {
|
|
1294
1398
|
fs.copyFileSync(configPath, `${configPath}.bak`);
|
|
1295
1399
|
}
|
|
@@ -1298,7 +1402,8 @@ export function saveRawConfig(yamlContent) {
|
|
|
1298
1402
|
// is BOTH current AND the first key; anything else goes through the
|
|
1299
1403
|
// canonical regroup, which rewrites it first with the current version.
|
|
1300
1404
|
const firstIsVersion = parsed.schemaVersion === SCHEMA_VERSION && Object.keys(parsed)[0] === 'schemaVersion';
|
|
1301
|
-
|
|
1405
|
+
const writeVerbatim = fromVersion === SCHEMA_VERSION && firstIsVersion && !canonicalizedSelection;
|
|
1406
|
+
fs.writeFileSync(configPath, writeVerbatim ? yamlContent : stringify(disk), 'utf8');
|
|
1302
1407
|
if (warnings.length > 0) {
|
|
1303
1408
|
console.warn(`[Config] ${configPath}: draft upgraded v${fromVersion} → v${SCHEMA_VERSION}:`);
|
|
1304
1409
|
for (const w of warnings)
|
|
@@ -1354,11 +1459,10 @@ function syncRuntimeAuthView(fresh) {
|
|
|
1354
1459
|
// only the WIRE capability (which providers implement createStream) is
|
|
1355
1460
|
// boot-fixed. The pipeline gate is re-seeded by the save handlers.
|
|
1356
1461
|
live.streaming = fresh.streaming;
|
|
1357
|
-
//
|
|
1462
|
+
// ingressProxy too — the MITM rule table and admission gate read the live
|
|
1358
1463
|
// boot snapshot per request, so a save must land here or the console's
|
|
1359
|
-
// "takes effect immediately" promise is false.
|
|
1360
|
-
|
|
1361
|
-
live.forwardProxy = fresh.forwardProxy;
|
|
1464
|
+
// "takes effect immediately" promise is false.
|
|
1465
|
+
live.ingressProxy = fresh.ingressProxy;
|
|
1362
1466
|
// proxy policy is hot-applied (initProxyConfig on the save path). Keep
|
|
1363
1467
|
// the boot snapshot on the same object so a later reader of the live
|
|
1364
1468
|
// ref does not keep the pre-save endpoint.
|
|
@@ -1414,6 +1518,43 @@ export function saveConfig(newConfig) {
|
|
|
1414
1518
|
merged.webAuth = { ...merged.webAuth, passwordHash: current.webAuth.passwordHash };
|
|
1415
1519
|
}
|
|
1416
1520
|
merged.webAuth = sanitizeWebAuthInput(merged.webAuth);
|
|
1521
|
+
// Canonical strategy values at the WRITE boundary: a stale console tab (or a
|
|
1522
|
+
// hand-built PUT) that still posts an unknown/retired spelling must never
|
|
1523
|
+
// reach disk — it resolves to the default `priority`.
|
|
1524
|
+
canonicalizeSelectionValues(merged);
|
|
1525
|
+
// Runtime-projection-only rule fields never reach disk: `exact` is derived
|
|
1526
|
+
// by markExactFullIds / combo expansion at commit time, so a stale console
|
|
1527
|
+
// tab (or a hand-built PUT) that echoes committed rules back must not
|
|
1528
|
+
// freeze it into the file. Strip it here, next to the other write-boundary
|
|
1529
|
+
// sanitizers.
|
|
1530
|
+
if (merged.tiers) {
|
|
1531
|
+
const nextTiers = { ...merged.tiers };
|
|
1532
|
+
for (const tier of MEMBER_TIER_ORDER) {
|
|
1533
|
+
const policy = nextTiers[tier];
|
|
1534
|
+
if (policy && Array.isArray(policy.members)) {
|
|
1535
|
+
nextTiers[tier] = {
|
|
1536
|
+
...policy,
|
|
1537
|
+
members: policy.members.map((rule) => {
|
|
1538
|
+
if (rule.exact === undefined)
|
|
1539
|
+
return rule;
|
|
1540
|
+
const clean = { pattern: rule.pattern };
|
|
1541
|
+
if (rule.weight !== undefined)
|
|
1542
|
+
clean.weight = rule.weight;
|
|
1543
|
+
if (rule.effortMap !== undefined)
|
|
1544
|
+
clean.effortMap = rule.effortMap;
|
|
1545
|
+
return clean;
|
|
1546
|
+
}),
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
merged.tiers = nextTiers;
|
|
1551
|
+
}
|
|
1552
|
+
// A combo member's `effortMap` is the same trust boundary as a tier
|
|
1553
|
+
// member rule's table: a hand-built PUT / stale console tab must never
|
|
1554
|
+
// persist an out-of-ladder translation (or an empty `{}` that would read
|
|
1555
|
+
// as a table rather than passthrough). Mirrors the load-path
|
|
1556
|
+
// `sanitizeCombos` (per member) and drops any stale combo-level table.
|
|
1557
|
+
merged.combos = sanitizeCombos(merged.combos);
|
|
1417
1558
|
// One-step undo for EVERY save, not just the raw-page editor: a sanitizer
|
|
1418
1559
|
// regression once dropped a whole section and the console save persisted
|
|
1419
1560
|
// the loss with no previous file to restore. Best effort — an absent file
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* anchor the exact transform. schema.ts binds `SECTION_MOVES_V1` as the
|
|
21
21
|
* CURRENT layout (see LATEST_LAYOUT there) — bump that pointer when v2 ships.
|
|
22
22
|
*/
|
|
23
|
-
import type { ApiKeyConfig, CatalogConfig, ClassifierConfig, ClientProfileMemoryEntry, ComboConfig, CompressionConfig, CredentialLimitConfig, DefaultModelsConfig, DirectivesConfig,
|
|
23
|
+
import type { ApiKeyConfig, CatalogConfig, ClassifierConfig, ClientProfileMemoryEntry, ComboConfig, CompressionConfig, CredentialLimitConfig, DefaultModelsConfig, DirectivesConfig, IngressProxyConfig, FallbackConfig, LoggingConfig, OpenCodeConfig, ProxyConfig, QuotaConfig, RateLimitConfig, RequestCaptureConfig, ResponsesSurfaceConfig, RoutingMode, SessionConfig, SystemoneSurfaceConfig, TiersConfig, TracePersistConfig, WebAuthConfig } from '../types.js';
|
|
24
24
|
import type { CircuitBreakerConfig } from '../../resilience/types.js';
|
|
25
25
|
import type { RouteEntriesConfig, RetryConfig } from '../types.js';
|
|
26
26
|
import type { Migration } from '../schema.js';
|
|
@@ -50,7 +50,7 @@ export interface DiskConfigV1 {
|
|
|
50
50
|
webAuth?: WebAuthConfig;
|
|
51
51
|
apiKeys?: ApiKeyConfig[];
|
|
52
52
|
rateLimit?: RateLimitConfig;
|
|
53
|
-
forwardProxy?:
|
|
53
|
+
forwardProxy?: IngressProxyConfig;
|
|
54
54
|
};
|
|
55
55
|
protocol?: {
|
|
56
56
|
systemone?: SystemoneSurfaceConfig;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration v10 → v11 — a config knob for the session-snapshot handoff store
|
|
3
|
+
* (ADR-0038).
|
|
4
|
+
*
|
|
5
|
+
* schemaVersion 10 had no operator lever for persisting a semantic, turn-level
|
|
6
|
+
* transcript that can be MOVED to another instance. v11 adds
|
|
7
|
+
* `ops.sessionSnapshots`, default ON: this plane is the PREREQUISITE for the
|
|
8
|
+
* console's message list/tree view and for handoff, so an off default would ship
|
|
9
|
+
* a feature that looks unimplemented (contrast `requestCapture`, whose off
|
|
10
|
+
* default costs only a log copy). The disk/privacy bound is its retention window
|
|
11
|
+
* and size caps; an operator who wants nothing on disk disables it.
|
|
12
|
+
*
|
|
13
|
+
* The step MOVES NOTHING and RENAMES NOTHING: `migrate` is the identity. The
|
|
14
|
+
* layout row is what makes the knob persist in BOTH directions — a disk path
|
|
15
|
+
* absent from the table is silently dropped by `toDiskConfigWith` /
|
|
16
|
+
* `toRuntimeConfigWith` (never written, never read, therefore never able to
|
|
17
|
+
* re-persist), exactly the reason v5/v6/v8 added their knobs with an identity
|
|
18
|
+
* transform. Bumping `SCHEMA_VERSION` is what makes a saved file declare the
|
|
19
|
+
* layout it was written under. No v10 key disappears, so a v10 file keeps every
|
|
20
|
+
* value it had.
|
|
21
|
+
*
|
|
22
|
+
* FROZEN after release: later schema versions MUST NOT edit this file — the
|
|
23
|
+
* chain v0→…→v10→v11→… only appends. schema.ts binds `SECTION_MOVES_V11` as the
|
|
24
|
+
* CURRENT layout (see LATEST_LAYOUT there) — bump that pointer when v12 ships.
|
|
25
|
+
*/
|
|
26
|
+
import { type DiskConfigV10 } from './v9-to-v10.js';
|
|
27
|
+
import type { SessionSnapshotConfig } from '../types.js';
|
|
28
|
+
import type { SectionMove } from '../layout.js';
|
|
29
|
+
import type { Migration } from '../schema.js';
|
|
30
|
+
/** THE v11 layout: the v10 moves plus the session-snapshot store section. */
|
|
31
|
+
export declare const SECTION_MOVES_V11: ReadonlyArray<SectionMove>;
|
|
32
|
+
/** Disk format of schemaVersion 11: v10 with `ops.sessionSnapshots` available. */
|
|
33
|
+
export type DiskConfigV11 = DiskConfigV10 & {
|
|
34
|
+
ops?: DiskConfigV10['ops'] & {
|
|
35
|
+
sessionSnapshots?: SessionSnapshotConfig;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const migrationV10ToV11: Migration;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration v10 → v11 — a config knob for the session-snapshot handoff store
|
|
3
|
+
* (ADR-0038).
|
|
4
|
+
*
|
|
5
|
+
* schemaVersion 10 had no operator lever for persisting a semantic, turn-level
|
|
6
|
+
* transcript that can be MOVED to another instance. v11 adds
|
|
7
|
+
* `ops.sessionSnapshots`, default ON: this plane is the PREREQUISITE for the
|
|
8
|
+
* console's message list/tree view and for handoff, so an off default would ship
|
|
9
|
+
* a feature that looks unimplemented (contrast `requestCapture`, whose off
|
|
10
|
+
* default costs only a log copy). The disk/privacy bound is its retention window
|
|
11
|
+
* and size caps; an operator who wants nothing on disk disables it.
|
|
12
|
+
*
|
|
13
|
+
* The step MOVES NOTHING and RENAMES NOTHING: `migrate` is the identity. The
|
|
14
|
+
* layout row is what makes the knob persist in BOTH directions — a disk path
|
|
15
|
+
* absent from the table is silently dropped by `toDiskConfigWith` /
|
|
16
|
+
* `toRuntimeConfigWith` (never written, never read, therefore never able to
|
|
17
|
+
* re-persist), exactly the reason v5/v6/v8 added their knobs with an identity
|
|
18
|
+
* transform. Bumping `SCHEMA_VERSION` is what makes a saved file declare the
|
|
19
|
+
* layout it was written under. No v10 key disappears, so a v10 file keeps every
|
|
20
|
+
* value it had.
|
|
21
|
+
*
|
|
22
|
+
* FROZEN after release: later schema versions MUST NOT edit this file — the
|
|
23
|
+
* chain v0→…→v10→v11→… only appends. schema.ts binds `SECTION_MOVES_V11` as the
|
|
24
|
+
* CURRENT layout (see LATEST_LAYOUT there) — bump that pointer when v12 ships.
|
|
25
|
+
*/
|
|
26
|
+
import { SECTION_MOVES_V10 } from './v9-to-v10.js';
|
|
27
|
+
/** THE v11 layout: the v10 moves plus the session-snapshot store section. */
|
|
28
|
+
export const SECTION_MOVES_V11 = [
|
|
29
|
+
...SECTION_MOVES_V10,
|
|
30
|
+
['ops.sessionSnapshots', 'sessionSnapshots'],
|
|
31
|
+
];
|
|
32
|
+
export const migrationV10ToV11 = {
|
|
33
|
+
from: 10,
|
|
34
|
+
to: 11,
|
|
35
|
+
warn: [
|
|
36
|
+
'schemaVersion 11 adds ops.sessionSnapshots (default ON): a semantic, turn-level transcript store that can be exported as a portable bundle and handed to another instance (ADR-0038), and the prerequisite for the console message list/tree view. Set enabled: false to keep nothing on disk. Distinct from ops.requestCapture (a byte-faithful debug log, default off)',
|
|
37
|
+
],
|
|
38
|
+
// Nothing moved, so nothing to rewrite — the identity is deliberate (v4→v5,
|
|
39
|
+
// v5→v6, v7→v8, v8→v9 precedent): materialising an absent section on files
|
|
40
|
+
// that never had one adds noise the writer does not need and breaks the
|
|
41
|
+
// migrate-idempotence contract the migration tests pin.
|
|
42
|
+
migrate: (raw) => ({ ...raw }),
|
|
43
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration v6 → v7 — the retired selection vocabulary becomes the
|
|
3
|
+
* industry-standard trio.
|
|
4
|
+
*
|
|
5
|
+
* v6 could store three strategies: `priority`, `weighted` (a weighted RANDOM
|
|
6
|
+
* draw) and `round_robin` (a rotating table of `weight` CONSECUTIVE slots per
|
|
7
|
+
* member — bursty weighted rotation, not equal turns). v7 replaces that
|
|
8
|
+
* vocabulary (ADR-0003): `weighted_round_robin` is smooth weighted round-robin
|
|
9
|
+
* and `round_robin` is PLAIN equal rotation with weights ignored.
|
|
10
|
+
*
|
|
11
|
+
* Both v6 weighting mechanisms therefore become `weighted_round_robin`, which
|
|
12
|
+
* preserves the operator's declared weight proportions while smoothing the
|
|
13
|
+
* order:
|
|
14
|
+
* - `weighted` → `weighted_round_robin` (random draw → deterministic
|
|
15
|
+
* weighted rotation, the requested replacement);
|
|
16
|
+
* - `round_robin` → `weighted_round_robin` (the old value WAS weighted, so
|
|
17
|
+
* letting it keep its name would silently turn a 3:1 pool
|
|
18
|
+
* into 1:1; with every weight at 1 the smooth core
|
|
19
|
+
* degenerates to exactly the old equal rotation).
|
|
20
|
+
* `priority` is untouched. A v6 file cannot carry the v7 meaning of
|
|
21
|
+
* `round_robin`, so this step consumes every occurrence of it; the new
|
|
22
|
+
* equal-turn strategy is an explicit post-upgrade choice.
|
|
23
|
+
*
|
|
24
|
+
* The step rewrites ONLY an existing `selection` value under
|
|
25
|
+
* `routing.tiers.<tier>` and `routing.combos[]`. It never creates a section the
|
|
26
|
+
* file did not carry, and it leaves unknown spellings alone — value cleaning
|
|
27
|
+
* stays in loadConfig; migrations move shapes/vocabulary, never enforce
|
|
28
|
+
* semantics (the same contract as v3→v4's `modelMode: none → default`).
|
|
29
|
+
*
|
|
30
|
+
* The layout is unchanged (no section moved), so `SECTION_MOVES_V7` is the v6
|
|
31
|
+
* table verbatim — derived, never re-declared, so the frozen tables stay the
|
|
32
|
+
* single source.
|
|
33
|
+
*
|
|
34
|
+
* FROZEN after release: later schema versions MUST NOT edit this file — the
|
|
35
|
+
* chain v0→…→v6→v7→… only appends. schema.ts binds `SECTION_MOVES_V7` as the
|
|
36
|
+
* CURRENT layout (see LATEST_LAYOUT there) — bump that pointer when v8 ships.
|
|
37
|
+
*/
|
|
38
|
+
import { type DiskConfigV6 } from './v5-to-v6.js';
|
|
39
|
+
import type { SectionMove } from '../layout.js';
|
|
40
|
+
import type { Migration } from '../schema.js';
|
|
41
|
+
/** THE v7 layout: identical to v6 (the section paths did not move). */
|
|
42
|
+
export declare const SECTION_MOVES_V7: ReadonlyArray<SectionMove>;
|
|
43
|
+
/** Disk format of schemaVersion 7: v6 with the weighted selection values folded into `weighted_round_robin`. */
|
|
44
|
+
export type DiskConfigV7 = DiskConfigV6;
|
|
45
|
+
export declare const migrationV6ToV7: Migration;
|