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,651 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine registry for the Local Models console (llama.cpp / Strata).
|
|
3
|
+
*
|
|
4
|
+
* An ENGINE is a locally-installed inference server the gateway can reach over
|
|
5
|
+
* its OpenAI-compatible HTTP API. This module owns the per-engine catalog:
|
|
6
|
+
* which build targets exist for the running platform/arch, how a target maps
|
|
7
|
+
* onto GitHub release assets, and how the newest usable release is resolved.
|
|
8
|
+
* The download/unpack/state half lives in `install.ts`.
|
|
9
|
+
*
|
|
10
|
+
* Asset realities this is written against (checked 2026-11):
|
|
11
|
+
* - llama.cpp (`ggml-org/llama.cpp`): binaries ride PRERELEASE tags (`b12722`);
|
|
12
|
+
* the stable `v*` tags (`v1.1.0`) carry ONLY a `nightly-tag.txt` pointer
|
|
13
|
+
* file and no binaries at all. A release therefore counts only when it
|
|
14
|
+
* ships a `llama-<tag>-bin-*` asset — a fresh stable tag sits at the TOP of
|
|
15
|
+
* the release list and would otherwise shadow every `b*` build behind its
|
|
16
|
+
* pointer file. A target resolves by exact asset name `llama-<tag>-bin-<asset>`
|
|
17
|
+
* over the release list, first binary release wins. CUDA targets need a
|
|
18
|
+
* SECOND asset (`cudart-*`) downloaded alongside the main one; its Windows
|
|
19
|
+
* spelling has no tag while the Ubuntu one does.
|
|
20
|
+
* - Strata (`Niko1221/Strata`): the app release (v0.2.27) is NOT the engine
|
|
21
|
+
* release. Since 2026-12 the app tags carry installers, the control bundle
|
|
22
|
+
* and the update feed only; engine archives stay pinned to the release that
|
|
23
|
+
* built them (the general `strata-engine` channel on v0.2.25, the Qwen4
|
|
24
|
+
* `strata-q4-lite` family on v0.2.26, `strata-hy4` on v0.2.21 …) and the
|
|
25
|
+
* vendor's signed feed (`releases/latest/download/strata-feed.json`)
|
|
26
|
+
* carries each package's exact download URL. Engine assets are
|
|
27
|
+
* `strata-engine-<engineVer>-<os>-<arch>-<backend>[-<variant>].tar.gz` where
|
|
28
|
+
* the engine version is INDEPENDENT of both the app tag and the release the
|
|
29
|
+
* asset lives on — it is parsed out of the matched asset name. The control
|
|
30
|
+
* bundle (`strata-control-<controlVer>-<os>-<arch>`) is the front-end and is
|
|
31
|
+
* installed beside the engine, not into the engine directory; its version is
|
|
32
|
+
* independent of the engine build too.
|
|
33
|
+
*/
|
|
34
|
+
import fs from 'node:fs';
|
|
35
|
+
import path from 'node:path';
|
|
36
|
+
import { getOcrHomeDir } from '../cli/paths.js';
|
|
37
|
+
import { githubHeaders } from '../harness/common/github.js';
|
|
38
|
+
import { LLAMACPP_RUNTIME } from './llamacpp.js';
|
|
39
|
+
import { STRATA_RUNTIME, strataRuntimeDir } from './strata.js';
|
|
40
|
+
const MB = 1024 * 1024;
|
|
41
|
+
/**
|
|
42
|
+
* A llama.cpp release only counts when it carries real binaries: the stable
|
|
43
|
+
* `v*` tags ship ONLY a `nightly-tag.txt` pointer, and a mid-upload release
|
|
44
|
+
* may have no asset yet — either would otherwise win the release walk over
|
|
45
|
+
* the `b*` build every target matcher needs.
|
|
46
|
+
*/
|
|
47
|
+
const llamaReleaseHasBinaries = (tag, assets) => tag !== '' && assets.some((name) => name.startsWith(`llama-${tag}-bin-`));
|
|
48
|
+
const LLAMACPP_ASSET_BYTES = {
|
|
49
|
+
// Measured sizes of recent nightly assets; refreshed targets fall back to 0.
|
|
50
|
+
'win-cpu-x64.zip': 24 * MB,
|
|
51
|
+
'win-cpu-arm64.zip': 12 * MB,
|
|
52
|
+
'win-vulkan-x64.zip': 37 * MB,
|
|
53
|
+
'win-vulkan-arm64.zip': 25 * MB,
|
|
54
|
+
'win-cuda-12.4-x64.zip': 342 * MB,
|
|
55
|
+
'win-cuda-13.5-x64.zip': 215 * MB,
|
|
56
|
+
'win-cuda-13.5-arm64.zip': 203 * MB,
|
|
57
|
+
'win-rocm-10.0-x64.zip': 272 * MB,
|
|
58
|
+
'win-sycl-x64.zip': 165 * MB,
|
|
59
|
+
'ubuntu-x64.tar.gz': 22 * MB,
|
|
60
|
+
'ubuntu-arm64.tar.gz': 18 * MB,
|
|
61
|
+
'ubuntu-vulkan-x64.tar.gz': 35 * MB,
|
|
62
|
+
'ubuntu-vulkan-arm64.tar.gz': 28 * MB,
|
|
63
|
+
'ubuntu-cuda-12.8-x64.tar.gz': 210 * MB,
|
|
64
|
+
'ubuntu-cuda-13.5-x64.tar.gz': 214 * MB,
|
|
65
|
+
'ubuntu-cuda-13.5-arm64.tar.gz': 209 * MB,
|
|
66
|
+
'ubuntu-rocm-10.0-x64.tar.gz': 264 * MB,
|
|
67
|
+
'ubuntu-sycl-fp16-x64.tar.gz': 66 * MB,
|
|
68
|
+
'macos-arm64.tar.gz': 16 * MB,
|
|
69
|
+
'macos-x64.tar.gz': 11 * MB,
|
|
70
|
+
};
|
|
71
|
+
const STRATA_ASSET_BYTES = {
|
|
72
|
+
'windows-x86_64-cuda-cuda12': 719 * MB,
|
|
73
|
+
'windows-x86_64-cuda-cuda13': 471 * MB,
|
|
74
|
+
'windows-x86_64-hip-rdna2': 159 * MB,
|
|
75
|
+
'windows-x86_64-hip-rdna3': 210 * MB,
|
|
76
|
+
'windows-x86_64-hip-rx9070': 512 * MB,
|
|
77
|
+
'linux-x86_64-cuda-cuda12': 746 * MB,
|
|
78
|
+
'linux-x86_64-cuda-cuda13': 565 * MB,
|
|
79
|
+
'linux-x86_64-hip-halo': 257 * MB,
|
|
80
|
+
'linux-x86_64-hip-rx6000': 183 * MB,
|
|
81
|
+
'linux-x86_64-hip-rx7900': 263 * MB,
|
|
82
|
+
'linux-x86_64-hip-rx9070': 608 * MB,
|
|
83
|
+
'linux-x86_64-sycl': 180 * MB,
|
|
84
|
+
'linux-aarch64-cuda-cuda13': 557 * MB,
|
|
85
|
+
'macos-arm64-metal': 3 * MB,
|
|
86
|
+
};
|
|
87
|
+
const LLAMACPP = {
|
|
88
|
+
id: 'llamacpp',
|
|
89
|
+
name: 'llama.cpp',
|
|
90
|
+
repo: 'ggml-org/llama.cpp',
|
|
91
|
+
description: 'llama-server speaks the OpenAI-compatible API; CPU/Vulkan/CUDA/ROCm/SYCL/Metal backends',
|
|
92
|
+
descriptionKey: 'localModels.descLlamacpp',
|
|
93
|
+
binaryNames: ['llama-server', 'llama-cli'],
|
|
94
|
+
targets: (platform, arch) => {
|
|
95
|
+
if (platform === 'win32') {
|
|
96
|
+
const targets = [
|
|
97
|
+
{ id: 'cpu', backend: 'cpu', label: 'CPU', requires: ['cpu'], approxBytes: LLAMACPP_ASSET_BYTES[`win-cpu-${arch}.zip`] ?? 0 },
|
|
98
|
+
{ id: 'vulkan', backend: 'vulkan', label: 'Vulkan', requires: ['vulkan'], approxBytes: LLAMACPP_ASSET_BYTES[`win-vulkan-${arch}.zip`] ?? 0 },
|
|
99
|
+
];
|
|
100
|
+
if (arch === 'x64') {
|
|
101
|
+
targets.push({ id: 'cuda-12.4', backend: 'cuda', label: 'CUDA 12.4', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['win-cuda-12.4-x64.zip'] ?? 0 }, { id: 'cuda-13.5', backend: 'cuda', label: 'CUDA 13.5', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['win-cuda-13.5-x64.zip'] ?? 0 }, { id: 'rocm-10.0', backend: 'rocm', label: 'ROCm 10.0 (AMD)', requires: ['amd-rocm'], approxBytes: LLAMACPP_ASSET_BYTES['win-rocm-10.0-x64.zip'] ?? 0 }, { id: 'sycl', backend: 'sycl', label: 'SYCL (Intel)', requires: ['intel-sycl'], approxBytes: LLAMACPP_ASSET_BYTES['win-sycl-x64.zip'] ?? 0 });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
targets.push({ id: 'cuda-13.5', backend: 'cuda', label: 'CUDA 13.5', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['win-cuda-13.5-arm64.zip'] ?? 0 });
|
|
105
|
+
}
|
|
106
|
+
return targets;
|
|
107
|
+
}
|
|
108
|
+
if (platform === 'linux') {
|
|
109
|
+
const targets = [
|
|
110
|
+
{ id: 'cpu', backend: 'cpu', label: 'CPU', requires: ['cpu'], approxBytes: LLAMACPP_ASSET_BYTES[`ubuntu-${arch}.tar.gz`] ?? 0 },
|
|
111
|
+
{ id: 'vulkan', backend: 'vulkan', label: 'Vulkan', requires: ['vulkan'], approxBytes: LLAMACPP_ASSET_BYTES[`ubuntu-vulkan-${arch}.tar.gz`] ?? 0 },
|
|
112
|
+
];
|
|
113
|
+
if (arch === 'x64') {
|
|
114
|
+
targets.push({ id: 'cuda-12.8', backend: 'cuda', label: 'CUDA 12.8', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['ubuntu-cuda-12.8-x64.tar.gz'] ?? 0 }, { id: 'cuda-13.5', backend: 'cuda', label: 'CUDA 13.5', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['ubuntu-cuda-13.5-x64.tar.gz'] ?? 0 }, { id: 'rocm-10.0', backend: 'rocm', label: 'ROCm 10.0 (AMD)', requires: ['amd-rocm'], approxBytes: LLAMACPP_ASSET_BYTES['ubuntu-rocm-10.0-x64.tar.gz'] ?? 0 }, { id: 'sycl', backend: 'sycl', label: 'SYCL (Intel)', requires: ['intel-sycl'], approxBytes: LLAMACPP_ASSET_BYTES['ubuntu-sycl-fp16-x64.tar.gz'] ?? 0 });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
targets.push({ id: 'cuda-13.5', backend: 'cuda', label: 'CUDA 13.5', requires: ['nvidia-driver'], approxBytes: LLAMACPP_ASSET_BYTES['ubuntu-cuda-13.5-arm64.tar.gz'] ?? 0 });
|
|
118
|
+
}
|
|
119
|
+
return targets;
|
|
120
|
+
}
|
|
121
|
+
if (platform === 'darwin') {
|
|
122
|
+
return [
|
|
123
|
+
{ id: 'metal', backend: 'metal', label: 'Metal (Apple Silicon / AMD)', requires: ['apple-metal'], approxBytes: LLAMACPP_ASSET_BYTES[`macos-${arch}.tar.gz`] ?? 0 },
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
return [];
|
|
127
|
+
},
|
|
128
|
+
matchAssets: ({ platform, arch, targetId, tag, assets }) => {
|
|
129
|
+
const asset = llamaAssetFor(platform, arch, targetId);
|
|
130
|
+
if (!asset)
|
|
131
|
+
return null;
|
|
132
|
+
const main = `llama-${tag}-bin-${asset.file}`;
|
|
133
|
+
if (!assets.includes(main))
|
|
134
|
+
return null;
|
|
135
|
+
const downloads = [main];
|
|
136
|
+
if (asset.cudart) {
|
|
137
|
+
// Windows cudart assets have no tag in the name; Ubuntu ones do.
|
|
138
|
+
const cudart = platform === 'win32' ? asset.cudart : asset.cudart.replace('{tag}', tag);
|
|
139
|
+
if (assets.includes(cudart))
|
|
140
|
+
downloads.push(cudart);
|
|
141
|
+
}
|
|
142
|
+
return { assets: downloads, version: tag };
|
|
143
|
+
},
|
|
144
|
+
resolveRelease: async (fetchImpl, signal) => {
|
|
145
|
+
// The binaries ride prerelease `b*` tags; `/releases/latest` points at the
|
|
146
|
+
// stable tag, which ships only a nightly pointer file. Walk the list and
|
|
147
|
+
// take the first release carrying REAL binaries — a pointer-only (or
|
|
148
|
+
// still-uploading) release is skipped, and the target matcher rejects any
|
|
149
|
+
// target the picked release has no asset for.
|
|
150
|
+
const res = await fetchImpl('https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=30', {
|
|
151
|
+
headers: githubHeaders(),
|
|
152
|
+
...(signal ? { signal } : {}),
|
|
153
|
+
});
|
|
154
|
+
if (!res.ok) {
|
|
155
|
+
throw new Error(`llama.cpp release lookup failed (${res.status})`);
|
|
156
|
+
}
|
|
157
|
+
const list = (await res.json());
|
|
158
|
+
for (const release of Array.isArray(list) ? list : []) {
|
|
159
|
+
const tag = typeof release.tag_name === 'string' ? release.tag_name : '';
|
|
160
|
+
const assets = Array.isArray(release.assets)
|
|
161
|
+
? release.assets.map((a) => (typeof a.name === 'string' ? a.name : '')).filter(Boolean)
|
|
162
|
+
: [];
|
|
163
|
+
if (llamaReleaseHasBinaries(tag, assets))
|
|
164
|
+
return { tag, assets };
|
|
165
|
+
}
|
|
166
|
+
throw new Error('llama.cpp release list has no binary release');
|
|
167
|
+
},
|
|
168
|
+
listTags: async (fetchImpl, signal) => {
|
|
169
|
+
// Nightly `b*` tags ARE the version choice here, so the picker offers the
|
|
170
|
+
// recent stream — minus any tag no target could install from (a stable
|
|
171
|
+
// `v*` tag ships only the nightly pointer file). Asset availability per
|
|
172
|
+
// tag is re-checked on install.
|
|
173
|
+
try {
|
|
174
|
+
const res = await fetchImpl('https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=15', {
|
|
175
|
+
headers: githubHeaders(),
|
|
176
|
+
...(signal ? { signal } : {}),
|
|
177
|
+
});
|
|
178
|
+
if (!res.ok)
|
|
179
|
+
return [];
|
|
180
|
+
const list = (await res.json());
|
|
181
|
+
return (Array.isArray(list) ? list : [])
|
|
182
|
+
.filter((release) => {
|
|
183
|
+
const tag = typeof release.tag_name === 'string' ? release.tag_name : '';
|
|
184
|
+
const assets = Array.isArray(release.assets)
|
|
185
|
+
? release.assets.map((a) => (typeof a.name === 'string' ? a.name : '')).filter(Boolean)
|
|
186
|
+
: [];
|
|
187
|
+
return llamaReleaseHasBinaries(tag, assets);
|
|
188
|
+
})
|
|
189
|
+
.map((release) => release.tag_name);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
runtime: LLAMACPP_RUNTIME,
|
|
196
|
+
recommendTarget: ({ platform, arch, nvidia, cudaMajor, amdRocm, vulkan }) => {
|
|
197
|
+
if (platform === 'darwin')
|
|
198
|
+
return 'metal';
|
|
199
|
+
if (nvidia) {
|
|
200
|
+
// CUDA 13 drivers run the 13.5 builds; older drivers get the 12.x pair.
|
|
201
|
+
if (arch === 'arm64')
|
|
202
|
+
return 'cuda-13.5';
|
|
203
|
+
return cudaMajor >= 13 ? 'cuda-13.5' : `cuda-${platform === 'win32' ? '12.4' : '12.8'}`;
|
|
204
|
+
}
|
|
205
|
+
if (amdRocm)
|
|
206
|
+
return 'rocm-10.0';
|
|
207
|
+
if (vulkan)
|
|
208
|
+
return 'vulkan';
|
|
209
|
+
return 'cpu';
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
/** llama.cpp asset spelling for one platform/arch/target; null = unsupported. */
|
|
213
|
+
function llamaAssetFor(platform, arch, targetId) {
|
|
214
|
+
if (platform === 'win32') {
|
|
215
|
+
if (targetId === 'cpu')
|
|
216
|
+
return { file: `win-cpu-${arch}.zip` };
|
|
217
|
+
if (targetId === 'vulkan')
|
|
218
|
+
return { file: `win-vulkan-${arch}.zip` };
|
|
219
|
+
if (arch === 'x64' && targetId === 'cuda-12.4')
|
|
220
|
+
return { file: 'win-cuda-12.4-x64.zip', cudart: 'cudart-llama-bin-win-cuda-12.4-x64.zip' };
|
|
221
|
+
if (targetId === 'cuda-13.5')
|
|
222
|
+
return { file: `win-cuda-13.5-${arch}.zip`, cudart: `cudart-llama-bin-win-cuda-13.5-${arch}.zip` };
|
|
223
|
+
if (arch === 'x64' && targetId === 'rocm-10.0')
|
|
224
|
+
return { file: 'win-rocm-10.0-x64.zip' };
|
|
225
|
+
if (arch === 'x64' && targetId === 'sycl')
|
|
226
|
+
return { file: 'win-sycl-x64.zip' };
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
if (platform === 'linux') {
|
|
230
|
+
if (targetId === 'cpu')
|
|
231
|
+
return { file: `ubuntu-${arch}.tar.gz` };
|
|
232
|
+
if (targetId === 'vulkan')
|
|
233
|
+
return { file: `ubuntu-vulkan-${arch}.tar.gz` };
|
|
234
|
+
if (arch === 'x64' && targetId === 'cuda-12.8')
|
|
235
|
+
return { file: 'ubuntu-cuda-12.8-x64.tar.gz', cudart: 'cudart-llama-b{tag}-bin-ubuntu-cuda-12.8-x64.tar.gz' };
|
|
236
|
+
if (targetId === 'cuda-13.5')
|
|
237
|
+
return { file: `ubuntu-cuda-13.5-${arch}.tar.gz`, cudart: `cudart-llama-b{tag}-bin-ubuntu-cuda-13.5-${arch}.tar.gz` };
|
|
238
|
+
if (arch === 'x64' && targetId === 'rocm-10.0')
|
|
239
|
+
return { file: 'ubuntu-rocm-10.0-x64.tar.gz' };
|
|
240
|
+
if (arch === 'x64' && targetId === 'sycl')
|
|
241
|
+
return { file: 'ubuntu-sycl-fp16-x64.tar.gz' };
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
if (platform === 'darwin') {
|
|
245
|
+
if (targetId === 'metal')
|
|
246
|
+
return { file: `macos-${arch}.tar.gz` };
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
/** Stable URL of Strata's update feed (always redirects to the newest app tag). */
|
|
252
|
+
const STRATA_FEED_URL = 'https://github.com/Niko1221/Strata/releases/latest/download/strata-feed.json';
|
|
253
|
+
/** A feed package this gateway can launch: the general engine channel and the
|
|
254
|
+
* front-end. `strata-hy4` / `strata-inkling` / `strata-ling32` / `strata-q4-lite`
|
|
255
|
+
* are model-specific channels the gateway's `--engine strata` contract does
|
|
256
|
+
* not serve. */
|
|
257
|
+
const strataFeedAsset = (name) => name.startsWith('strata-engine-') || name.startsWith('strata-control-') || name.startsWith('strata-terminal-');
|
|
258
|
+
/** Last path segment of a feed `url` (the feed mixes absolute GitHub URLs with
|
|
259
|
+
* bare asset filenames, so both spellings name the same asset). */
|
|
260
|
+
function strataFeedAssetName(url) {
|
|
261
|
+
const clean = url.split(/[?#]/, 1)[0] ?? '';
|
|
262
|
+
const at = clean.lastIndexOf('/');
|
|
263
|
+
const name = at >= 0 ? clean.slice(at + 1) : clean;
|
|
264
|
+
try {
|
|
265
|
+
return decodeURIComponent(name);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return name;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const STRATA = {
|
|
272
|
+
id: 'strata',
|
|
273
|
+
name: 'Strata',
|
|
274
|
+
repo: 'Niko1221/Strata',
|
|
275
|
+
description: 'MoE expert-offload engine that runs huge models on small VRAM; OpenAI/Anthropic-compatible API',
|
|
276
|
+
descriptionKey: 'localModels.descStrata',
|
|
277
|
+
binaryNames: ['strata-engine', 'strata', 'strata-control'],
|
|
278
|
+
targets: (platform, arch) => {
|
|
279
|
+
if (platform === 'darwin') {
|
|
280
|
+
if (arch !== 'arm64')
|
|
281
|
+
return [];
|
|
282
|
+
return [
|
|
283
|
+
{ id: 'metal', backend: 'metal', label: 'Metal (Apple Silicon)', requires: ['apple-metal'], approxBytes: STRATA_ASSET_BYTES['macos-arm64-metal'] ?? 0 },
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
const osTag = platform === 'win32' ? 'windows-x86_64' : arch === 'x64' ? 'linux-x86_64' : arch === 'arm64' ? 'linux-aarch64' : null;
|
|
287
|
+
if (!osTag)
|
|
288
|
+
return [];
|
|
289
|
+
const ids = platform === 'win32'
|
|
290
|
+
? ['cuda12', 'cuda13', 'hip-rdna2', 'hip-rdna3', 'hip-rx9070']
|
|
291
|
+
: arch === 'x64'
|
|
292
|
+
? ['cuda12', 'cuda13', 'hip-halo', 'hip-rx6000', 'hip-rx7900', 'hip-rx9070', 'sycl']
|
|
293
|
+
: ['cuda13'];
|
|
294
|
+
return ids.map((id) => {
|
|
295
|
+
const backend = id.startsWith('cuda') ? 'cuda' : id.startsWith('hip') ? 'rocm' : 'sycl';
|
|
296
|
+
const requires = backend === 'cuda' ? ['nvidia-driver'] : backend === 'rocm' ? ['amd-rocm'] : ['intel-sycl'];
|
|
297
|
+
// Byte-table keys use the asset tail (`cuda-cuda13`), not the target id.
|
|
298
|
+
const tail = id.startsWith('cuda') ? `cuda-${id}` : id;
|
|
299
|
+
return { id, backend, label: strataTargetLabel(id), requires, approxBytes: STRATA_ASSET_BYTES[`${osTag}-${tail}`] ?? 0 };
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
matchAssets: ({ platform, arch, targetId, assets }) => {
|
|
303
|
+
const osTag = platform === 'win32' ? 'windows-x86_64' : platform === 'darwin' ? (arch === 'arm64' ? 'macos-arm64' : null) : arch === 'x64' ? 'linux-x86_64' : arch === 'arm64' ? 'linux-aarch64' : null;
|
|
304
|
+
if (!osTag)
|
|
305
|
+
return null;
|
|
306
|
+
// Asset tail is `<backend>[-<variant>][-<build variant>]`: Windows CUDA ids
|
|
307
|
+
// carry BOTH (`cuda-cuda12` for target `cuda12`), the Linux CUDA build
|
|
308
|
+
// drops the duplication (`cuda12`), and a release may ship only a build
|
|
309
|
+
// variant of it (`cuda12-noavx2-experimental`). Matching on the exact
|
|
310
|
+
// suffix refused releases that ARE installable — the fresh-machine bug
|
|
311
|
+
// this tolerant match fixes — so the tail is compared by its leading
|
|
312
|
+
// token and an extra `-<variant>` suffix is accepted, exact spelling first.
|
|
313
|
+
const tail = targetId.startsWith('cuda') ? `cuda-${targetId}` : targetId;
|
|
314
|
+
// A CUDA target has two spellings on the release: `cuda-<id>` (Windows) and
|
|
315
|
+
// `<id>` (Linux). Both name the same backend.
|
|
316
|
+
const spellings = targetId.startsWith('cuda') ? [tail, targetId] : [tail];
|
|
317
|
+
const prefix = 'strata-engine-';
|
|
318
|
+
const middle = `-${osTag}-`;
|
|
319
|
+
const candidates = [];
|
|
320
|
+
for (const asset of assets) {
|
|
321
|
+
if (!asset.startsWith(prefix) || !asset.endsWith('.tar.gz'))
|
|
322
|
+
continue;
|
|
323
|
+
const at = asset.indexOf(middle, prefix.length);
|
|
324
|
+
if (at < 0)
|
|
325
|
+
continue;
|
|
326
|
+
const version = asset.slice(prefix.length, at);
|
|
327
|
+
const variant = asset.slice(at + middle.length, -'.tar.gz'.length);
|
|
328
|
+
const exact = spellings.includes(variant);
|
|
329
|
+
// `<spelling>`, or `<spelling>-<build variant>` (noavx2-experimental).
|
|
330
|
+
const buildVariant = !exact && spellings.some((spelling) => variant.startsWith(`${spelling}-`));
|
|
331
|
+
if (!exact && !buildVariant)
|
|
332
|
+
continue;
|
|
333
|
+
candidates.push({ name: asset, version, exact });
|
|
334
|
+
}
|
|
335
|
+
if (candidates.length === 0)
|
|
336
|
+
return null;
|
|
337
|
+
// Newest engine build wins, then the exact spelling over a build variant.
|
|
338
|
+
candidates.sort((a, b) => compareVersions(b.version, a.version) || Number(b.exact) - Number(a.exact));
|
|
339
|
+
const matched = candidates[0];
|
|
340
|
+
// The front-end is a separate archive on the same release, but its version
|
|
341
|
+
// does NOT track the engine build: the vendor's feed pairs a 0.1.73 engine
|
|
342
|
+
// with control 0.1.74.4, so an exact-version lookup would leave every
|
|
343
|
+
// fresh install with an engine and no front-end. Windows ships a zip;
|
|
344
|
+
// every other target a tar.gz. The vendor has used BOTH `strata-control-`
|
|
345
|
+
// (current) and `strata-terminal-` (the 0.1.69 line), so both spellings
|
|
346
|
+
// are probed — a rename must not leave a fresh install without a
|
|
347
|
+
// front-end. Prefer an exact engine-version match when the release has
|
|
348
|
+
// one, otherwise take the newest matching archive. Absent → the engine
|
|
349
|
+
// still installs, and launch names the missing front-end.
|
|
350
|
+
const controlExt = osTag.startsWith('windows') ? 'zip' : 'tar.gz';
|
|
351
|
+
const controlSuffix = `-${osTag}.${controlExt}`;
|
|
352
|
+
const controls = [];
|
|
353
|
+
for (const asset of assets) {
|
|
354
|
+
for (const family of ['strata-control-', 'strata-terminal-']) {
|
|
355
|
+
if (!asset.startsWith(family) || !asset.endsWith(controlSuffix))
|
|
356
|
+
continue;
|
|
357
|
+
const version = asset.slice(family.length, -controlSuffix.length);
|
|
358
|
+
if (version)
|
|
359
|
+
controls.push({ asset, version });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
controls.sort((a, b) => compareVersions(b.version, a.version));
|
|
363
|
+
const control = (controls.find((row) => row.version === matched.version) ?? controls[0])?.asset;
|
|
364
|
+
return {
|
|
365
|
+
assets: [matched.name],
|
|
366
|
+
version: matched.version,
|
|
367
|
+
...(control ? { companions: [{ asset: control, dest: strataRuntimeDir() }] } : {}),
|
|
368
|
+
};
|
|
369
|
+
},
|
|
370
|
+
resolveRelease: async (fetchImpl, signal) => {
|
|
371
|
+
// Read the vendor's update feed FIRST. Since the v0.2.27 app release the
|
|
372
|
+
// installers, Control and the feed ride one tag while the engine archives
|
|
373
|
+
// stay on the releases that built them (general `strata-engine` 0.1.73 on
|
|
374
|
+
// v0.2.25, Qwen4 `strata-q4-lite` 0.1.74 on v0.2.26, `strata-hy4` 0.1.67
|
|
375
|
+
// on v0.2.21). Only the feed names each package's exact URL; resolving
|
|
376
|
+
// "latest" and matching its own asset names reported every target
|
|
377
|
+
// unavailable (the v0.2.27 incident, 2026-12-05).
|
|
378
|
+
try {
|
|
379
|
+
const res = await fetchImpl(STRATA_FEED_URL, {
|
|
380
|
+
headers: githubHeaders(),
|
|
381
|
+
...(signal ? { signal } : {}),
|
|
382
|
+
});
|
|
383
|
+
if (res.ok) {
|
|
384
|
+
const feed = (await res.json());
|
|
385
|
+
const appVersion = typeof feed?.app?.version === 'string' ? feed.app.version : '';
|
|
386
|
+
if (feed?.schema_version === 1 && appVersion) {
|
|
387
|
+
const assets = [];
|
|
388
|
+
const assetUrls = {};
|
|
389
|
+
const collect = (packages) => {
|
|
390
|
+
if (!Array.isArray(packages))
|
|
391
|
+
return;
|
|
392
|
+
for (const pkg of packages) {
|
|
393
|
+
const url = typeof pkg?.url === 'string' ? pkg.url : '';
|
|
394
|
+
if (!url)
|
|
395
|
+
continue;
|
|
396
|
+
const name = strataFeedAssetName(url);
|
|
397
|
+
if (!strataFeedAsset(name) || assets.includes(name))
|
|
398
|
+
continue;
|
|
399
|
+
assets.push(name);
|
|
400
|
+
if (/^https?:\/\//i.test(url))
|
|
401
|
+
assetUrls[name] = url;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
collect(feed.engine?.packages);
|
|
405
|
+
collect(feed.control?.packages);
|
|
406
|
+
if (assets.some((name) => name.startsWith('strata-engine-'))) {
|
|
407
|
+
return { tag: `v${appVersion.replace(/^v/i, '')}`, assets, assetUrls };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// Feed unreachable or malformed: fall through to the release walk.
|
|
414
|
+
}
|
|
415
|
+
// Fallback: walk the release list and take the newest release that still
|
|
416
|
+
// ships general `strata-engine-` archives. A control-only release (the
|
|
417
|
+
// app tags) or a model-specific one (`strata-q4-lite-`) must not win the
|
|
418
|
+
// walk — the same failure mode as llama.cpp's pointer-only stable tags.
|
|
419
|
+
const res = await fetchImpl('https://api.github.com/repos/Niko1221/Strata/releases?per_page=30', {
|
|
420
|
+
headers: githubHeaders(),
|
|
421
|
+
...(signal ? { signal } : {}),
|
|
422
|
+
});
|
|
423
|
+
if (!res.ok) {
|
|
424
|
+
throw new Error(`Strata release lookup failed (${res.status})`);
|
|
425
|
+
}
|
|
426
|
+
const list = (await res.json());
|
|
427
|
+
for (const release of Array.isArray(list) ? list : []) {
|
|
428
|
+
const tag = typeof release.tag_name === 'string' ? release.tag_name : '';
|
|
429
|
+
const assets = Array.isArray(release.assets)
|
|
430
|
+
? release.assets.map((a) => (typeof a.name === 'string' ? a.name : '')).filter(Boolean)
|
|
431
|
+
: [];
|
|
432
|
+
if (tag && assets.some((name) => name.startsWith('strata-engine-')))
|
|
433
|
+
return { tag, assets };
|
|
434
|
+
}
|
|
435
|
+
throw new Error('Strata release list has no engine release');
|
|
436
|
+
},
|
|
437
|
+
runtime: STRATA_RUNTIME,
|
|
438
|
+
recommendTarget: ({ platform, arch, nvidia, cudaMajor }) => {
|
|
439
|
+
if (platform === 'darwin')
|
|
440
|
+
return arch === 'arm64' ? 'metal' : null;
|
|
441
|
+
if (!nvidia)
|
|
442
|
+
return null;
|
|
443
|
+
// Strata's arm64 Linux build only exists for CUDA 13.
|
|
444
|
+
return arch === 'arm64' ? (cudaMajor >= 13 ? 'cuda13' : null) : cudaMajor >= 13 ? 'cuda13' : 'cuda12';
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
function strataTargetLabel(id) {
|
|
448
|
+
if (id === 'cuda12')
|
|
449
|
+
return 'CUDA 12';
|
|
450
|
+
if (id === 'cuda13')
|
|
451
|
+
return 'CUDA 13';
|
|
452
|
+
if (id === 'sycl')
|
|
453
|
+
return 'SYCL (Intel Arc)';
|
|
454
|
+
if (id === 'hip-halo')
|
|
455
|
+
return 'ROCm (Strix Halo)';
|
|
456
|
+
if (id === 'hip-rdna2')
|
|
457
|
+
return 'ROCm (RDNA2)';
|
|
458
|
+
if (id === 'hip-rdna3')
|
|
459
|
+
return 'ROCm (RDNA3)';
|
|
460
|
+
if (id.startsWith('hip-'))
|
|
461
|
+
return `ROCm (${id.slice(4).toUpperCase()})`;
|
|
462
|
+
return id;
|
|
463
|
+
}
|
|
464
|
+
/* ------------------------------------------------------------------------- *
|
|
465
|
+
* The registry
|
|
466
|
+
* ------------------------------------------------------------------------- */
|
|
467
|
+
/**
|
|
468
|
+
* Live engine registry, in console order. Core engines are registered at import
|
|
469
|
+
* time; a new engine (in-tree, a plugin, or a test double) calls
|
|
470
|
+
* `registerEngine` and EVERY consumer — file gating, the run console, the plan
|
|
471
|
+
* endpoint, target recommendations — picks it up without another edit. That is
|
|
472
|
+
* the whole point of ADR-0045.
|
|
473
|
+
*/
|
|
474
|
+
const ENGINE_REGISTRY = [LLAMACPP, STRATA];
|
|
475
|
+
/** The registry as the catalog endpoint reads it. Mutated by `registerEngine`. */
|
|
476
|
+
export const ENGINES = ENGINE_REGISTRY;
|
|
477
|
+
export function engineById(id) {
|
|
478
|
+
return ENGINE_REGISTRY.find((engine) => engine.id === id) ?? null;
|
|
479
|
+
}
|
|
480
|
+
/** Add (or replace by id) one engine definition. */
|
|
481
|
+
export function registerEngine(engine) {
|
|
482
|
+
const at = ENGINE_REGISTRY.findIndex((existing) => existing.id === engine.id);
|
|
483
|
+
if (at >= 0)
|
|
484
|
+
ENGINE_REGISTRY[at] = engine;
|
|
485
|
+
else
|
|
486
|
+
ENGINE_REGISTRY.push(engine);
|
|
487
|
+
}
|
|
488
|
+
/** Drop one engine from the registry (test teardown; no route exposes this). */
|
|
489
|
+
export function unregisterEngine(id) {
|
|
490
|
+
const at = ENGINE_REGISTRY.findIndex((engine) => engine.id === id);
|
|
491
|
+
if (at < 0)
|
|
492
|
+
return false;
|
|
493
|
+
ENGINE_REGISTRY.splice(at, 1);
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
/** Every engine the gateway can launch (install-only entries excluded). */
|
|
497
|
+
export function launchableEngines() {
|
|
498
|
+
return ENGINE_REGISTRY.filter((engine) => !!engine.runtime);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Which engines can run one local file, given its parsed header and the
|
|
502
|
+
* operator's stored profiles. Every answer comes from the engine's own
|
|
503
|
+
* `runtime.serves()` — this function holds NO engine names, so a newly
|
|
504
|
+
* registered engine (or a StubEngine test double) participates automatically.
|
|
505
|
+
*/
|
|
506
|
+
export function engineSupportFor(filePath, meta, profiles = {}) {
|
|
507
|
+
const verdicts = {};
|
|
508
|
+
const runnable = [];
|
|
509
|
+
for (const engine of launchableEngines()) {
|
|
510
|
+
const verdict = engine.runtime.serves({ modelPath: filePath, meta, profile: profiles[engine.id] });
|
|
511
|
+
verdicts[engine.id] = verdict;
|
|
512
|
+
if (verdict.serves)
|
|
513
|
+
runnable.push(engine.id);
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
runnable,
|
|
517
|
+
moe: (meta?.experts ?? 0) > 0,
|
|
518
|
+
engines: verdicts,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
export function engineRuntimeInfo(engine) {
|
|
522
|
+
const runtime = engine.runtime;
|
|
523
|
+
if (!runtime)
|
|
524
|
+
return null;
|
|
525
|
+
return {
|
|
526
|
+
placement: runtime.placement,
|
|
527
|
+
accepts: runtime.accepts,
|
|
528
|
+
profile: runtime.profile ? { intro: runtime.profile.intro, groups: runtime.profile.groups } : null,
|
|
529
|
+
...(runtime.setup ? { setup: { intro: runtime.setup.intro, fields: runtime.setup.fields } } : {}),
|
|
530
|
+
...(runtime.catalog ? { catalog: true } : {}),
|
|
531
|
+
...(runtime.drafter ? { drafter: true } : {}),
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/** Default build target per engine for this machine. Keys ARE the registry's. */
|
|
535
|
+
export function recommendTargets(detect) {
|
|
536
|
+
const out = {};
|
|
537
|
+
for (const engine of ENGINES) {
|
|
538
|
+
out[engine.id] = engine.recommendTarget ? engine.recommendTarget(detect) : null;
|
|
539
|
+
}
|
|
540
|
+
return out;
|
|
541
|
+
}
|
|
542
|
+
/** `0.1.44` vs `0.1.69`; a missing side is 0, so `0.2` > `0.2.0`. */
|
|
543
|
+
export function compareVersions(left, right) {
|
|
544
|
+
const parts = (value) => value.split(/[.+-]/).map((piece) => Number.parseInt(piece, 10) || 0);
|
|
545
|
+
const a = parts(left);
|
|
546
|
+
const b = parts(right);
|
|
547
|
+
for (let i = 0; i < Math.max(a.length, b.length); i += 1) {
|
|
548
|
+
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
|
549
|
+
if (diff !== 0)
|
|
550
|
+
return diff > 0 ? 1 : -1;
|
|
551
|
+
}
|
|
552
|
+
return 0;
|
|
553
|
+
}
|
|
554
|
+
export function catalogModelGate(model, opts) {
|
|
555
|
+
if (model.minEngine && opts.engineVersion && compareVersions(opts.engineVersion, model.minEngine) < 0) {
|
|
556
|
+
return { ok: false, code: 'engine-too-old', param: model.minEngine };
|
|
557
|
+
}
|
|
558
|
+
for (const token of model.requires ?? []) {
|
|
559
|
+
if (token === 'nvidia') {
|
|
560
|
+
if (!opts.machine.nvidia)
|
|
561
|
+
return { ok: false, code: 'needs-nvidia' };
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
// Fail CLOSED on a token this build cannot verify: the requirement exists
|
|
565
|
+
// because the model breaks without it, so guessing "probably fine" would
|
|
566
|
+
// reinstate exactly the silent failure the field prevents.
|
|
567
|
+
return { ok: false, code: 'unknown-requirement', param: token };
|
|
568
|
+
}
|
|
569
|
+
return { ok: true };
|
|
570
|
+
}
|
|
571
|
+
/** The version this gateway installed for one engine, when it did. */
|
|
572
|
+
export function installedEngineVersion(engineId) {
|
|
573
|
+
const rows = Object.values(readInstalledEngines()).filter((row) => row.engine === engineId);
|
|
574
|
+
return rows.map((row) => row.version).sort((a, b) => compareVersions(b, a))[0];
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Resolve the engine's current release and report which catalog targets it
|
|
578
|
+
* actually ships — a target chip whose asset is missing is rendered disabled
|
|
579
|
+
* instead of failing the install click after the operator committed to it.
|
|
580
|
+
*/
|
|
581
|
+
export async function probeEngineAvailability(engine, fetchImpl = fetch) {
|
|
582
|
+
let release;
|
|
583
|
+
try {
|
|
584
|
+
release = await engine.resolveRelease(fetchImpl);
|
|
585
|
+
}
|
|
586
|
+
catch (err) {
|
|
587
|
+
return { id: engine.id, error: err instanceof Error ? err.message : 'release lookup failed' };
|
|
588
|
+
}
|
|
589
|
+
const targets = {};
|
|
590
|
+
for (const target of engine.targets(process.platform, process.arch)) {
|
|
591
|
+
const matched = engine.matchAssets({
|
|
592
|
+
platform: process.platform,
|
|
593
|
+
arch: process.arch,
|
|
594
|
+
targetId: target.id,
|
|
595
|
+
tag: release.tag,
|
|
596
|
+
assets: release.assets,
|
|
597
|
+
});
|
|
598
|
+
targets[target.id] = matched
|
|
599
|
+
? { available: true, ...(matched.version !== release.tag ? { version: matched.version } : {}) }
|
|
600
|
+
: { available: false };
|
|
601
|
+
}
|
|
602
|
+
return { id: engine.id, tag: release.tag, targets };
|
|
603
|
+
}
|
|
604
|
+
/** Install root: `<ocrHome>/engines/<engineId>/<version>/`. */
|
|
605
|
+
export function engineInstallRoot() {
|
|
606
|
+
return path.join(getOcrHomeDir(), 'engines');
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* State key for one install: `<engineId>:<target>` — an engine may keep
|
|
610
|
+
* several build targets side by side (a CPU fallback next to the GPU build),
|
|
611
|
+
* and the run console picks among them at launch time. Legacy rows keyed by
|
|
612
|
+
* the bare engine id are normalised on READ (`record.engine + ':' + record.target`
|
|
613
|
+
* is the same key their install wrote).
|
|
614
|
+
*/
|
|
615
|
+
export function engineInstallKey(engineId, target) {
|
|
616
|
+
return `${engineId}:${target}`;
|
|
617
|
+
}
|
|
618
|
+
export function engineStateFile() {
|
|
619
|
+
return path.join(engineInstallRoot(), 'installed.json');
|
|
620
|
+
}
|
|
621
|
+
export function readInstalledEngines() {
|
|
622
|
+
try {
|
|
623
|
+
const parsed = JSON.parse(fs.readFileSync(engineStateFile(), 'utf8'));
|
|
624
|
+
if (!parsed || typeof parsed !== 'object')
|
|
625
|
+
return {};
|
|
626
|
+
const out = {};
|
|
627
|
+
for (const [key, record] of Object.entries(parsed)) {
|
|
628
|
+
if (!record || typeof record !== 'object' || !record.engine || !record.target)
|
|
629
|
+
continue;
|
|
630
|
+
out[key.includes(':') ? key : engineInstallKey(record.engine, record.target)] = record;
|
|
631
|
+
}
|
|
632
|
+
return out;
|
|
633
|
+
}
|
|
634
|
+
catch {
|
|
635
|
+
return {};
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
export function writeInstalledEngines(state) {
|
|
639
|
+
fs.mkdirSync(engineInstallRoot(), { recursive: true });
|
|
640
|
+
fs.writeFileSync(engineStateFile(), `${JSON.stringify(state, null, 2)}\n`);
|
|
641
|
+
}
|
|
642
|
+
/** Installs of one engine (every target), sorted by target id. */
|
|
643
|
+
export function installedEnginesFor(engineId) {
|
|
644
|
+
return Object.values(readInstalledEngines())
|
|
645
|
+
.filter((record) => record.engine === engineId)
|
|
646
|
+
.sort((a, b) => a.target.localeCompare(b.target));
|
|
647
|
+
}
|
|
648
|
+
/** One install by engine + target, when present. */
|
|
649
|
+
export function installedEngineFor(engineId, target) {
|
|
650
|
+
return readInstalledEngines()[engineInstallKey(engineId, target)] ?? null;
|
|
651
|
+
}
|