@qvac/inference 0.18.2 → 0.19.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/NOTICE +11 -2
- package/README.md +1 -5
- package/dist/api/assess-model-fit.d.ts +16 -0
- package/dist/api/assess-model-fit.js +27 -0
- package/dist/api/audio-gen.d.ts +4 -4
- package/dist/api/audio-gen.js +17 -6
- package/dist/api/completion-stream.d.ts +1 -1
- package/dist/api/completion-stream.js +1 -1
- package/dist/api/download-asset.d.ts +1 -1
- package/dist/api/download-asset.js +2 -2
- package/dist/api/finetune.js +1 -1
- package/dist/api/get-loaded-model-info.d.ts +6 -10
- package/dist/api/get-loaded-model-info.js +6 -10
- package/dist/api/heartbeat.d.ts +5 -22
- package/dist/api/heartbeat.js +6 -23
- package/dist/api/index.d.ts +36 -35
- package/dist/api/index.js +35 -35
- package/dist/api/load-model.d.ts +5 -1
- package/dist/api/load-model.js +3 -5
- package/dist/api/logging-stream-registry.js +1 -1
- package/dist/api/resume.d.ts +0 -3
- package/dist/api/resume.js +0 -3
- package/dist/api/subscribe-logs.js +1 -1
- package/dist/api/suspend.d.ts +0 -4
- package/dist/api/suspend.js +0 -4
- package/dist/api/translate.d.ts +3 -1
- package/dist/api/translate.js +16 -8
- package/dist/api/unload-model.js +3 -5
- package/dist/api/video-request.d.ts +207 -0
- package/dist/api/video-request.js +18 -0
- package/dist/api/video.d.ts +22 -2
- package/dist/api/video.js +25 -15
- package/dist/api/vla-helpers.d.ts +1 -2
- package/dist/api/vla-helpers.js +1 -2
- package/dist/api/vla.js +1 -1
- package/dist/api/world-result.d.ts +71 -0
- package/dist/api/world-result.js +293 -0
- package/dist/api/world.d.ts +143 -0
- package/dist/api/world.js +71 -0
- package/dist/config/resolve-config.d.ts +1 -1
- package/dist/config/resolve-config.js +1 -1
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +2 -2
- package/dist/dispatch.js +15 -28
- package/dist/errors/index.d.ts +35 -31
- package/dist/errors/index.js +66 -56
- package/dist/handlers/assess-model-fit.d.ts +10 -0
- package/dist/handlers/assess-model-fit.js +75 -0
- package/dist/handlers/cancelHandler.js +1 -1
- package/dist/handlers/completion-orchestrate.js +1 -1
- package/dist/handlers/download-asset.js +6 -5
- package/dist/handlers/finetune.js +1 -1
- package/dist/handlers/get-loaded-model-info.js +0 -12
- package/dist/handlers/get-model-info.js +1 -1
- package/dist/handlers/get-system-resources.js +8 -0
- package/dist/handlers/load-model/download-manager.d.ts +1 -1
- package/dist/handlers/load-model/download-stats.d.ts +3 -3
- package/dist/handlers/load-model/download-stats.js +5 -5
- package/dist/handlers/load-model/handler.js +6 -8
- package/dist/handlers/load-model/http-verify.d.ts +20 -0
- package/dist/handlers/load-model/http-verify.js +54 -0
- package/dist/handlers/load-model/http.d.ts +12 -2
- package/dist/handlers/load-model/http.js +119 -230
- package/dist/handlers/load-model/hyperdrive.d.ts +1 -1
- package/dist/handlers/load-model/hyperdrive.js +1 -1
- package/dist/handlers/load-model/index.d.ts +2 -2
- package/dist/handlers/load-model/index.js +2 -2
- package/dist/handlers/load-model/registry-companion-set.d.ts +1 -1
- package/dist/handlers/load-model/registry-companion-set.js +1 -1
- package/dist/handlers/load-model/registry-download-utils.d.ts +3 -3
- package/dist/handlers/load-model/registry-download-utils.js +2 -2
- package/dist/handlers/load-model/registry.d.ts +2 -2
- package/dist/handlers/load-model/registry.js +4 -4
- package/dist/handlers/load-model/resolve-session.d.ts +8 -1
- package/dist/handlers/load-model/resolve-session.js +12 -9
- package/dist/handlers/load-model/resolve.d.ts +4 -4
- package/dist/handlers/load-model/resolve.js +18 -16
- package/dist/handlers/load-model/safe-fetch.d.ts +44 -0
- package/dist/handlers/load-model/safe-fetch.js +143 -0
- package/dist/handlers/load-model/types.d.ts +9 -0
- package/dist/handlers/plugin-dispatch.js +1 -4
- package/dist/handlers/plugin-invoke.js +1 -4
- package/dist/handlers/types.d.ts +0 -2
- package/dist/handlers/unload-model.js +1 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/logging/addon.d.ts +1 -1
- package/dist/logging/addon.js +1 -1
- package/dist/logging/index.d.ts +5 -5
- package/dist/logging/index.js +4 -4
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.js +2 -2
- package/dist/models/registry/index.d.ts +1 -1
- package/dist/models/registry/index.js +2 -2
- package/dist/models/registry/models.d.ts +250 -0
- package/dist/models/registry/models.js +2071 -1806
- package/dist/models/registry/resource-profiles.d.ts +18 -0
- package/dist/models/registry/resource-profiles.js +4934 -0
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +14 -0
- package/dist/plugins/builtin/audiogen-ggml/config.js +23 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +47 -5
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +134 -4
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +47 -28
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +1 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +3 -3
- package/dist/plugins/builtin/ggml-classification/plugin.js +1 -1
- package/dist/plugins/builtin/ggml-ocr/plugin.js +2 -2
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +1 -1
- package/dist/plugins/builtin/ggml-vla/plugin.js +3 -3
- package/dist/plugins/builtin/index.d.ts +12 -12
- package/dist/plugins/builtin/index.js +12 -12
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +2 -2
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +37 -26
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.d.ts +12 -11
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.js +133 -41
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +7 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +26 -4
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +19 -8
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +10 -13
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +4 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +13 -2
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +2 -2
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +2 -2
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +3 -3
- package/dist/plugins/builtin/sdcpp-generation/ops/upscale.js +1 -1
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +32 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/world.d.ts +126 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/world.js +820 -0
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +153 -4
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +134 -13
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +1 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +1 -1
- package/dist/plugins/builtin/tts-ggml/plugin.js +2 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +2 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +3 -3
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/ops/kv-cache-utils.js +1 -1
- package/dist/plugins/ops/load-model.js +1 -1
- package/dist/plugins/ops/transcribe.js +2 -2
- package/dist/plugins/ops/translate.js +4 -12
- package/dist/plugins/ops/unload-model.js +19 -21
- package/dist/plugins/registry.d.ts +1 -0
- package/dist/plugins/registry.js +12 -0
- package/dist/profiling/aggregator.d.ts +1 -1
- package/dist/profiling/aggregator.js +1 -1
- package/dist/profiling/controller.d.ts +1 -1
- package/dist/profiling/controller.js +2 -2
- package/dist/profiling/envelope.d.ts +0 -1
- package/dist/profiling/envelope.js +0 -10
- package/dist/profiling/events.d.ts +2 -3
- package/dist/profiling/events.js +2 -9
- package/dist/profiling/exporters.d.ts +1 -1
- package/dist/profiling/exporters.js +3 -3
- package/dist/profiling/index.d.ts +13 -14
- package/dist/profiling/index.js +12 -13
- package/dist/profiling/operation-metrics.d.ts +1 -1
- package/dist/profiling/operation-metrics.js +35 -2
- package/dist/profiling/operation-wrappers.js +12 -15
- package/dist/profiling/profiler.d.ts +1 -2
- package/dist/profiling/profiler.js +7 -26
- package/dist/profiling/types.d.ts +1 -1
- package/dist/rag/handler.js +1 -1
- package/dist/rag/handlers/close-workspace.js +1 -1
- package/dist/rag/handlers/delete-embeddings.js +1 -1
- package/dist/rag/handlers/delete-workspace.js +2 -6
- package/dist/rag/handlers/ingest.js +1 -1
- package/dist/rag/handlers/list-workspaces.d.ts +1 -1
- package/dist/rag/handlers/list-workspaces.js +1 -1
- package/dist/rag/handlers/reindex.js +1 -1
- package/dist/rag/handlers/save-embeddings.js +1 -1
- package/dist/rag/handlers/search.js +1 -1
- package/dist/rag/index.d.ts +11 -11
- package/dist/rag/index.js +11 -11
- package/dist/rag/rag-workspace-manager.d.ts +4 -2
- package/dist/rag/rag-workspace-manager.js +268 -15
- package/dist/registry.js +8 -58
- package/dist/resources/collector.d.ts +3 -1
- package/dist/resources/collector.js +91 -9
- package/dist/resources/instance.d.ts +1 -1
- package/dist/resources/instance.js +1 -1
- package/dist/resources/model-fit/assess.d.ts +36 -0
- package/dist/resources/model-fit/assess.js +578 -0
- package/dist/resources/model-fit/calibration/darwin-arm64.d.ts +8 -0
- package/dist/resources/model-fit/calibration/darwin-arm64.js +36 -0
- package/dist/resources/model-fit/calibration/darwin-x64.d.ts +8 -0
- package/dist/resources/model-fit/calibration/darwin-x64.js +38 -0
- package/dist/resources/model-fit/calibration/fit.d.ts +73 -0
- package/dist/resources/model-fit/calibration/fit.js +152 -0
- package/dist/resources/model-fit/calibration/index.d.ts +37 -0
- package/dist/resources/model-fit/calibration/index.js +75 -0
- package/dist/resources/model-fit/calibration/linux-arm64.d.ts +8 -0
- package/dist/resources/model-fit/calibration/linux-arm64.js +38 -0
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.d.ts +8 -0
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.js +39 -0
- package/dist/resources/model-fit/calibration/linux-x64.d.ts +8 -0
- package/dist/resources/model-fit/calibration/linux-x64.js +38 -0
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.d.ts +8 -0
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.js +39 -0
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.d.ts +8 -0
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.js +36 -0
- package/dist/resources/model-fit/calibration/win32-x64.d.ts +8 -0
- package/dist/resources/model-fit/calibration/win32-x64.js +38 -0
- package/dist/resources/model-fit/estimators/llm.d.ts +45 -0
- package/dist/resources/model-fit/estimators/llm.js +220 -0
- package/dist/resources/model-fit/estimators/whisper.d.ts +10 -0
- package/dist/resources/model-fit/estimators/whisper.js +77 -0
- package/dist/resources/model-fit/types.d.ts +120 -0
- package/dist/resources/model-fit/types.js +1 -0
- package/dist/resources/native.d.ts +1 -1
- package/dist/resources/native.js +14 -0
- package/dist/resources/normalize.d.ts +1 -1
- package/dist/resources/types.d.ts +16 -0
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/lifecycle.js +5 -7
- package/dist/runtime/model-registry.d.ts +0 -14
- package/dist/runtime/model-registry.js +17 -40
- package/dist/runtime/registry-client.js +1 -1
- package/dist/runtime/request-context.d.ts +3 -3
- package/dist/runtime/request-context.js +13 -1
- package/dist/runtime/request-registry.d.ts +1 -1
- package/dist/runtime/request-registry.js +4 -5
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.js +18 -3
- package/dist/schemas/assess-model-fit.d.ts +271 -0
- package/dist/schemas/assess-model-fit.js +153 -0
- package/dist/schemas/audio-gen.d.ts +434 -4
- package/dist/schemas/audio-gen.js +131 -19
- package/dist/schemas/batch-completion-stream.d.ts +2 -2
- package/dist/schemas/batch-completion-stream.js +3 -3
- package/dist/schemas/bci-config.js +73 -27
- package/dist/schemas/bci.d.ts +2 -2
- package/dist/schemas/bci.js +5 -5
- package/dist/schemas/cancel.d.ts +5 -0
- package/dist/schemas/cancel.js +1 -0
- package/dist/schemas/classification.js +13 -6
- package/dist/schemas/common.d.ts +662 -331
- package/dist/schemas/common.js +33 -31
- package/dist/schemas/completion-event.d.ts +2 -2
- package/dist/schemas/completion-event.js +1 -1
- package/dist/schemas/completion-stream.d.ts +1 -5
- package/dist/schemas/completion-stream.js +4 -8
- package/dist/schemas/config.d.ts +640 -18
- package/dist/schemas/config.js +50 -8
- package/dist/schemas/download-asset.d.ts +19 -1
- package/dist/schemas/download-asset.js +20 -4
- package/dist/schemas/engine-addon-map.d.ts +1 -1
- package/dist/schemas/engine-addon-map.js +3 -3
- package/dist/schemas/error.d.ts +2 -2
- package/dist/schemas/error.js +2 -2
- package/dist/schemas/errors.d.ts +2 -6
- package/dist/schemas/errors.js +30 -40
- package/dist/schemas/heartbeat.d.ts +10 -0
- package/dist/schemas/heartbeat.js +8 -0
- package/dist/schemas/index.d.ts +46 -44
- package/dist/schemas/index.js +45 -43
- package/dist/schemas/llamacpp-config.d.ts +32 -10
- package/dist/schemas/llamacpp-config.js +11 -8
- package/dist/schemas/load-model.d.ts +2933 -1948
- package/dist/schemas/load-model.js +52 -52
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-config-schemas.d.ts +2354 -0
- package/dist/schemas/model-config-schemas.js +46 -0
- package/dist/schemas/model-info.d.ts +10 -20
- package/dist/schemas/model-info.js +4 -25
- package/dist/schemas/model-ops.d.ts +0 -1
- package/dist/schemas/model-ops.js +1 -2
- package/dist/schemas/model-resource-profile.d.ts +109 -0
- package/dist/schemas/model-resource-profile.js +83 -0
- package/dist/schemas/model-src-utils.d.ts +1 -0
- package/dist/schemas/model-src-utils.js +33 -13
- package/dist/schemas/ocr.js +48 -13
- package/dist/schemas/path-validation.js +8 -2
- package/dist/schemas/plugin.d.ts +14 -1
- package/dist/schemas/plugin.js +11 -0
- package/dist/schemas/profiling.d.ts +138 -43
- package/dist/schemas/profiling.js +1 -22
- package/dist/schemas/rag.js +1 -1
- package/dist/schemas/registry.js +1 -1
- package/dist/schemas/reload-config.d.ts +0 -2
- package/dist/schemas/reload-config.js +2 -3
- package/dist/schemas/sdcpp-config.d.ts +344 -4
- package/dist/schemas/sdcpp-config.js +504 -17
- package/dist/schemas/system-resources.d.ts +138 -0
- package/dist/schemas/system-resources.js +3 -1
- package/dist/schemas/text-to-speech.js +183 -76
- package/dist/schemas/transcription-config.js +253 -85
- package/dist/schemas/transcription.d.ts +3 -3
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/schemas/translate.js +1 -1
- package/dist/schemas/translation-config.js +53 -25
- package/dist/schemas/vla.d.ts +1 -1
- package/dist/selection.d.ts +1 -5
- package/dist/selection.js +2 -6
- package/dist/surface.d.ts +1 -1
- package/dist/utils/aggregate-events.d.ts +1 -1
- package/dist/utils/aggregate-events.js +2 -2
- package/dist/utils/archive.js +2 -2
- package/dist/utils/audio-input.js +1 -1
- package/dist/utils/cache/auto-history.d.ts +1 -1
- package/dist/utils/cache/auto-history.js +1 -1
- package/dist/utils/cache/paths.js +5 -5
- package/dist/utils/completion-normalizer.js +1 -1
- package/dist/utils/gguf-tensor-extractor.js +1 -1
- package/dist/utils/image-dimensions.d.ts +26 -0
- package/dist/utils/image-dimensions.js +46 -0
- package/dist/utils/index.d.ts +13 -10
- package/dist/utils/index.js +13 -10
- package/dist/utils/mcp-adapter.d.ts +1 -1
- package/dist/utils/mcp-adapter.js +1 -1
- package/dist/utils/path-sanitize.d.ts +7 -0
- package/dist/utils/path-sanitize.js +36 -0
- package/dist/utils/path-security.d.ts +0 -7
- package/dist/utils/path-security.js +1 -36
- package/dist/utils/shard-utils.js +3 -3
- package/dist/utils/tool-integration.js +1 -1
- package/dist/utils/tools/dialect.js +1 -1
- package/dist/utils/tools/index.d.ts +2 -2
- package/dist/utils/tools/index.js +2 -2
- package/dist/utils/tools/parser.js +8 -8
- package/dist/utils/tools/parsers/dsml.d.ts +1 -1
- package/dist/utils/tools/parsers/dsml.js +1 -1
- package/dist/utils/tools/parsers/gemma4native.d.ts +1 -1
- package/dist/utils/tools/parsers/gemma4native.js +1 -1
- package/dist/utils/tools/parsers/harmony.d.ts +1 -1
- package/dist/utils/tools/parsers/harmony.js +1 -1
- package/dist/utils/tools/parsers/hermes.d.ts +1 -1
- package/dist/utils/tools/parsers/hermes.js +1 -1
- package/dist/utils/tools/parsers/json.d.ts +1 -1
- package/dist/utils/tools/parsers/json.js +1 -1
- package/dist/utils/tools/parsers/pythonic.d.ts +1 -1
- package/dist/utils/tools/parsers/pythonic.js +1 -1
- package/dist/utils/tools/parsers/qwen35.d.ts +1 -1
- package/dist/utils/tools/parsers/qwen35.js +3 -3
- package/dist/utils/url-security.d.ts +17 -0
- package/dist/utils/url-security.js +75 -0
- package/package.json +31 -26
- package/dist/api/provide.d.ts +0 -23
- package/dist/api/provide.js +0 -32
- package/dist/api/stop-provider.d.ts +0 -20
- package/dist/api/stop-provider.js +0 -30
- package/dist/p2p/cancel-delegated.d.ts +0 -3
- package/dist/p2p/cancel-delegated.js +0 -64
- package/dist/p2p/completion-stream-delegated.d.ts +0 -4
- package/dist/p2p/completion-stream-delegated.js +0 -51
- package/dist/p2p/delegate-client.d.ts +0 -9
- package/dist/p2p/delegate-client.js +0 -219
- package/dist/p2p/delegate-connect-diagnostics.d.ts +0 -8
- package/dist/p2p/delegate-connect-diagnostics.js +0 -38
- package/dist/p2p/delegate-transport.d.ts +0 -18
- package/dist/p2p/delegate-transport.js +0 -237
- package/dist/p2p/error-handlers.d.ts +0 -4
- package/dist/p2p/error-handlers.js +0 -31
- package/dist/p2p/handle-request.d.ts +0 -2
- package/dist/p2p/handle-request.js +0 -171
- package/dist/p2p/handler-utils.d.ts +0 -19
- package/dist/p2p/handler-utils.js +0 -180
- package/dist/p2p/heartbeat-delegated.d.ts +0 -3
- package/dist/p2p/heartbeat-delegated.js +0 -32
- package/dist/p2p/load-model-delegated.d.ts +0 -6
- package/dist/p2p/load-model-delegated.js +0 -132
- package/dist/p2p/progress-throttle.d.ts +0 -7
- package/dist/p2p/progress-throttle.js +0 -47
- package/dist/p2p/provideHandler/connection.d.ts +0 -2
- package/dist/p2p/provideHandler/connection.js +0 -38
- package/dist/p2p/provideHandler/handler.d.ts +0 -2
- package/dist/p2p/provideHandler/handler.js +0 -66
- package/dist/p2p/provideHandler/proxy.d.ts +0 -2
- package/dist/p2p/provideHandler/proxy.js +0 -24
- package/dist/p2p/provideHandler.d.ts +0 -1
- package/dist/p2p/provideHandler.js +0 -2
- package/dist/p2p/rpc-utils.d.ts +0 -4
- package/dist/p2p/rpc-utils.js +0 -8
- package/dist/p2p/stopProvideHandler.d.ts +0 -2
- package/dist/p2p/stopProvideHandler.js +0 -29
- package/dist/p2p/swarm.d.ts +0 -9
- package/dist/p2p/swarm.js +0 -103
- package/dist/p2p/transport-selector.d.ts +0 -2
- package/dist/p2p/transport-selector.js +0 -18
- package/dist/p2p/unload-model-delegated.d.ts +0 -2
- package/dist/p2p/unload-model-delegated.js +0 -31
- package/dist/profiling/delegation-profiler.d.ts +0 -31
- package/dist/profiling/delegation-profiler.js +0 -155
- package/dist/schemas/delegate.d.ts +0 -29
- package/dist/schemas/delegate.js +0 -40
- package/dist/schemas/provide.d.ts +0 -50
- package/dist/schemas/provide.js +0 -32
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelAlreadyRegisteredError, ModelNotFoundError
|
|
1
|
+
import { ModelAlreadyRegisteredError, ModelNotFoundError } from '../errors/index.js';
|
|
2
2
|
import { getEngineLogger } from '../logging/index.js';
|
|
3
3
|
const logger = getEngineLogger();
|
|
4
4
|
// Global registry state - using stateless functions to manage it
|
|
@@ -7,36 +7,19 @@ export function registerModel(id, options) {
|
|
|
7
7
|
if (modelRegistry.has(id)) {
|
|
8
8
|
throw new ModelAlreadyRegisteredError(id);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
modelRegistry.set(id, {
|
|
26
|
-
id,
|
|
27
|
-
isDelegated: false,
|
|
28
|
-
local: {
|
|
29
|
-
model: options.model,
|
|
30
|
-
path: options.path,
|
|
31
|
-
loadedAt: new Date(),
|
|
32
|
-
config: options.config,
|
|
33
|
-
modelType: options.modelType,
|
|
34
|
-
name: options.name
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const nameStr = options.name ? ` (${options.name})` : '';
|
|
38
|
-
logger.info(`Local model registered: ${id}${nameStr} -> ${options.path}`);
|
|
39
|
-
}
|
|
10
|
+
modelRegistry.set(id, {
|
|
11
|
+
id,
|
|
12
|
+
local: {
|
|
13
|
+
model: options.model,
|
|
14
|
+
path: options.path,
|
|
15
|
+
loadedAt: new Date(),
|
|
16
|
+
config: options.config,
|
|
17
|
+
modelType: options.modelType,
|
|
18
|
+
name: options.name
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const nameStr = options.name ? ` (${options.name})` : '';
|
|
22
|
+
logger.info(`Local model registered: ${id}${nameStr} -> ${options.path}`);
|
|
40
23
|
}
|
|
41
24
|
export function getModelEntry(id) {
|
|
42
25
|
return modelRegistry.get(id) || null;
|
|
@@ -46,9 +29,6 @@ export function getModel(id) {
|
|
|
46
29
|
if (!entry) {
|
|
47
30
|
throw new ModelNotFoundError(id);
|
|
48
31
|
}
|
|
49
|
-
if (entry.isDelegated) {
|
|
50
|
-
throw new ModelIsDelegatedError(id);
|
|
51
|
-
}
|
|
52
32
|
return entry.local.model;
|
|
53
33
|
}
|
|
54
34
|
export function isModelLoaded(id) {
|
|
@@ -68,7 +48,7 @@ export function getAllModelIds() {
|
|
|
68
48
|
}
|
|
69
49
|
export function getModelInfo(id) {
|
|
70
50
|
const entry = modelRegistry.get(id);
|
|
71
|
-
if (!entry
|
|
51
|
+
if (!entry) {
|
|
72
52
|
return null;
|
|
73
53
|
}
|
|
74
54
|
const result = {
|
|
@@ -84,7 +64,7 @@ export function getModelInfo(id) {
|
|
|
84
64
|
}
|
|
85
65
|
export function getModelConfig(id) {
|
|
86
66
|
const entry = modelRegistry.get(id);
|
|
87
|
-
if (!entry
|
|
67
|
+
if (!entry) {
|
|
88
68
|
throw new ModelNotFoundError(id);
|
|
89
69
|
}
|
|
90
70
|
return entry.local.config;
|
|
@@ -94,9 +74,6 @@ export function updateModelConfig(id, config) {
|
|
|
94
74
|
if (!entry) {
|
|
95
75
|
throw new ModelNotFoundError(id);
|
|
96
76
|
}
|
|
97
|
-
if (entry.isDelegated) {
|
|
98
|
-
throw new ModelIsDelegatedError(id);
|
|
99
|
-
}
|
|
100
77
|
entry.local.config = config;
|
|
101
78
|
}
|
|
102
79
|
export function clearRegistry() {
|
|
@@ -114,7 +91,7 @@ export async function unloadAllModels() {
|
|
|
114
91
|
for (const modelId of modelIds) {
|
|
115
92
|
const entry = modelRegistry.get(modelId);
|
|
116
93
|
try {
|
|
117
|
-
if (entry
|
|
94
|
+
if (entry) {
|
|
118
95
|
if (entry.local.model.unload) {
|
|
119
96
|
await entry.local.model.unload();
|
|
120
97
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QVACRegistryClient } from '@qvac/registry-client';
|
|
2
2
|
import { getCacheDir } from '../utils/cache/paths.js';
|
|
3
|
-
import { registerSwarm, unregisterSwarm, registerCorestore, unregisterCorestore } from '
|
|
3
|
+
import { registerSwarm, unregisterSwarm, registerCorestore, unregisterCorestore } from './runtime-lifecycle.js';
|
|
4
4
|
import { getEngineLogger } from '../logging/index.js';
|
|
5
5
|
import { DEFAULT_REGISTRY_CORE_KEY } from '../constants/index.js';
|
|
6
6
|
const logger = getEngineLogger();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type { DisposableScope } from '
|
|
3
|
-
import { createRequestRegistry as createRegistry, type RequestRegistry } from '
|
|
2
|
+
import type { DisposableScope } from './disposable-scope.js';
|
|
3
|
+
import { createRequestRegistry as createRegistry, type RequestRegistry } from './request-registry.js';
|
|
4
4
|
import type { Logger } from '../logging/types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Coarse classification of a long-running request. Used by
|
|
@@ -11,7 +11,7 @@ import type { Logger } from '../logging/types.js';
|
|
|
11
11
|
* The set is intentionally open-coded — adding a new kind is a one-line
|
|
12
12
|
* change and the union surfaces in editor autocomplete at every call site.
|
|
13
13
|
*/
|
|
14
|
-
export type RequestKind = 'completion' | 'batchCompletion' | 'embeddings' | 'transcribe' | 'translate' | 'diffusion' | 'audiogen' | 'tts' | 'ocr' | 'vla' | 'finetune' | 'loadModel' | 'downloadAsset' | 'rag';
|
|
14
|
+
export type RequestKind = 'completion' | 'batchCompletion' | 'embeddings' | 'transcribe' | 'translate' | 'diffusion' | 'world' | 'audiogen' | 'tts' | 'ocr' | 'vla' | 'finetune' | 'loadModel' | 'downloadAsset' | 'rag';
|
|
15
15
|
/**
|
|
16
16
|
* Lifecycle states a request transitions through. A new context starts in
|
|
17
17
|
* `"running"`. `cancel(...)` flips it to `"cancelling"` and aborts the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRequestRegistry as createRegistry } from '
|
|
1
|
+
import { createRequestRegistry as createRegistry } from './request-registry.js';
|
|
2
2
|
/**
|
|
3
3
|
* Shared singleton. Every long-running request registers under this
|
|
4
4
|
* registry, so a `cancel({ requestId })` call can find its target without
|
|
@@ -65,6 +65,18 @@ function installDefaultPolicies(r) {
|
|
|
65
65
|
onOverflow: 'queue',
|
|
66
66
|
maxQueueDepthPerModel: 64
|
|
67
67
|
});
|
|
68
|
+
// An ABot-World session runs one job at a time: the addon rejects a second
|
|
69
|
+
// step while a block is still streaming, and scene creation shares the same
|
|
70
|
+
// lane. Reject rather than queue, unlike every other policy here, because a
|
|
71
|
+
// walk is driven by live key input and a backlog of stale keypresses is worse
|
|
72
|
+
// for the caller than a prompt refusal it can drop. Making the registry
|
|
73
|
+
// authoritative also means the refusal arrives as a typed SDK error rather
|
|
74
|
+
// than the addon's opaque busy string.
|
|
75
|
+
r.policy({
|
|
76
|
+
kind: 'world',
|
|
77
|
+
maxConcurrentPerModel: 1,
|
|
78
|
+
onOverflow: 'reject'
|
|
79
|
+
});
|
|
68
80
|
}
|
|
69
81
|
export function getRequestRegistry() {
|
|
70
82
|
if (!registry) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type { RequestContext, RequestKind } from '
|
|
2
|
+
import type { RequestContext, RequestKind } from './request-context.js';
|
|
3
3
|
import type { Logger } from '../logging/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Outcome the caller declares when terminating a request through
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortController } from 'bare-abort-controller';
|
|
2
|
-
import { createDisposableScope } from '
|
|
2
|
+
import { createDisposableScope } from './disposable-scope.js';
|
|
3
3
|
import { RequestIdConflictError, RequestRejectedByPolicyError } from '../errors/index.js';
|
|
4
4
|
import { getEngineLogger } from '../logging/index.js';
|
|
5
5
|
/**
|
|
@@ -9,10 +9,9 @@ import { getEngineLogger } from '../logging/index.js';
|
|
|
9
9
|
* the matching operation's `begin(...)`: a `cancel` issued at the same
|
|
10
10
|
* time as the matching `completion(...)` either lands first (and we need
|
|
11
11
|
* to remember it long enough for `begin(...)` to follow) or lands second
|
|
12
|
-
* (and we never touch this set).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* slack while still bounding worst-case retention.
|
|
12
|
+
* (and we never touch this set). The gap is tiny, so 30 seconds is overkill
|
|
13
|
+
* but gives slow networks / pause-the-debugger scenarios enough slack while
|
|
14
|
+
* still bounding worst-case retention.
|
|
16
15
|
*
|
|
17
16
|
* The size cap protects against a buggy or malicious caller firing a
|
|
18
17
|
* stream of cancels for ids that never get a `begin(...)` follow-up —
|
package/dist/runtime/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QvacConfig, RuntimeContext, CanonicalModelType } from '../schemas/index.js';
|
|
2
|
-
export { CANONICAL_TO_ALIAS, MODEL_CONFIG_SCHEMAS, BUILTIN_DEVICE_PATTERNS, matchesPattern, findAllMatchingPatterns, getDefaultsFromPattern, resolveModelConfigWithContext } from '
|
|
2
|
+
export { CANONICAL_TO_ALIAS, MODEL_CONFIG_SCHEMAS, BUILTIN_DEVICE_PATTERNS, matchesPattern, findAllMatchingPatterns, getDefaultsFromPattern, resolveModelConfigWithContext } from './model-config-utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Sets the QVAC configuration. This can only be called ONCE during initialization.
|
|
5
5
|
* After the first call, the config becomes immutable and any subsequent calls will throw.
|
package/dist/runtime/state.js
CHANGED
|
@@ -3,8 +3,8 @@ import path from 'bare-path';
|
|
|
3
3
|
import { getQvacPath } from '../utils/qvac-paths.js';
|
|
4
4
|
import { CacheDirNotAbsoluteError, CacheDirNotWritableError, ConfigAlreadySetError } from '../errors/index.js';
|
|
5
5
|
import { getEngineLogger, setGlobalConsoleOutput, setGlobalLogLevel } from '../logging/index.js';
|
|
6
|
-
export { CANONICAL_TO_ALIAS, MODEL_CONFIG_SCHEMAS, BUILTIN_DEVICE_PATTERNS, matchesPattern, findAllMatchingPatterns, getDefaultsFromPattern, resolveModelConfigWithContext } from '
|
|
7
|
-
import { BUILTIN_DEVICE_PATTERNS, resolveModelConfigWithContext } from '
|
|
6
|
+
export { CANONICAL_TO_ALIAS, MODEL_CONFIG_SCHEMAS, BUILTIN_DEVICE_PATTERNS, matchesPattern, findAllMatchingPatterns, getDefaultsFromPattern, resolveModelConfigWithContext } from './model-config-utils.js';
|
|
7
|
+
import { BUILTIN_DEVICE_PATTERNS, resolveModelConfigWithContext } from './model-config-utils.js';
|
|
8
8
|
const logger = getEngineLogger();
|
|
9
9
|
// ============================================
|
|
10
10
|
// Global configuration
|
|
@@ -15,9 +15,12 @@ const configRegistry = {
|
|
|
15
15
|
loggerLevel: undefined,
|
|
16
16
|
loggerConsoleOutput: undefined,
|
|
17
17
|
httpDownloadConcurrency: undefined,
|
|
18
|
+
requireHttpChecksum: undefined,
|
|
19
|
+
requireSecureTransport: undefined,
|
|
18
20
|
registryDownloadMaxRetries: undefined,
|
|
19
21
|
registryStreamTimeoutMs: undefined,
|
|
20
|
-
deviceDefaults: undefined
|
|
22
|
+
deviceDefaults: undefined,
|
|
23
|
+
ragTurbovec: undefined
|
|
21
24
|
};
|
|
22
25
|
let configIsSet = false;
|
|
23
26
|
/**
|
|
@@ -68,6 +71,14 @@ export function setConfig(config) {
|
|
|
68
71
|
configRegistry.httpDownloadConcurrency = config.httpDownloadConcurrency;
|
|
69
72
|
logger.info(`HTTP download concurrency set to: ${config.httpDownloadConcurrency}`);
|
|
70
73
|
}
|
|
74
|
+
if (config.requireHttpChecksum !== undefined && config.requireHttpChecksum !== null) {
|
|
75
|
+
configRegistry.requireHttpChecksum = config.requireHttpChecksum;
|
|
76
|
+
logger.info(`Require HTTP checksum: ${config.requireHttpChecksum}`);
|
|
77
|
+
}
|
|
78
|
+
if (config.requireSecureTransport !== undefined && config.requireSecureTransport !== null) {
|
|
79
|
+
configRegistry.requireSecureTransport = config.requireSecureTransport;
|
|
80
|
+
logger.info(`Require secure transport: ${config.requireSecureTransport}`);
|
|
81
|
+
}
|
|
71
82
|
if (config.registryDownloadMaxRetries !== undefined &&
|
|
72
83
|
config.registryDownloadMaxRetries !== null) {
|
|
73
84
|
configRegistry.registryDownloadMaxRetries = config.registryDownloadMaxRetries;
|
|
@@ -81,6 +92,10 @@ export function setConfig(config) {
|
|
|
81
92
|
configRegistry.deviceDefaults = config.deviceDefaults;
|
|
82
93
|
logger.info(`✅ Device defaults configured: ${config.deviceDefaults.length} pattern(s)`);
|
|
83
94
|
}
|
|
95
|
+
if (config.ragTurbovec !== undefined && config.ragTurbovec !== null) {
|
|
96
|
+
configRegistry.ragTurbovec = config.ragTurbovec;
|
|
97
|
+
logger.info(`✅ New RAG workspaces will use ${config.ragTurbovec ? 'TurboVec' : 'HyperDB'} (ragTurbovec: ${config.ragTurbovec})`);
|
|
98
|
+
}
|
|
84
99
|
// Mark config as set - now it's immutable
|
|
85
100
|
configIsSet = true;
|
|
86
101
|
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Advisory outcome of a pre-download fit assessment.
|
|
4
|
+
*
|
|
5
|
+
* `unknown` is a first-class answer, not a failure: it is what the SDK returns
|
|
6
|
+
* whenever the evidence does not support a defensible claim either way.
|
|
7
|
+
*/
|
|
8
|
+
export declare const modelFitVerdictSchema: z.ZodEnum<{
|
|
9
|
+
unknown: "unknown";
|
|
10
|
+
"likely-fits": "likely-fits";
|
|
11
|
+
"likely-too-large": "likely-too-large";
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Normalized workload shapes. An engine's estimator declares which kinds it
|
|
15
|
+
* supports; anything else assesses as `unknown`.
|
|
16
|
+
*
|
|
17
|
+
* Phase 1 covers LLM context and an audio window. Further kinds (fixed-cost
|
|
18
|
+
* loads, text, image, video) are additive in later phases — a kind joins the
|
|
19
|
+
* union only once an estimator actually handles it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const modelFitWorkloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"llm">;
|
|
23
|
+
contextTokens: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
|
+
kind: z.ZodLiteral<"audio">;
|
|
26
|
+
windowMs: z.ZodNumber;
|
|
27
|
+
streaming: z.ZodBoolean;
|
|
28
|
+
batch: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, z.core.$strip>], "kind">;
|
|
30
|
+
/**
|
|
31
|
+
* The part of a model constant an assessment reads. Pass a catalog constant
|
|
32
|
+
* directly — the extra fields are ignored.
|
|
33
|
+
*
|
|
34
|
+
* Only the checksum (the profile lookup key) and the name (the result label)
|
|
35
|
+
* are read; everything else — engine, byte totals, transformer facts — comes
|
|
36
|
+
* from the resolved resource profile, not from the caller.
|
|
37
|
+
*/
|
|
38
|
+
export declare const modelFitModelRefSchema: z.ZodObject<{
|
|
39
|
+
sha256Checksum: z.ZodString;
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/**
|
|
43
|
+
* One model the caller is considering, with the workload it would run.
|
|
44
|
+
*
|
|
45
|
+
* @property model - A catalog model constant. The generated resource profile,
|
|
46
|
+
* looked up by checksum, supplies the byte totals and transformer facts.
|
|
47
|
+
* @property artifacts - Extra catalog constants a compound load needs (a VAD
|
|
48
|
+
* model, a pivot model). Their artifact bytes are added to this candidate.
|
|
49
|
+
*/
|
|
50
|
+
export declare const modelFitCandidateSchema: z.ZodObject<{
|
|
51
|
+
model: z.ZodObject<{
|
|
52
|
+
sha256Checksum: z.ZodString;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
56
|
+
sha256Checksum: z.ZodString;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
}, z.core.$strip>>>;
|
|
59
|
+
workload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
60
|
+
kind: z.ZodLiteral<"llm">;
|
|
61
|
+
contextTokens: z.ZodNumber;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
kind: z.ZodLiteral<"audio">;
|
|
64
|
+
windowMs: z.ZodNumber;
|
|
65
|
+
streaming: z.ZodBoolean;
|
|
66
|
+
batch: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, z.core.$strip>], "kind">;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
/**
|
|
70
|
+
* How the caller intends to run the candidates. This is a **declared
|
|
71
|
+
* assumption** used for aggregation, not a scheduling instruction — the SDK
|
|
72
|
+
* neither enforces nor reserves anything.
|
|
73
|
+
*
|
|
74
|
+
* - `sequential`: every model stays resident, but only the largest single
|
|
75
|
+
* working-memory peak is counted.
|
|
76
|
+
* - `concurrent`: every model stays resident and every peak is counted.
|
|
77
|
+
*/
|
|
78
|
+
export declare const modelFitExecutionSchema: z.ZodEnum<{
|
|
79
|
+
sequential: "sequential";
|
|
80
|
+
concurrent: "concurrent";
|
|
81
|
+
}>;
|
|
82
|
+
export declare const assessModelFitInputSchema: z.ZodObject<{
|
|
83
|
+
models: z.ZodArray<z.ZodObject<{
|
|
84
|
+
model: z.ZodObject<{
|
|
85
|
+
sha256Checksum: z.ZodString;
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
89
|
+
sha256Checksum: z.ZodString;
|
|
90
|
+
name: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>>;
|
|
92
|
+
workload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"llm">;
|
|
94
|
+
contextTokens: z.ZodNumber;
|
|
95
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
96
|
+
kind: z.ZodLiteral<"audio">;
|
|
97
|
+
windowMs: z.ZodNumber;
|
|
98
|
+
streaming: z.ZodBoolean;
|
|
99
|
+
batch: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.core.$strip>], "kind">;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
execution: z.ZodDefault<z.ZodEnum<{
|
|
103
|
+
sequential: "sequential";
|
|
104
|
+
concurrent: "concurrent";
|
|
105
|
+
}>>;
|
|
106
|
+
policy: z.ZodDefault<z.ZodLiteral<"interactive-v1">>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
/**
|
|
109
|
+
* What evidence the budget was derived from.
|
|
110
|
+
*
|
|
111
|
+
* - `system-memory`: total system RAM minus current use. The desktop model,
|
|
112
|
+
* and Android's — the low-memory killer acts system-wide.
|
|
113
|
+
* - `process-memory`: this process's own ceiling. iOS jetsam terminates an app
|
|
114
|
+
* on its per-process footprint against a limit well below device RAM, so a
|
|
115
|
+
* system-wide budget there would defend verdicts the OS does not honor.
|
|
116
|
+
*/
|
|
117
|
+
export declare const modelFitBasisSchema: z.ZodEnum<{
|
|
118
|
+
"system-memory": "system-memory";
|
|
119
|
+
"process-memory": "process-memory";
|
|
120
|
+
"device-memory": "device-memory";
|
|
121
|
+
"device-budget": "device-budget";
|
|
122
|
+
}>;
|
|
123
|
+
export declare const modelFitBudgetSchema: z.ZodObject<{
|
|
124
|
+
totalBytes: z.ZodNumber;
|
|
125
|
+
usedBytes: z.ZodNumber;
|
|
126
|
+
availableBytes: z.ZodNumber;
|
|
127
|
+
reservedBytes: z.ZodNumber;
|
|
128
|
+
availableAfterReserveBytes: z.ZodNumber;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
export declare const modelFitModelResultSchema: z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
verdict: z.ZodEnum<{
|
|
133
|
+
unknown: "unknown";
|
|
134
|
+
"likely-fits": "likely-fits";
|
|
135
|
+
"likely-too-large": "likely-too-large";
|
|
136
|
+
}>;
|
|
137
|
+
estimate: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
lowerBoundBytes: z.ZodNumber;
|
|
139
|
+
upperBoundBytes: z.ZodNumber;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
142
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
export declare const assessModelFitResultSchema: z.ZodObject<{
|
|
145
|
+
verdict: z.ZodEnum<{
|
|
146
|
+
unknown: "unknown";
|
|
147
|
+
"likely-fits": "likely-fits";
|
|
148
|
+
"likely-too-large": "likely-too-large";
|
|
149
|
+
}>;
|
|
150
|
+
basis: z.ZodEnum<{
|
|
151
|
+
"system-memory": "system-memory";
|
|
152
|
+
"process-memory": "process-memory";
|
|
153
|
+
"device-memory": "device-memory";
|
|
154
|
+
"device-budget": "device-budget";
|
|
155
|
+
}>;
|
|
156
|
+
execution: z.ZodEnum<{
|
|
157
|
+
sequential: "sequential";
|
|
158
|
+
concurrent: "concurrent";
|
|
159
|
+
}>;
|
|
160
|
+
budget: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
totalBytes: z.ZodNumber;
|
|
162
|
+
usedBytes: z.ZodNumber;
|
|
163
|
+
availableBytes: z.ZodNumber;
|
|
164
|
+
reservedBytes: z.ZodNumber;
|
|
165
|
+
availableAfterReserveBytes: z.ZodNumber;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
estimate: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
lowerBoundBytes: z.ZodNumber;
|
|
169
|
+
upperBoundBytes: z.ZodNumber;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
models: z.ZodArray<z.ZodObject<{
|
|
172
|
+
name: z.ZodString;
|
|
173
|
+
verdict: z.ZodEnum<{
|
|
174
|
+
unknown: "unknown";
|
|
175
|
+
"likely-fits": "likely-fits";
|
|
176
|
+
"likely-too-large": "likely-too-large";
|
|
177
|
+
}>;
|
|
178
|
+
estimate: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
lowerBoundBytes: z.ZodNumber;
|
|
180
|
+
upperBoundBytes: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
183
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
184
|
+
}, z.core.$strip>>;
|
|
185
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
186
|
+
assumptions: z.ZodArray<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export declare const assessModelFitRequestSchema: z.ZodObject<{
|
|
189
|
+
models: z.ZodArray<z.ZodObject<{
|
|
190
|
+
model: z.ZodObject<{
|
|
191
|
+
sha256Checksum: z.ZodString;
|
|
192
|
+
name: z.ZodString;
|
|
193
|
+
}, z.core.$strip>;
|
|
194
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
195
|
+
sha256Checksum: z.ZodString;
|
|
196
|
+
name: z.ZodString;
|
|
197
|
+
}, z.core.$strip>>>;
|
|
198
|
+
workload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
199
|
+
kind: z.ZodLiteral<"llm">;
|
|
200
|
+
contextTokens: z.ZodNumber;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
kind: z.ZodLiteral<"audio">;
|
|
203
|
+
windowMs: z.ZodNumber;
|
|
204
|
+
streaming: z.ZodBoolean;
|
|
205
|
+
batch: z.ZodOptional<z.ZodNumber>;
|
|
206
|
+
}, z.core.$strip>], "kind">;
|
|
207
|
+
}, z.core.$strip>>;
|
|
208
|
+
execution: z.ZodDefault<z.ZodEnum<{
|
|
209
|
+
sequential: "sequential";
|
|
210
|
+
concurrent: "concurrent";
|
|
211
|
+
}>>;
|
|
212
|
+
policy: z.ZodDefault<z.ZodLiteral<"interactive-v1">>;
|
|
213
|
+
type: z.ZodLiteral<"assessModelFit">;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
export declare const assessModelFitResponseSchema: z.ZodObject<{
|
|
216
|
+
verdict: z.ZodEnum<{
|
|
217
|
+
unknown: "unknown";
|
|
218
|
+
"likely-fits": "likely-fits";
|
|
219
|
+
"likely-too-large": "likely-too-large";
|
|
220
|
+
}>;
|
|
221
|
+
basis: z.ZodEnum<{
|
|
222
|
+
"system-memory": "system-memory";
|
|
223
|
+
"process-memory": "process-memory";
|
|
224
|
+
"device-memory": "device-memory";
|
|
225
|
+
"device-budget": "device-budget";
|
|
226
|
+
}>;
|
|
227
|
+
execution: z.ZodEnum<{
|
|
228
|
+
sequential: "sequential";
|
|
229
|
+
concurrent: "concurrent";
|
|
230
|
+
}>;
|
|
231
|
+
budget: z.ZodOptional<z.ZodObject<{
|
|
232
|
+
totalBytes: z.ZodNumber;
|
|
233
|
+
usedBytes: z.ZodNumber;
|
|
234
|
+
availableBytes: z.ZodNumber;
|
|
235
|
+
reservedBytes: z.ZodNumber;
|
|
236
|
+
availableAfterReserveBytes: z.ZodNumber;
|
|
237
|
+
}, z.core.$strip>>;
|
|
238
|
+
estimate: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
lowerBoundBytes: z.ZodNumber;
|
|
240
|
+
upperBoundBytes: z.ZodNumber;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
models: z.ZodArray<z.ZodObject<{
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
verdict: z.ZodEnum<{
|
|
245
|
+
unknown: "unknown";
|
|
246
|
+
"likely-fits": "likely-fits";
|
|
247
|
+
"likely-too-large": "likely-too-large";
|
|
248
|
+
}>;
|
|
249
|
+
estimate: z.ZodOptional<z.ZodObject<{
|
|
250
|
+
lowerBoundBytes: z.ZodNumber;
|
|
251
|
+
upperBoundBytes: z.ZodNumber;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
254
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
255
|
+
}, z.core.$strip>>;
|
|
256
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
257
|
+
assumptions: z.ZodArray<z.ZodString>;
|
|
258
|
+
type: z.ZodLiteral<"assessModelFit">;
|
|
259
|
+
}, z.core.$strip>;
|
|
260
|
+
export type ModelFitVerdict = z.infer<typeof modelFitVerdictSchema>;
|
|
261
|
+
export type ModelFitModelRef = z.infer<typeof modelFitModelRefSchema>;
|
|
262
|
+
export type ModelFitWorkload = z.infer<typeof modelFitWorkloadSchema>;
|
|
263
|
+
export type ModelFitCandidate = z.infer<typeof modelFitCandidateSchema>;
|
|
264
|
+
export type ModelFitExecution = z.infer<typeof modelFitExecutionSchema>;
|
|
265
|
+
export type ModelFitBasis = z.infer<typeof modelFitBasisSchema>;
|
|
266
|
+
export type ModelFitBudget = z.infer<typeof modelFitBudgetSchema>;
|
|
267
|
+
export type ModelFitModelResult = z.infer<typeof modelFitModelResultSchema>;
|
|
268
|
+
export type AssessModelFitInput = z.input<typeof assessModelFitInputSchema>;
|
|
269
|
+
export type AssessModelFitResult = z.infer<typeof assessModelFitResultSchema>;
|
|
270
|
+
export type AssessModelFitRequest = z.infer<typeof assessModelFitRequestSchema>;
|
|
271
|
+
export type AssessModelFitResponse = z.infer<typeof assessModelFitResponseSchema>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { modelRegistryEntrySchema } from './registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Advisory outcome of a pre-download fit assessment.
|
|
5
|
+
*
|
|
6
|
+
* `unknown` is a first-class answer, not a failure: it is what the SDK returns
|
|
7
|
+
* whenever the evidence does not support a defensible claim either way.
|
|
8
|
+
*/
|
|
9
|
+
export const modelFitVerdictSchema = z.enum(['likely-fits', 'likely-too-large', 'unknown']);
|
|
10
|
+
/**
|
|
11
|
+
* Normalized workload shapes. An engine's estimator declares which kinds it
|
|
12
|
+
* supports; anything else assesses as `unknown`.
|
|
13
|
+
*
|
|
14
|
+
* Phase 1 covers LLM context and an audio window. Further kinds (fixed-cost
|
|
15
|
+
* loads, text, image, video) are additive in later phases — a kind joins the
|
|
16
|
+
* union only once an estimator actually handles it.
|
|
17
|
+
*/
|
|
18
|
+
export const modelFitWorkloadSchema = z.discriminatedUnion('kind', [
|
|
19
|
+
z
|
|
20
|
+
.object({
|
|
21
|
+
kind: z.literal('llm'),
|
|
22
|
+
contextTokens: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.positive()
|
|
26
|
+
.describe('Context window the caller intends to use, in tokens.')
|
|
27
|
+
})
|
|
28
|
+
.describe('Token-context workload for llama.cpp completion and embedding models.'),
|
|
29
|
+
z
|
|
30
|
+
.object({
|
|
31
|
+
kind: z.literal('audio'),
|
|
32
|
+
windowMs: z
|
|
33
|
+
.number()
|
|
34
|
+
.positive()
|
|
35
|
+
.describe('Audio window handed to the engine per call, in milliseconds.'),
|
|
36
|
+
streaming: z.boolean().describe('Whether the caller streams continuously.'),
|
|
37
|
+
batch: z.number().int().positive().optional().describe('Concurrent windows per call.')
|
|
38
|
+
})
|
|
39
|
+
.describe('Audio-window workload for speech-to-text models.')
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* The part of a model constant an assessment reads. Pass a catalog constant
|
|
43
|
+
* directly — the extra fields are ignored.
|
|
44
|
+
*
|
|
45
|
+
* Only the checksum (the profile lookup key) and the name (the result label)
|
|
46
|
+
* are read; everything else — engine, byte totals, transformer facts — comes
|
|
47
|
+
* from the resolved resource profile, not from the caller.
|
|
48
|
+
*/
|
|
49
|
+
export const modelFitModelRefSchema = modelRegistryEntrySchema.pick({
|
|
50
|
+
name: true,
|
|
51
|
+
sha256Checksum: true
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* One model the caller is considering, with the workload it would run.
|
|
55
|
+
*
|
|
56
|
+
* @property model - A catalog model constant. The generated resource profile,
|
|
57
|
+
* looked up by checksum, supplies the byte totals and transformer facts.
|
|
58
|
+
* @property artifacts - Extra catalog constants a compound load needs (a VAD
|
|
59
|
+
* model, a pivot model). Their artifact bytes are added to this candidate.
|
|
60
|
+
*/
|
|
61
|
+
export const modelFitCandidateSchema = z.object({
|
|
62
|
+
model: modelFitModelRefSchema.describe('Catalog model constant to assess.'),
|
|
63
|
+
artifacts: z
|
|
64
|
+
.array(modelFitModelRefSchema)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Additional catalog constants this load also requires.'),
|
|
67
|
+
workload: modelFitWorkloadSchema.describe('Workload the caller intends to run.')
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* How the caller intends to run the candidates. This is a **declared
|
|
71
|
+
* assumption** used for aggregation, not a scheduling instruction — the SDK
|
|
72
|
+
* neither enforces nor reserves anything.
|
|
73
|
+
*
|
|
74
|
+
* - `sequential`: every model stays resident, but only the largest single
|
|
75
|
+
* working-memory peak is counted.
|
|
76
|
+
* - `concurrent`: every model stays resident and every peak is counted.
|
|
77
|
+
*/
|
|
78
|
+
export const modelFitExecutionSchema = z.enum(['sequential', 'concurrent']);
|
|
79
|
+
export const assessModelFitInputSchema = z.object({
|
|
80
|
+
models: z
|
|
81
|
+
.array(modelFitCandidateSchema)
|
|
82
|
+
.min(1)
|
|
83
|
+
.describe('Candidates to assess together under one memory budget.'),
|
|
84
|
+
execution: modelFitExecutionSchema
|
|
85
|
+
.default('sequential')
|
|
86
|
+
.describe('Declared co-residency assumption for aggregation. Not a scheduling instruction: the SDK does not serialize, reserve, or enforce anything.'),
|
|
87
|
+
policy: z
|
|
88
|
+
.literal('interactive-v1')
|
|
89
|
+
.default('interactive-v1')
|
|
90
|
+
.describe('Headroom policy. `interactive-v1` withholds 20% of the memory available right now, capped at 2 GiB on desktop and 1 GiB on mobile.')
|
|
91
|
+
});
|
|
92
|
+
const byteRangeSchema = z.object({
|
|
93
|
+
lowerBoundBytes: z.number(),
|
|
94
|
+
upperBoundBytes: z.number()
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* What evidence the budget was derived from.
|
|
98
|
+
*
|
|
99
|
+
* - `system-memory`: total system RAM minus current use. The desktop model,
|
|
100
|
+
* and Android's — the low-memory killer acts system-wide.
|
|
101
|
+
* - `process-memory`: this process's own ceiling. iOS jetsam terminates an app
|
|
102
|
+
* on its per-process footprint against a limit well below device RAM, so a
|
|
103
|
+
* system-wide budget there would defend verdicts the OS does not honor.
|
|
104
|
+
*/
|
|
105
|
+
export const modelFitBasisSchema = z.enum([
|
|
106
|
+
'system-memory',
|
|
107
|
+
'process-memory',
|
|
108
|
+
'device-memory',
|
|
109
|
+
'device-budget'
|
|
110
|
+
]);
|
|
111
|
+
export const modelFitBudgetSchema = z.object({
|
|
112
|
+
totalBytes: z
|
|
113
|
+
.number()
|
|
114
|
+
.describe('Total budgetable memory under the result’s basis: system RAM, or the process ceiling (allowance plus current footprint) under process-memory.'),
|
|
115
|
+
usedBytes: z
|
|
116
|
+
.number()
|
|
117
|
+
.describe('Memory in use at sample time under the same basis (system-wide, or this process).'),
|
|
118
|
+
availableBytes: z
|
|
119
|
+
.number()
|
|
120
|
+
.describe('Headroom before the policy applies: total − used, or the process allowance under process-memory. The reserve is a share of this.'),
|
|
121
|
+
reservedBytes: z.number().describe('Headroom withheld by the policy.'),
|
|
122
|
+
availableAfterReserveBytes: z
|
|
123
|
+
.number()
|
|
124
|
+
.describe('Budget the estimate is compared against: available − reserved.')
|
|
125
|
+
});
|
|
126
|
+
export const modelFitModelResultSchema = z.object({
|
|
127
|
+
name: z.string().describe('Catalog name of the assessed model.'),
|
|
128
|
+
verdict: modelFitVerdictSchema,
|
|
129
|
+
estimate: byteRangeSchema.optional().describe('Absent when this model assessed as `unknown`.'),
|
|
130
|
+
estimatorVersion: z
|
|
131
|
+
.string()
|
|
132
|
+
.optional()
|
|
133
|
+
.describe('Estimator that produced the bounds, e.g. `llm-v1`.'),
|
|
134
|
+
reasons: z.array(z.string()).describe('Why this model got this verdict.')
|
|
135
|
+
});
|
|
136
|
+
export const assessModelFitResultSchema = z.object({
|
|
137
|
+
verdict: modelFitVerdictSchema.describe('Combined verdict across every candidate.'),
|
|
138
|
+
basis: modelFitBasisSchema.describe('The evidence the budget was derived from — system RAM, the per-process ceiling on iOS, a discrete GPU’s own memory, or on Windows the GPU memory budget the OS grants this process. The two device bases also require the system-memory budget to hold.'),
|
|
139
|
+
execution: modelFitExecutionSchema.describe('The declared execution mode this result assumed.'),
|
|
140
|
+
budget: modelFitBudgetSchema.optional().describe('Absent when memory evidence was unusable.'),
|
|
141
|
+
estimate: byteRangeSchema.optional().describe('Absent when the combined verdict is `unknown`.'),
|
|
142
|
+
models: z.array(modelFitModelResultSchema).describe('Per-candidate verdicts, in input order.'),
|
|
143
|
+
reasons: z.array(z.string()).describe('Why the combined verdict came out this way.'),
|
|
144
|
+
assumptions: z
|
|
145
|
+
.array(z.string())
|
|
146
|
+
.describe('Everything the result took for granted, including estimator defaults.')
|
|
147
|
+
});
|
|
148
|
+
export const assessModelFitRequestSchema = assessModelFitInputSchema.extend({
|
|
149
|
+
type: z.literal('assessModelFit')
|
|
150
|
+
});
|
|
151
|
+
export const assessModelFitResponseSchema = assessModelFitResultSchema.extend({
|
|
152
|
+
type: z.literal('assessModelFit')
|
|
153
|
+
});
|