omnicell-router 0.2.0 → 0.7.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 +70 -10
- package/README.zh-CN.md +57 -8
- package/RELEASING.md +6 -0
- package/RELEASING.zh-CN.md +5 -0
- package/backend/dist/auth/api-keys.d.ts +14 -2
- package/backend/dist/auth/api-keys.js +26 -14
- package/backend/dist/auth/model-access.d.ts +27 -10
- package/backend/dist/auth/model-access.js +34 -17
- package/backend/dist/capture/migrate/engine.d.ts +38 -0
- package/backend/dist/capture/migrate/engine.js +307 -0
- package/backend/dist/capture/migrate/index.d.ts +18 -0
- package/backend/dist/capture/migrate/index.js +18 -0
- package/backend/dist/capture/migrate/migrator.d.ts +113 -0
- package/backend/dist/capture/migrate/migrator.js +16 -0
- package/backend/dist/capture/migrate/registry.d.ts +16 -0
- package/backend/dist/capture/migrate/registry.js +19 -0
- package/backend/dist/capture/migrate/steps/v1-to-v2.d.ts +86 -0
- package/backend/dist/capture/migrate/steps/v1-to-v2.js +396 -0
- package/backend/dist/capture/recorder.d.ts +422 -272
- package/backend/dist/capture/recorder.js +873 -417
- package/backend/dist/capture/turn-boundary.d.ts +17 -0
- package/backend/dist/capture/turn-boundary.js +31 -0
- package/backend/dist/cli/clients/base.d.ts +158 -23
- package/backend/dist/cli/clients/base.js +150 -4
- package/backend/dist/cli/clients/claude.d.ts +3 -2
- package/backend/dist/cli/clients/claude.js +4 -3
- package/backend/dist/cli/clients/codex.d.ts +3 -2
- package/backend/dist/cli/clients/codex.js +4 -3
- package/backend/dist/cli/clients/core-adapters.d.ts +25 -0
- package/backend/dist/cli/clients/core-adapters.js +44 -0
- package/backend/dist/cli/clients/dsh.d.ts +5 -3
- package/backend/dist/cli/clients/dsh.js +29 -18
- package/backend/dist/cli/clients/grok.d.ts +53 -0
- package/backend/dist/cli/clients/grok.js +249 -0
- package/backend/dist/cli/clients/index.d.ts +28 -19
- package/backend/dist/cli/clients/index.js +156 -58
- package/backend/dist/cli/clients/kimi.d.ts +75 -0
- package/backend/dist/cli/clients/kimi.js +316 -0
- package/backend/dist/cli/clients/launcher.d.ts +48 -0
- package/backend/dist/cli/clients/launcher.js +41 -0
- package/backend/dist/cli/clients/omp.d.ts +43 -0
- package/backend/dist/cli/clients/omp.js +537 -0
- package/backend/dist/cli/clients/openclaw.d.ts +55 -0
- package/backend/dist/cli/clients/openclaw.js +525 -0
- package/backend/dist/cli/clients/opencode.d.ts +7 -20
- package/backend/dist/cli/clients/opencode.js +32 -159
- package/backend/dist/cli/clients/pi.d.ts +7 -21
- package/backend/dist/cli/clients/pi.js +87 -229
- package/backend/dist/cli/clients/plugin-adapters.d.ts +20 -0
- package/backend/dist/cli/clients/plugin-adapters.js +88 -0
- package/backend/dist/cli/clients/reserved.d.ts +51 -0
- package/backend/dist/cli/clients/reserved.js +53 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +31 -0
- package/backend/dist/cli/clients/workbuddy.js +259 -0
- package/backend/dist/cli/daemon.d.ts +105 -27
- package/backend/dist/cli/daemon.js +509 -151
- package/backend/dist/cli/index.d.ts +6 -1
- package/backend/dist/cli/index.js +238 -22
- package/backend/dist/cli/paths.d.ts +86 -0
- package/backend/dist/cli/paths.js +269 -0
- package/backend/dist/cli/shim.d.ts +47 -1
- package/backend/dist/cli/shim.js +180 -13
- package/backend/dist/cli/types.d.ts +102 -16
- package/backend/dist/cli/types.js +5 -4
- package/backend/dist/compression/caveman-prompts.d.ts +1 -1
- package/backend/dist/compression/caveman.d.ts +2 -16
- package/backend/dist/compression/caveman.js +25 -37
- package/backend/dist/compression/headroom.d.ts +4 -3
- package/backend/dist/compression/headroom.js +2 -2
- package/backend/dist/compression/index.d.ts +5 -26
- package/backend/dist/compression/index.js +79 -17
- package/backend/dist/compression/tool-output.d.ts +2 -20
- package/backend/dist/compression/tool-output.js +40 -47
- package/backend/dist/config/comments-en.d.ts +17 -0
- package/backend/dist/config/comments-en.js +232 -0
- package/backend/dist/config/comments-zh.d.ts +10 -0
- package/backend/dist/config/comments-zh.js +217 -0
- package/backend/dist/config/defaults.d.ts +190 -2
- package/backend/dist/config/defaults.js +191 -2
- package/backend/dist/config/env-archive.js +77 -38
- package/backend/dist/config/env.d.ts +4 -0
- package/backend/dist/config/env.js +16 -0
- package/backend/dist/config/index.d.ts +48 -12
- package/backend/dist/config/index.js +794 -368
- package/backend/dist/config/layout.d.ts +29 -0
- package/backend/dist/config/layout.js +86 -0
- package/backend/dist/config/migrations/v0-to-v1.d.ts +105 -0
- package/backend/dist/config/migrations/v0-to-v1.js +78 -0
- package/backend/dist/config/migrations/v1-to-v2.d.ts +14 -0
- package/backend/dist/config/migrations/v1-to-v2.js +41 -0
- package/backend/dist/config/migrations/v2-to-v3.d.ts +34 -0
- package/backend/dist/config/migrations/v2-to-v3.js +66 -0
- package/backend/dist/config/migrations/v3-to-v4.d.ts +34 -0
- package/backend/dist/config/migrations/v3-to-v4.js +61 -0
- package/backend/dist/config/runtime.d.ts +13 -0
- package/backend/dist/config/runtime.js +26 -0
- package/backend/dist/config/schema.d.ts +28 -0
- package/backend/dist/config/schema.js +98 -0
- package/backend/dist/config/types.d.ts +501 -84
- package/backend/dist/forward-proxy/access-log.d.ts +173 -0
- package/backend/dist/forward-proxy/access-log.js +657 -0
- package/backend/dist/forward-proxy/ca-trust.d.ts +42 -0
- package/backend/dist/forward-proxy/ca-trust.js +242 -0
- package/backend/dist/forward-proxy/ca.d.ts +66 -2
- package/backend/dist/forward-proxy/ca.js +146 -11
- package/backend/dist/forward-proxy/caller-context.d.ts +18 -0
- package/backend/dist/forward-proxy/caller-context.js +20 -0
- package/backend/dist/forward-proxy/egress.d.ts +104 -0
- package/backend/dist/forward-proxy/egress.js +280 -0
- package/backend/dist/forward-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/forward-proxy/h2-forward.js +526 -0
- package/backend/dist/forward-proxy/index.d.ts +13 -1
- package/backend/dist/forward-proxy/index.js +148 -7
- package/backend/dist/forward-proxy/interceptor.d.ts +16 -13
- package/backend/dist/forward-proxy/interceptor.js +35 -57
- package/backend/dist/forward-proxy/relay.d.ts +21 -1
- package/backend/dist/forward-proxy/relay.js +48 -1
- package/backend/dist/forward-proxy/rules.d.ts +148 -0
- package/backend/dist/forward-proxy/rules.js +280 -0
- package/backend/dist/forward-proxy/server.d.ts +102 -9
- package/backend/dist/forward-proxy/server.js +1310 -305
- package/backend/dist/forward-proxy/sni.d.ts +29 -7
- package/backend/dist/forward-proxy/sni.js +109 -47
- package/backend/dist/forward-proxy/system-proxy.d.ts +72 -0
- package/backend/dist/forward-proxy/system-proxy.js +303 -0
- package/backend/dist/forward-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/forward-proxy/upstream-tls.js +105 -0
- package/backend/dist/forward-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/forward-proxy/ws-frames.js +153 -0
- package/backend/dist/harness/common/catalog-registry.d.ts +63 -0
- package/backend/dist/harness/common/catalog-registry.js +77 -0
- package/backend/dist/harness/common/github.d.ts +6 -0
- package/backend/dist/harness/common/github.js +13 -0
- package/backend/dist/harness/common/market.d.ts +590 -0
- package/backend/dist/harness/common/market.js +1079 -0
- package/backend/dist/harness/common/marketplace-rescan-scheduler.d.ts +24 -0
- package/backend/dist/harness/common/marketplace-rescan-scheduler.js +62 -0
- package/backend/dist/harness/{catalog-npm.d.ts → common/npm-catalog.d.ts} +5 -5
- package/backend/dist/harness/{catalog-npm.js → common/npm-catalog.js} +7 -7
- package/backend/dist/harness/common/npm-source.d.ts +29 -0
- package/backend/dist/harness/common/npm-source.js +121 -0
- package/backend/dist/harness/common/pypi-source.d.ts +28 -0
- package/backend/dist/harness/common/pypi-source.js +71 -0
- package/backend/dist/harness/common/source-views.d.ts +22 -0
- package/backend/dist/harness/common/source-views.js +25 -0
- package/backend/dist/harness/{stars.d.ts → common/stars.d.ts} +1 -1
- package/backend/dist/harness/{stars.js → common/stars.js} +2 -2
- package/backend/dist/harness/common/text.d.ts +11 -0
- package/backend/dist/harness/common/text.js +18 -0
- package/backend/dist/harness/config-file.d.ts +14 -1
- package/backend/dist/harness/config-file.js +38 -0
- package/backend/dist/harness/db-probe.d.ts +29 -0
- package/backend/dist/harness/db-probe.js +270 -0
- package/backend/dist/harness/detail.d.ts +10 -1
- package/backend/dist/harness/detail.js +144 -7
- package/backend/dist/harness/host/adapters/amp.d.ts +19 -0
- package/backend/dist/harness/host/adapters/amp.js +21 -0
- package/backend/dist/harness/host/adapters/antigravity.d.ts +18 -0
- package/backend/dist/harness/host/adapters/antigravity.js +21 -0
- package/backend/dist/harness/host/adapters/base.d.ts +225 -0
- package/backend/dist/harness/host/adapters/base.js +521 -0
- package/backend/dist/harness/host/adapters/claude.d.ts +54 -0
- package/backend/dist/harness/host/adapters/claude.js +145 -0
- package/backend/dist/harness/host/adapters/cline.d.ts +18 -0
- package/backend/dist/harness/host/adapters/cline.js +20 -0
- package/backend/dist/harness/host/adapters/codex.d.ts +54 -0
- package/backend/dist/harness/host/adapters/codex.js +133 -0
- package/backend/dist/harness/host/adapters/cursor.d.ts +18 -0
- package/backend/dist/harness/host/adapters/cursor.js +24 -0
- package/backend/dist/harness/host/adapters/declarative.d.ts +22 -0
- package/backend/dist/harness/host/adapters/declarative.js +38 -0
- package/backend/dist/harness/host/adapters/dsh.d.ts +76 -0
- package/backend/dist/harness/host/adapters/dsh.js +253 -0
- package/backend/dist/harness/host/adapters/factory.d.ts +36 -0
- package/backend/dist/harness/host/adapters/factory.js +34 -0
- package/backend/dist/harness/host/adapters/gemini-cli.d.ts +17 -0
- package/backend/dist/harness/host/adapters/gemini-cli.js +19 -0
- package/backend/dist/harness/host/adapters/grok.d.ts +66 -0
- package/backend/dist/harness/host/adapters/grok.js +136 -0
- package/backend/dist/harness/{adapters → host/adapters}/index.d.ts +18 -5
- package/backend/dist/harness/{adapters → host/adapters}/index.js +73 -5
- package/backend/dist/harness/host/adapters/kimi.d.ts +30 -0
- package/backend/dist/harness/host/adapters/kimi.js +59 -0
- package/backend/dist/harness/host/adapters/omp.d.ts +55 -0
- package/backend/dist/harness/host/adapters/omp.js +90 -0
- package/backend/dist/harness/host/adapters/openclaw.d.ts +54 -0
- package/backend/dist/harness/host/adapters/openclaw.js +141 -0
- package/backend/dist/harness/host/adapters/opencode.d.ts +24 -0
- package/backend/dist/harness/host/adapters/opencode.js +48 -0
- package/backend/dist/harness/host/adapters/pi.d.ts +27 -0
- package/backend/dist/harness/host/adapters/pi.js +58 -0
- package/backend/dist/harness/host/adapters/types.d.ts +395 -0
- package/backend/dist/harness/host/adapters/types.js +17 -0
- package/backend/dist/harness/host/adapters/universal.d.ts +14 -0
- package/backend/dist/harness/host/adapters/universal.js +18 -0
- package/backend/dist/harness/host/adapters/windsurf.d.ts +20 -0
- package/backend/dist/harness/host/adapters/windsurf.js +22 -0
- package/backend/dist/harness/host/adapters/zed.d.ts +12 -0
- package/backend/dist/harness/host/adapters/zed.js +14 -0
- package/backend/dist/harness/host/claude-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/claude-mcp-runtime.js +56 -0
- package/backend/dist/harness/{discover.d.ts → host/discover.d.ts} +54 -18
- package/backend/dist/harness/{discover.js → host/discover.js} +314 -53
- package/backend/dist/harness/{drift.d.ts → host/drift.d.ts} +1 -1
- package/backend/dist/harness/{drift.js → host/drift.js} +1 -1
- package/backend/dist/harness/host/grok-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/grok-mcp-runtime.js +56 -0
- package/backend/dist/harness/{hosts.d.ts → host/hosts.d.ts} +3 -3
- package/backend/dist/harness/{hosts.js → host/hosts.js} +7 -2
- package/backend/dist/harness/host/index.d.ts +10 -0
- package/backend/dist/harness/host/index.js +12 -0
- package/backend/dist/harness/host/install-log.d.ts +22 -0
- package/backend/dist/harness/host/install-log.js +106 -0
- package/backend/dist/harness/{install.d.ts → host/install.d.ts} +32 -13
- package/backend/dist/harness/{install.js → host/install.js} +133 -50
- package/backend/dist/harness/host/inventory.d.ts +30 -0
- package/backend/dist/harness/{inventory.js → host/inventory.js} +107 -16
- package/backend/dist/harness/host/kimi-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/kimi-mcp-runtime.js +84 -0
- package/backend/dist/harness/{ledger.d.ts → host/ledger.d.ts} +1 -1
- package/backend/dist/harness/{ledger.js → host/ledger.js} +3 -3
- package/backend/dist/harness/{maintenance.d.ts → host/maintenance.d.ts} +23 -6
- package/backend/dist/harness/{maintenance.js → host/maintenance.js} +355 -63
- package/backend/dist/harness/{manifest.d.ts → host/manifest.d.ts} +11 -2
- package/backend/dist/harness/{manifest.js → host/manifest.js} +76 -15
- package/backend/dist/harness/host/marketplace-sync.d.ts +64 -0
- package/backend/dist/harness/host/marketplace-sync.js +231 -0
- package/backend/dist/harness/host/mcp-cli.d.ts +44 -0
- package/backend/dist/harness/host/mcp-cli.js +545 -0
- package/backend/dist/harness/host/mcp-edit.d.ts +89 -0
- package/backend/dist/harness/host/mcp-edit.js +342 -0
- package/backend/dist/harness/host/mcp-entry.d.ts +100 -0
- package/backend/dist/harness/host/mcp-entry.js +435 -0
- package/backend/dist/harness/host/mcp-inspector.d.ts +125 -0
- package/backend/dist/harness/host/mcp-inspector.js +634 -0
- package/backend/dist/harness/host/mcp-registry.d.ts +66 -0
- package/backend/dist/harness/host/mcp-registry.js +331 -0
- package/backend/dist/harness/host/mcp-runtime.d.ts +19 -0
- package/backend/dist/harness/host/mcp-runtime.js +22 -0
- package/backend/dist/harness/host/opencode-mcp-runtime.d.ts +7 -0
- package/backend/dist/harness/host/opencode-mcp-runtime.js +73 -0
- package/backend/dist/harness/{probe.d.ts → host/probe.d.ts} +4 -4
- package/backend/dist/harness/{probe.js → host/probe.js} +8 -8
- package/backend/dist/harness/{registry.d.ts → host/registry.d.ts} +1 -1
- package/backend/dist/harness/host/registry.js +28 -0
- package/backend/dist/harness/host/request.d.ts +56 -0
- package/backend/dist/harness/host/request.js +1 -0
- package/backend/dist/harness/{sources → host/resolvers}/clawhub.d.ts +1 -1
- package/backend/dist/harness/{sources → host/resolvers}/clawhub.js +1 -1
- package/backend/dist/harness/host/resolvers/git-marketplace.d.ts +16 -0
- package/backend/dist/harness/host/resolvers/git-marketplace.js +53 -0
- package/backend/dist/harness/{sources → host/resolvers}/github.d.ts +1 -1
- package/backend/dist/harness/{sources → host/resolvers}/github.js +2 -2
- package/backend/dist/harness/host/resolvers/npm.d.ts +2 -0
- package/backend/dist/harness/{sources → host/resolvers}/npm.js +16 -10
- package/backend/dist/harness/host/resolvers/pypi.d.ts +2 -0
- package/backend/dist/harness/host/resolvers/pypi.js +100 -0
- package/backend/dist/harness/host/scopes.d.ts +11 -0
- package/backend/dist/harness/host/scopes.js +12 -0
- package/backend/dist/harness/host/timeouts.d.ts +8 -0
- package/backend/dist/harness/host/timeouts.js +8 -0
- package/backend/dist/harness/host/writers/kimi-web.d.ts +70 -0
- package/backend/dist/harness/host/writers/kimi-web.js +222 -0
- package/backend/dist/harness/host/writers/mcp.d.ts +119 -0
- package/backend/dist/harness/host/writers/mcp.js +359 -0
- package/backend/dist/harness/host/writers/plugin.d.ts +176 -0
- package/backend/dist/harness/host/writers/plugin.js +528 -0
- package/backend/dist/harness/{writers → host/writers}/skill.d.ts +3 -3
- package/backend/dist/harness/{writers → host/writers}/skill.js +6 -3
- package/backend/dist/harness/lang.d.ts +14 -0
- package/backend/dist/harness/lang.js +33 -0
- package/backend/dist/harness/net.d.ts +33 -0
- package/backend/dist/harness/net.js +63 -0
- package/backend/dist/harness/plugin/adapters/antigravity.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/antigravity.js +14 -0
- package/backend/dist/harness/plugin/adapters/base.d.ts +107 -0
- package/backend/dist/harness/plugin/adapters/base.js +454 -0
- package/backend/dist/harness/plugin/adapters/claude.d.ts +28 -0
- package/backend/dist/harness/plugin/adapters/claude.js +63 -0
- package/backend/dist/harness/plugin/adapters/codex.d.ts +13 -0
- package/backend/dist/harness/plugin/adapters/codex.js +16 -0
- package/backend/dist/harness/plugin/adapters/cursor.d.ts +13 -0
- package/backend/dist/harness/plugin/adapters/cursor.js +16 -0
- package/backend/dist/harness/plugin/adapters/dsh-plugin-net.d.ts +20 -0
- package/backend/dist/harness/plugin/adapters/dsh-plugin-net.js +371 -0
- package/backend/dist/harness/plugin/adapters/dsh.d.ts +22 -0
- package/backend/dist/harness/plugin/adapters/dsh.js +50 -0
- package/backend/dist/harness/plugin/adapters/factory.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/factory.js +19 -0
- package/backend/dist/harness/plugin/adapters/gemini.d.ts +12 -0
- package/backend/dist/harness/plugin/adapters/gemini.js +22 -0
- package/backend/dist/harness/plugin/adapters/grok.d.ts +15 -0
- package/backend/dist/harness/plugin/adapters/grok.js +23 -0
- package/backend/dist/harness/plugin/adapters/index.d.ts +41 -0
- package/backend/dist/harness/plugin/adapters/index.js +143 -0
- package/backend/dist/harness/plugin/adapters/kimi.d.ts +6 -0
- package/backend/dist/harness/plugin/adapters/kimi.js +35 -0
- package/backend/dist/harness/plugin/adapters/omp.d.ts +19 -0
- package/backend/dist/harness/plugin/adapters/omp.js +26 -0
- package/backend/dist/harness/plugin/adapters/openclaw.d.ts +20 -0
- package/backend/dist/harness/plugin/adapters/openclaw.js +36 -0
- package/backend/dist/harness/plugin/adapters/pi-dev.d.ts +124 -0
- package/backend/dist/harness/plugin/adapters/pi-dev.js +420 -0
- package/backend/dist/harness/plugin/adapters/pi-github.d.ts +18 -0
- package/backend/dist/harness/plugin/adapters/pi-github.js +27 -0
- package/backend/dist/harness/plugin/adapters/universal.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/universal.js +18 -0
- package/backend/dist/harness/plugin/builtin.d.ts +13 -0
- package/backend/dist/harness/plugin/builtin.js +34 -0
- package/backend/dist/harness/plugin/catalog.d.ts +30 -0
- package/backend/dist/harness/plugin/catalog.js +200 -0
- package/backend/dist/harness/plugin/index.d.ts +9 -0
- package/backend/dist/harness/plugin/index.js +9 -0
- package/backend/dist/harness/plugin/types.d.ts +164 -0
- package/backend/dist/harness/plugin/types.js +1 -0
- package/backend/dist/harness/{clawhub.d.ts → skill/clawhub.d.ts} +28 -5
- package/backend/dist/harness/{clawhub.js → skill/clawhub.js} +170 -5
- package/backend/dist/harness/skill/skills-sh.d.ts +47 -0
- package/backend/dist/harness/skill/skills-sh.js +270 -0
- package/backend/dist/harness/skill/sources.d.ts +41 -0
- package/backend/dist/harness/skill/sources.js +131 -0
- package/backend/dist/harness/spi.d.ts +11 -7
- package/backend/dist/harness/tcp-reach.d.ts +30 -0
- package/backend/dist/harness/tcp-reach.js +61 -0
- package/backend/dist/harness/translation.d.ts +31 -13
- package/backend/dist/harness/translation.js +212 -62
- package/backend/dist/harness/types.d.ts +61 -16
- package/backend/dist/index.js +170 -16
- package/backend/dist/ir/adapters/anthropic-messages-stream.d.ts +18 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +266 -0
- package/backend/dist/ir/adapters/anthropic-messages.d.ts +30 -0
- package/backend/dist/ir/adapters/anthropic-messages.js +870 -0
- package/backend/dist/ir/adapters/google-gemini-stream.d.ts +22 -0
- package/backend/dist/ir/adapters/google-gemini-stream.js +246 -0
- package/backend/dist/ir/adapters/google-gemini.d.ts +9 -0
- package/backend/dist/ir/adapters/google-gemini.js +450 -0
- package/backend/dist/ir/adapters/openai-chat-stream.d.ts +41 -0
- package/backend/dist/ir/adapters/openai-chat-stream.js +369 -0
- package/backend/dist/ir/adapters/openai-chat.d.ts +17 -0
- package/backend/dist/ir/adapters/openai-chat.js +670 -0
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +50 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +353 -0
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +12 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +193 -0
- package/backend/dist/ir/adapters/openai-responses.d.ts +14 -0
- package/backend/dist/ir/adapters/openai-responses.js +670 -0
- package/backend/dist/ir/capabilities.d.ts +41 -0
- package/backend/dist/ir/capabilities.js +147 -0
- package/backend/dist/ir/errors.d.ts +23 -0
- package/backend/dist/ir/errors.js +31 -0
- package/backend/dist/ir/index.d.ts +5 -0
- package/backend/dist/ir/index.js +5 -0
- package/backend/dist/ir/media.d.ts +2 -0
- package/backend/dist/ir/media.js +2 -0
- package/backend/dist/ir/stream.d.ts +17 -0
- package/backend/dist/ir/stream.js +250 -0
- package/backend/dist/ir/types.d.ts +523 -0
- package/backend/dist/ir/types.js +19 -0
- package/backend/dist/ir/validate.d.ts +18 -0
- package/backend/dist/ir/validate.js +272 -0
- package/backend/dist/metrics/request-cost.d.ts +3 -11
- package/backend/dist/metrics/request-cost.js +9 -27
- package/backend/dist/observability/failure-events.d.ts +20 -4
- package/backend/dist/observability/failure-events.js +9 -1
- package/backend/dist/observability/http-exchange.d.ts +75 -27
- package/backend/dist/observability/http-exchange.js +136 -39
- package/backend/dist/observability/request-identity.d.ts +40 -0
- package/backend/dist/observability/request-identity.js +102 -0
- package/backend/dist/observability/traffic-live-hidden.d.ts +24 -0
- package/backend/dist/observability/traffic-live-hidden.js +82 -0
- package/backend/dist/observability/upstream-body-redaction.d.ts +23 -0
- package/backend/dist/observability/upstream-body-redaction.js +72 -0
- package/backend/dist/observability/upstream-events.d.ts +16 -10
- package/backend/dist/observability/upstream-events.js +17 -11
- package/backend/dist/opencode/agents.d.ts +10 -2
- package/backend/dist/opencode/agents.js +22 -3
- package/backend/dist/opencode/catalog/auto-pull.d.ts +35 -1
- package/backend/dist/opencode/catalog/auto-pull.js +169 -33
- package/backend/dist/opencode/catalog/ocr-store.d.ts +6 -6
- package/backend/dist/opencode/catalog/ocr-store.js +2 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +6 -5
- package/backend/dist/opencode/catalog/overrides-store.js +28 -3
- package/backend/dist/opencode/catalog/repository.d.ts +4 -0
- package/backend/dist/opencode/catalog/repository.js +19 -0
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +4 -0
- package/backend/dist/opencode/catalog/sources/models-dev.js +15 -4
- package/backend/dist/opencode/catalog/types.d.ts +10 -7
- package/backend/dist/opencode/connector.d.ts +2 -2
- package/backend/dist/opencode/connector.js +2 -2
- package/backend/dist/opencode/credentials/def-materialize.d.ts +0 -5
- package/backend/dist/opencode/credentials/def-materialize.js +149 -11
- package/backend/dist/opencode/credentials/ocr-store.d.ts +18 -0
- package/backend/dist/opencode/credentials/ocr-store.js +88 -7
- package/backend/dist/opencode/credentials/opencode-v2-store.d.ts +24 -13
- package/backend/dist/opencode/credentials/opencode-v2-store.js +70 -29
- package/backend/dist/opencode/credentials/paths.d.ts +8 -0
- package/backend/dist/opencode/credentials/paths.js +10 -0
- package/backend/dist/opencode/credentials/sync.d.ts +1 -1
- package/backend/dist/opencode/credentials/sync.js +4 -4
- package/backend/dist/opencode/credentials/types.d.ts +40 -4
- package/backend/dist/opencode/probe.d.ts +9 -5
- package/backend/dist/opencode/probe.js +68 -15
- package/backend/dist/opencode/provider-defs.js +59 -2
- package/backend/dist/opencode/provider-package.d.ts +31 -0
- package/backend/dist/opencode/provider-package.js +70 -0
- package/backend/dist/opencode/user-config.d.ts +11 -17
- package/backend/dist/opencode/user-config.js +42 -66
- package/backend/dist/pipeline/credential-selection.d.ts +13 -0
- package/backend/dist/pipeline/credential-selection.js +29 -1
- package/backend/dist/pipeline/directives.d.ts +14 -22
- package/backend/dist/pipeline/directives.js +122 -68
- package/backend/dist/pipeline/orchestrator.d.ts +42 -7
- package/backend/dist/pipeline/orchestrator.js +736 -235
- package/backend/dist/pipeline/prompt-optimizer.d.ts +6 -13
- package/backend/dist/pipeline/prompt-optimizer.js +9 -52
- package/backend/dist/pipeline/streaming-posture.d.ts +29 -0
- package/backend/dist/pipeline/streaming-posture.js +27 -0
- package/backend/dist/pipeline/tool-pairing.d.ts +10 -0
- package/backend/dist/pipeline/tool-pairing.js +90 -0
- package/backend/dist/plugins/builtin/model-gateway.d.ts +30 -0
- package/backend/dist/plugins/builtin/model-gateway.js +98 -0
- package/backend/dist/plugins/config.d.ts +41 -0
- package/backend/dist/plugins/config.js +113 -0
- package/backend/dist/plugins/gateways.d.ts +98 -0
- package/backend/dist/plugins/gateways.js +151 -0
- package/backend/dist/plugins/host.d.ts +203 -0
- package/backend/dist/plugins/host.js +1310 -0
- package/backend/dist/plugins/manifest.d.ts +43 -0
- package/backend/dist/plugins/manifest.js +462 -0
- package/backend/dist/plugins/pack.d.ts +32 -0
- package/backend/dist/plugins/pack.js +222 -0
- package/backend/dist/plugins/seed.d.ts +53 -0
- package/backend/dist/plugins/seed.js +136 -0
- package/backend/dist/plugins/types.d.ts +721 -0
- package/backend/dist/plugins/types.js +1 -0
- package/backend/dist/projects/store.d.ts +56 -0
- package/backend/dist/projects/store.js +194 -0
- package/backend/dist/projects/types.d.ts +12 -0
- package/backend/dist/projects/types.js +1 -0
- package/backend/dist/protocols/chat-compat.d.ts +2 -0
- package/backend/dist/protocols/chat-compat.js +137 -0
- package/backend/dist/protocols/systemone/convert.d.ts +5 -4
- package/backend/dist/protocols/systemone/convert.js +72 -26
- package/backend/dist/protocols/systemone/decide.js +128 -51
- package/backend/dist/protocols/systemone/native.d.ts +1 -1
- package/backend/dist/protocols/systemone/native.js +6 -6
- package/backend/dist/providers/anthropic.js +6 -6
- package/backend/dist/providers/base.d.ts +8 -47
- package/backend/dist/providers/boot-direct.d.ts +20 -2
- package/backend/dist/providers/boot-direct.js +72 -23
- package/backend/dist/providers/compat/tool-markup-leak.d.ts +41 -0
- package/backend/dist/providers/compat/tool-markup-leak.js +57 -0
- package/backend/dist/providers/compat/tool-markup-recovery.d.ts +27 -0
- package/backend/dist/providers/compat/tool-markup-recovery.js +831 -0
- package/backend/dist/providers/dispatch.d.ts +5 -8
- package/backend/dist/providers/dispatch.js +18 -12
- package/backend/dist/providers/executors/anthropic-messages.d.ts +12 -0
- package/backend/dist/providers/executors/anthropic-messages.js +56 -0
- package/backend/dist/providers/executors/dispatch.d.ts +14 -0
- package/backend/dist/providers/executors/dispatch.js +71 -0
- package/backend/dist/providers/executors/google-gemini.d.ts +12 -0
- package/backend/dist/providers/executors/google-gemini.js +53 -0
- package/backend/dist/providers/executors/http-json.d.ts +19 -0
- package/backend/dist/providers/executors/http-json.js +125 -0
- package/backend/dist/providers/executors/http-stream.d.ts +53 -0
- package/backend/dist/providers/executors/http-stream.js +472 -0
- package/backend/dist/providers/executors/openai-chat.d.ts +13 -0
- package/backend/dist/providers/executors/openai-chat.js +89 -0
- package/backend/dist/providers/executors/openai-responses.d.ts +12 -0
- package/backend/dist/providers/executors/openai-responses.js +71 -0
- package/backend/dist/providers/executors/plugin-adapter.d.ts +9 -0
- package/backend/dist/providers/executors/plugin-adapter.js +31 -0
- package/backend/dist/providers/google.js +6 -6
- package/backend/dist/providers/openai-compatible.js +13 -13
- package/backend/dist/providers/opencode-proxy.js +6 -6
- package/backend/dist/providers/plugin-wires.d.ts +34 -0
- package/backend/dist/providers/plugin-wires.js +82 -0
- package/backend/dist/providers/pool-refresh.d.ts +14 -0
- package/backend/dist/providers/pool-refresh.js +13 -0
- package/backend/dist/providers/protocol.d.ts +4 -0
- package/backend/dist/providers/protocol.js +61 -0
- package/backend/dist/providers/provider-takedown.d.ts +59 -0
- package/backend/dist/providers/provider-takedown.js +135 -0
- package/backend/dist/providers/registry.d.ts +37 -21
- package/backend/dist/providers/registry.js +204 -109
- package/backend/dist/providers/responses.d.ts +4 -2
- package/backend/dist/providers/responses.js +12 -9
- package/backend/dist/providers/vocabulary.d.ts +24 -6
- package/backend/dist/providers/vocabulary.js +75 -33
- package/backend/dist/providers/wire.d.ts +12 -17
- package/backend/dist/providers/wire.js +43 -91
- package/backend/dist/proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/proxy/manual-node-spec.js +408 -0
- package/backend/dist/proxy/mihomo-binary.d.ts +39 -0
- package/backend/dist/proxy/mihomo-binary.js +267 -0
- package/backend/dist/proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/proxy/mihomo-client.js +294 -0
- package/backend/dist/proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/proxy/mihomo-config.js +152 -0
- package/backend/dist/proxy/mihomo-pac.d.ts +26 -0
- package/backend/dist/proxy/mihomo-pac.js +60 -0
- package/backend/dist/proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/proxy/mihomo-sidecar.d.ts +65 -0
- package/backend/dist/proxy/mihomo-sidecar.js +515 -0
- package/backend/dist/quota/engine.d.ts +9 -2
- package/backend/dist/quota/engine.js +19 -1
- package/backend/dist/quota/prober.d.ts +8 -4
- package/backend/dist/quota/prober.js +9 -10
- package/backend/dist/ratelimit/rate-limiter.d.ts +119 -6
- package/backend/dist/ratelimit/rate-limiter.js +358 -20
- package/backend/dist/ratelimit/window-store.d.ts +34 -0
- package/backend/dist/ratelimit/window-store.js +70 -0
- package/backend/dist/resilience/breaker-state.js +8 -1
- package/backend/dist/resilience/circuit-breaker-manager.d.ts +229 -132
- package/backend/dist/resilience/circuit-breaker-manager.js +566 -297
- package/backend/dist/resilience/circuit-breaker.d.ts +11 -0
- package/backend/dist/resilience/circuit-breaker.js +39 -7
- package/backend/dist/resilience/error-classifier.d.ts +31 -3
- package/backend/dist/resilience/error-classifier.js +159 -31
- package/backend/dist/resilience/health-prober.d.ts +21 -4
- package/backend/dist/resilience/health-prober.js +100 -18
- package/backend/dist/resilience/types.d.ts +56 -9
- package/backend/dist/resilience/types.js +1 -1
- package/backend/dist/router/index.d.ts +6 -29
- package/backend/dist/router/index.js +15 -61
- package/backend/dist/router/layer2-decision.d.ts +2 -2
- package/backend/dist/router/layer2-decision.js +22 -19
- package/backend/dist/router/request-traits.d.ts +4 -11
- package/backend/dist/router/request-traits.js +5 -13
- package/backend/dist/routes/console.js +1948 -253
- package/backend/dist/routes/environments.d.ts +3 -2
- package/backend/dist/routes/environments.js +8 -4
- package/backend/dist/routes/harness.d.ts +3 -1
- package/backend/dist/routes/harness.js +1164 -355
- package/backend/dist/routes/mihomo.d.ts +5 -0
- package/backend/dist/routes/mihomo.js +882 -0
- package/backend/dist/routes/projects.d.ts +2 -0
- package/backend/dist/routes/projects.js +90 -0
- package/backend/dist/routes/responses.d.ts +20 -1
- package/backend/dist/routes/responses.js +65 -3
- package/backend/dist/routes/translation.d.ts +9 -0
- package/backend/dist/routes/translation.js +155 -0
- package/backend/dist/server.d.ts +0 -15
- package/backend/dist/server.js +388 -105
- package/backend/dist/session/resp-store.d.ts +18 -49
- package/backend/dist/session/resp-store.js +114 -122
- package/backend/dist/session/session-manager.d.ts +237 -81
- package/backend/dist/session/session-manager.js +445 -180
- package/backend/dist/session/session-row.d.ts +157 -0
- package/backend/dist/session/session-row.js +120 -0
- package/backend/dist/surfaces/anthropic.d.ts +1 -15
- package/backend/dist/surfaces/anthropic.js +63 -44
- package/backend/dist/surfaces/chat-pipeline.d.ts +8 -4
- package/backend/dist/surfaces/chat-pipeline.js +102 -35
- package/backend/dist/surfaces/chat.d.ts +1 -9
- package/backend/dist/surfaces/chat.js +52 -29
- package/backend/dist/surfaces/decision-pipeline.js +26 -18
- package/backend/dist/surfaces/gateway-chat.d.ts +53 -0
- package/backend/dist/surfaces/gateway-chat.js +204 -0
- package/backend/dist/surfaces/ocr-headers.d.ts +25 -4
- package/backend/dist/surfaces/ocr-headers.js +52 -6
- package/backend/dist/surfaces/responses.d.ts +9 -1
- package/backend/dist/surfaces/responses.js +141 -141
- package/backend/dist/surfaces/systemone-probe.js +1 -1
- package/backend/dist/surfaces/systemone.d.ts +1 -1
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/table.d.ts +15 -0
- package/backend/dist/surfaces/table.js +15 -0
- package/backend/dist/surfaces/transport-backpressure.d.ts +46 -0
- package/backend/dist/surfaces/transport-backpressure.js +122 -0
- package/backend/dist/surfaces/transport-fastify.js +92 -21
- package/backend/dist/surfaces/transport-node-http.js +92 -18
- package/backend/dist/surfaces/types.d.ts +74 -12
- package/backend/dist/trace/persist.d.ts +5 -0
- package/backend/dist/trace/persist.js +185 -24
- package/backend/dist/trace/tracker.d.ts +153 -16
- package/backend/dist/trace/tracker.js +77 -27
- package/backend/dist/translation/index.d.ts +151 -0
- package/backend/dist/translation/index.js +735 -0
- package/backend/dist/types/openai.d.ts +82 -1
- package/backend/dist/types/router.d.ts +71 -6
- package/backend/dist/types/router.js +33 -1
- package/backend/dist/update/check.d.ts +43 -0
- package/backend/dist/update/check.js +126 -0
- package/backend/dist/utils/chat-sse.d.ts +2 -22
- package/backend/dist/utils/chat-sse.js +1 -69
- package/backend/dist/utils/chat-stream.d.ts +2 -1
- package/backend/dist/utils/client-envelope.d.ts +108 -0
- package/backend/dist/utils/client-envelope.js +305 -0
- package/backend/dist/utils/event-ring.d.ts +8 -1
- package/backend/dist/utils/event-ring.js +13 -5
- package/backend/dist/utils/harness-profiles.d.ts +51 -0
- package/backend/dist/utils/harness-profiles.js +70 -0
- package/backend/dist/utils/percentile.d.ts +16 -0
- package/backend/dist/utils/percentile.js +29 -0
- package/backend/dist/utils/popularity.d.ts +4 -0
- package/backend/dist/utils/popularity.js +33 -0
- package/backend/dist/utils/probe-interval.d.ts +12 -0
- package/backend/dist/utils/probe-interval.js +16 -0
- package/backend/dist/utils/proxy-node.d.ts +13 -0
- package/backend/dist/utils/proxy-node.js +471 -0
- package/backend/dist/utils/proxy.d.ts +12 -0
- package/backend/dist/utils/proxy.js +44 -4
- package/backend/dist/utils/run-command.d.ts +42 -0
- package/backend/dist/utils/run-command.js +93 -0
- package/backend/dist/utils/self-url.d.ts +13 -0
- package/backend/dist/utils/self-url.js +90 -2
- package/backend/dist/utils/semver.d.ts +22 -0
- package/backend/dist/utils/semver.js +75 -0
- package/backend/dist/utils/stream-relay.d.ts +35 -0
- package/backend/dist/utils/stream-relay.js +1 -0
- package/backend/dist/utils/upstream-url-guard.d.ts +15 -0
- package/backend/dist/utils/upstream-url-guard.js +107 -0
- package/backend/dist/validator/parser.d.ts +2 -5
- package/backend/dist/validator/parser.js +12 -16
- package/backend/dist/validator/schema-assertion.d.ts +3 -2
- package/backend/dist/validator/schema-assertion.js +53 -8
- package/bin/ocr.js +2 -2
- package/frontend/dist/assets/index-CLvxJjp_.js +1476 -0
- package/frontend/dist/assets/index-CQSLGFTV.css +1 -0
- package/frontend/dist/assets/qoder.color-tVX5GCcD.svg +5 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/provider-logos/302ai.svg +7 -0
- package/frontend/dist/provider-logos/NOTICE.txt +39 -0
- package/frontend/dist/provider-logos/abacus.svg +14 -0
- package/frontend/dist/provider-logos/abliteration-ai.svg +6 -0
- package/frontend/dist/provider-logos/above.svg +3 -0
- package/frontend/dist/provider-logos/agentrouter.svg +4 -0
- package/frontend/dist/provider-logos/agnes.svg +1 -0
- package/frontend/dist/provider-logos/ai-router.svg +5 -0
- package/frontend/dist/provider-logos/ai21.svg +3 -0
- package/frontend/dist/provider-logos/aiand.svg +4 -0
- package/frontend/dist/provider-logos/aihubmix.svg +3 -0
- package/frontend/dist/provider-logos/aimlapi.svg +3 -0
- package/frontend/dist/provider-logos/ainetcafe.svg +1 -0
- package/frontend/dist/provider-logos/aixy.svg +4 -0
- package/frontend/dist/provider-logos/aki-io.svg +8 -0
- package/frontend/dist/provider-logos/alibaba-cn.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-coding-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-token-plan-cn.svg +1 -0
- package/frontend/dist/provider-logos/alibaba-token-plan.svg +1 -0
- package/frontend/dist/provider-logos/alibaba.svg +3 -0
- package/frontend/dist/provider-logos/amazon-bedrock.svg +3 -0
- package/frontend/dist/provider-logos/ambient.svg +3 -0
- package/frontend/dist/provider-logos/amd.svg +3 -0
- package/frontend/dist/provider-logos/anthropic.svg +3 -0
- package/frontend/dist/provider-logos/anyapi.svg +3 -0
- package/frontend/dist/provider-logos/arcee.svg +3 -0
- package/frontend/dist/provider-logos/atomic-chat.svg +1 -0
- package/frontend/dist/provider-logos/auriko.svg +6 -0
- package/frontend/dist/provider-logos/azure-cognitive-services.svg +3 -0
- package/frontend/dist/provider-logos/azure.svg +3 -0
- package/frontend/dist/provider-logos/bailing.svg +3 -0
- package/frontend/dist/provider-logos/baseten.svg +3 -0
- package/frontend/dist/provider-logos/bee.svg +1 -0
- package/frontend/dist/provider-logos/berget.svg +3 -0
- package/frontend/dist/provider-logos/blueclaw.svg +3 -0
- package/frontend/dist/provider-logos/bothub.svg +33 -0
- package/frontend/dist/provider-logos/boundless.svg +12 -0
- package/frontend/dist/provider-logos/cerebras.svg +4 -0
- package/frontend/dist/provider-logos/chutes.svg +24 -0
- package/frontend/dist/provider-logos/clarifai.svg +3 -0
- package/frontend/dist/provider-logos/claudinio.svg +19 -0
- package/frontend/dist/provider-logos/cline-pass.svg +24 -0
- package/frontend/dist/provider-logos/cloudferro-sherlock.svg +5 -0
- package/frontend/dist/provider-logos/cloudflare-ai-gateway.svg +4 -0
- package/frontend/dist/provider-logos/cloudflare-workers-ai.svg +4 -0
- package/frontend/dist/provider-logos/cohere.svg +5 -0
- package/frontend/dist/provider-logos/commandcode.svg +11 -0
- package/frontend/dist/provider-logos/coralbricks.svg +6 -0
- package/frontend/dist/provider-logos/cortecs.svg +24 -0
- package/frontend/dist/provider-logos/crossmodel.svg +5 -0
- package/frontend/dist/provider-logos/crusoe.svg +23 -0
- package/frontend/dist/provider-logos/daoxe.svg +3 -0
- package/frontend/dist/provider-logos/databricks.svg +3 -0
- package/frontend/dist/provider-logos/deepinfra.svg +4 -0
- package/frontend/dist/provider-logos/deepseek.svg +3 -0
- package/frontend/dist/provider-logos/digitalocean.svg +6 -0
- package/frontend/dist/provider-logos/dinference.svg +1 -0
- package/frontend/dist/provider-logos/drun.svg +8 -0
- package/frontend/dist/provider-logos/ebcloud.svg +8 -0
- package/frontend/dist/provider-logos/echo.svg +7 -0
- package/frontend/dist/provider-logos/edenai.svg +8 -0
- package/frontend/dist/provider-logos/empiriolabs.svg +1 -0
- package/frontend/dist/provider-logos/engy.svg +1 -0
- package/frontend/dist/provider-logos/evroc.svg +3 -0
- package/frontend/dist/provider-logos/fastrouter.svg +3 -0
- package/frontend/dist/provider-logos/fireworks-ai.svg +3 -0
- package/frontend/dist/provider-logos/freemodel.svg +3 -0
- package/frontend/dist/provider-logos/friendli.svg +3 -0
- package/frontend/dist/provider-logos/frogbot.svg +36 -0
- package/frontend/dist/provider-logos/github-copilot.svg +3 -0
- package/frontend/dist/provider-logos/gitlab.svg +3 -0
- package/frontend/dist/provider-logos/gmicloud.svg +24 -0
- package/frontend/dist/provider-logos/google-vertex-anthropic.svg +10 -0
- package/frontend/dist/provider-logos/google-vertex.svg +10 -0
- package/frontend/dist/provider-logos/google.svg +3 -0
- package/frontend/dist/provider-logos/greenpt.svg +6 -0
- package/frontend/dist/provider-logos/groq.svg +3 -0
- package/frontend/dist/provider-logos/helicone.svg +6 -0
- package/frontend/dist/provider-logos/hetzner.svg +3 -0
- package/frontend/dist/provider-logos/hopper.svg +4 -0
- package/frontend/dist/provider-logos/hpc-ai.svg +446 -0
- package/frontend/dist/provider-logos/huggingface.svg +3 -0
- package/frontend/dist/provider-logos/hyper.svg +20 -0
- package/frontend/dist/provider-logos/impossibl.svg +3 -0
- package/frontend/dist/provider-logos/inception.svg +14 -0
- package/frontend/dist/provider-logos/inceptron.svg +14 -0
- package/frontend/dist/provider-logos/inco.svg +3 -0
- package/frontend/dist/provider-logos/infer.svg +4 -0
- package/frontend/dist/provider-logos/inference.svg +3 -0
- package/frontend/dist/provider-logos/inferx.svg +5 -0
- package/frontend/dist/provider-logos/infomaniak.svg +3 -0
- package/frontend/dist/provider-logos/io-net.svg +5 -0
- package/frontend/dist/provider-logos/iteracompute.svg +7 -0
- package/frontend/dist/provider-logos/jalapeno.svg +8 -0
- package/frontend/dist/provider-logos/jiekou.svg +4 -0
- package/frontend/dist/provider-logos/kenari.svg +4 -0
- package/frontend/dist/provider-logos/kilo.svg +4 -0
- package/frontend/dist/provider-logos/kimi-code-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/kimi-code-plan-global.svg +3 -0
- package/frontend/dist/provider-logos/klokintegration.svg +11 -0
- package/frontend/dist/provider-logos/kosmik.svg +28 -0
- package/frontend/dist/provider-logos/kuae-cloud-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/lilac.svg +6 -0
- package/frontend/dist/provider-logos/liquid.svg +1 -0
- package/frontend/dist/provider-logos/llmgateway-providers.svg +6 -0
- package/frontend/dist/provider-logos/llmgateway.svg +6 -0
- package/frontend/dist/provider-logos/llmtech.svg +6 -0
- package/frontend/dist/provider-logos/llmtr.svg +12 -0
- package/frontend/dist/provider-logos/lmstudio.svg +3 -0
- package/frontend/dist/provider-logos/longcat.svg +6 -0
- package/frontend/dist/provider-logos/lowrouter.svg +8 -0
- package/frontend/dist/provider-logos/lucidquery.svg +3 -0
- package/frontend/dist/provider-logos/lynkr.svg +1 -0
- package/frontend/dist/provider-logos/meganova.svg +3 -0
- package/frontend/dist/provider-logos/melious.svg +3 -0
- package/frontend/dist/provider-logos/merge-gateway.svg +4 -0
- package/frontend/dist/provider-logos/meta.svg +3 -0
- package/frontend/dist/provider-logos/minimax-cn-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/minimax-cn.svg +3 -0
- package/frontend/dist/provider-logos/minimax-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/minimax.svg +3 -0
- package/frontend/dist/provider-logos/mistral.svg +3 -0
- package/frontend/dist/provider-logos/mixlayer.svg +9 -0
- package/frontend/dist/provider-logos/moark.svg +3 -0
- package/frontend/dist/provider-logos/modal.svg +3 -0
- package/frontend/dist/provider-logos/model-oracle-ai.svg +11 -0
- package/frontend/dist/provider-logos/modelis.svg +1 -0
- package/frontend/dist/provider-logos/modelscope.svg +5 -0
- package/frontend/dist/provider-logos/modular.svg +3 -0
- package/frontend/dist/provider-logos/moonshotai-cn.svg +3 -0
- package/frontend/dist/provider-logos/moonshotai.svg +3 -0
- package/frontend/dist/provider-logos/morph.svg +24 -0
- package/frontend/dist/provider-logos/munito-eu.svg +1 -0
- package/frontend/dist/provider-logos/munito.svg +1 -0
- package/frontend/dist/provider-logos/nan.svg +1 -0
- package/frontend/dist/provider-logos/nano-gpt.svg +3 -0
- package/frontend/dist/provider-logos/nearai.svg +1 -0
- package/frontend/dist/provider-logos/nebius.svg +4 -0
- package/frontend/dist/provider-logos/neon.svg +3 -0
- package/frontend/dist/provider-logos/neosmith.svg +6 -0
- package/frontend/dist/provider-logos/neuralwatt.svg +27 -0
- package/frontend/dist/provider-logos/nova.svg +3 -0
- package/frontend/dist/provider-logos/novita-ai.svg +10 -0
- package/frontend/dist/provider-logos/nvidia.svg +3 -0
- package/frontend/dist/provider-logos/oci.svg +3 -0
- package/frontend/dist/provider-logos/ofox.svg +5 -0
- package/frontend/dist/provider-logos/ollama-cloud.svg +7 -0
- package/frontend/dist/provider-logos/openai.svg +3 -0
- package/frontend/dist/provider-logos/opencode-go.svg +4 -0
- package/frontend/dist/provider-logos/opencode.svg +4 -0
- package/frontend/dist/provider-logos/openreason.svg +8 -0
- package/frontend/dist/provider-logos/openrouter.svg +5 -0
- package/frontend/dist/provider-logos/opper.svg +3 -0
- package/frontend/dist/provider-logos/orcarouter.svg +2 -0
- package/frontend/dist/provider-logos/ovhcloud.svg +3 -0
- package/frontend/dist/provider-logos/pareto.svg +5 -0
- package/frontend/dist/provider-logos/pendra.svg +10 -0
- package/frontend/dist/provider-logos/perplexity-agent.svg +3 -0
- package/frontend/dist/provider-logos/perplexity.svg +3 -0
- package/frontend/dist/provider-logos/pioneer.svg +3 -0
- package/frontend/dist/provider-logos/poe.svg +7 -0
- package/frontend/dist/provider-logos/poolside.svg +3 -0
- package/frontend/dist/provider-logos/prime.svg +7 -0
- package/frontend/dist/provider-logos/privatemode-ai.svg +5 -0
- package/frontend/dist/provider-logos/qihang-ai.svg +9 -0
- package/frontend/dist/provider-logos/qiniu-ai.svg +7 -0
- package/frontend/dist/provider-logos/qvac.svg +6 -0
- package/frontend/dist/provider-logos/reflection.svg +3 -0
- package/frontend/dist/provider-logos/regolo-ai.svg +46 -0
- package/frontend/dist/provider-logos/requesty.svg +24 -0
- package/frontend/dist/provider-logos/routing-run.svg +4 -0
- package/frontend/dist/provider-logos/runinfra.svg +10 -0
- package/frontend/dist/provider-logos/sakana.svg +24 -0
- package/frontend/dist/provider-logos/salad-cloud.svg +15 -0
- package/frontend/dist/provider-logos/sambanova.svg +26 -0
- package/frontend/dist/provider-logos/sap-ai-core.svg +24 -0
- package/frontend/dist/provider-logos/sarvam.svg +24 -0
- package/frontend/dist/provider-logos/scaleway.svg +5 -0
- package/frontend/dist/provider-logos/scnet-token-plan.svg +8 -0
- package/frontend/dist/provider-logos/scx-ai.svg +1 -0
- package/frontend/dist/provider-logos/sensenova.svg +18 -0
- package/frontend/dist/provider-logos/siliconflow-cn.svg +3 -0
- package/frontend/dist/provider-logos/siliconflow.svg +3 -0
- package/frontend/dist/provider-logos/snowflake-cortex.svg +3 -0
- package/frontend/dist/provider-logos/stackit.svg +4 -0
- package/frontend/dist/provider-logos/standardcompute.svg +5 -0
- package/frontend/dist/provider-logos/stepfun-ai-step-plan.svg +16 -0
- package/frontend/dist/provider-logos/stepfun-ai.svg +16 -0
- package/frontend/dist/provider-logos/stepfun-step-plan.svg +16 -0
- package/frontend/dist/provider-logos/stepfun.svg +16 -0
- package/frontend/dist/provider-logos/subconscious.svg +3 -0
- package/frontend/dist/provider-logos/submodel.svg +3 -0
- package/frontend/dist/provider-logos/synthetic.svg +24 -0
- package/frontend/dist/provider-logos/tempr.svg +4 -0
- package/frontend/dist/provider-logos/tencent-coding-plan.svg +5 -0
- package/frontend/dist/provider-logos/tencent-token-plan.svg +3 -0
- package/frontend/dist/provider-logos/tencent-tokenhub.svg +3 -0
- package/frontend/dist/provider-logos/tensorx.svg +6 -0
- package/frontend/dist/provider-logos/the-grid-ai.svg +14 -0
- package/frontend/dist/provider-logos/thinkingmachines.svg +3 -0
- package/frontend/dist/provider-logos/tinfoil.svg +3 -0
- package/frontend/dist/provider-logos/togetherai.svg +4 -0
- package/frontend/dist/provider-logos/tokengo.svg +3 -0
- package/frontend/dist/provider-logos/tokenrouter.svg +4 -0
- package/frontend/dist/provider-logos/trustedrouter.svg +4 -0
- package/frontend/dist/provider-logos/umans-ai-coding-plan.svg +29 -0
- package/frontend/dist/provider-logos/umans-ai.svg +29 -0
- package/frontend/dist/provider-logos/unorouter.svg +7 -0
- package/frontend/dist/provider-logos/upstage.svg +24 -0
- package/frontend/dist/provider-logos/vancine.svg +6 -0
- package/frontend/dist/provider-logos/venice.svg +4 -0
- package/frontend/dist/provider-logos/vercel.svg +3 -0
- package/frontend/dist/provider-logos/vispark.svg +3 -0
- package/frontend/dist/provider-logos/vivgrid.svg +4 -0
- package/frontend/dist/provider-logos/volcengine-coding-plan.svg +1 -0
- package/frontend/dist/provider-logos/volcengine.svg +1 -0
- package/frontend/dist/provider-logos/vultr.svg +6 -0
- package/frontend/dist/provider-logos/wafer.ai.svg +3 -0
- package/frontend/dist/provider-logos/wallaby.svg +4 -0
- package/frontend/dist/provider-logos/wally.svg +1 -0
- package/frontend/dist/provider-logos/wandb.svg +6 -0
- package/frontend/dist/provider-logos/watsonx.svg +5 -0
- package/frontend/dist/provider-logos/xai.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-ams.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-sgp.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi.svg +3 -0
- package/frontend/dist/provider-logos/xpersona.svg +8 -0
- package/frontend/dist/provider-logos/zai-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/zai.svg +3 -0
- package/frontend/dist/provider-logos/zeldoc.svg +3 -0
- package/frontend/dist/provider-logos/zenifra.svg +4 -0
- package/frontend/dist/provider-logos/zenmux.svg +4 -0
- package/frontend/dist/provider-logos/zhipuai-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/zhipuai.svg +3 -0
- package/package.json +13 -5
- package/backend/dist/cli/clients/opencode-proxy.d.ts +0 -16
- package/backend/dist/cli/clients/opencode-proxy.js +0 -372
- package/backend/dist/forward-proxy/bypass.d.ts +0 -20
- package/backend/dist/forward-proxy/bypass.js +0 -28
- package/backend/dist/harness/adapters/amp.d.ts +0 -2
- package/backend/dist/harness/adapters/amp.js +0 -7
- package/backend/dist/harness/adapters/claude.d.ts +0 -2
- package/backend/dist/harness/adapters/claude.js +0 -7
- package/backend/dist/harness/adapters/cline.d.ts +0 -2
- package/backend/dist/harness/adapters/cline.js +0 -6
- package/backend/dist/harness/adapters/codex.d.ts +0 -2
- package/backend/dist/harness/adapters/codex.js +0 -6
- package/backend/dist/harness/adapters/cursor.d.ts +0 -5
- package/backend/dist/harness/adapters/cursor.js +0 -10
- package/backend/dist/harness/adapters/declarative.d.ts +0 -62
- package/backend/dist/harness/adapters/declarative.js +0 -202
- package/backend/dist/harness/adapters/dsh.d.ts +0 -5
- package/backend/dist/harness/adapters/dsh.js +0 -6
- package/backend/dist/harness/adapters/gemini-cli.d.ts +0 -2
- package/backend/dist/harness/adapters/gemini-cli.js +0 -7
- package/backend/dist/harness/adapters/github-copilot.d.ts +0 -5
- package/backend/dist/harness/adapters/github-copilot.js +0 -10
- package/backend/dist/harness/adapters/opencode.d.ts +0 -2
- package/backend/dist/harness/adapters/opencode.js +0 -55
- package/backend/dist/harness/adapters/pi.d.ts +0 -1
- package/backend/dist/harness/adapters/pi.js +0 -22
- package/backend/dist/harness/adapters/types.d.ts +0 -174
- package/backend/dist/harness/adapters/types.js +0 -12
- package/backend/dist/harness/adapters/universal.d.ts +0 -6
- package/backend/dist/harness/adapters/universal.js +0 -10
- package/backend/dist/harness/adapters/windsurf.d.ts +0 -2
- package/backend/dist/harness/adapters/windsurf.js +0 -10
- package/backend/dist/harness/adapters/zed.d.ts +0 -2
- package/backend/dist/harness/adapters/zed.js +0 -6
- package/backend/dist/harness/awesome-opencode.d.ts +0 -40
- package/backend/dist/harness/awesome-opencode.js +0 -75
- package/backend/dist/harness/browse.d.ts +0 -202
- package/backend/dist/harness/browse.js +0 -1214
- package/backend/dist/harness/inventory.d.ts +0 -10
- package/backend/dist/harness/opencode-cafe.d.ts +0 -40
- package/backend/dist/harness/opencode-cafe.js +0 -85
- package/backend/dist/harness/opencode-ecosystem.d.ts +0 -34
- package/backend/dist/harness/opencode-ecosystem.js +0 -246
- package/backend/dist/harness/pi-dev.d.ts +0 -81
- package/backend/dist/harness/pi-dev.js +0 -187
- package/backend/dist/harness/registry.js +0 -26
- package/backend/dist/harness/scopes.d.ts +0 -21
- package/backend/dist/harness/scopes.js +0 -22
- package/backend/dist/harness/skills-sh.d.ts +0 -109
- package/backend/dist/harness/skills-sh.js +0 -178
- package/backend/dist/harness/smithery.d.ts +0 -64
- package/backend/dist/harness/smithery.js +0 -146
- package/backend/dist/harness/sources/awesome-opencode.d.ts +0 -11
- package/backend/dist/harness/sources/awesome-opencode.js +0 -39
- package/backend/dist/harness/sources/mcp-official.d.ts +0 -2
- package/backend/dist/harness/sources/mcp-official.js +0 -110
- package/backend/dist/harness/sources/npm.d.ts +0 -2
- package/backend/dist/harness/sources/opencode-cafe.d.ts +0 -11
- package/backend/dist/harness/sources/opencode-cafe.js +0 -41
- package/backend/dist/harness/sources/smithery.d.ts +0 -2
- package/backend/dist/harness/sources/smithery.js +0 -81
- package/backend/dist/harness/writers/extension.d.ts +0 -116
- package/backend/dist/harness/writers/extension.js +0 -219
- package/backend/dist/harness/writers/mcp.d.ts +0 -72
- package/backend/dist/harness/writers/mcp.js +0 -195
- package/backend/dist/observability/trace-id.d.ts +0 -40
- package/backend/dist/observability/trace-id.js +0 -134
- package/frontend/dist/assets/index-1o7qI-KJ.css +0 -1
- package/frontend/dist/assets/index-DvXKvNxl.js +0 -962
- package/frontend/dist/assets/inter-cyrillic-800-normal-C7MGvYyJ.woff2 +0 -0
- package/frontend/dist/assets/inter-cyrillic-800-normal-CCHyn08d.woff +0 -0
- package/frontend/dist/assets/inter-cyrillic-ext-800-normal-BZOjs1Xv.woff2 +0 -0
- package/frontend/dist/assets/inter-cyrillic-ext-800-normal-Ca-gJeZY.woff +0 -0
- package/frontend/dist/assets/inter-greek-800-normal-BU00tryP.woff +0 -0
- package/frontend/dist/assets/inter-greek-800-normal-CLIouy3y.woff2 +0 -0
- package/frontend/dist/assets/inter-greek-ext-800-normal-B--PVpEC.woff2 +0 -0
- package/frontend/dist/assets/inter-greek-ext-800-normal-DUe57HfS.woff +0 -0
- package/frontend/dist/assets/inter-latin-800-normal-BYj_oED-.woff2 +0 -0
- package/frontend/dist/assets/inter-latin-800-normal-D1mf63XC.woff +0 -0
- package/frontend/dist/assets/inter-latin-ext-800-normal-BOMpwxm3.woff +0 -0
- package/frontend/dist/assets/inter-latin-ext-800-normal-DZJjya6U.woff2 +0 -0
- package/frontend/dist/assets/inter-vietnamese-800-normal-Cm7tD1pz.woff2 +0 -0
- package/frontend/dist/assets/inter-vietnamese-800-normal-DDlpr_Ee.woff +0 -0
- /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.d.ts +0 -0
- /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.js +0 -0
- /package/backend/dist/harness/{skill-md.d.ts → skill/skill-md.d.ts} +0 -0
- /package/backend/dist/harness/{skill-md.js → skill/skill-md.js} +0 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mihomo sidecar lifecycle (ADR-0022).
|
|
3
|
+
*
|
|
4
|
+
* The gateway owns the process it spawns: pid file + an `owner` marker
|
|
5
|
+
* (`spawned` vs `adopted`) live under `<env>/mihomo/`. A controller that is
|
|
6
|
+
* already healthy is adopted and left running. Explicit stop kills a local
|
|
7
|
+
* listener either way. When the run policy turns the core off, only a process
|
|
8
|
+
* this gateway spawned is stopped — an operator's own mihomo is not touched.
|
|
9
|
+
*
|
|
10
|
+
* Run policy is `proxy.mihomo.autoStart`, NOT the outbound mode. The core is an
|
|
11
|
+
* independent capability: it can serve a manual-URL outbound setup (pre-warm
|
|
12
|
+
* subscriptions, probe nodes, offer its mixed port to other clients) and it can
|
|
13
|
+
* be stopped while `mode: mihomo` stays configured. When `autoStart` is absent
|
|
14
|
+
* the pre-split rule applies (`proxy.enabled && proxy.mode === 'mihomo'`), so
|
|
15
|
+
* existing configs behave exactly as before. A missing binary is reported
|
|
16
|
+
* (`binary-missing`); the download helper is opt-in and never runs at boot.
|
|
17
|
+
* Subscription URLs and the controller secret are never logged.
|
|
18
|
+
*/
|
|
19
|
+
import crypto from 'node:crypto';
|
|
20
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
21
|
+
import fs from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { getEnvRootDir } from '../config/env.js';
|
|
24
|
+
import { renameWithRetry } from '../utils/atomic-write.js';
|
|
25
|
+
import { loadConfig, saveConfig } from '../config/index.js';
|
|
26
|
+
import { DEFAULT_MIHOMO_CONTROLLER_PORT, DEFAULT_MIHOMO_GROUP, DEFAULT_MIHOMO_MIXED_PORT, } from '../config/defaults.js';
|
|
27
|
+
import { resolveMihomoBinary } from './mihomo-binary.js';
|
|
28
|
+
import { MihomoClient } from './mihomo-client.js';
|
|
29
|
+
import { mihomoConfigSummary, renderMihomoConfig } from './mihomo-config.js';
|
|
30
|
+
const PROBE_TIMEOUT_MS = 1500;
|
|
31
|
+
const DEFAULT_READY_TIMEOUT_MS = 15_000;
|
|
32
|
+
const DEFAULT_POLL_INTERVAL_MS = 200;
|
|
33
|
+
let testDeps = null;
|
|
34
|
+
let queue = Promise.resolve();
|
|
35
|
+
let lastError = { error: null, code: null };
|
|
36
|
+
export function setMihomoSidecarDepsForTests(deps) {
|
|
37
|
+
testDeps = deps;
|
|
38
|
+
lastError = { error: null, code: null };
|
|
39
|
+
}
|
|
40
|
+
function merged(extra) {
|
|
41
|
+
return { ...testDeps, ...extra };
|
|
42
|
+
}
|
|
43
|
+
function enqueue(fn) {
|
|
44
|
+
const run = queue.then(fn, fn);
|
|
45
|
+
queue = run.then(() => undefined, () => undefined);
|
|
46
|
+
return run;
|
|
47
|
+
}
|
|
48
|
+
export function mihomoWorkDir(deps) {
|
|
49
|
+
return deps?.workDir ?? path.join(getEnvRootDir(), 'mihomo');
|
|
50
|
+
}
|
|
51
|
+
function remember(error, code) {
|
|
52
|
+
lastError = { error, code };
|
|
53
|
+
}
|
|
54
|
+
function proxyOf(deps) {
|
|
55
|
+
return deps.config ?? loadConfig().proxy ?? {};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Should the core be running? Two axes are involved and they are NOT the same
|
|
59
|
+
* question: `proxy.mode` says where outbound traffic goes, `autoStart` says
|
|
60
|
+
* whether this process should exist. Only the latter is consulted here, so the
|
|
61
|
+
* core can run while outbound goes direct (and can be stopped while the mode
|
|
62
|
+
* still says mihomo — the console shows that mismatch rather than "fixing" it
|
|
63
|
+
* by restarting a process the operator just stopped).
|
|
64
|
+
*
|
|
65
|
+
* An absent `autoStart` falls back to the historical rule, which keeps every
|
|
66
|
+
* existing config byte-identical in behaviour.
|
|
67
|
+
*/
|
|
68
|
+
function shouldRun(proxy) {
|
|
69
|
+
return proxy.mihomo?.autoStart ?? (proxy.enabled === true && proxy.mode === 'mihomo');
|
|
70
|
+
}
|
|
71
|
+
function portsOf(proxy) {
|
|
72
|
+
const mihomo = proxy.mihomo ?? {};
|
|
73
|
+
return {
|
|
74
|
+
mixed: mihomo.mixedPort ?? DEFAULT_MIHOMO_MIXED_PORT,
|
|
75
|
+
controller: mihomo.controllerPort ?? DEFAULT_MIHOMO_CONTROLLER_PORT,
|
|
76
|
+
group: mihomo.selectedGroup || DEFAULT_MIHOMO_GROUP,
|
|
77
|
+
secret: (mihomo.controllerSecret || '').trim(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function newSecret() {
|
|
81
|
+
return crypto.randomBytes(24).toString('hex');
|
|
82
|
+
}
|
|
83
|
+
/** Persist a generated secret through the normal config writer. Never logs it. */
|
|
84
|
+
export function persistMihomoSecret(secret) {
|
|
85
|
+
const current = loadConfig();
|
|
86
|
+
const proxy = current.proxy ?? {};
|
|
87
|
+
if ((proxy.mihomo?.controllerSecret || '') === secret)
|
|
88
|
+
return;
|
|
89
|
+
saveConfig({
|
|
90
|
+
proxy: {
|
|
91
|
+
...proxy,
|
|
92
|
+
mihomo: { ...(proxy.mihomo ?? {}), controllerSecret: secret },
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function readPid(file) {
|
|
97
|
+
try {
|
|
98
|
+
const pid = Number(fs.readFileSync(file, 'utf8').trim());
|
|
99
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function pidAlive(pid) {
|
|
106
|
+
try {
|
|
107
|
+
process.kill(pid, 0);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function writePid(file, pid) {
|
|
115
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
116
|
+
fs.writeFileSync(file, String(pid), 'utf8');
|
|
117
|
+
}
|
|
118
|
+
function ownerOf(dir) {
|
|
119
|
+
try {
|
|
120
|
+
const raw = fs.readFileSync(path.join(dir, 'owner'), 'utf8').trim();
|
|
121
|
+
return raw === 'spawned' || raw === 'adopted' ? raw : null;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function writeOwner(dir, owner) {
|
|
128
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
129
|
+
fs.writeFileSync(path.join(dir, 'owner'), owner, 'utf8');
|
|
130
|
+
}
|
|
131
|
+
async function probe(fetchImpl, port, secret) {
|
|
132
|
+
if (!secret)
|
|
133
|
+
return { ok: false, version: null };
|
|
134
|
+
try {
|
|
135
|
+
const res = await fetchImpl(`http://127.0.0.1:${port}/version`, {
|
|
136
|
+
headers: { Authorization: `Bearer ${secret}` },
|
|
137
|
+
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
138
|
+
});
|
|
139
|
+
if (!res.ok)
|
|
140
|
+
return { ok: false, version: null };
|
|
141
|
+
let version = null;
|
|
142
|
+
try {
|
|
143
|
+
const body = await res.json();
|
|
144
|
+
if (typeof body?.version === 'string' && body.version.trim())
|
|
145
|
+
version = body.version;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
version = null;
|
|
149
|
+
}
|
|
150
|
+
return { ok: true, version };
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return { ok: false, version: null };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function writeGeneratedConfig(dir, proxy, secret) {
|
|
157
|
+
const { mixed, controller, group } = portsOf(proxy);
|
|
158
|
+
const rendered = renderMihomoConfig({
|
|
159
|
+
mixedPort: mixed,
|
|
160
|
+
controllerPort: controller,
|
|
161
|
+
secret,
|
|
162
|
+
group,
|
|
163
|
+
routingMode: proxy.mihomo?.routingMode,
|
|
164
|
+
groupType: proxy.mihomo?.groupType,
|
|
165
|
+
groupInterval: proxy.mihomo?.groupInterval,
|
|
166
|
+
groupTolerance: proxy.mihomo?.groupTolerance,
|
|
167
|
+
testUrl: proxy.mihomo?.testUrl,
|
|
168
|
+
rules: proxy.mihomo?.rules ?? [],
|
|
169
|
+
subscriptions: proxy.mihomo?.subscriptions ?? [],
|
|
170
|
+
manualNodes: proxy.mihomo?.manualNodes ?? [],
|
|
171
|
+
});
|
|
172
|
+
fs.mkdirSync(path.join(dir, 'providers'), { recursive: true });
|
|
173
|
+
const yamlPath = path.join(dir, 'config.yaml');
|
|
174
|
+
const next = rendered.yaml;
|
|
175
|
+
let changed = true;
|
|
176
|
+
try {
|
|
177
|
+
changed = fs.readFileSync(yamlPath, 'utf8') !== next;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
changed = true;
|
|
181
|
+
}
|
|
182
|
+
if (changed) {
|
|
183
|
+
// Atomic: the file carries the controller secret and subscription URLs, and
|
|
184
|
+
// mihomo parses it on reload — a torn write would fail the whole config.
|
|
185
|
+
const tmp = `${yamlPath}.tmp`;
|
|
186
|
+
fs.writeFileSync(tmp, next, 'utf8');
|
|
187
|
+
renameWithRetry(tmp, yamlPath);
|
|
188
|
+
}
|
|
189
|
+
return { yamlPath, summary: mihomoConfigSummary(rendered, { mixedPort: mixed, controllerPort: controller }), changed };
|
|
190
|
+
}
|
|
191
|
+
function ensureSecret(proxy, deps) {
|
|
192
|
+
const existing = (proxy.mihomo?.controllerSecret || '').trim();
|
|
193
|
+
if (existing)
|
|
194
|
+
return existing;
|
|
195
|
+
const secret = newSecret();
|
|
196
|
+
proxy.mihomo = { ...(proxy.mihomo ?? {}), controllerSecret: secret };
|
|
197
|
+
try {
|
|
198
|
+
(deps.persistSecret ?? persistMihomoSecret)(secret);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
const message = err instanceof Error ? err.message : 'persist failed';
|
|
202
|
+
console.warn(`[Clash] could not persist controller secret (${message})`);
|
|
203
|
+
}
|
|
204
|
+
return secret;
|
|
205
|
+
}
|
|
206
|
+
function clientFor(port, secret, fetchImpl) {
|
|
207
|
+
return new MihomoClient({ port, secret, fetchImpl, timeoutMs: 8000 });
|
|
208
|
+
}
|
|
209
|
+
/** How long a remembered selection is retried after the core comes up. A
|
|
210
|
+
* provider-backed node only exists once mihomo has fetched the subscription,
|
|
211
|
+
* which routinely finishes AFTER the controller answers /version; without the
|
|
212
|
+
* retry a restart silently leaves the group on its first member until the
|
|
213
|
+
* operator picks again. */
|
|
214
|
+
const SELECTION_WAIT_MS = 30_000;
|
|
215
|
+
const SELECTION_POLL_MS = 500;
|
|
216
|
+
/** One attempt: select the remembered node only when the group actually lists
|
|
217
|
+
* it. Returns false while the provider snapshot is still loading. */
|
|
218
|
+
async function trySelect(client, group, node) {
|
|
219
|
+
try {
|
|
220
|
+
const snapshot = await client.proxies();
|
|
221
|
+
if (!snapshot.proxies[group]?.all?.includes(node))
|
|
222
|
+
return false;
|
|
223
|
+
await client.select(group, node);
|
|
224
|
+
console.log(`[Clash] selected "${node}" in group "${group}"`);
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Re-apply the operator's remembered node UNDER A MANUAL GROUP. The first
|
|
233
|
+
* attempt is awaited so an already-loaded group switches immediately (startup
|
|
234
|
+
* goes through the saved node, no operator action); a provider that is still
|
|
235
|
+
* downloading is retried in the BACKGROUND, because blocking boot on a slow
|
|
236
|
+
* subscription buys nothing. Never throws: a missing node just leaves the
|
|
237
|
+
* core's default in place.
|
|
238
|
+
*
|
|
239
|
+
* `url-test` / `fallback` are skipped on purpose: their choice belongs to the
|
|
240
|
+
* core, and `PUT /proxies/{group}` is `URLTest.Set` — a PIN. A pinned node wins
|
|
241
|
+
* inside mihomo's `URLTest.fast()` for as long as it stays alive, so restoring
|
|
242
|
+
* the remembered pick would silently freeze auto-switching until the pinned
|
|
243
|
+
* node died.
|
|
244
|
+
*/
|
|
245
|
+
async function applySelection(proxy, port, secret, fetchImpl) {
|
|
246
|
+
if ((proxy.mihomo?.groupType ?? 'select') !== 'select')
|
|
247
|
+
return;
|
|
248
|
+
const group = proxy.mihomo?.selectedGroup || DEFAULT_MIHOMO_GROUP;
|
|
249
|
+
const node = proxy.mihomo?.selectedNodes?.[group];
|
|
250
|
+
if (!node)
|
|
251
|
+
return;
|
|
252
|
+
const client = clientFor(port, secret, fetchImpl);
|
|
253
|
+
if (await trySelect(client, group, node))
|
|
254
|
+
return;
|
|
255
|
+
void (async () => {
|
|
256
|
+
const deadline = Date.now() + SELECTION_WAIT_MS;
|
|
257
|
+
while (Date.now() < deadline) {
|
|
258
|
+
await new Promise((resolve) => setTimeout(resolve, SELECTION_POLL_MS));
|
|
259
|
+
if (await trySelect(client, group, node))
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
console.warn(`[Clash] remembered node "${node}" is not in group "${group}"; leaving the core default`);
|
|
263
|
+
})();
|
|
264
|
+
}
|
|
265
|
+
function defaultSpawn(cmd, args, opts) {
|
|
266
|
+
return spawn(cmd, args, opts);
|
|
267
|
+
}
|
|
268
|
+
function defaultKill(pid) {
|
|
269
|
+
try {
|
|
270
|
+
if (process.platform === 'win32') {
|
|
271
|
+
const res = spawnSync('taskkill', ['/F', '/T', '/PID', String(pid)], { windowsHide: true });
|
|
272
|
+
return res.status === 0;
|
|
273
|
+
}
|
|
274
|
+
process.kill(pid, 'SIGTERM');
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function defaultPidByPort(port) {
|
|
282
|
+
try {
|
|
283
|
+
if (process.platform === 'win32') {
|
|
284
|
+
const res = spawnSync('powershell', ['-NoProfile', '-Command', `(Get-NetTCPConnection -LocalPort ${port} -State Listen | Select-Object -First 1).OwningProcess`], { windowsHide: true, encoding: 'utf8' });
|
|
285
|
+
const pid = Number(res.stdout?.trim());
|
|
286
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
287
|
+
}
|
|
288
|
+
const res = spawnSync('lsof', ['-ti', `tcp:${port}`], { encoding: 'utf8' });
|
|
289
|
+
const pid = Number(res.stdout?.trim().split(/\r?\n/)[0]);
|
|
290
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function fail(code, error) {
|
|
297
|
+
remember(error, code);
|
|
298
|
+
return { ok: false, action: 'noop', reused: false, pid: null, version: null, error, code };
|
|
299
|
+
}
|
|
300
|
+
async function startUnlocked(deps) {
|
|
301
|
+
const proxy = proxyOf(deps);
|
|
302
|
+
if (!shouldRun(proxy)) {
|
|
303
|
+
// Diagnostic only: the console renders this code ('disabled') through its own
|
|
304
|
+
// i18n table, so this English text is a log/debug fallback, never the toast.
|
|
305
|
+
// Reaching it means `autoStart` is false — the start route flips that flag
|
|
306
|
+
// before calling in, so a direct caller is the only way here.
|
|
307
|
+
return fail('disabled', 'the Clash core is marked stopped (proxy.mihomo.autoStart is false)');
|
|
308
|
+
}
|
|
309
|
+
const { mixed, controller } = portsOf(proxy);
|
|
310
|
+
if (mixed === controller)
|
|
311
|
+
return fail('port-collision', 'Clash mixedPort and controllerPort must differ');
|
|
312
|
+
const secret = ensureSecret(proxy, deps);
|
|
313
|
+
const dir = mihomoWorkDir(deps);
|
|
314
|
+
let written;
|
|
315
|
+
try {
|
|
316
|
+
written = writeGeneratedConfig(dir, proxy, secret);
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
const message = err instanceof Error ? err.message : 'config write failed';
|
|
320
|
+
return fail('spawn-failed', `could not write the Clash config (${message})`);
|
|
321
|
+
}
|
|
322
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
323
|
+
const health = await probe(fetchImpl, controller, secret);
|
|
324
|
+
if (health.ok) {
|
|
325
|
+
if (written.changed) {
|
|
326
|
+
try {
|
|
327
|
+
await clientFor(controller, secret, fetchImpl).reloadConfig(written.yamlPath);
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
const message = err instanceof Error ? err.message : 'reload failed';
|
|
331
|
+
return fail('reload-failed', `Clash config reload failed (${message})`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const pidFile = path.join(dir, 'mihomo.pid');
|
|
335
|
+
const recorded = readPid(pidFile);
|
|
336
|
+
if (!ownerOf(dir))
|
|
337
|
+
writeOwner(dir, 'adopted');
|
|
338
|
+
await applySelection(proxy, controller, secret, fetchImpl);
|
|
339
|
+
remember(null, null);
|
|
340
|
+
console.log(`[Clash] ${written.changed ? 'reloaded' : 'adopted'} ${written.summary}`);
|
|
341
|
+
return {
|
|
342
|
+
ok: true,
|
|
343
|
+
action: written.changed ? 'reload' : 'adopt',
|
|
344
|
+
reused: true,
|
|
345
|
+
pid: recorded && pidAlive(recorded) ? recorded : null,
|
|
346
|
+
version: health.version,
|
|
347
|
+
error: null,
|
|
348
|
+
code: null,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const resolved = (deps.binaryResolver ?? resolveMihomoBinary)(proxy.mihomo?.binaryPath);
|
|
352
|
+
if (!resolved.path)
|
|
353
|
+
return fail('binary-missing', 'Clash core binary not found — install it or set proxy.mihomo.binaryPath');
|
|
354
|
+
const spawnImpl = deps.spawnImpl ?? defaultSpawn;
|
|
355
|
+
const spawnState = { error: null, exitCode: null };
|
|
356
|
+
let child;
|
|
357
|
+
try {
|
|
358
|
+
child = spawnImpl(resolved.path, ['-d', dir, '-f', written.yamlPath], {
|
|
359
|
+
cwd: dir,
|
|
360
|
+
detached: false,
|
|
361
|
+
stdio: 'ignore',
|
|
362
|
+
windowsHide: true,
|
|
363
|
+
shell: false,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
const message = err instanceof Error ? err.message : 'spawn failed';
|
|
368
|
+
return fail('spawn-failed', `failed to spawn the Clash core (${message})`);
|
|
369
|
+
}
|
|
370
|
+
child.on?.('error', (err) => {
|
|
371
|
+
spawnState.error = err;
|
|
372
|
+
});
|
|
373
|
+
child.on?.('exit', (code) => {
|
|
374
|
+
spawnState.exitCode = code;
|
|
375
|
+
});
|
|
376
|
+
child.unref?.();
|
|
377
|
+
if (child.pid) {
|
|
378
|
+
writePid(path.join(dir, 'mihomo.pid'), child.pid);
|
|
379
|
+
writeOwner(dir, 'spawned');
|
|
380
|
+
}
|
|
381
|
+
const readyTimeoutMs = deps.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS;
|
|
382
|
+
const pollIntervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
383
|
+
const deadline = Date.now() + readyTimeoutMs;
|
|
384
|
+
for (;;) {
|
|
385
|
+
if (spawnState.error) {
|
|
386
|
+
const code = spawnState.error.code;
|
|
387
|
+
return fail('spawn-exited', `the Clash core exited immediately (${spawnState.error.message}${code ? ` [${code}]` : ''})`);
|
|
388
|
+
}
|
|
389
|
+
if (spawnState.exitCode !== null) {
|
|
390
|
+
return fail('spawn-exited', `the Clash core exited immediately (code ${spawnState.exitCode})`);
|
|
391
|
+
}
|
|
392
|
+
const again = await probe(fetchImpl, controller, secret);
|
|
393
|
+
if (again.ok) {
|
|
394
|
+
await applySelection(proxy, controller, secret, fetchImpl);
|
|
395
|
+
remember(null, null);
|
|
396
|
+
console.log(`[Clash] started ${written.summary}${child.pid ? ` pid=${child.pid}` : ''}`);
|
|
397
|
+
return { ok: true, action: 'start', reused: false, pid: child.pid ?? null, version: again.version, error: null, code: null };
|
|
398
|
+
}
|
|
399
|
+
if (Date.now() >= deadline) {
|
|
400
|
+
return fail('not-ready', `the Clash core did not become ready within ${Math.round(readyTimeoutMs / 1000)}s`);
|
|
401
|
+
}
|
|
402
|
+
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async function stopUnlocked(deps, onlySpawned) {
|
|
406
|
+
const proxy = proxyOf(deps);
|
|
407
|
+
const { controller } = portsOf(proxy);
|
|
408
|
+
const dir = mihomoWorkDir(deps);
|
|
409
|
+
const pidFile = path.join(dir, 'mihomo.pid');
|
|
410
|
+
const recorded = readPid(pidFile);
|
|
411
|
+
const owner = ownerOf(dir);
|
|
412
|
+
if (onlySpawned && owner !== 'spawned') {
|
|
413
|
+
return { ok: true, action: 'noop', reused: false, pid: null, version: null, error: null, code: null };
|
|
414
|
+
}
|
|
415
|
+
const kill = deps.killTreeImpl ?? defaultKill;
|
|
416
|
+
let pid = recorded && pidAlive(recorded) ? recorded : null;
|
|
417
|
+
if (pid == null && !onlySpawned) {
|
|
418
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
419
|
+
const secret = (proxy.mihomo?.controllerSecret || '').trim();
|
|
420
|
+
const health = await probe(fetchImpl, controller, secret);
|
|
421
|
+
if (health.ok) {
|
|
422
|
+
pid = (deps.pidByPortImpl ?? defaultPidByPort)(controller);
|
|
423
|
+
if (pid == null)
|
|
424
|
+
return fail('pid-unknown', 'the Clash core is listening but its pid could not be identified');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (pid == null) {
|
|
428
|
+
try {
|
|
429
|
+
fs.unlinkSync(pidFile);
|
|
430
|
+
}
|
|
431
|
+
catch { /* already gone */ }
|
|
432
|
+
try {
|
|
433
|
+
fs.unlinkSync(path.join(dir, 'owner'));
|
|
434
|
+
}
|
|
435
|
+
catch { /* already gone */ }
|
|
436
|
+
remember(null, null);
|
|
437
|
+
return { ok: true, action: 'noop', reused: false, pid: null, version: null, error: null, code: null };
|
|
438
|
+
}
|
|
439
|
+
if (!kill(pid))
|
|
440
|
+
return fail('kill-failed', `failed to terminate the Clash core process ${pid}`);
|
|
441
|
+
try {
|
|
442
|
+
fs.unlinkSync(pidFile);
|
|
443
|
+
}
|
|
444
|
+
catch { /* already gone */ }
|
|
445
|
+
try {
|
|
446
|
+
fs.unlinkSync(path.join(dir, 'owner'));
|
|
447
|
+
}
|
|
448
|
+
catch { /* already gone */ }
|
|
449
|
+
remember(null, null);
|
|
450
|
+
console.log(`[Clash] stopped pid=${pid}`);
|
|
451
|
+
return { ok: true, action: 'stop', reused: false, pid, version: null, error: null, code: null };
|
|
452
|
+
}
|
|
453
|
+
export function getMihomoStatus(extra) {
|
|
454
|
+
const deps = merged(extra);
|
|
455
|
+
const proxy = proxyOf(deps);
|
|
456
|
+
const { mixed, controller, secret } = portsOf(proxy);
|
|
457
|
+
const resolved = (deps.binaryResolver ?? resolveMihomoBinary)(proxy.mihomo?.binaryPath);
|
|
458
|
+
const dir = mihomoWorkDir(deps);
|
|
459
|
+
const recorded = readPid(path.join(dir, 'mihomo.pid'));
|
|
460
|
+
const alive = recorded != null && pidAlive(recorded);
|
|
461
|
+
const owner = ownerOf(dir);
|
|
462
|
+
return probe(deps.fetchImpl ?? fetch, controller, secret).then((health) => ({
|
|
463
|
+
installed: resolved.path != null,
|
|
464
|
+
binaryPath: resolved.path,
|
|
465
|
+
running: health.ok,
|
|
466
|
+
managed: owner === 'spawned' && alive,
|
|
467
|
+
adopted: owner === 'adopted' && (health.ok || alive),
|
|
468
|
+
pid: alive ? recorded : null,
|
|
469
|
+
mode: proxy.mode === 'mihomo' ? 'mihomo' : 'manual',
|
|
470
|
+
/** The outbound master switch — what `proxy.enabled` means, unchanged. */
|
|
471
|
+
enabled: proxy.enabled === true,
|
|
472
|
+
/** Whether the core is SUPPOSED to be running (same rule as `shouldRun`).
|
|
473
|
+
* Distinct from `running`, which is what the controller actually answers. */
|
|
474
|
+
autoStart: proxy.mihomo?.autoStart ?? (proxy.enabled === true && proxy.mode === 'mihomo'),
|
|
475
|
+
mixedPort: mixed,
|
|
476
|
+
controllerPort: controller,
|
|
477
|
+
secretConfigured: secret.length > 0,
|
|
478
|
+
version: health.version,
|
|
479
|
+
error: lastError.error,
|
|
480
|
+
code: lastError.code,
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
export function startMihomoSidecar(extra) {
|
|
484
|
+
const deps = merged(extra);
|
|
485
|
+
return enqueue(() => startUnlocked(deps));
|
|
486
|
+
}
|
|
487
|
+
export function stopMihomoSidecar(extra) {
|
|
488
|
+
const deps = merged(extra);
|
|
489
|
+
return enqueue(() => stopUnlocked(deps, false));
|
|
490
|
+
}
|
|
491
|
+
export function restartMihomoSidecar(extra) {
|
|
492
|
+
const deps = merged(extra);
|
|
493
|
+
return enqueue(async () => {
|
|
494
|
+
const stopped = await stopUnlocked(deps, false);
|
|
495
|
+
if (!stopped.ok)
|
|
496
|
+
return stopped;
|
|
497
|
+
return startUnlocked(deps);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Bring the sidecar in line with the saved proxy section.
|
|
502
|
+
* Runs at boot and after a config save. Never throws.
|
|
503
|
+
*/
|
|
504
|
+
export async function reconcileMihomoSidecar(proxy, extra) {
|
|
505
|
+
const deps = merged({ ...extra, ...(proxy ? { config: proxy } : {}) });
|
|
506
|
+
const current = proxyOf(deps);
|
|
507
|
+
if (!shouldRun(current)) {
|
|
508
|
+
return enqueue(() => stopUnlocked(deps, true));
|
|
509
|
+
}
|
|
510
|
+
return startMihomoSidecar(deps);
|
|
511
|
+
}
|
|
512
|
+
/** Test-only: the last log-safe failure, so suites can assert the secret stayed out of it. */
|
|
513
|
+
export function mihomoLastErrorForTests() {
|
|
514
|
+
return lastError;
|
|
515
|
+
}
|
|
@@ -61,7 +61,14 @@ export interface EffectiveQuotaPlan {
|
|
|
61
61
|
* documented). DSL entries can be replaced per provider by an `override:`
|
|
62
62
|
* config entry.
|
|
63
63
|
*/
|
|
64
|
-
export declare function buildEffectivePlan(quotaProbes: Record<string, QuotaProbeConfigEntry[]> | undefined, providerBaseUrl: (providerId: string) => string | undefined
|
|
64
|
+
export declare function buildEffectivePlan(quotaProbes: Record<string, QuotaProbeConfigEntry[]> | undefined, providerBaseUrl: (providerId: string) => string | undefined,
|
|
65
|
+
/** L-e seam (ADR-0009): candidate provider ids for the plugin layer plus
|
|
66
|
+
* the per-id capability lookup (a loaded model-service plugin's
|
|
67
|
+
* quotaCheck, wrapped as an adapter). Fills ONLY uncovered providers. */
|
|
68
|
+
pluginLayer?: {
|
|
69
|
+
candidateIds: () => Iterable<string>;
|
|
70
|
+
adapterFor: (providerId: string) => QuotaCodeAdapter | undefined;
|
|
71
|
+
}): EffectiveQuotaPlan;
|
|
65
72
|
export interface RunProbeOpts {
|
|
66
73
|
/** Raw key — in-process only, the same consumer contract as the executor
|
|
67
74
|
* chain — raw keys travel in process memory only, per the credential
|
|
@@ -69,7 +76,7 @@ export interface RunProbeOpts {
|
|
|
69
76
|
key: string;
|
|
70
77
|
providerId: string;
|
|
71
78
|
/** Display-safe prefix supplied by the caller (chain entry or the
|
|
72
|
-
*
|
|
79
|
+
* default-credential degeneracy) — the identity every snapshot hangs on. */
|
|
73
80
|
prefix: string;
|
|
74
81
|
fetchImpl?: typeof fetch;
|
|
75
82
|
now?: () => number;
|
|
@@ -122,7 +122,11 @@ export function buildConfigEntry(providerId, index, raw, originProviderBaseUrl,
|
|
|
122
122
|
* documented). DSL entries can be replaced per provider by an `override:`
|
|
123
123
|
* config entry.
|
|
124
124
|
*/
|
|
125
|
-
export function buildEffectivePlan(quotaProbes, providerBaseUrl
|
|
125
|
+
export function buildEffectivePlan(quotaProbes, providerBaseUrl,
|
|
126
|
+
/** L-e seam (ADR-0009): candidate provider ids for the plugin layer plus
|
|
127
|
+
* the per-id capability lookup (a loaded model-service plugin's
|
|
128
|
+
* quotaCheck, wrapped as an adapter). Fills ONLY uncovered providers. */
|
|
129
|
+
pluginLayer) {
|
|
126
130
|
const byProvider = new Map();
|
|
127
131
|
const rejected = [];
|
|
128
132
|
// L-c adapters first (absolute coverage).
|
|
@@ -174,6 +178,20 @@ export function buildEffectivePlan(quotaProbes, providerBaseUrl) {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
}
|
|
181
|
+
// L-e plugin adapters (lowest precedence): a vendor plugin that declares
|
|
182
|
+
// the quotaCheck capability covers its wire's providers — but only where
|
|
183
|
+
// no release knowledge (L-b/L-c) and no operator entry (L-d) already
|
|
184
|
+
// speaks for the provider. The plugin owns the endpoint knowledge; core
|
|
185
|
+
// owns the scheduling, the store and the display vocabulary.
|
|
186
|
+
if (pluginLayer) {
|
|
187
|
+
for (const providerId of pluginLayer.candidateIds()) {
|
|
188
|
+
if (byProvider.has(providerId))
|
|
189
|
+
continue;
|
|
190
|
+
const adapter = pluginLayer.adapterFor(providerId);
|
|
191
|
+
if (adapter)
|
|
192
|
+
byProvider.set(providerId, { kind: 'adapter', adapter });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
177
195
|
return { byProvider, rejected };
|
|
178
196
|
}
|
|
179
197
|
export async function runDslProbe(entry, opts) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RouterConfig } from '../config/types.js';
|
|
2
|
-
import { type EffectiveQuotaPlan } from './engine.js';
|
|
2
|
+
import { buildEffectivePlan, type EffectiveQuotaPlan } from './engine.js';
|
|
3
3
|
/**
|
|
4
4
|
* Due-based quota scheduler, shaped after
|
|
5
5
|
* resilience/health-prober.ts (the due-decision/execution split is borrowed
|
|
@@ -74,6 +74,9 @@ export interface QuotaProberDeps {
|
|
|
74
74
|
/** Test seam — plan() resolves pairs through this, run() fetches through it. */
|
|
75
75
|
fetchImpl?: typeof fetch;
|
|
76
76
|
now?: () => number;
|
|
77
|
+
/** L-e plugin layer (ADR-0009 §5): candidate ids + the quotaCheck
|
|
78
|
+
* capability lookup. Omitted = no plugin quota coverage. */
|
|
79
|
+
pluginLayer?: Parameters<typeof buildEffectivePlan>[2];
|
|
77
80
|
}
|
|
78
81
|
export declare class QuotaProber {
|
|
79
82
|
private readonly registry;
|
|
@@ -81,6 +84,7 @@ export declare class QuotaProber {
|
|
|
81
84
|
private readonly intervalMs;
|
|
82
85
|
private readonly fetchImpl?;
|
|
83
86
|
private readonly nowFn;
|
|
87
|
+
private readonly pluginLayer;
|
|
84
88
|
private timer;
|
|
85
89
|
/** The one in-flight cycle — the timer tick and a manual refresh share it. */
|
|
86
90
|
private current;
|
|
@@ -94,9 +98,9 @@ export declare class QuotaProber {
|
|
|
94
98
|
/** Rebuild the effective entry set (boot + every config save hot path). */
|
|
95
99
|
reloadConfig(): void;
|
|
96
100
|
private buildPlan;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Entries rejected at load (validation failures) — console surfaces them.
|
|
103
|
+
*/
|
|
100
104
|
getRejectedEntries(): {
|
|
101
105
|
id: string;
|
|
102
106
|
error: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { keyHashPrefix } from '../opencode/credentials/types.js';
|
|
2
2
|
import { buildEffectivePlan, probePair, clampTtl } from './engine.js';
|
|
3
3
|
import { getQuotaStore } from './store.js';
|
|
4
|
-
|
|
4
|
+
import { clampProbeIntervalMs, DEFAULT_PROBE_INTERVAL_MS } from '../utils/probe-interval.js';
|
|
5
5
|
/** Fraction of the TTL randomized per due date (spread, never a stampede). */
|
|
6
6
|
const JITTER_FRACTION = 0.15;
|
|
7
7
|
/** Engine-level 429 backoff: base, factor, ceiling. */
|
|
@@ -23,6 +23,7 @@ export class QuotaProber {
|
|
|
23
23
|
intervalMs;
|
|
24
24
|
fetchImpl;
|
|
25
25
|
nowFn;
|
|
26
|
+
pluginLayer;
|
|
26
27
|
timer = null;
|
|
27
28
|
/** The one in-flight cycle — the timer tick and a manual refresh share it. */
|
|
28
29
|
current = null;
|
|
@@ -35,9 +36,11 @@ export class QuotaProber {
|
|
|
35
36
|
constructor(deps) {
|
|
36
37
|
this.registry = deps.registry;
|
|
37
38
|
this.configFn = deps.config;
|
|
38
|
-
this.intervalMs =
|
|
39
|
+
this.intervalMs =
|
|
40
|
+
deps.intervalMs ?? clampProbeIntervalMs(deps.config().quota?.intervalMs ?? DEFAULT_PROBE_INTERVAL_MS);
|
|
39
41
|
this.fetchImpl = deps.fetchImpl;
|
|
40
42
|
this.nowFn = deps.now ?? Date.now;
|
|
43
|
+
this.pluginLayer = deps.pluginLayer;
|
|
41
44
|
this.plan = this.buildPlan();
|
|
42
45
|
}
|
|
43
46
|
/** Rebuild the effective entry set (boot + every config save hot path). */
|
|
@@ -46,15 +49,11 @@ export class QuotaProber {
|
|
|
46
49
|
}
|
|
47
50
|
buildPlan() {
|
|
48
51
|
const cfg = this.configFn();
|
|
49
|
-
return buildEffectivePlan(cfg.quotaProbes, (pid) => this.registry.getProviderBaseUrl(pid));
|
|
52
|
+
return buildEffectivePlan(cfg.quotaProbes, (pid) => this.registry.getProviderBaseUrl(pid), this.pluginLayer);
|
|
50
53
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return DEFAULT_TICK_MS;
|
|
55
|
-
return Math.max(10_000, Math.min(3_600_000, ms));
|
|
56
|
-
}
|
|
57
|
-
/** Entries rejected at load (validation failures) — console surfaces them. */
|
|
54
|
+
/**
|
|
55
|
+
* Entries rejected at load (validation failures) — console surfaces them.
|
|
56
|
+
*/
|
|
58
57
|
getRejectedEntries() {
|
|
59
58
|
return this.plan.rejected;
|
|
60
59
|
}
|