omnicell-router 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -7
- package/README.zh-CN.md +18 -5
- package/backend/dist/auth/api-keys.js +11 -0
- package/backend/dist/auth/key-models.d.ts +36 -0
- package/backend/dist/auth/key-models.js +99 -0
- package/backend/dist/capture/recorder.d.ts +4 -10
- package/backend/dist/capture/recorder.js +6 -58
- package/backend/dist/cli/clients/activity.js +2 -0
- package/backend/dist/cli/clients/base.d.ts +36 -11
- package/backend/dist/cli/clients/base.js +31 -15
- package/backend/dist/cli/clients/claude.d.ts +9 -0
- package/backend/dist/cli/clients/claude.js +6 -0
- package/backend/dist/cli/clients/codex.d.ts +78 -0
- package/backend/dist/cli/clients/codex.js +475 -57
- package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
- package/backend/dist/cli/clients/core-adapters.js +1 -1
- package/backend/dist/cli/clients/dsh.d.ts +8 -0
- package/backend/dist/cli/clients/dsh.js +5 -0
- package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
- package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
- package/backend/dist/cli/clients/grok.d.ts +15 -1
- package/backend/dist/cli/clients/grok.js +16 -2
- package/backend/dist/cli/clients/index.d.ts +13 -1
- package/backend/dist/cli/clients/index.js +97 -19
- package/backend/dist/cli/clients/kimi.d.ts +6 -0
- package/backend/dist/cli/clients/kimi.js +3 -0
- package/backend/dist/cli/clients/launcher.d.ts +1 -1
- package/backend/dist/cli/clients/model-meta.js +6 -3
- package/backend/dist/cli/clients/omp.d.ts +6 -0
- package/backend/dist/cli/clients/omp.js +3 -0
- package/backend/dist/cli/clients/openclaw.d.ts +6 -0
- package/backend/dist/cli/clients/openclaw.js +3 -0
- package/backend/dist/cli/clients/opencode.d.ts +8 -0
- package/backend/dist/cli/clients/opencode.js +8 -2
- package/backend/dist/cli/clients/pi.d.ts +6 -0
- package/backend/dist/cli/clients/pi.js +3 -0
- package/backend/dist/cli/clients/reserved.js +2 -0
- package/backend/dist/cli/clients/update-check.d.ts +37 -0
- package/backend/dist/cli/clients/update-check.js +309 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
- package/backend/dist/cli/clients/workbuddy.js +66 -0
- package/backend/dist/cli/index.js +5 -4
- package/backend/dist/cli/paths.js +8 -0
- package/backend/dist/cli/types.d.ts +101 -16
- package/backend/dist/config/comments-en.js +34 -25
- package/backend/dist/config/comments-zh.js +33 -24
- package/backend/dist/config/defaults.d.ts +280 -22
- package/backend/dist/config/defaults.js +279 -21
- package/backend/dist/config/env.d.ts +10 -0
- package/backend/dist/config/env.js +3 -2
- package/backend/dist/config/index.d.ts +22 -1
- package/backend/dist/config/index.js +218 -43
- package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
- package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
- package/backend/dist/config/migrations/v10-to-v11.js +43 -0
- package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
- package/backend/dist/config/migrations/v4-to-v5.js +42 -0
- package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
- package/backend/dist/config/migrations/v5-to-v6.js +29 -0
- package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
- package/backend/dist/config/migrations/v6-to-v7.js +97 -0
- package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
- package/backend/dist/config/migrations/v7-to-v8.js +43 -0
- package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
- package/backend/dist/config/migrations/v8-to-v9.js +43 -0
- package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
- package/backend/dist/config/migrations/v9-to-v10.js +71 -0
- package/backend/dist/config/runtime.js +1 -1
- package/backend/dist/config/schema.d.ts +3 -3
- package/backend/dist/config/schema.js +18 -4
- package/backend/dist/config/types.d.ts +221 -41
- package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
- package/backend/dist/egress-proxy/asset-download.js +420 -0
- package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
- package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
- package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
- package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/egress-proxy/mihomo-client.js +308 -0
- package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/egress-proxy/mihomo-config.js +161 -0
- package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
- package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
- package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
- package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
- package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
- package/backend/dist/forward-proxy/egress.d.ts +50 -11
- package/backend/dist/forward-proxy/egress.js +63 -17
- package/backend/dist/forward-proxy/h2-forward.js +42 -15
- package/backend/dist/forward-proxy/index.d.ts +11 -8
- package/backend/dist/forward-proxy/index.js +27 -60
- package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
- package/backend/dist/forward-proxy/interceptor.js +4 -4
- package/backend/dist/forward-proxy/relay.js +3 -3
- package/backend/dist/forward-proxy/rules.d.ts +4 -4
- package/backend/dist/forward-proxy/rules.js +25 -4
- package/backend/dist/forward-proxy/server.d.ts +12 -16
- package/backend/dist/forward-proxy/server.js +237 -171
- package/backend/dist/harness/host/hosts.js +3 -2
- package/backend/dist/index.js +59 -19
- package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
- package/backend/dist/ingress-proxy/access-log.js +774 -0
- package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
- package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
- package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
- package/backend/dist/ingress-proxy/ca-trust.js +315 -0
- package/backend/dist/ingress-proxy/ca.d.ts +104 -0
- package/backend/dist/ingress-proxy/ca.js +273 -0
- package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
- package/backend/dist/ingress-proxy/data-dir.js +45 -0
- package/backend/dist/ingress-proxy/egress.d.ts +151 -0
- package/backend/dist/ingress-proxy/egress.js +364 -0
- package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/ingress-proxy/h2-forward.js +561 -0
- package/backend/dist/ingress-proxy/index.d.ts +24 -0
- package/backend/dist/ingress-proxy/index.js +144 -0
- package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
- package/backend/dist/ingress-proxy/interceptor.js +52 -0
- package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
- package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
- package/backend/dist/ingress-proxy/relay.d.ts +54 -0
- package/backend/dist/ingress-proxy/relay.js +188 -0
- package/backend/dist/ingress-proxy/rules.d.ts +195 -0
- package/backend/dist/ingress-proxy/rules.js +348 -0
- package/backend/dist/ingress-proxy/server.d.ts +153 -0
- package/backend/dist/ingress-proxy/server.js +2065 -0
- package/backend/dist/ingress-proxy/sni.d.ts +35 -0
- package/backend/dist/ingress-proxy/sni.js +124 -0
- package/backend/dist/ingress-proxy/status.d.ts +32 -0
- package/backend/dist/ingress-proxy/status.js +15 -0
- package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
- package/backend/dist/ingress-proxy/system-proxy.js +481 -0
- package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
- package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
- package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
- package/backend/dist/ingress-proxy/traffic-files.js +10 -0
- package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
- package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/ingress-proxy/ws-frames.js +153 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
- package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
- package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
- package/backend/dist/ir/adapters/google-gemini.js +5 -2
- package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
- package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
- package/backend/dist/ir/adapters/openai-chat.js +50 -6
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
- package/backend/dist/ir/adapters/openai-responses.d.ts +92 -1
- package/backend/dist/ir/adapters/openai-responses.js +163 -12
- package/backend/dist/ir/capabilities.js +4 -0
- package/backend/dist/ir/media.d.ts +20 -0
- package/backend/dist/ir/media.js +41 -0
- package/backend/dist/ir/tool-identity.d.ts +35 -0
- package/backend/dist/ir/tool-identity.js +40 -0
- package/backend/dist/ir/types.d.ts +9 -1
- package/backend/dist/ir/validate.d.ts +24 -0
- package/backend/dist/ir/validate.js +113 -63
- package/backend/dist/local/build-jobs.d.ts +66 -0
- package/backend/dist/local/build-jobs.js +243 -0
- package/backend/dist/local/detect.d.ts +32 -0
- package/backend/dist/local/detect.js +145 -0
- package/backend/dist/local/draft-match.d.ts +58 -0
- package/backend/dist/local/draft-match.js +124 -0
- package/backend/dist/local/engine-runtime.d.ts +522 -0
- package/backend/dist/local/engine-runtime.js +1 -0
- package/backend/dist/local/engines.d.ts +241 -0
- package/backend/dist/local/engines.js +651 -0
- package/backend/dist/local/gguf.d.ts +35 -0
- package/backend/dist/local/gguf.js +314 -0
- package/backend/dist/local/hf.d.ts +120 -0
- package/backend/dist/local/hf.js +304 -0
- package/backend/dist/local/install.d.ts +90 -0
- package/backend/dist/local/install.js +421 -0
- package/backend/dist/local/llamacpp.d.ts +55 -0
- package/backend/dist/local/llamacpp.js +177 -0
- package/backend/dist/local/local-provider.d.ts +81 -0
- package/backend/dist/local/local-provider.js +301 -0
- package/backend/dist/local/machine-stats.d.ts +87 -0
- package/backend/dist/local/machine-stats.js +332 -0
- package/backend/dist/local/model-store.d.ts +347 -0
- package/backend/dist/local/model-store.js +1215 -0
- package/backend/dist/local/part-sweep.d.ts +32 -0
- package/backend/dist/local/part-sweep.js +156 -0
- package/backend/dist/local/plan.d.ts +65 -0
- package/backend/dist/local/plan.js +146 -0
- package/backend/dist/local/resources.d.ts +49 -0
- package/backend/dist/local/resources.js +64 -0
- package/backend/dist/local/run-stats.d.ts +95 -0
- package/backend/dist/local/run-stats.js +195 -0
- package/backend/dist/local/runner.d.ts +235 -0
- package/backend/dist/local/runner.js +1392 -0
- package/backend/dist/local/settings.d.ts +79 -0
- package/backend/dist/local/settings.js +180 -0
- package/backend/dist/local/strata-catalog.d.ts +30 -0
- package/backend/dist/local/strata-catalog.js +511 -0
- package/backend/dist/local/strata-drafting.d.ts +46 -0
- package/backend/dist/local/strata-drafting.js +265 -0
- package/backend/dist/local/strata.d.ts +278 -0
- package/backend/dist/local/strata.js +1392 -0
- package/backend/dist/local/tar.d.ts +20 -0
- package/backend/dist/local/tar.js +367 -0
- package/backend/dist/local/transport.d.ts +35 -0
- package/backend/dist/local/transport.js +89 -0
- package/backend/dist/local/tune.d.ts +58 -0
- package/backend/dist/local/tune.js +324 -0
- package/backend/dist/observability/http-exchange.d.ts +2 -2
- package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
- package/backend/dist/opencode/catalog/auto-pull.js +284 -77
- package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
- package/backend/dist/opencode/catalog/ocr-store.js +4 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +15 -4
- package/backend/dist/opencode/catalog/overrides-store.js +28 -19
- package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
- package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
- package/backend/dist/opencode/catalog/repository.js +28 -5
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
- package/backend/dist/opencode/catalog/sources/models-dev.js +42 -14
- package/backend/dist/opencode/catalog/types.d.ts +42 -12
- package/backend/dist/opencode/catalog/types.js +38 -1
- package/backend/dist/opencode/credentials/def-materialize.js +27 -21
- package/backend/dist/opencode/credentials/ocr-store.js +11 -2
- package/backend/dist/opencode/credentials/sync.js +12 -3
- package/backend/dist/opencode/credentials/types.d.ts +31 -4
- package/backend/dist/opencode/credentials/types.js +25 -0
- package/backend/dist/opencode/migrate/engine.d.ts +20 -0
- package/backend/dist/opencode/migrate/engine.js +71 -0
- package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
- package/backend/dist/opencode/migrate/migrator.js +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
- package/backend/dist/opencode/probe.d.ts +21 -4
- package/backend/dist/opencode/probe.js +34 -10
- package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
- package/backend/dist/opencode/provider-def-adapters.js +43 -27
- package/backend/dist/opencode/provider-defs.d.ts +10 -16
- package/backend/dist/opencode/provider-defs.js +45 -45
- package/backend/dist/opencode/user-config.d.ts +23 -26
- package/backend/dist/opencode/user-config.js +95 -77
- package/backend/dist/pipeline/directives.d.ts +9 -4
- package/backend/dist/pipeline/directives.js +14 -10
- package/backend/dist/pipeline/orchestrator.d.ts +42 -13
- package/backend/dist/pipeline/orchestrator.js +514 -172
- package/backend/dist/plugins/builtin/model-gateway.js +38 -12
- package/backend/dist/plugins/environment-ack.d.ts +51 -0
- package/backend/dist/plugins/environment-ack.js +81 -0
- package/backend/dist/plugins/gateways.d.ts +6 -6
- package/backend/dist/plugins/gateways.js +2 -2
- package/backend/dist/plugins/host.d.ts +100 -16
- package/backend/dist/plugins/host.js +637 -99
- package/backend/dist/plugins/install-run.d.ts +27 -0
- package/backend/dist/plugins/install-run.js +99 -0
- package/backend/dist/plugins/manifest.d.ts +84 -32
- package/backend/dist/plugins/manifest.js +149 -45
- package/backend/dist/plugins/market-install.d.ts +18 -0
- package/backend/dist/plugins/market-install.js +111 -0
- package/backend/dist/plugins/market-source.d.ts +100 -0
- package/backend/dist/plugins/market-source.js +449 -0
- package/backend/dist/plugins/market-updates.d.ts +70 -0
- package/backend/dist/plugins/market-updates.js +97 -0
- package/backend/dist/plugins/market.d.ts +677 -0
- package/backend/dist/plugins/market.js +2113 -0
- package/backend/dist/plugins/source-index.d.ts +155 -0
- package/backend/dist/plugins/source-index.js +217 -0
- package/backend/dist/plugins/types.d.ts +402 -37
- package/backend/dist/projects/worktrees.d.ts +88 -0
- package/backend/dist/projects/worktrees.js +220 -0
- package/backend/dist/providers/boot-direct.d.ts +41 -7
- package/backend/dist/providers/boot-direct.js +284 -44
- package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
- package/backend/dist/providers/dial-wire.d.ts +17 -0
- package/backend/dist/providers/dial-wire.js +49 -0
- package/backend/dist/providers/executors/dispatch.d.ts +17 -7
- package/backend/dist/providers/executors/dispatch.js +28 -9
- package/backend/dist/providers/executors/openai-chat.js +14 -2
- package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
- package/backend/dist/providers/executors/plugin-adapter.js +59 -3
- package/backend/dist/providers/member-match.d.ts +32 -9
- package/backend/dist/providers/member-match.js +65 -21
- package/backend/dist/providers/model-resolution.d.ts +62 -0
- package/backend/dist/providers/model-resolution.js +62 -0
- package/backend/dist/providers/price-order.d.ts +51 -0
- package/backend/dist/providers/price-order.js +54 -0
- package/backend/dist/providers/protocols-field.d.ts +24 -0
- package/backend/dist/providers/protocols-field.js +66 -0
- package/backend/dist/providers/provider-takedown.d.ts +5 -2
- package/backend/dist/providers/registry.d.ts +87 -26
- package/backend/dist/providers/registry.js +232 -121
- package/backend/dist/providers/selection.d.ts +91 -0
- package/backend/dist/providers/selection.js +158 -0
- package/backend/dist/providers/virtual-meta.d.ts +33 -2
- package/backend/dist/providers/virtual-meta.js +74 -18
- package/backend/dist/quota/cli-login.d.ts +25 -4
- package/backend/dist/quota/cli-login.js +38 -6
- package/backend/dist/quota/coverage-generation.d.ts +24 -0
- package/backend/dist/quota/coverage-generation.js +29 -0
- package/backend/dist/quota/declarations.js +8 -4
- package/backend/dist/quota/engine.js +2 -2
- package/backend/dist/quota/prober.d.ts +43 -2
- package/backend/dist/quota/prober.js +97 -22
- package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
- package/backend/dist/resilience/error-classifier.js +29 -0
- package/backend/dist/router/index.d.ts +1 -1
- package/backend/dist/router/index.js +17 -1
- package/backend/dist/router/layer2-decision.d.ts +1 -1
- package/backend/dist/router/layer2-decision.js +2 -2
- package/backend/dist/routes/console.js +1043 -405
- package/backend/dist/routes/environments.js +1 -1
- package/backend/dist/routes/local-models.d.ts +2 -0
- package/backend/dist/routes/local-models.js +1414 -0
- package/backend/dist/routes/mihomo.d.ts +2 -2
- package/backend/dist/routes/mihomo.js +20 -11
- package/backend/dist/routes/projects.js +121 -0
- package/backend/dist/server.js +409 -15
- package/backend/dist/session/session-manager.d.ts +42 -5
- package/backend/dist/session/session-manager.js +64 -11
- package/backend/dist/session/session-row.d.ts +29 -8
- package/backend/dist/session/session-row.js +18 -13
- package/backend/dist/snapshot/bundle.d.ts +40 -0
- package/backend/dist/snapshot/bundle.js +177 -0
- package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
- package/backend/dist/snapshot/handoff/compress.js +77 -0
- package/backend/dist/snapshot/handoff/index.d.ts +119 -0
- package/backend/dist/snapshot/handoff/index.js +160 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
- package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
- package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
- package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
- package/backend/dist/snapshot/handoff/summarize.js +118 -0
- package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
- package/backend/dist/snapshot/handoff/transcript.js +167 -0
- package/backend/dist/snapshot/media-fs.d.ts +10 -0
- package/backend/dist/snapshot/media-fs.js +50 -0
- package/backend/dist/snapshot/media.d.ts +32 -0
- package/backend/dist/snapshot/media.js +87 -0
- package/backend/dist/snapshot/store.d.ts +226 -0
- package/backend/dist/snapshot/store.js +887 -0
- package/backend/dist/snapshot/tree.d.ts +112 -0
- package/backend/dist/snapshot/tree.js +207 -0
- package/backend/dist/snapshot/types.d.ts +212 -0
- package/backend/dist/snapshot/types.js +14 -0
- package/backend/dist/snapshot/view.d.ts +19 -0
- package/backend/dist/snapshot/view.js +57 -0
- package/backend/dist/snapshot/write-worker.d.ts +67 -0
- package/backend/dist/snapshot/write-worker.js +129 -0
- package/backend/dist/surfaces/anthropic.js +4 -1
- package/backend/dist/surfaces/body-admission.d.ts +344 -0
- package/backend/dist/surfaces/body-admission.js +818 -0
- package/backend/dist/surfaces/chat-pipeline.js +8 -0
- package/backend/dist/surfaces/decision-pipeline.js +10 -7
- package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
- package/backend/dist/surfaces/gateway-catalog.js +202 -0
- package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
- package/backend/dist/surfaces/gateway-chat.js +50 -12
- package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
- package/backend/dist/surfaces/ocr-headers.js +11 -7
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/transport-fastify.js +32 -5
- package/backend/dist/surfaces/transport-node-http.d.ts +51 -6
- package/backend/dist/surfaces/transport-node-http.js +76 -16
- package/backend/dist/surfaces/types.d.ts +11 -3
- package/backend/dist/trace/persist.js +21 -1
- package/backend/dist/trace/tracker.d.ts +35 -3
- package/backend/dist/trace/tracker.js +23 -0
- package/backend/dist/types/openai.d.ts +8 -0
- package/backend/dist/types/router.d.ts +17 -6
- package/backend/dist/types/router.js +14 -2
- package/backend/dist/utils/client-families.d.ts +66 -0
- package/backend/dist/utils/client-families.js +127 -0
- package/backend/dist/utils/event-ring.d.ts +1 -1
- package/backend/dist/utils/event-ring.js +1 -1
- package/backend/dist/utils/proxy-node.js +1 -1
- package/backend/dist/utils/proxy.d.ts +135 -11
- package/backend/dist/utils/proxy.js +144 -29
- package/backend/dist/utils/run-command.d.ts +21 -1
- package/backend/dist/utils/run-command.js +64 -4
- package/backend/dist/utils/server-liveness.d.ts +28 -0
- package/backend/dist/utils/server-liveness.js +32 -0
- package/backend/dist/utils/session-file.d.ts +28 -0
- package/backend/dist/utils/session-file.js +34 -0
- package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
- package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
- package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
- package/frontend/dist/assets/{index-DxZ9MHKB.css → index-CqDSOPQ0.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +3 -1
- package/frontend/dist/assets/index-55VVwfFQ.js +0 -1521
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine build jobs (ADR-0045 §9).
|
|
3
|
+
*
|
|
4
|
+
* A BUILD produces the launch input an engine derives — today that is Strata's
|
|
5
|
+
* pack, written by the workspace's own tooling (`tools/iq_pack.py`). A build is
|
|
6
|
+
* NOT a run: no port, no health probe, no adoption, no restart budget. It
|
|
7
|
+
* spawns the engine's legs in order, streams their output into a per-job log
|
|
8
|
+
* ring, and finishes. Interruption safety comes from the packer's own
|
|
9
|
+
* contract — the completion marker is published last and `looksLikePack`
|
|
10
|
+
* requires it — so a gateway restart mid-build needs no bookkeeping here: the
|
|
11
|
+
* half-written pack simply never matches, and the next build rewrites it.
|
|
12
|
+
*
|
|
13
|
+
* The module names no engine: the argv comes from the engine's
|
|
14
|
+
* `EngineRuntime.build`, the same registry the runner reads (ADR-0045).
|
|
15
|
+
*/
|
|
16
|
+
import { spawn } from 'node:child_process';
|
|
17
|
+
import { EventRing, MIHOMO_LOG_RING_CAPACITY, nextRingEventId } from '../utils/event-ring.js';
|
|
18
|
+
import { engineById, readInstalledEngines } from './engines.js';
|
|
19
|
+
import { profileFor, readInstalledModels, rescanModelMeta } from './model-store.js';
|
|
20
|
+
import { readGgufMeta } from './gguf.js';
|
|
21
|
+
import { localProxyEnv } from './transport.js';
|
|
22
|
+
import { pipeChildLines, sanitizeRunLogText, } from './runner.js';
|
|
23
|
+
const jobs = new Map();
|
|
24
|
+
const logs = new Map();
|
|
25
|
+
/** Finished jobs the console's poll still shows; the oldest beyond this go. */
|
|
26
|
+
const FINISHED_JOBS_KEPT = 20;
|
|
27
|
+
let jobSeq = 0;
|
|
28
|
+
let testSpawn = null;
|
|
29
|
+
/** Test seam, mirroring setLocalRunnerDepsForTests. */
|
|
30
|
+
export function setBuildJobDepsForTests(deps) {
|
|
31
|
+
testSpawn = deps?.spawnImpl ?? null;
|
|
32
|
+
}
|
|
33
|
+
function ringFor(id) {
|
|
34
|
+
let ring = logs.get(id);
|
|
35
|
+
if (!ring) {
|
|
36
|
+
ring = new EventRing(undefined, MIHOMO_LOG_RING_CAPACITY);
|
|
37
|
+
logs.set(id, ring);
|
|
38
|
+
}
|
|
39
|
+
return ring;
|
|
40
|
+
}
|
|
41
|
+
export function appendBuildLog(id, stream, raw) {
|
|
42
|
+
const text = sanitizeRunLogText(raw);
|
|
43
|
+
if (text === null)
|
|
44
|
+
return;
|
|
45
|
+
const ts = Date.now();
|
|
46
|
+
ringFor(id).append({ id: nextRingEventId('b-', ts), ts, stream, text });
|
|
47
|
+
}
|
|
48
|
+
export function buildLogs(id, limit = 300) {
|
|
49
|
+
const rows = ringFor(id).rows();
|
|
50
|
+
return limit >= rows.length ? rows : rows.slice(rows.length - limit);
|
|
51
|
+
}
|
|
52
|
+
/** Newest first; finished history is capped, building jobs are always listed. */
|
|
53
|
+
export function listBuildJobs() {
|
|
54
|
+
return [...jobs.values()].sort((a, b) => b.startedAt - a.startedAt);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Drop the finished jobs (and their rings) beyond the retention cap. Applied
|
|
58
|
+
* when a job finishes, so the cap is enforced on a job transition rather than
|
|
59
|
+
* on the console's poll — a read path never mutates the registry.
|
|
60
|
+
*/
|
|
61
|
+
function trimFinishedJobs() {
|
|
62
|
+
const finished = [...jobs.values()]
|
|
63
|
+
.filter((job) => job.status !== 'building')
|
|
64
|
+
.sort((a, b) => (b.finishedAt ?? b.startedAt) - (a.finishedAt ?? a.startedAt));
|
|
65
|
+
for (const job of finished.slice(FINISHED_JOBS_KEPT)) {
|
|
66
|
+
jobs.delete(job.id);
|
|
67
|
+
logs.delete(job.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function getBuildJob(id) {
|
|
71
|
+
return jobs.get(id) ?? null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Start one build for one (model, engine). The legs come from the engine's
|
|
75
|
+
* runtime; a refusal (incomplete workspace, missing tool) surfaces as the
|
|
76
|
+
* error rather than spawning something half-formed.
|
|
77
|
+
*/
|
|
78
|
+
export async function startBuildJob(opts) {
|
|
79
|
+
const model = readInstalledModels()[opts.modelId];
|
|
80
|
+
if (!model)
|
|
81
|
+
return { ok: false, code: 'model-missing', error: `model '${opts.modelId}' is not in the registry` };
|
|
82
|
+
const engine = engineById(opts.engine);
|
|
83
|
+
if (!engine)
|
|
84
|
+
return { ok: false, code: 'unknown-engine', error: `unknown engine '${opts.engine}'` };
|
|
85
|
+
const build = engine.runtime?.build;
|
|
86
|
+
if (!build)
|
|
87
|
+
return { ok: false, code: 'engine-cannot-build', error: `${engine.name} has no launch input it can build` };
|
|
88
|
+
// One active build per (model, engine): two packers writing one pack dir
|
|
89
|
+
// would interleave their writes into a single weight set.
|
|
90
|
+
for (const job of jobs.values()) {
|
|
91
|
+
if (job.modelId === opts.modelId && job.engine === engine.id && job.status === 'building') {
|
|
92
|
+
return { ok: false, code: 'build-active', error: `a build is already running for this model on ${engine.name} (job ${job.id})` };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const job = {
|
|
96
|
+
id: `build-${Date.now().toString(36)}-${(jobSeq++).toString(36)}`,
|
|
97
|
+
modelId: opts.modelId,
|
|
98
|
+
engine: engine.id,
|
|
99
|
+
status: 'building',
|
|
100
|
+
startedAt: Date.now(),
|
|
101
|
+
};
|
|
102
|
+
// Register BEFORE asking the engine for its legs: `build()` is async, so two
|
|
103
|
+
// near-simultaneous requests (two tabs, a double click, a retry) both passed
|
|
104
|
+
// the active-build guard above and both spawned a packer into the same output
|
|
105
|
+
// directory — exactly the interleaving the guard exists to prevent. A refusal
|
|
106
|
+
// or a throw must remove the placeholder again, or the model stays locked out
|
|
107
|
+
// of every later build.
|
|
108
|
+
jobs.set(job.id, job);
|
|
109
|
+
const abandon = () => {
|
|
110
|
+
jobs.delete(job.id);
|
|
111
|
+
logs.delete(job.id);
|
|
112
|
+
};
|
|
113
|
+
// The installed binary is only a discovery fallback (a workspace that ships
|
|
114
|
+
// its tooling beside the engine); the model path anchors everything else.
|
|
115
|
+
const install = Object.values(readInstalledEngines()).find((row) => row.engine === engine.id);
|
|
116
|
+
let legs;
|
|
117
|
+
try {
|
|
118
|
+
legs = await build({
|
|
119
|
+
jobId: job.id,
|
|
120
|
+
modelPath: model.filePath,
|
|
121
|
+
profile: profileFor(model, engine.id),
|
|
122
|
+
...(install?.binaries[0] ? { binary: install.binaries[0] } : {}),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
abandon();
|
|
127
|
+
return { ok: false, code: 'build-refused', error: err instanceof Error ? err.message : `${engine.name} could not plan this build` };
|
|
128
|
+
}
|
|
129
|
+
if (!Array.isArray(legs)) {
|
|
130
|
+
abandon();
|
|
131
|
+
return { ok: false, code: legs.code ?? 'build-refused', error: legs.error };
|
|
132
|
+
}
|
|
133
|
+
appendBuildLog(job.id, 'gateway', `building the ${engine.name} launch input for ${model.filePath}`);
|
|
134
|
+
void executeLegs(job, legs);
|
|
135
|
+
return { ok: true, job };
|
|
136
|
+
}
|
|
137
|
+
async function executeLegs(job, legs) {
|
|
138
|
+
for (const leg of legs) {
|
|
139
|
+
// A step already satisfied needs no process: the engine declares the test
|
|
140
|
+
// (`skipIf`), so a restart mid-chain resumes where it stopped instead of
|
|
141
|
+
// repacking finished work.
|
|
142
|
+
if (leg.skipIf?.()) {
|
|
143
|
+
appendBuildLog(job.id, 'gateway', `${leg.name ?? 'step'} already present, skipped`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const code = await spawnLeg(job, leg);
|
|
147
|
+
if (code !== 0) {
|
|
148
|
+
job.status = 'failed';
|
|
149
|
+
job.errorCode = 'build-leg-exited';
|
|
150
|
+
job.error = `${leg.name ?? 'build'} exited (code ${code ?? 'null'})`;
|
|
151
|
+
job.finishedAt = Date.now();
|
|
152
|
+
appendBuildLog(job.id, 'gateway', job.error);
|
|
153
|
+
trimFinishedJobs();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
job.status = 'done';
|
|
158
|
+
job.finishedAt = Date.now();
|
|
159
|
+
appendBuildLog(job.id, 'gateway', 'build finished');
|
|
160
|
+
// The build changed what the engine can serve (the pack is ON DISK now), so
|
|
161
|
+
// the model's cached verdicts are stale: re-derive them, and the console's
|
|
162
|
+
// next list flips the engine to runnable with no restart (ADR-0045 §9).
|
|
163
|
+
rescanModelMeta(job.modelId);
|
|
164
|
+
trimFinishedJobs();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* What a catalog download does next, once its files are on disk.
|
|
168
|
+
*
|
|
169
|
+
* "Downloaded" is not "runnable": a model whose launch input the ENGINE derives
|
|
170
|
+
* (a pack, or the in-place tokenizer) is still `serves: false` until that input
|
|
171
|
+
* exists. Asking the engine's own verdict (`buildable`) is what keeps this
|
|
172
|
+
* engine-agnostic — the gateway never decides by name that a model "needs a
|
|
173
|
+
* pack". `null` means nothing to do: the model already runs, or no engine can
|
|
174
|
+
* derive what it is missing (the console's Pack button covers that case).
|
|
175
|
+
*
|
|
176
|
+
* A start that fails is returned, not thrown, and it changes nothing about the
|
|
177
|
+
* model: `startBuildJob` only registers a job on success, so a failure leaves
|
|
178
|
+
* the model `buildable` and its Pack button in place — that IS the retry path.
|
|
179
|
+
*/
|
|
180
|
+
export async function prepareAfterDownload(model, engineId) {
|
|
181
|
+
const engine = engineById(engineId);
|
|
182
|
+
if (!engine?.runtime)
|
|
183
|
+
return undefined;
|
|
184
|
+
const row = readInstalledModels()[model.id];
|
|
185
|
+
const verdict = engine.runtime.serves({
|
|
186
|
+
modelPath: model.filePath,
|
|
187
|
+
meta: readGgufMeta(model.filePath),
|
|
188
|
+
profile: row ? profileFor(row, engineId) : undefined,
|
|
189
|
+
});
|
|
190
|
+
// Two ways a build is wanted: the model cannot serve yet and the engine can
|
|
191
|
+
// derive what it is missing (`buildable`), or it serves but a derived
|
|
192
|
+
// artefact would make it better (`preparable` — Strata's draft layer).
|
|
193
|
+
if (verdict.serves ? verdict.preparable !== true : verdict.buildable !== true)
|
|
194
|
+
return undefined;
|
|
195
|
+
const started = await startBuildJob({ modelId: model.id, engine: engineId });
|
|
196
|
+
// `nothing-to-do` is not a refusal to report: the verdict said work was left
|
|
197
|
+
// and the engine has since caught up (a build that finished between the two
|
|
198
|
+
// reads). Saying "still needs preparing, use Pack" there would send the
|
|
199
|
+
// operator to a button that does nothing.
|
|
200
|
+
if (!started.ok && started.code === 'nothing-to-do')
|
|
201
|
+
return undefined;
|
|
202
|
+
return started.ok
|
|
203
|
+
? { status: 'started', jobId: started.job.id }
|
|
204
|
+
: { status: 'refused', code: started.code, error: started.error };
|
|
205
|
+
}
|
|
206
|
+
/** Spawn one leg and resolve with its exit code (-1 when the spawn failed). */
|
|
207
|
+
function spawnLeg(job, leg) {
|
|
208
|
+
const spawnImpl = testSpawn ?? ((cmd, args, o) => spawn(cmd, args, o));
|
|
209
|
+
return new Promise((resolve) => {
|
|
210
|
+
let child;
|
|
211
|
+
try {
|
|
212
|
+
child = spawnImpl(leg.cmd, leg.args, {
|
|
213
|
+
cwd: leg.cwd,
|
|
214
|
+
detached: false,
|
|
215
|
+
// Piped so the build log drawer can show the tool's own words; both
|
|
216
|
+
// pipes are drained, so a chatty build never blocks on a full buffer.
|
|
217
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
218
|
+
windowsHide: true,
|
|
219
|
+
shell: false,
|
|
220
|
+
// A tool that reads a mirror or a token from the environment gets the
|
|
221
|
+
// gateway's own (the same values a model download uses), so a machine
|
|
222
|
+
// that can fetch the model can also prepare it. A leg that DIALS the
|
|
223
|
+
// hub also gets the market's egress env: a draft layer fetched over a
|
|
224
|
+
// direct dial while the weights came through the proxy is the same
|
|
225
|
+
// leak the market switch exists to prevent.
|
|
226
|
+
...(leg.env || leg.network ? { env: { ...process.env, ...(leg.network ? localProxyEnv() : {}), ...leg.env } } : {}),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
appendBuildLog(job.id, 'gateway', `spawn failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
231
|
+
resolve(-1);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
appendBuildLog(job.id, 'gateway', `process started (pid ${child.pid ?? '?'})`);
|
|
235
|
+
pipeChildLines(child.stdout ?? null, (line) => appendBuildLog(job.id, 'stdout', line));
|
|
236
|
+
pipeChildLines(child.stderr ?? null, (line) => appendBuildLog(job.id, 'stderr', line));
|
|
237
|
+
child.on?.('error', (err) => {
|
|
238
|
+
appendBuildLog(job.id, 'gateway', `spawn error: ${err.message}`);
|
|
239
|
+
resolve(-1);
|
|
240
|
+
});
|
|
241
|
+
child.on?.('exit', (code) => resolve(code));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { EngineDetectSummary } from './engines.js';
|
|
2
|
+
export interface DepCheck {
|
|
3
|
+
id: string;
|
|
4
|
+
ok: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Human-readable detail (`NVIDIA GeForce RTX 4070 · driver 566.36 · CUDA 12.7`). */
|
|
7
|
+
detail: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DetectReport {
|
|
10
|
+
platform: string;
|
|
11
|
+
arch: string;
|
|
12
|
+
/** Discrete GPUs as printed by the vendor tools (may be empty). */
|
|
13
|
+
gpus: string[];
|
|
14
|
+
/** Driver-reported max CUDA version (`12.7`), absent without an NVIDIA stack. */
|
|
15
|
+
cudaVersion?: string;
|
|
16
|
+
/** Total discrete VRAM in MiB (NVIDIA only), for model-fit hints. */
|
|
17
|
+
vramMb?: number;
|
|
18
|
+
/** Currently FREE discrete VRAM in MiB (NVIDIA only) — the machine panel's
|
|
19
|
+
* "available" readout. */
|
|
20
|
+
vramFreeMb?: number;
|
|
21
|
+
/** Physical system RAM in MiB — the fit a catalog model's RAM figure is
|
|
22
|
+
* checked against (an engine that keeps experts in RAM is bounded by it). */
|
|
23
|
+
ramMb: number;
|
|
24
|
+
checks: DepCheck[];
|
|
25
|
+
}
|
|
26
|
+
/** Probe the machine once and return the raw report. */
|
|
27
|
+
export declare function detectDependencies(): Promise<DetectReport>;
|
|
28
|
+
/**
|
|
29
|
+
* The machine facts a per-engine target recommendation reads (ADR-0045: the
|
|
30
|
+
* recommendation lives on the ENGINE, so this stays a neutral summary).
|
|
31
|
+
*/
|
|
32
|
+
export declare function summarizeDetect(report: DetectReport): EngineDetectSummary;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local dependency detection for the Local Models console.
|
|
3
|
+
*
|
|
4
|
+
* The console asks "can this machine run a GPU engine, and which one?" — this
|
|
5
|
+
* module answers with a check list plus a per-engine recommended target:
|
|
6
|
+
* - `nvidia-smi` → NVIDIA GPUs, driver version and the driver's max CUDA
|
|
7
|
+
* version (parsed from the banner, the same place nvidia-smi prints it).
|
|
8
|
+
* - `vulkaninfo` → a Vulkan loader on PATH (driver + loader installed).
|
|
9
|
+
* - `rocminfo` → an AMD ROCm userspace (Linux/Windows HIP runtimes).
|
|
10
|
+
* - `clinfo` → an OpenCL runtime, the weakest signal for an Intel SYCL stack.
|
|
11
|
+
* - macOS → Metal is part of the OS; no probe exists to fail.
|
|
12
|
+
* - CPU is always available as the last resort (llama.cpp only).
|
|
13
|
+
*
|
|
14
|
+
* Everything runs with short timeouts and swallows failures: a missing tool
|
|
15
|
+
* is a `not-found` check row, never an error response. Results are reports —
|
|
16
|
+
* the console decides what to offer; `recommend()` only proposes.
|
|
17
|
+
*/
|
|
18
|
+
import { execFile } from 'node:child_process';
|
|
19
|
+
import os from 'node:os';
|
|
20
|
+
function run(command, args, timeoutMs = 6000) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
try {
|
|
23
|
+
execFile(command, args, { timeout: timeoutMs, windowsHide: true, encoding: 'utf8', maxBuffer: 4 * 1024 * 1024 }, (err, stdout) => {
|
|
24
|
+
resolve({ ok: !err, stdout: typeof stdout === 'string' ? stdout : '' });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
resolve({ ok: false, stdout: '' });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function detectNvidia() {
|
|
33
|
+
const res = await run('nvidia-smi', []);
|
|
34
|
+
if (!res.ok || !res.stdout.trim())
|
|
35
|
+
return { present: false, gpus: [], driver: '' };
|
|
36
|
+
const out = res.stdout;
|
|
37
|
+
const driver = /\bDriver Version:\s*([0-9.]+)/.exec(out)?.[1] ?? '';
|
|
38
|
+
const cudaVersion = /\bCUDA Version:\s*([0-9.]+)/.exec(out)?.[1];
|
|
39
|
+
const gpus = [];
|
|
40
|
+
for (const line of out.split('\n')) {
|
|
41
|
+
// The process table also names GPUs; only the device rows start with an
|
|
42
|
+
// index. Match the `0 NVIDIA GeForce ...` shape before the MiB columns.
|
|
43
|
+
const match = /^\s*(\d+)\s+(\S[^|]*?)\s{2,}[\d.]+MiB/.exec(line);
|
|
44
|
+
if (match)
|
|
45
|
+
gpus.push(match[2].trim());
|
|
46
|
+
}
|
|
47
|
+
if (gpus.length === 0 && /NVIDIA/i.test(out))
|
|
48
|
+
gpus.push('NVIDIA GPU');
|
|
49
|
+
// Fit-hint metric: sum every GPU's frame buffer (csv keeps the parse dull).
|
|
50
|
+
const vram = await run('nvidia-smi', ['--query-gpu=memory.total,memory.free', '--format=csv,noheader,nounits'], 6000);
|
|
51
|
+
let vramMb;
|
|
52
|
+
let vramFreeMb;
|
|
53
|
+
if (vram.ok) {
|
|
54
|
+
for (const line of vram.stdout.split('\n')) {
|
|
55
|
+
if (!line.trim())
|
|
56
|
+
continue;
|
|
57
|
+
const [totalRaw, freeRaw] = line.split(',');
|
|
58
|
+
const total = Number(totalRaw?.trim());
|
|
59
|
+
const free = Number(freeRaw?.trim());
|
|
60
|
+
// A full card reports 0 free. That is a reading, not a missing probe —
|
|
61
|
+
// dropping it hides the one case the run page warns about.
|
|
62
|
+
if (!Number.isFinite(total) || total <= 0)
|
|
63
|
+
continue;
|
|
64
|
+
vramMb = (vramMb ?? 0) + total;
|
|
65
|
+
if (Number.isFinite(free) && free >= 0)
|
|
66
|
+
vramFreeMb = (vramFreeMb ?? 0) + free;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { present: gpus.length > 0, gpus, driver, ...(cudaVersion ? { cudaVersion } : {}), ...(vramMb != null ? { vramMb } : {}), ...(vramFreeMb != null ? { vramFreeMb } : {}) };
|
|
70
|
+
}
|
|
71
|
+
async function detectVulkan() {
|
|
72
|
+
const res = await run('vulkaninfo', ['--summary'], 8000);
|
|
73
|
+
return res.ok && /GPU/i.test(res.stdout);
|
|
74
|
+
}
|
|
75
|
+
async function detectRocm() {
|
|
76
|
+
const res = await run('rocminfo', [], 8000);
|
|
77
|
+
if (!res.ok)
|
|
78
|
+
return { present: false, gpus: [] };
|
|
79
|
+
const gpus = [];
|
|
80
|
+
for (const line of res.stdout.split('\n')) {
|
|
81
|
+
const match = /Marketing Name:\s*(.+)/.exec(line);
|
|
82
|
+
if (match && /AMD|Advanced Micro/i.test(res.stdout))
|
|
83
|
+
gpus.push(match[1].trim());
|
|
84
|
+
}
|
|
85
|
+
return { present: true, gpus: gpus.slice(0, 4) };
|
|
86
|
+
}
|
|
87
|
+
async function detectCl() {
|
|
88
|
+
const res = await run('clinfo', [], 8000);
|
|
89
|
+
return res.ok && /Device Name/i.test(res.stdout);
|
|
90
|
+
}
|
|
91
|
+
/** Probe the machine once and return the raw report. */
|
|
92
|
+
export async function detectDependencies() {
|
|
93
|
+
const [nvidia, vulkan, rocm, cl] = await Promise.all([detectNvidia(), detectVulkan(), detectRocm(), detectCl()]);
|
|
94
|
+
const isMac = process.platform === 'darwin';
|
|
95
|
+
const checks = [];
|
|
96
|
+
const gpus = [...nvidia.gpus, ...rocm.gpus];
|
|
97
|
+
checks.push({
|
|
98
|
+
id: 'nvidia-driver',
|
|
99
|
+
ok: nvidia.present,
|
|
100
|
+
label: 'NVIDIA GPU / driver',
|
|
101
|
+
detail: nvidia.present
|
|
102
|
+
? `${nvidia.gpus.join(', ')}${nvidia.driver ? ` · driver ${nvidia.driver}` : ''}${nvidia.cudaVersion ? ` · CUDA ${nvidia.cudaVersion}` : ''}`
|
|
103
|
+
: 'nvidia-smi not found',
|
|
104
|
+
});
|
|
105
|
+
if (!isMac) {
|
|
106
|
+
checks.push({ id: 'vulkan', ok: vulkan, label: 'Vulkan runtime', detail: vulkan ? 'vulkaninfo reports a GPU' : 'vulkaninfo not found' });
|
|
107
|
+
checks.push({
|
|
108
|
+
id: 'amd-rocm',
|
|
109
|
+
ok: rocm.present,
|
|
110
|
+
label: 'AMD ROCm / HIP',
|
|
111
|
+
detail: rocm.present ? (rocm.gpus.join(', ') || 'rocminfo present') : 'rocminfo not found',
|
|
112
|
+
});
|
|
113
|
+
checks.push({ id: 'intel-sycl', ok: cl, label: 'Intel SYCL / OpenCL', detail: cl ? 'clinfo reports a device' : 'clinfo not found' });
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
checks.push({ id: 'apple-metal', ok: true, label: 'Metal', detail: 'built into macOS' });
|
|
117
|
+
}
|
|
118
|
+
checks.push({ id: 'cpu', ok: true, label: 'CPU', detail: `${process.arch} ${process.platform}` });
|
|
119
|
+
return {
|
|
120
|
+
platform: process.platform,
|
|
121
|
+
arch: process.arch,
|
|
122
|
+
gpus,
|
|
123
|
+
...(nvidia.cudaVersion ? { cudaVersion: nvidia.cudaVersion } : {}),
|
|
124
|
+
...(nvidia.vramMb != null ? { vramMb: nvidia.vramMb } : {}),
|
|
125
|
+
...(nvidia.vramFreeMb != null ? { vramFreeMb: nvidia.vramFreeMb } : {}),
|
|
126
|
+
ramMb: Math.round(os.totalmem() / 1_048_576),
|
|
127
|
+
checks,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The machine facts a per-engine target recommendation reads (ADR-0045: the
|
|
132
|
+
* recommendation lives on the ENGINE, so this stays a neutral summary).
|
|
133
|
+
*/
|
|
134
|
+
export function summarizeDetect(report) {
|
|
135
|
+
const ok = (id) => report.checks.some((check) => check.id === id && check.ok);
|
|
136
|
+
const cudaMajor = report.cudaVersion ? Number(report.cudaVersion.split('.')[0]) || 0 : 0;
|
|
137
|
+
return {
|
|
138
|
+
platform: report.platform,
|
|
139
|
+
arch: report.arch,
|
|
140
|
+
nvidia: ok('nvidia-driver'),
|
|
141
|
+
cudaMajor,
|
|
142
|
+
amdRocm: ok('amd-rocm'),
|
|
143
|
+
vulkan: ok('vulkan'),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { GgufMeta } from './gguf.js';
|
|
2
|
+
export interface DraftMatch {
|
|
3
|
+
at: number;
|
|
4
|
+
/** Usable select values per engine. `off` and the empty placeholder stay
|
|
5
|
+
* available even when a list is empty. */
|
|
6
|
+
choices: Record<string, string[]>;
|
|
7
|
+
/** Paired draft GGUF for a llama.cpp type, when one installed file matched. */
|
|
8
|
+
files: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/** The llama.cpp spec type a draft file's name announces, if any. */
|
|
11
|
+
export declare function draftKindOf(text: string): string | null;
|
|
12
|
+
export declare function matchDrafts(input: {
|
|
13
|
+
filename: string;
|
|
14
|
+
meta: GgufMeta;
|
|
15
|
+
/** Other installed GGUFs. A file is never matched against itself. */
|
|
16
|
+
others: Array<{
|
|
17
|
+
filePath: string;
|
|
18
|
+
filename: string;
|
|
19
|
+
meta: GgufMeta;
|
|
20
|
+
}>;
|
|
21
|
+
strata?: {
|
|
22
|
+
dflash2: boolean;
|
|
23
|
+
mtp: boolean;
|
|
24
|
+
};
|
|
25
|
+
}): DraftMatch;
|
|
26
|
+
/** Disk check for the Strata artefacts. Tests pass `strata` in and skip this. */
|
|
27
|
+
export declare function matchDraftsOnDisk(input: {
|
|
28
|
+
filename: string;
|
|
29
|
+
meta: GgufMeta;
|
|
30
|
+
others: Array<{
|
|
31
|
+
filePath: string;
|
|
32
|
+
filename: string;
|
|
33
|
+
meta: GgufMeta;
|
|
34
|
+
}>;
|
|
35
|
+
}): DraftMatch;
|
|
36
|
+
/**
|
|
37
|
+
* Is a STORED llama.cpp draft choice still usable?
|
|
38
|
+
*
|
|
39
|
+
* `choices` above answers "what is on disk", which is what the picker OFFERS —
|
|
40
|
+
* not what the profile may keep. The two are different questions, and conflating
|
|
41
|
+
* them silently erased the operator's choice: the spec select offers every type
|
|
42
|
+
* this build knows, so picking EAGLE-3 and pointing it at a draft GGUF kept
|
|
43
|
+
* outside the models root (a shared drafts folder, a hand-typed path) is a
|
|
44
|
+
* legitimate setup. Any later re-scan — which every unrelated download triggers —
|
|
45
|
+
* then deleted `specType` because no matching file was installed, and the next
|
|
46
|
+
* launch quietly stopped drafting. Found by reading the prune against the
|
|
47
|
+
* dropdown; ADR-0045 already says Detect "does not remove a choice".
|
|
48
|
+
*
|
|
49
|
+
* Usable therefore means: a type THIS BUILD offers, and a file where the type
|
|
50
|
+
* needs one. Whether that file exists is the launcher's check (`llamaDraftArgs`
|
|
51
|
+
* refuses by name), not a scan's.
|
|
52
|
+
*/
|
|
53
|
+
export declare function llamaDraftChoiceUsable(specType: unknown, draftModel: unknown): boolean;
|
|
54
|
+
/** Is a stored Strata drafting mode still one this engine accepts? The artefact
|
|
55
|
+
* a mode needs is reported by the verdict (`buildable` / `preparable`), and a
|
|
56
|
+
* typed `mtp` path is honoured by `findMtp`, so presence on disk is NOT the
|
|
57
|
+
* test — the vocabulary is. */
|
|
58
|
+
export declare function strataDraftingUsable(mode: unknown): boolean;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which drafters a local model can actually run (ADR-0045).
|
|
3
|
+
*
|
|
4
|
+
* The run console hides the rest. A choice is "usable" only from facts on
|
|
5
|
+
* this machine: n-gram needs nothing, MTP needs `nextn` metadata in the
|
|
6
|
+
* file, a named drafter (EAGLE-3, DFlash, …) needs another installed GGUF
|
|
7
|
+
* whose name shares the target's, and Strata's MTP / DFlash2 need the
|
|
8
|
+
* artefact already under the gateway data directory. Nothing is downloaded
|
|
9
|
+
* here.
|
|
10
|
+
*/
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { LLAMA_SPEC_TYPES } from './llamacpp.js';
|
|
14
|
+
import { STRATA_FAMILY_ARCHES, strataDataDir } from './strata.js';
|
|
15
|
+
const NGRAM = LLAMA_SPEC_TYPES.filter((row) => row.value.startsWith('ngram-')).map((row) => row.value);
|
|
16
|
+
const QUANT = /^(q\d.*|iq\d.*|gguf|imatrix|hf|of|\d{4,})$/;
|
|
17
|
+
function tokens(text) {
|
|
18
|
+
return text.toLowerCase().split(/[^a-z0-9]+/).filter((token) => token.length >= 2 && !QUANT.test(token));
|
|
19
|
+
}
|
|
20
|
+
function shared(a, b) {
|
|
21
|
+
const have = new Set(a);
|
|
22
|
+
let n = 0;
|
|
23
|
+
for (const token of b)
|
|
24
|
+
if (have.has(token))
|
|
25
|
+
n += 1;
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
/** The llama.cpp spec type a draft file's name announces, if any. */
|
|
29
|
+
export function draftKindOf(text) {
|
|
30
|
+
const name = text.toLowerCase();
|
|
31
|
+
if (name.includes('eagle3') || name.includes('eagle-3'))
|
|
32
|
+
return 'draft-eagle3';
|
|
33
|
+
if (name.includes('lilicorr'))
|
|
34
|
+
return 'draft-lilicorr';
|
|
35
|
+
if (name.includes('dspark'))
|
|
36
|
+
return 'draft-dspark';
|
|
37
|
+
if (name.includes('dflash2') || name.includes('dflash-2'))
|
|
38
|
+
return 'draft-dflash2';
|
|
39
|
+
if (name.includes('dflash'))
|
|
40
|
+
return 'draft-dflash';
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function strataArtefacts() {
|
|
44
|
+
const data = strataDataDir();
|
|
45
|
+
let dflash2 = false;
|
|
46
|
+
try {
|
|
47
|
+
dflash2 = fs.readdirSync(path.join(data, 'dflash2')).some((name) => name.endsWith('.pack'));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
dflash2 = false;
|
|
51
|
+
}
|
|
52
|
+
const rt = path.join(data, 'mtp', 'rt');
|
|
53
|
+
const mtp = fs.existsSync(path.join(rt, 'experts.bin')) || fs.existsSync(path.join(rt, 'dense.bin'));
|
|
54
|
+
return { dflash2, mtp };
|
|
55
|
+
}
|
|
56
|
+
export function matchDrafts(input) {
|
|
57
|
+
const mine = tokens(`${input.filename} ${input.meta.name ?? ''}`);
|
|
58
|
+
const llama = new Set(NGRAM);
|
|
59
|
+
const files = {};
|
|
60
|
+
if (input.meta.hasNextn)
|
|
61
|
+
llama.add('draft-mtp');
|
|
62
|
+
for (const other of input.others) {
|
|
63
|
+
const kind = draftKindOf(`${other.filename} ${other.meta.name ?? ''}`);
|
|
64
|
+
if (!kind)
|
|
65
|
+
continue;
|
|
66
|
+
const theirs = tokens(`${other.filename} ${other.meta.name ?? ''}`);
|
|
67
|
+
if (shared(mine, theirs) < 2)
|
|
68
|
+
continue;
|
|
69
|
+
llama.add(kind);
|
|
70
|
+
if (!files[kind])
|
|
71
|
+
files[kind] = other.filePath;
|
|
72
|
+
}
|
|
73
|
+
const strataChoices = [];
|
|
74
|
+
const artefacts = input.strata ?? { dflash2: false, mtp: false };
|
|
75
|
+
if (input.meta.arch && STRATA_FAMILY_ARCHES.has(input.meta.arch)) {
|
|
76
|
+
if (artefacts.dflash2)
|
|
77
|
+
strataChoices.push('dflash2');
|
|
78
|
+
if (artefacts.mtp)
|
|
79
|
+
strataChoices.push('mtp');
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
at: Date.now(),
|
|
83
|
+
choices: { llamacpp: [...llama], strata: strataChoices },
|
|
84
|
+
files,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Disk check for the Strata artefacts. Tests pass `strata` in and skip this. */
|
|
88
|
+
export function matchDraftsOnDisk(input) {
|
|
89
|
+
return matchDrafts({ ...input, strata: strataArtefacts() });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Is a STORED llama.cpp draft choice still usable?
|
|
93
|
+
*
|
|
94
|
+
* `choices` above answers "what is on disk", which is what the picker OFFERS —
|
|
95
|
+
* not what the profile may keep. The two are different questions, and conflating
|
|
96
|
+
* them silently erased the operator's choice: the spec select offers every type
|
|
97
|
+
* this build knows, so picking EAGLE-3 and pointing it at a draft GGUF kept
|
|
98
|
+
* outside the models root (a shared drafts folder, a hand-typed path) is a
|
|
99
|
+
* legitimate setup. Any later re-scan — which every unrelated download triggers —
|
|
100
|
+
* then deleted `specType` because no matching file was installed, and the next
|
|
101
|
+
* launch quietly stopped drafting. Found by reading the prune against the
|
|
102
|
+
* dropdown; ADR-0045 already says Detect "does not remove a choice".
|
|
103
|
+
*
|
|
104
|
+
* Usable therefore means: a type THIS BUILD offers, and a file where the type
|
|
105
|
+
* needs one. Whether that file exists is the launcher's check (`llamaDraftArgs`
|
|
106
|
+
* refuses by name), not a scan's.
|
|
107
|
+
*/
|
|
108
|
+
export function llamaDraftChoiceUsable(specType, draftModel) {
|
|
109
|
+
if (typeof specType !== 'string' || specType.trim() === '')
|
|
110
|
+
return true;
|
|
111
|
+
const row = LLAMA_SPEC_TYPES.find((item) => item.value === specType);
|
|
112
|
+
if (!row)
|
|
113
|
+
return false; // a flag this build dropped (e.g. a retired draft type)
|
|
114
|
+
if (!row.needsModel)
|
|
115
|
+
return true; // MTP reads heads in the main file; n-gram needs none
|
|
116
|
+
return typeof draftModel === 'string' && draftModel.trim().length > 0;
|
|
117
|
+
}
|
|
118
|
+
/** Is a stored Strata drafting mode still one this engine accepts? The artefact
|
|
119
|
+
* a mode needs is reported by the verdict (`buildable` / `preparable`), and a
|
|
120
|
+
* typed `mtp` path is honoured by `findMtp`, so presence on disk is NOT the
|
|
121
|
+
* test — the vocabulary is. */
|
|
122
|
+
export function strataDraftingUsable(mode) {
|
|
123
|
+
return mode === undefined || mode === 'mtp' || mode === 'dflash2' || mode === 'off';
|
|
124
|
+
}
|