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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ProviderRegistry } from '../providers/registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* The ONE install pipeline (ADR-0017 §6 / ADR-0037).
|
|
4
|
+
*
|
|
5
|
+
* A package arrives from exactly two places: the console's file picker (raw
|
|
6
|
+
* bytes in a POST body) and the plugin market (bytes the backend downloaded
|
|
7
|
+
* from a repository the registry names). Both must land identically — same
|
|
8
|
+
* version gate, same engine parking, same discard-and-roll-back on a failed
|
|
9
|
+
* load, same preset registration, same pool refresh — so there is one function,
|
|
10
|
+
* not two routes that agree today and drift tomorrow.
|
|
11
|
+
*
|
|
12
|
+
* Answers a status + body rather than touching a reply: the caller owns the
|
|
13
|
+
* envelope it sends (`status: 'error'` vs `status: 'ok'`), and the market verb
|
|
14
|
+
* adds nothing to it.
|
|
15
|
+
*/
|
|
16
|
+
export interface PluginInstallOutcome {
|
|
17
|
+
statusCode: number;
|
|
18
|
+
body: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export declare function installPluginBytes(bytes: Uint8Array, registry: ProviderRegistry,
|
|
21
|
+
/** The caller states that a LOWER version is intentional. `installPluginPackage`
|
|
22
|
+
* refuses a downgrade because the console's upload picker cannot tell a
|
|
23
|
+
* mistake from a rollback — but the market's "install this tag" verb CAN: the
|
|
24
|
+
* operator picked that version off a list. */
|
|
25
|
+
opts?: {
|
|
26
|
+
allowDowngrade?: boolean;
|
|
27
|
+
}): Promise<PluginInstallOutcome>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { refreshDirectPool } from '../providers/boot-direct.js';
|
|
2
|
+
import { discardPluginPackage, installPluginPackage, listInstalledPlugins, loadInstalledPlugins, packageIdOf, pluginPackageZip, syncPluginPresets, } from './host.js';
|
|
3
|
+
export async function installPluginBytes(bytes, registry,
|
|
4
|
+
/** The caller states that a LOWER version is intentional. `installPluginPackage`
|
|
5
|
+
* refuses a downgrade because the console's upload picker cannot tell a
|
|
6
|
+
* mistake from a rollback — but the market's "install this tag" verb CAN: the
|
|
7
|
+
* operator picked that version off a list. */
|
|
8
|
+
opts = {}) {
|
|
9
|
+
// Snapshot the version this upload is about to REPLACE (a packaged one — a
|
|
10
|
+
// dev-tree plugin is not ours to materialize here). A failed upgrade must not
|
|
11
|
+
// delete a working install. `disabled` does NOT disqualify the snapshot: a
|
|
12
|
+
// switched-off package is still an install the operator owns, and a broken
|
|
13
|
+
// upload over it would otherwise leave them with nothing to roll back to.
|
|
14
|
+
let previous;
|
|
15
|
+
try {
|
|
16
|
+
const target = packageIdOf(new Uint8Array(bytes));
|
|
17
|
+
const existing = listInstalledPlugins().find((p) => p.id === target);
|
|
18
|
+
if (existing?.source === 'packaged')
|
|
19
|
+
previous = await pluginPackageZip(target);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// unreadable upload: installPluginPackage below reports it properly
|
|
23
|
+
}
|
|
24
|
+
const { id: installed, version: installedVersion, replacedVersion } = installPluginPackage(new Uint8Array(bytes), opts.allowDowngrade ? { allowDowngrade: true } : {});
|
|
25
|
+
await loadInstalledPlugins();
|
|
26
|
+
const plugins = listInstalledPlugins();
|
|
27
|
+
// An engine-INCOMPATIBLE package is not a broken one: it is on disk, it is
|
|
28
|
+
// listed as disabled, and it becomes usable in place once the matching side is
|
|
29
|
+
// updated. Discarding it would only make the operator upload the same file
|
|
30
|
+
// again after that update, so the discard / rollback path below stays reserved
|
|
31
|
+
// for packages that genuinely fail to load. The test is the ROW'S OWN flag,
|
|
32
|
+
// never `disabled && !loaded` — an operator-disabled package satisfies that
|
|
33
|
+
// shape too, and a failed load of one must still be discarded and rolled back.
|
|
34
|
+
//
|
|
35
|
+
// The upload itself is PARKED, not refused (ADR-0036 §5): the engine gate lets
|
|
36
|
+
// an incompatible package land and this branch reports it in the 200 body
|
|
37
|
+
// (`incompatible: true`) so the console toasts the honest outcome instead of a
|
|
38
|
+
// green "installed" over a dead row. A swap that would displace a package this
|
|
39
|
+
// host CAN run is still refused up front, inside `installPluginPackage`.
|
|
40
|
+
const view = plugins.find((p) => p.id === installed);
|
|
41
|
+
const incompatible = view?.incompatible === true;
|
|
42
|
+
if (!view?.loaded && !incompatible) {
|
|
43
|
+
// a package that cannot load would re-fail every boot — discard it; discard
|
|
44
|
+
// BEFORE preset sync / pool refresh so a broken package registers nothing
|
|
45
|
+
discardPluginPackage(installed);
|
|
46
|
+
// Roll BACK to the version that was working until this upload, so a bad
|
|
47
|
+
// upgrade is a no-op instead of a lost plugin.
|
|
48
|
+
if (previous) {
|
|
49
|
+
// A ROLLBACK is the one legitimate downgrade: the caller did not ask for
|
|
50
|
+
// it, the loader did — the version guard exists for uploads, and it must
|
|
51
|
+
// not block the recovery path.
|
|
52
|
+
installPluginPackage(previous, { allowDowngrade: true });
|
|
53
|
+
await loadInstalledPlugins();
|
|
54
|
+
return {
|
|
55
|
+
statusCode: 422,
|
|
56
|
+
body: {
|
|
57
|
+
status: 'error',
|
|
58
|
+
error: `package rejected and discarded (${view?.error ?? 'unknown error'}); rolled back to the previously installed version`,
|
|
59
|
+
plugins: listInstalledPlugins(),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Reload AFTER the discard: otherwise the response would hand the console a
|
|
64
|
+
// row for a package that is no longer on disk (the list is the disk's truth,
|
|
65
|
+
// not the last failed import's).
|
|
66
|
+
await loadInstalledPlugins();
|
|
67
|
+
return {
|
|
68
|
+
statusCode: 422,
|
|
69
|
+
body: {
|
|
70
|
+
status: 'error',
|
|
71
|
+
error: `package installed but failed to load (discarded): ${view?.error ?? 'unknown error'}`,
|
|
72
|
+
plugins: listInstalledPlugins(),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// presets register at install time (same contract as boot/reload) — after a
|
|
77
|
+
// verified successful load, BEFORE the pool refresh so the defs are routable
|
|
78
|
+
// immediately on the next dispatch. An engine-refused package reaches this
|
|
79
|
+
// line too: it loaded nothing, so `syncPluginPresets` has nothing of it to
|
|
80
|
+
// register, and its row stays DISABLED in `plugins`.
|
|
81
|
+
const registered = await syncPluginPresets();
|
|
82
|
+
await refreshDirectPool(registry);
|
|
83
|
+
return {
|
|
84
|
+
statusCode: 200,
|
|
85
|
+
body: {
|
|
86
|
+
status: 'ok',
|
|
87
|
+
id: installed,
|
|
88
|
+
version: installedVersion,
|
|
89
|
+
replacedVersion,
|
|
90
|
+
plugins,
|
|
91
|
+
registered,
|
|
92
|
+
// Kept in the 200 body so the console can toast the honest outcome: the
|
|
93
|
+
// bytes landed, but the package answers nothing until one side is updated.
|
|
94
|
+
// A green "installed" toast over a red row is the one reading an operator
|
|
95
|
+
// must not be left with.
|
|
96
|
+
...(incompatible ? { incompatible: true, error: view.error } : {}),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* extension point is claimed SNI hosts; the runtime view reads `wires ?? []`),
|
|
11
11
|
* every other shape rule holds for both plugin types.
|
|
12
12
|
*/
|
|
13
|
-
import type {
|
|
13
|
+
import type { PluginDeclaredEgress, PluginConfigField, PluginManifest, PluginPart, PluginType } from './types.js';
|
|
14
14
|
/** The plugin ENGINE version the host implements — the version of the plugin
|
|
15
15
|
* surface core offers package code (`createPlugin(host)` and everything
|
|
16
16
|
* reachable from it).
|
|
@@ -26,7 +26,7 @@ import type { PluginClaimEgress, PluginConfigField, PluginManifest, PluginPart,
|
|
|
26
26
|
* Bump discipline: raising this constant is the ONLY step a surface change
|
|
27
27
|
* needs. Packages declaring the previous value are then refused with a
|
|
28
28
|
* sentence that says which side is behind; nothing else in core reads it. */
|
|
29
|
-
export declare const PLUGIN_ENGINE_VERSION =
|
|
29
|
+
export declare const PLUGIN_ENGINE_VERSION = 2;
|
|
30
30
|
/** The plugin CONTRACT this host implements — the same number by another name.
|
|
31
31
|
* Kept as its own constant because readers come at it from two directions: a
|
|
32
32
|
* package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
|
|
@@ -34,12 +34,12 @@ export declare const PLUGIN_ENGINE_VERSION = 1;
|
|
|
34
34
|
* `pluginEngineCompatibility`). Equal to {@link PLUGIN_ENGINE_VERSION} by
|
|
35
35
|
* construction, never by coincidence — see ADR-0036 on why there is one
|
|
36
36
|
* number. */
|
|
37
|
-
export declare const SUPPORTED_PLUGIN_API =
|
|
37
|
+
export declare const SUPPORTED_PLUGIN_API = 2;
|
|
38
38
|
/** Lower bound of the supported CONTRACT window. Equal to
|
|
39
39
|
* `SUPPORTED_PLUGIN_API` today: one contract, no legacy. Raising it retires
|
|
40
40
|
* the contracts in `[MIN, SUPPORTED)` — packages declaring them are refused
|
|
41
41
|
* exactly like a too-new one. */
|
|
42
|
-
export declare const MIN_SUPPORTED_PLUGIN_API =
|
|
42
|
+
export declare const MIN_SUPPORTED_PLUGIN_API = 2;
|
|
43
43
|
/** Why a package was refused. Two directions, never one sentence: a package
|
|
44
44
|
* that targeted a retired contract is fixed by installing its newer release;
|
|
45
45
|
* a package that needs a newer engine is fixed by updating the GATEWAY, and
|
|
@@ -76,28 +76,71 @@ export declare function pluginEngineCompatibility(manifest: PluginManifest): Plu
|
|
|
76
76
|
* by CORE, never by a package: it is an instruction about what the operator
|
|
77
77
|
* must DO, and it has to name the right side to act on. */
|
|
78
78
|
export declare function pluginEngineRefusal(manifest: PluginManifest): string | undefined;
|
|
79
|
-
/** Reject a package the host cannot run. Called at
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
79
|
+
/** Reject a package the host cannot run. Called at LOAD (and by the installer
|
|
80
|
+
* before it parks a package); the LOAD path turns the same verdict into a
|
|
81
|
+
* disabled console row instead of a failed one, so the message below is what
|
|
82
|
+
* the operator reads either way. */
|
|
83
83
|
export declare function assertSupportedPluginApi(manifest: PluginManifest): void;
|
|
84
|
+
/**
|
|
85
|
+
* The INSTALL-time gate (ADR-0036 §5, amended 2026-12-01). A package this host
|
|
86
|
+
* cannot run is still the operator's file: refusing it outright made the
|
|
87
|
+
* console reject a picker they had already made, and cost them a second upload
|
|
88
|
+
* of the same bytes after the upgrade that fixes it.
|
|
89
|
+
*
|
|
90
|
+
* So an incompatible upload is PARKED instead — written to disk and listed as a
|
|
91
|
+
* disabled `incompatible: true` row, exactly the state a package already on
|
|
92
|
+
* disk reaches when the gateway is downgraded under it (the loader refuses to
|
|
93
|
+
* import it either way; see `doLoadInstalledPlugins`). The row adopts the
|
|
94
|
+
* package in place the moment the mismatch is resolved, with no reinstall.
|
|
95
|
+
*
|
|
96
|
+
* The ONE thing a parked package may not do is take over an install that
|
|
97
|
+
* WORKS. Install is over-the-top — the previous package file is replaced and
|
|
98
|
+
* the console's rollback path deliberately skips incompatible rows — so parking
|
|
99
|
+
* over a working install would trade a running plugin for a dead one with
|
|
100
|
+
* nothing to restore it from. `replaced` is the manifest this upload would
|
|
101
|
+
* displace; taking that place requires uninstalling it first, which is the
|
|
102
|
+
* operator saying "yes, I mean the swap".
|
|
103
|
+
*/
|
|
104
|
+
export declare function assertInstallablePluginApi(manifest: PluginManifest, replaced?: PluginManifest): void;
|
|
84
105
|
/** Where a config field is edited: the plugin drawer (default), the Client Hub
|
|
85
106
|
* card the hook backs, or nowhere (stored, but dead for this hook). */
|
|
86
107
|
export declare const CONFIG_PLACEMENTS: readonly ["drawer", "card", "none"];
|
|
108
|
+
/**
|
|
109
|
+
* A declared `state` path, resolved to its path SEGMENTS relative to the OCR
|
|
110
|
+
* home — or undefined when the declaration would reach outside what uninstall
|
|
111
|
+
* owns. ONE reader, used by both the packager's refusal and the uninstall
|
|
112
|
+
* sweep: two spellings of this rule would drift, and the drift would delete (or
|
|
113
|
+
* refuse) the wrong files.
|
|
114
|
+
*
|
|
115
|
+
* Two shapes are accepted, because both are documented layouts:
|
|
116
|
+
*
|
|
117
|
+
* - under `plugins/` — the envelope the host SDK describes for outliving state
|
|
118
|
+
* (`plugins/workbuddy-auth.json`, `plugins/traffic/<id>`, `plugins/clients`);
|
|
119
|
+
* - a TOP-LEVEL entry whose name starts with `<id>.` / `<id>-` — vendor-neutral
|
|
120
|
+
* plugin files that predate the `plugins/` envelope. Top level only: a
|
|
121
|
+
* foreign envelope must never become deletable by a name prefix.
|
|
122
|
+
*
|
|
123
|
+
* Absolute paths, drive letters, `..` and empty segments are REFUSED rather than
|
|
124
|
+
* normalized (a normalizer would quietly turn a suspicious entry into a valid
|
|
125
|
+
* one), and the install roots/ledgers (`unpacked`, `bundled`, `config`,
|
|
126
|
+
* `traffic`) are core layout a package may not claim as a whole.
|
|
127
|
+
*/
|
|
128
|
+
export declare function resolvePluginStatePath(id: string, raw: unknown): string[] | undefined;
|
|
87
129
|
/**
|
|
88
130
|
* The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
|
|
89
|
-
* CORE. Once a package
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
131
|
+
* CORE. Once a package owns traffic — a claimed host, or a wire whose dial only
|
|
132
|
+
* the package can make — the leg under it is the package's business. The
|
|
133
|
+
* operator keeps the last word over the code they installed, and that word is
|
|
134
|
+
* spoken ONCE per plugin, not once per host or per wire: one switch that reaches
|
|
135
|
+
* every dial this package makes.
|
|
93
136
|
*
|
|
94
137
|
* The default is `inherit`, deliberately NOT the manifest's own declaration:
|
|
95
138
|
* the switch sits ABOVE the plugin's code, and a default of `proxy` would make
|
|
96
|
-
* every untouched plugin a silent override of its own `egressFor()`
|
|
97
|
-
* `inherit` is the state that leaves the
|
|
139
|
+
* every untouched plugin a silent override of its own `egressFor()` / `fetch`
|
|
140
|
+
* argument. `inherit` is the state that leaves the package in charge.
|
|
98
141
|
*/
|
|
99
|
-
export declare const
|
|
100
|
-
export declare const
|
|
142
|
+
export declare const PLUGIN_EGRESS_CONFIG_KEY = "egress";
|
|
143
|
+
export declare const PLUGIN_EGRESS_VALUES: readonly ["inherit", "proxy", "direct"];
|
|
101
144
|
/** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
|
|
102
145
|
* prefers to label them: a package that is both an ingress hook and a traffic
|
|
103
146
|
* owner reads as a client adapter first, because that is the half the operator
|
|
@@ -116,35 +159,44 @@ export declare function normalizePluginParts(manifest: PluginManifest): PluginPa
|
|
|
116
159
|
* is not a gateway at all. */
|
|
117
160
|
export declare function gatewayClaimedHosts(manifest: PluginManifest): string[];
|
|
118
161
|
/**
|
|
119
|
-
* Whether the console should offer the operator the plugin-level leg switch
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
162
|
+
* Whether the console should offer the operator the plugin-level leg switch.
|
|
163
|
+
*
|
|
164
|
+
* A gateway qualifies with at least one CONCRETE claimed host: a wildcard
|
|
165
|
+
* gateway claims no host, so a switch over it would be a switch over traffic it
|
|
166
|
+
* does not own (the same refusal the manifest validator applies to `egress` on
|
|
167
|
+
* `'*'`).
|
|
168
|
+
*
|
|
169
|
+
* A model-service qualifies with at least one WIRE, whether or not it dials
|
|
170
|
+
* itself: its traffic leaves this machine on the leg the operator pays for, and
|
|
171
|
+
* a package that spawns a vendor daemon (qoder-cli) has NO other way to be told
|
|
172
|
+
* (ADR-0022 amendment). The switch names a leg, never an address, so it grants a
|
|
173
|
+
* package no reach it did not already have.
|
|
123
174
|
*/
|
|
124
175
|
export declare function hasOwnableClaim(manifest: PluginManifest): boolean;
|
|
125
176
|
/**
|
|
126
|
-
* The field core injects into a
|
|
127
|
-
* switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
|
|
128
|
-
* `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
|
|
129
|
-
* content, so its wording comes from the console's translation tables
|
|
130
|
-
* as every other label (`isCoreEgressField` in the frontend recognizes
|
|
131
|
-
*
|
|
177
|
+
* The field core injects into a package's `configSchema` so the operator's
|
|
178
|
+
* switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
|
|
179
|
+
* No `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
|
|
180
|
+
* package content, so its wording comes from the console's translation tables
|
|
181
|
+
* the same as every other label (`isCoreEgressField` in the frontend recognizes
|
|
182
|
+
* it, and picks the gateway or model-service sentence by `type`) and never from
|
|
183
|
+
* a package author's English.
|
|
132
184
|
*/
|
|
133
|
-
export declare function
|
|
185
|
+
export declare function pluginEgressField(): PluginConfigField;
|
|
134
186
|
/**
|
|
135
187
|
* The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
|
|
136
188
|
* the untouched default — is deliberately NOT a choice: it means "let the claim
|
|
137
|
-
* answer", so it must not outrank the plugin's own `egressFor()`
|
|
138
|
-
* picked value does.
|
|
189
|
+
* answer", so it must not outrank the plugin's own `egressFor()` / `fetch`
|
|
190
|
+
* argument the way a picked value does.
|
|
139
191
|
*/
|
|
140
|
-
export declare function operatorEgressChoice(values: Record<string, unknown>):
|
|
192
|
+
export declare function operatorEgressChoice(values: Record<string, unknown>): PluginDeclaredEgress | undefined;
|
|
141
193
|
/**
|
|
142
|
-
* Add the core switch to a
|
|
194
|
+
* Add the core switch to a package manifest, idempotently and without touching
|
|
143
195
|
* any other field. Called at MANIFEST READ, before the host SDK hands the
|
|
144
196
|
* manifest to a plugin's `config()` closure: injected later, the drawer, the
|
|
145
197
|
* merge and the plugin's own read would disagree about whether the key exists.
|
|
146
198
|
*/
|
|
147
|
-
export declare function
|
|
199
|
+
export declare function withPluginEgressField(manifest: PluginManifest): PluginManifest;
|
|
148
200
|
export declare function isValidPluginId(id: unknown): id is string;
|
|
149
201
|
export declare function validatePluginManifest(manifest: unknown, label: string): void;
|
|
150
202
|
/** Validate one plugin's `configSchema` (flat primitive fields, ADR-0017 §7)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Bump discipline: raising this constant is the ONLY step a surface change
|
|
14
14
|
* needs. Packages declaring the previous value are then refused with a
|
|
15
15
|
* sentence that says which side is behind; nothing else in core reads it. */
|
|
16
|
-
export const PLUGIN_ENGINE_VERSION =
|
|
16
|
+
export const PLUGIN_ENGINE_VERSION = 2;
|
|
17
17
|
/** The plugin CONTRACT this host implements — the same number by another name.
|
|
18
18
|
* Kept as its own constant because readers come at it from two directions: a
|
|
19
19
|
* package DECLARES `apiVersion`, this host boasts `SUPPORTED_PLUGIN_API`, and
|
|
@@ -64,32 +64,110 @@ export function pluginEngineRefusal(manifest) {
|
|
|
64
64
|
}
|
|
65
65
|
return `plugin ${who} targets plugin contract ${verdict.required}, which this gateway no longer supports (supported: ${MIN_SUPPORTED_PLUGIN_API}–${SUPPORTED_PLUGIN_API}) — update the plugin to a newer release`;
|
|
66
66
|
}
|
|
67
|
-
/** Reject a package the host cannot run. Called at
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
67
|
+
/** Reject a package the host cannot run. Called at LOAD (and by the installer
|
|
68
|
+
* before it parks a package); the LOAD path turns the same verdict into a
|
|
69
|
+
* disabled console row instead of a failed one, so the message below is what
|
|
70
|
+
* the operator reads either way. */
|
|
71
71
|
export function assertSupportedPluginApi(manifest) {
|
|
72
72
|
const refusal = pluginEngineRefusal(manifest);
|
|
73
73
|
if (refusal)
|
|
74
74
|
throw new Error(refusal);
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The INSTALL-time gate (ADR-0036 §5, amended 2026-12-01). A package this host
|
|
78
|
+
* cannot run is still the operator's file: refusing it outright made the
|
|
79
|
+
* console reject a picker they had already made, and cost them a second upload
|
|
80
|
+
* of the same bytes after the upgrade that fixes it.
|
|
81
|
+
*
|
|
82
|
+
* So an incompatible upload is PARKED instead — written to disk and listed as a
|
|
83
|
+
* disabled `incompatible: true` row, exactly the state a package already on
|
|
84
|
+
* disk reaches when the gateway is downgraded under it (the loader refuses to
|
|
85
|
+
* import it either way; see `doLoadInstalledPlugins`). The row adopts the
|
|
86
|
+
* package in place the moment the mismatch is resolved, with no reinstall.
|
|
87
|
+
*
|
|
88
|
+
* The ONE thing a parked package may not do is take over an install that
|
|
89
|
+
* WORKS. Install is over-the-top — the previous package file is replaced and
|
|
90
|
+
* the console's rollback path deliberately skips incompatible rows — so parking
|
|
91
|
+
* over a working install would trade a running plugin for a dead one with
|
|
92
|
+
* nothing to restore it from. `replaced` is the manifest this upload would
|
|
93
|
+
* displace; taking that place requires uninstalling it first, which is the
|
|
94
|
+
* operator saying "yes, I mean the swap".
|
|
95
|
+
*/
|
|
96
|
+
export function assertInstallablePluginApi(manifest, replaced) {
|
|
97
|
+
const refusal = pluginEngineRefusal(manifest);
|
|
98
|
+
// A fresh id (or a same-id upgrade by a compatible package) is always fine.
|
|
99
|
+
if (!refusal)
|
|
100
|
+
return;
|
|
101
|
+
if (!replaced)
|
|
102
|
+
return;
|
|
103
|
+
// The outgoing package is engine-refused too: it is not "working", so there
|
|
104
|
+
// is nothing to protect — this replaces one parked row with another.
|
|
105
|
+
if (pluginEngineRefusal(replaced))
|
|
106
|
+
return;
|
|
107
|
+
throw new Error(`${refusal} — refused to replace the working '${replaced.id}' ${replaced.version}; uninstall it first if you really mean to swap it for a package this gateway cannot run`);
|
|
108
|
+
}
|
|
76
109
|
/** Where a config field is edited: the plugin drawer (default), the Client Hub
|
|
77
110
|
* card the hook backs, or nowhere (stored, but dead for this hook). */
|
|
78
111
|
export const CONFIG_PLACEMENTS = ['drawer', 'card', 'none'];
|
|
112
|
+
/**
|
|
113
|
+
* A declared `state` path, resolved to its path SEGMENTS relative to the OCR
|
|
114
|
+
* home — or undefined when the declaration would reach outside what uninstall
|
|
115
|
+
* owns. ONE reader, used by both the packager's refusal and the uninstall
|
|
116
|
+
* sweep: two spellings of this rule would drift, and the drift would delete (or
|
|
117
|
+
* refuse) the wrong files.
|
|
118
|
+
*
|
|
119
|
+
* Two shapes are accepted, because both are documented layouts:
|
|
120
|
+
*
|
|
121
|
+
* - under `plugins/` — the envelope the host SDK describes for outliving state
|
|
122
|
+
* (`plugins/workbuddy-auth.json`, `plugins/traffic/<id>`, `plugins/clients`);
|
|
123
|
+
* - a TOP-LEVEL entry whose name starts with `<id>.` / `<id>-` — vendor-neutral
|
|
124
|
+
* plugin files that predate the `plugins/` envelope. Top level only: a
|
|
125
|
+
* foreign envelope must never become deletable by a name prefix.
|
|
126
|
+
*
|
|
127
|
+
* Absolute paths, drive letters, `..` and empty segments are REFUSED rather than
|
|
128
|
+
* normalized (a normalizer would quietly turn a suspicious entry into a valid
|
|
129
|
+
* one), and the install roots/ledgers (`unpacked`, `bundled`, `config`,
|
|
130
|
+
* `traffic`) are core layout a package may not claim as a whole.
|
|
131
|
+
*/
|
|
132
|
+
export function resolvePluginStatePath(id, raw) {
|
|
133
|
+
if (typeof raw !== 'string')
|
|
134
|
+
return undefined;
|
|
135
|
+
const rel = raw.trim().replaceAll('\\', '/');
|
|
136
|
+
if (!rel || rel.startsWith('/') || /^[A-Za-z]:/.test(rel))
|
|
137
|
+
return undefined;
|
|
138
|
+
const segments = rel.split('/').filter((s) => s.length > 0);
|
|
139
|
+
if (segments.length === 0 || segments.some((s) => s === '.' || s === '..'))
|
|
140
|
+
return undefined;
|
|
141
|
+
if (segments[0] === 'plugins') {
|
|
142
|
+
const inside = segments.slice(1);
|
|
143
|
+
if (inside.length === 0)
|
|
144
|
+
return undefined;
|
|
145
|
+
if (inside.length === 1 && ['unpacked', 'bundled', 'config', 'traffic'].includes(inside[0]))
|
|
146
|
+
return undefined;
|
|
147
|
+
return segments;
|
|
148
|
+
}
|
|
149
|
+
if (segments.length !== 1)
|
|
150
|
+
return undefined;
|
|
151
|
+
const name = segments[0];
|
|
152
|
+
if (!name.startsWith(`${id}.`) && !name.startsWith(`${id}-`))
|
|
153
|
+
return undefined;
|
|
154
|
+
return segments;
|
|
155
|
+
}
|
|
79
156
|
/**
|
|
80
157
|
* The plugin-level outbound-leg switch (ADR-0018 Revision 5), keyed and valued by
|
|
81
|
-
* CORE. Once a package
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
158
|
+
* CORE. Once a package owns traffic — a claimed host, or a wire whose dial only
|
|
159
|
+
* the package can make — the leg under it is the package's business. The
|
|
160
|
+
* operator keeps the last word over the code they installed, and that word is
|
|
161
|
+
* spoken ONCE per plugin, not once per host or per wire: one switch that reaches
|
|
162
|
+
* every dial this package makes.
|
|
85
163
|
*
|
|
86
164
|
* The default is `inherit`, deliberately NOT the manifest's own declaration:
|
|
87
165
|
* the switch sits ABOVE the plugin's code, and a default of `proxy` would make
|
|
88
|
-
* every untouched plugin a silent override of its own `egressFor()`
|
|
89
|
-
* `inherit` is the state that leaves the
|
|
166
|
+
* every untouched plugin a silent override of its own `egressFor()` / `fetch`
|
|
167
|
+
* argument. `inherit` is the state that leaves the package in charge.
|
|
90
168
|
*/
|
|
91
|
-
export const
|
|
92
|
-
export const
|
|
169
|
+
export const PLUGIN_EGRESS_CONFIG_KEY = 'egress';
|
|
170
|
+
export const PLUGIN_EGRESS_VALUES = ['inherit', 'proxy', 'direct'];
|
|
93
171
|
/** The three extension axes (ADR-0017 / ADR-0027), in the order a console row
|
|
94
172
|
* prefers to label them: a package that is both an ingress hook and a traffic
|
|
95
173
|
* owner reads as a client adapter first, because that is the half the operator
|
|
@@ -118,27 +196,39 @@ export function gatewayClaimedHosts(manifest) {
|
|
|
118
196
|
return normalizePluginParts(manifest).find((p) => p.type === 'client-gateway')?.hosts ?? [];
|
|
119
197
|
}
|
|
120
198
|
/**
|
|
121
|
-
* Whether the console should offer the operator the plugin-level leg switch
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
199
|
+
* Whether the console should offer the operator the plugin-level leg switch.
|
|
200
|
+
*
|
|
201
|
+
* A gateway qualifies with at least one CONCRETE claimed host: a wildcard
|
|
202
|
+
* gateway claims no host, so a switch over it would be a switch over traffic it
|
|
203
|
+
* does not own (the same refusal the manifest validator applies to `egress` on
|
|
204
|
+
* `'*'`).
|
|
205
|
+
*
|
|
206
|
+
* A model-service qualifies with at least one WIRE, whether or not it dials
|
|
207
|
+
* itself: its traffic leaves this machine on the leg the operator pays for, and
|
|
208
|
+
* a package that spawns a vendor daemon (qoder-cli) has NO other way to be told
|
|
209
|
+
* (ADR-0022 amendment). The switch names a leg, never an address, so it grants a
|
|
210
|
+
* package no reach it did not already have.
|
|
125
211
|
*/
|
|
126
212
|
export function hasOwnableClaim(manifest) {
|
|
213
|
+
if (normalizePluginParts(manifest).some((p) => p.type === 'model-service' && (p.wires?.length ?? 0) > 0)) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
127
216
|
return gatewayClaimedHosts(manifest).some((h) => String(h).trim() !== '*');
|
|
128
217
|
}
|
|
129
218
|
/**
|
|
130
|
-
* The field core injects into a
|
|
131
|
-
* switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
|
|
132
|
-
* `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
|
|
133
|
-
* content, so its wording comes from the console's translation tables
|
|
134
|
-
* as every other label (`isCoreEgressField` in the frontend recognizes
|
|
135
|
-
*
|
|
219
|
+
* The field core injects into a package's `configSchema` so the operator's
|
|
220
|
+
* switch appears in the plugin's own settings drawer (ADR-0018 Revision 5).
|
|
221
|
+
* No `title`/`desc`/`enumLabels` on purpose: this row is CORE chrome, not
|
|
222
|
+
* package content, so its wording comes from the console's translation tables
|
|
223
|
+
* the same as every other label (`isCoreEgressField` in the frontend recognizes
|
|
224
|
+
* it, and picks the gateway or model-service sentence by `type`) and never from
|
|
225
|
+
* a package author's English.
|
|
136
226
|
*/
|
|
137
|
-
export function
|
|
227
|
+
export function pluginEgressField() {
|
|
138
228
|
return {
|
|
139
|
-
key:
|
|
229
|
+
key: PLUGIN_EGRESS_CONFIG_KEY,
|
|
140
230
|
type: 'enum',
|
|
141
|
-
values: [...
|
|
231
|
+
values: [...PLUGIN_EGRESS_VALUES],
|
|
142
232
|
default: 'inherit',
|
|
143
233
|
control: 'segmented',
|
|
144
234
|
essential: true,
|
|
@@ -147,26 +237,26 @@ export function gatewayEgressField() {
|
|
|
147
237
|
/**
|
|
148
238
|
* The operator's EXPLICIT leg choice out of a merged plugin config. `inherit` —
|
|
149
239
|
* the untouched default — is deliberately NOT a choice: it means "let the claim
|
|
150
|
-
* answer", so it must not outrank the plugin's own `egressFor()`
|
|
151
|
-
* picked value does.
|
|
240
|
+
* answer", so it must not outrank the plugin's own `egressFor()` / `fetch`
|
|
241
|
+
* argument the way a picked value does.
|
|
152
242
|
*/
|
|
153
243
|
export function operatorEgressChoice(values) {
|
|
154
|
-
const v = values[
|
|
244
|
+
const v = values[PLUGIN_EGRESS_CONFIG_KEY];
|
|
155
245
|
return v === 'proxy' || v === 'direct' ? v : undefined;
|
|
156
246
|
}
|
|
157
247
|
/**
|
|
158
|
-
* Add the core switch to a
|
|
248
|
+
* Add the core switch to a package manifest, idempotently and without touching
|
|
159
249
|
* any other field. Called at MANIFEST READ, before the host SDK hands the
|
|
160
250
|
* manifest to a plugin's `config()` closure: injected later, the drawer, the
|
|
161
251
|
* merge and the plugin's own read would disagree about whether the key exists.
|
|
162
252
|
*/
|
|
163
|
-
export function
|
|
253
|
+
export function withPluginEgressField(manifest) {
|
|
164
254
|
if (!hasOwnableClaim(manifest))
|
|
165
255
|
return manifest;
|
|
166
256
|
const schema = manifest.configSchema ?? [];
|
|
167
|
-
if (schema.some((f) => f.key ===
|
|
257
|
+
if (schema.some((f) => f.key === PLUGIN_EGRESS_CONFIG_KEY))
|
|
168
258
|
return manifest;
|
|
169
|
-
return { ...manifest, configSchema: [
|
|
259
|
+
return { ...manifest, configSchema: [pluginEgressField(), ...schema] };
|
|
170
260
|
}
|
|
171
261
|
/** A plugin id is a PATH COMPONENT — `<pluginsRoot>/<id>.zip`,
|
|
172
262
|
* `<pluginsRoot>/unpacked/<id>/`, `<pluginsRoot>/bundled/<id>.zip` — so the
|
|
@@ -208,7 +298,7 @@ export function validatePluginManifest(manifest, label) {
|
|
|
208
298
|
if (typeof m.version !== 'string' || !m.version)
|
|
209
299
|
fail('version must be a non-empty string');
|
|
210
300
|
if (typeof m.apiVersion !== 'number' || !Number.isInteger(m.apiVersion) || m.apiVersion < 1) {
|
|
211
|
-
fail(
|
|
301
|
+
fail(`apiVersion must be a positive integer (the plugin contract version, currently ${SUPPORTED_PLUGIN_API})`);
|
|
212
302
|
}
|
|
213
303
|
// `engines` is RETIRED (ADR-0036 Amendment 1): the engine version is the
|
|
214
304
|
// contract version, so `apiVersion` above is the whole declaration. A
|
|
@@ -228,7 +318,7 @@ export function validatePluginManifest(manifest, label) {
|
|
|
228
318
|
// wildcard claim: `'*'` is not a host, and a declaration that reached every
|
|
229
319
|
// host would let one installed package pin the egress of the whole machine —
|
|
230
320
|
// the exact blast radius Revision 4 was written to keep out of a claim.
|
|
231
|
-
const
|
|
321
|
+
const declaredEgress = (value, label, hosts) => {
|
|
232
322
|
if (value === undefined)
|
|
233
323
|
return;
|
|
234
324
|
if (value !== 'inherit' && value !== 'proxy' && value !== 'direct') {
|
|
@@ -287,7 +377,7 @@ export function validatePluginManifest(manifest, label) {
|
|
|
287
377
|
fail(`parts[${i}] is a client-gateway part and needs a non-empty hosts array`);
|
|
288
378
|
}
|
|
289
379
|
wildcardExclusive(part.hosts, `parts[${i}].hosts`, fail);
|
|
290
|
-
|
|
380
|
+
declaredEgress(part.egress, `parts[${i}].egress`, part.hosts);
|
|
291
381
|
}
|
|
292
382
|
else if (part.egress !== undefined) {
|
|
293
383
|
fail(`parts[${i}].egress declares the exit of a host, and only a client-gateway part claims hosts`);
|
|
@@ -308,7 +398,7 @@ export function validatePluginManifest(manifest, label) {
|
|
|
308
398
|
fail('a client-gateway manifest needs a non-empty hosts array');
|
|
309
399
|
}
|
|
310
400
|
wildcardExclusive(m.hosts, 'hosts', fail);
|
|
311
|
-
|
|
401
|
+
declaredEgress(m.egress, 'egress', m.hosts);
|
|
312
402
|
}
|
|
313
403
|
else if (m.egress !== undefined) {
|
|
314
404
|
fail('`egress` declares the exit of a host, and only a client-gateway plugin claims hosts');
|
|
@@ -321,19 +411,33 @@ export function validatePluginManifest(manifest, label) {
|
|
|
321
411
|
if (m.configSections !== undefined && m.configSchema === undefined) {
|
|
322
412
|
fail('configSections without configSchema groups nothing');
|
|
323
413
|
}
|
|
324
|
-
// The leg switch is core-owned vocabulary (`
|
|
325
|
-
// core INJECTS it into a
|
|
414
|
+
// The leg switch is core-owned vocabulary (`PLUGIN_EGRESS_CONFIG_KEY`), and
|
|
415
|
+
// core INJECTS it into a package's schema. A package that declares the key
|
|
326
416
|
// itself is refused here rather than silently shadowed: two rows named
|
|
327
417
|
// `egress` in one drawer means the merged read can no longer say which one
|
|
328
418
|
// the operator touched, and the operator's word on the leg is the whole
|
|
329
|
-
// contract of that field.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
m.configSchema.some((f) => f?.key ===
|
|
333
|
-
fail(`configSchema may not declare '${
|
|
419
|
+
// contract of that field. Refused for EVERY package type that could grow the
|
|
420
|
+
// switch — model-service packages gain it too (ADR-0022 amendment).
|
|
421
|
+
if (Array.isArray(m.configSchema) &&
|
|
422
|
+
m.configSchema.some((f) => f?.key === PLUGIN_EGRESS_CONFIG_KEY)) {
|
|
423
|
+
fail(`configSchema may not declare '${PLUGIN_EGRESS_CONFIG_KEY}' — the outbound-leg switch belongs to core`);
|
|
334
424
|
}
|
|
335
425
|
if (m.logo !== undefined && typeof m.logo !== 'string')
|
|
336
426
|
fail('logo must be a string');
|
|
427
|
+
// `state` paths are resolved against the OCR home and deleted on uninstall,
|
|
428
|
+
// so a declaration must stay inside what uninstall owns: a path under
|
|
429
|
+
// `plugins/`, or a top-level entry named `<id>.…` / `<id>-…`. The uninstall
|
|
430
|
+
// sweep re-guards the same rule; this copy exists so the packager refuses the
|
|
431
|
+
// package before an operator ever has it.
|
|
432
|
+
if (m.state !== undefined) {
|
|
433
|
+
stringArray(m.state, 'state');
|
|
434
|
+
const id = String(m.id);
|
|
435
|
+
for (const raw of m.state) {
|
|
436
|
+
if (!resolvePluginStatePath(id, raw)) {
|
|
437
|
+
fail(`state entry '${raw}' must be a path under 'plugins/' or a top-level '<id>.' / '<id>-' entry`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
337
441
|
if (m.description !== undefined &&
|
|
338
442
|
typeof m.description !== 'string' &&
|
|
339
443
|
(typeof m.description !== 'object' || m.description === null)) {
|
|
@@ -463,7 +567,7 @@ const CONFIG_CONTROLS = {
|
|
|
463
567
|
models: { 'string[]': true },
|
|
464
568
|
// A mapping table of `client=target[#label]` specs; each row maps one of the
|
|
465
569
|
// client's OWN model ids onto an OCR model the gateway rewrites to.
|
|
466
|
-
|
|
570
|
+
mappings: { 'string[]': true },
|
|
467
571
|
// A short closed choice rendered as joined buttons instead of a dropdown --
|
|
468
572
|
// the console's own mode switches (none / custom / follow) use the same shape.
|
|
469
573
|
segmented: { enum: true },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProviderRegistry } from '../providers/registry.js';
|
|
2
|
+
import { type PluginInstallOutcome } from './install-run.js';
|
|
3
|
+
/**
|
|
4
|
+
* ONE market install, reached from three verbs (ADR-0037 §5/§7): the market
|
|
5
|
+
* card's Install, one plugin's Upgrade, and the bulk upgrade run. All three do
|
|
6
|
+
* exactly this — resolve the registry row, obtain the bytes by the row's
|
|
7
|
+
* method, verify the zip declares the row's id, land it through the shared
|
|
8
|
+
* install pipeline, and record where it came from.
|
|
9
|
+
*
|
|
10
|
+
* Keeping it in one function is the same rule the upload path follows: two
|
|
11
|
+
* copies of "download, verify, install, remember" would agree today and drift
|
|
12
|
+
* the day one of them learns a new gate.
|
|
13
|
+
*/
|
|
14
|
+
export declare function installFromMarket(repo: string, opts?: {
|
|
15
|
+
ref?: string;
|
|
16
|
+
allowDowngrade?: boolean;
|
|
17
|
+
upgrade?: boolean;
|
|
18
|
+
}, registry?: ProviderRegistry): Promise<PluginInstallOutcome>;
|