@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
package/dist/errors/index.d.ts
CHANGED
|
@@ -27,12 +27,6 @@ export declare class RequestValidationFailedError extends QvacErrorBase {
|
|
|
27
27
|
export declare class RPCNoHandlerError extends QvacErrorBase {
|
|
28
28
|
constructor(requestType: string, cause?: unknown);
|
|
29
29
|
}
|
|
30
|
-
export declare class ProviderStartFailedError extends QvacErrorBase {
|
|
31
|
-
constructor(details?: string, cause?: unknown);
|
|
32
|
-
}
|
|
33
|
-
export declare class ProviderStopFailedError extends QvacErrorBase {
|
|
34
|
-
constructor(details?: string, cause?: unknown);
|
|
35
|
-
}
|
|
36
30
|
export declare class PluginsNotRegisteredError extends QvacErrorBase {
|
|
37
31
|
constructor(cause?: unknown);
|
|
38
32
|
}
|
|
@@ -63,9 +57,6 @@ export declare class ModelNotFoundError extends QvacErrorBase {
|
|
|
63
57
|
export declare class ModelNotLoadedError extends QvacErrorBase {
|
|
64
58
|
constructor(modelId: string, cause?: unknown);
|
|
65
59
|
}
|
|
66
|
-
export declare class ModelIsDelegatedError extends QvacErrorBase {
|
|
67
|
-
constructor(modelId: string, cause?: unknown);
|
|
68
|
-
}
|
|
69
60
|
export declare class ModelLoadFailedError extends QvacErrorBase {
|
|
70
61
|
constructor(details?: string, cause?: unknown);
|
|
71
62
|
}
|
|
@@ -133,29 +124,45 @@ export declare class TranslationFailedError extends QvacErrorBase {
|
|
|
133
124
|
export declare class CompletionFailedError extends QvacErrorBase {
|
|
134
125
|
constructor(details?: string, cause?: unknown);
|
|
135
126
|
}
|
|
127
|
+
/** The overflow sizes as one record; fields admit explicit `undefined` so a parser result assigns directly. */
|
|
128
|
+
export type ContextOverflowErrorSizes = {
|
|
129
|
+
promptTokens?: number | undefined;
|
|
130
|
+
cachedTokens?: number | undefined;
|
|
131
|
+
requiredTokens?: number | undefined;
|
|
132
|
+
ctxSize?: number | undefined;
|
|
133
|
+
};
|
|
136
134
|
/**
|
|
137
|
-
* Thrown when
|
|
138
|
-
*
|
|
135
|
+
* Thrown when a request no longer fits the model's effective context
|
|
136
|
+
* capacity — distinct from a generic `CompletionFailedError` so consumers
|
|
139
137
|
* can drive UX (truncate, summarize, or surface a "increase ctx_size /
|
|
140
138
|
* start a new thread" CTA) instead of treating it as an opaque failure.
|
|
141
139
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* fallback in `LlamaModel.cpp` carries neither — both fields are
|
|
147
|
-
* therefore optional). `modelId` is supplied by the handler that wraps
|
|
148
|
-
* the addon error.
|
|
140
|
+
* All size fields are optional: they carry whatever the addon guard
|
|
141
|
+
* reported (a cold prompt, a warm cached-plus-prompt split, or a bare
|
|
142
|
+
* overflow with no numbers). `modelId` is supplied by the handler that
|
|
143
|
+
* wraps the addon error.
|
|
149
144
|
*
|
|
150
145
|
* Serializes its typed fields (`toErrorResponseFields`) so a receiver can
|
|
151
|
-
* rebuild it after the error crosses a serialization boundary (
|
|
152
|
-
*
|
|
146
|
+
* rebuild it after the error crosses a serialization boundary (an RPC
|
|
147
|
+
* response).
|
|
153
148
|
*/
|
|
154
149
|
export declare class ContextOverflowError extends QvacErrorBase {
|
|
150
|
+
/** The prompt alone, in tokens; unset when the source reported KV cells. */
|
|
155
151
|
readonly promptTokens?: number;
|
|
152
|
+
/** Cached conversation on a warm-cache overflow, in `ctxSize` units. */
|
|
153
|
+
readonly cachedTokens?: number;
|
|
154
|
+
/** Total the failing guard reported, in `ctxSize` units; can equal the window (`>=` triggers). */
|
|
155
|
+
readonly requiredTokens?: number;
|
|
156
|
+
/** Effective per-request ceiling: `ctx_size` split across slots at `parallel > 1`. */
|
|
156
157
|
readonly ctxSize?: number;
|
|
157
158
|
readonly modelId?: string;
|
|
158
|
-
|
|
159
|
+
/** Canonical form: the parsed sizes as one record. */
|
|
160
|
+
constructor(contextSizes: ContextOverflowErrorSizes, modelId?: string, cause?: unknown);
|
|
161
|
+
/** @deprecated Kept for external consumers of the published package; in-repo callers use the record form. */
|
|
162
|
+
constructor(promptTokens?: number, ctxSize?: number, modelId?: string, cause?: unknown, extraSizes?: {
|
|
163
|
+
cachedTokens?: number | undefined;
|
|
164
|
+
requiredTokens?: number | undefined;
|
|
165
|
+
});
|
|
159
166
|
toErrorResponseFields(): Record<string, unknown>;
|
|
160
167
|
}
|
|
161
168
|
export declare class AttachmentNotFoundError extends QvacErrorBase {
|
|
@@ -170,7 +177,7 @@ export declare class RequestIdConflictError extends QvacErrorBase {
|
|
|
170
177
|
/**
|
|
171
178
|
* Surface typed fields on the serialized error envelope so a receiver can
|
|
172
179
|
* rebuild this exact class from `typedFields` after the error is serialized
|
|
173
|
-
* across a boundary (
|
|
180
|
+
* across a boundary (an RPC response). Without this,
|
|
174
181
|
* `err instanceof RequestIdConflictError` would be `false` on the far side.
|
|
175
182
|
*/
|
|
176
183
|
toErrorResponseFields(): Record<string, unknown>;
|
|
@@ -295,6 +302,12 @@ export declare class DownloadCancelledError extends QvacErrorBase {
|
|
|
295
302
|
export declare class ChecksumValidationFailedError extends QvacErrorBase {
|
|
296
303
|
constructor(fileName: string, cause?: unknown);
|
|
297
304
|
}
|
|
305
|
+
export declare class InsecureModelSourceError extends QvacErrorBase {
|
|
306
|
+
constructor(url: string, reason: string, cause?: unknown);
|
|
307
|
+
}
|
|
308
|
+
export declare class ChecksumUnavailableError extends QvacErrorBase {
|
|
309
|
+
constructor(url: string, cause?: unknown);
|
|
310
|
+
}
|
|
298
311
|
export declare class HTTPError extends QvacErrorBase {
|
|
299
312
|
/** HTTP status code; `0` denotes a connection/network failure (no response). */
|
|
300
313
|
readonly httpStatus: number;
|
|
@@ -357,15 +370,6 @@ export declare class AudioPlayerFailedError extends QvacErrorBase {
|
|
|
357
370
|
export declare class InvalidAudioChunkError extends QvacErrorBase {
|
|
358
371
|
constructor(cause?: unknown);
|
|
359
372
|
}
|
|
360
|
-
export declare class DelegateNoFinalResponseError extends QvacErrorBase {
|
|
361
|
-
constructor(cause?: unknown);
|
|
362
|
-
}
|
|
363
|
-
export declare class DelegateConnectionFailedError extends QvacErrorBase {
|
|
364
|
-
constructor(details: string, cause?: unknown);
|
|
365
|
-
}
|
|
366
|
-
export declare class DelegateProviderError extends QvacErrorBase {
|
|
367
|
-
constructor(details: string, providerCode?: number, cause?: unknown);
|
|
368
|
-
}
|
|
369
373
|
export declare class RPCNoDataReceivedError extends QvacErrorBase {
|
|
370
374
|
constructor(cause?: unknown);
|
|
371
375
|
}
|
package/dist/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QvacErrorBase } from '@qvac/error';
|
|
2
2
|
import { ERROR_CODES } from '../schemas/errors.js';
|
|
3
|
-
import { createErrorOptions } from '
|
|
3
|
+
import { createErrorOptions } from './options.js';
|
|
4
4
|
// ============== Response / request validation ==============
|
|
5
5
|
export class InvalidResponseError extends QvacErrorBase {
|
|
6
6
|
constructor(expected, cause) {
|
|
@@ -48,17 +48,6 @@ export class RPCNoHandlerError extends QvacErrorBase {
|
|
|
48
48
|
super(createErrorOptions(ERROR_CODES.RPC_NO_HANDLER, [requestType], cause));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
// ============== Provider / delegation, consumer side ==============
|
|
52
|
-
export class ProviderStartFailedError extends QvacErrorBase {
|
|
53
|
-
constructor(details, cause) {
|
|
54
|
-
super(createErrorOptions(ERROR_CODES.PROVIDER_START_FAILED, details ? [details] : undefined, cause));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export class ProviderStopFailedError extends QvacErrorBase {
|
|
58
|
-
constructor(details, cause) {
|
|
59
|
-
super(createErrorOptions(ERROR_CODES.PROVIDER_STOP_FAILED, details ? [details] : undefined, cause));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
51
|
export class PluginsNotRegisteredError extends QvacErrorBase {
|
|
63
52
|
constructor(cause) {
|
|
64
53
|
super(createErrorOptions(ERROR_CODES.PLUGINS_NOT_REGISTERED, [], cause));
|
|
@@ -112,11 +101,6 @@ export class ModelNotLoadedError extends QvacErrorBase {
|
|
|
112
101
|
super(createErrorOptions(ERROR_CODES.MODEL_NOT_LOADED, [modelId], cause));
|
|
113
102
|
}
|
|
114
103
|
}
|
|
115
|
-
export class ModelIsDelegatedError extends QvacErrorBase {
|
|
116
|
-
constructor(modelId, cause) {
|
|
117
|
-
super(createErrorOptions(ERROR_CODES.MODEL_IS_DELEGATED, [modelId], cause));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
104
|
// ============== Model loading ==============
|
|
121
105
|
export class ModelLoadFailedError extends QvacErrorBase {
|
|
122
106
|
constructor(details, cause) {
|
|
@@ -203,44 +187,75 @@ export class CompletionFailedError extends QvacErrorBase {
|
|
|
203
187
|
super(createErrorOptions(ERROR_CODES.COMPLETION_FAILED, details ? [details] : undefined, cause));
|
|
204
188
|
}
|
|
205
189
|
}
|
|
190
|
+
function normalizeContextOverflowArgs(sizesOrPromptTokens, modelIdOrCtxSize, causeOrModelId, cause, extraSizes) {
|
|
191
|
+
if (typeof sizesOrPromptTokens === 'object' && sizesOrPromptTokens !== null) {
|
|
192
|
+
return {
|
|
193
|
+
...sizesOrPromptTokens,
|
|
194
|
+
modelId: modelIdOrCtxSize,
|
|
195
|
+
cause: causeOrModelId
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// Only the two supported extra fields — a spread would let a wider,
|
|
199
|
+
// structurally assignable extras object override the positional args.
|
|
200
|
+
return {
|
|
201
|
+
promptTokens: sizesOrPromptTokens,
|
|
202
|
+
ctxSize: modelIdOrCtxSize,
|
|
203
|
+
modelId: causeOrModelId,
|
|
204
|
+
cause,
|
|
205
|
+
cachedTokens: extraSizes?.cachedTokens,
|
|
206
|
+
requiredTokens: extraSizes?.requiredTokens
|
|
207
|
+
};
|
|
208
|
+
}
|
|
206
209
|
/**
|
|
207
|
-
* Thrown when
|
|
208
|
-
*
|
|
210
|
+
* Thrown when a request no longer fits the model's effective context
|
|
211
|
+
* capacity — distinct from a generic `CompletionFailedError` so consumers
|
|
209
212
|
* can drive UX (truncate, summarize, or surface a "increase ctx_size /
|
|
210
213
|
* start a new thread" CTA) instead of treating it as an opaque failure.
|
|
211
214
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* fallback in `LlamaModel.cpp` carries neither — both fields are
|
|
217
|
-
* therefore optional). `modelId` is supplied by the handler that wraps
|
|
218
|
-
* the addon error.
|
|
215
|
+
* All size fields are optional: they carry whatever the addon guard
|
|
216
|
+
* reported (a cold prompt, a warm cached-plus-prompt split, or a bare
|
|
217
|
+
* overflow with no numbers). `modelId` is supplied by the handler that
|
|
218
|
+
* wraps the addon error.
|
|
219
219
|
*
|
|
220
220
|
* Serializes its typed fields (`toErrorResponseFields`) so a receiver can
|
|
221
|
-
* rebuild it after the error crosses a serialization boundary (
|
|
222
|
-
*
|
|
221
|
+
* rebuild it after the error crosses a serialization boundary (an RPC
|
|
222
|
+
* response).
|
|
223
223
|
*/
|
|
224
224
|
export class ContextOverflowError extends QvacErrorBase {
|
|
225
|
+
/** The prompt alone, in tokens; unset when the source reported KV cells. */
|
|
225
226
|
promptTokens;
|
|
227
|
+
/** Cached conversation on a warm-cache overflow, in `ctxSize` units. */
|
|
228
|
+
cachedTokens;
|
|
229
|
+
/** Total the failing guard reported, in `ctxSize` units; can equal the window (`>=` triggers). */
|
|
230
|
+
requiredTokens;
|
|
231
|
+
/** Effective per-request ceiling: `ctx_size` split across slots at `parallel > 1`. */
|
|
226
232
|
ctxSize;
|
|
227
233
|
modelId;
|
|
228
|
-
constructor(
|
|
234
|
+
constructor(sizesOrPromptTokens, modelIdOrCtxSize, causeOrModelId, cause, extraSizes) {
|
|
235
|
+
const n = normalizeContextOverflowArgs(sizesOrPromptTokens, modelIdOrCtxSize, causeOrModelId, cause, extraSizes);
|
|
229
236
|
super(createErrorOptions(ERROR_CODES.CONTEXT_OVERFLOW, [
|
|
230
|
-
promptTokens !== undefined ? String(promptTokens) : '',
|
|
231
|
-
ctxSize !== undefined ? String(ctxSize) : '',
|
|
232
|
-
modelId ?? ''
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
this.
|
|
238
|
-
if (
|
|
239
|
-
this.
|
|
237
|
+
n.promptTokens !== undefined ? String(n.promptTokens) : '',
|
|
238
|
+
n.ctxSize !== undefined ? String(n.ctxSize) : '',
|
|
239
|
+
n.modelId ?? '',
|
|
240
|
+
n.cachedTokens !== undefined ? String(n.cachedTokens) : '',
|
|
241
|
+
n.requiredTokens !== undefined ? String(n.requiredTokens) : ''
|
|
242
|
+
], n.cause));
|
|
243
|
+
if (n.promptTokens !== undefined)
|
|
244
|
+
this.promptTokens = n.promptTokens;
|
|
245
|
+
if (n.ctxSize !== undefined)
|
|
246
|
+
this.ctxSize = n.ctxSize;
|
|
247
|
+
if (n.modelId !== undefined)
|
|
248
|
+
this.modelId = n.modelId;
|
|
249
|
+
if (n.cachedTokens !== undefined)
|
|
250
|
+
this.cachedTokens = n.cachedTokens;
|
|
251
|
+
if (n.requiredTokens !== undefined)
|
|
252
|
+
this.requiredTokens = n.requiredTokens;
|
|
240
253
|
}
|
|
241
254
|
toErrorResponseFields() {
|
|
242
255
|
return {
|
|
243
256
|
...(this.promptTokens !== undefined && { promptTokens: this.promptTokens }),
|
|
257
|
+
...(this.cachedTokens !== undefined && { cachedTokens: this.cachedTokens }),
|
|
258
|
+
...(this.requiredTokens !== undefined && { requiredTokens: this.requiredTokens }),
|
|
244
259
|
...(this.ctxSize !== undefined && { ctxSize: this.ctxSize }),
|
|
245
260
|
...(this.modelId !== undefined && { modelId: this.modelId })
|
|
246
261
|
};
|
|
@@ -265,7 +280,7 @@ export class RequestIdConflictError extends QvacErrorBase {
|
|
|
265
280
|
/**
|
|
266
281
|
* Surface typed fields on the serialized error envelope so a receiver can
|
|
267
282
|
* rebuild this exact class from `typedFields` after the error is serialized
|
|
268
|
-
* across a boundary (
|
|
283
|
+
* across a boundary (an RPC response). Without this,
|
|
269
284
|
* `err instanceof RequestIdConflictError` would be `false` on the far side.
|
|
270
285
|
*/
|
|
271
286
|
toErrorResponseFields() {
|
|
@@ -473,6 +488,16 @@ export class ChecksumValidationFailedError extends QvacErrorBase {
|
|
|
473
488
|
super(createErrorOptions(ERROR_CODES.CHECKSUM_VALIDATION_FAILED, [fileName], cause));
|
|
474
489
|
}
|
|
475
490
|
}
|
|
491
|
+
export class InsecureModelSourceError extends QvacErrorBase {
|
|
492
|
+
constructor(url, reason, cause) {
|
|
493
|
+
super(createErrorOptions(ERROR_CODES.INSECURE_MODEL_SOURCE, [url, reason], cause));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
export class ChecksumUnavailableError extends QvacErrorBase {
|
|
497
|
+
constructor(url, cause) {
|
|
498
|
+
super(createErrorOptions(ERROR_CODES.CHECKSUM_UNAVAILABLE, [url], cause));
|
|
499
|
+
}
|
|
500
|
+
}
|
|
476
501
|
export class HTTPError extends QvacErrorBase {
|
|
477
502
|
/** HTTP status code; `0` denotes a connection/network failure (no response). */
|
|
478
503
|
httpStatus;
|
|
@@ -578,22 +603,7 @@ export class InvalidAudioChunkError extends QvacErrorBase {
|
|
|
578
603
|
super(createErrorOptions(ERROR_CODES.INVALID_AUDIO_CHUNK_TYPE, undefined, cause));
|
|
579
604
|
}
|
|
580
605
|
}
|
|
581
|
-
// ==============
|
|
582
|
-
export class DelegateNoFinalResponseError extends QvacErrorBase {
|
|
583
|
-
constructor(cause) {
|
|
584
|
-
super(createErrorOptions(ERROR_CODES.DELEGATE_NO_FINAL_RESPONSE, undefined, cause));
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
export class DelegateConnectionFailedError extends QvacErrorBase {
|
|
588
|
-
constructor(details, cause) {
|
|
589
|
-
super(createErrorOptions(ERROR_CODES.DELEGATE_CONNECTION_FAILED, [details], cause));
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
export class DelegateProviderError extends QvacErrorBase {
|
|
593
|
-
constructor(details, providerCode, cause) {
|
|
594
|
-
super(createErrorOptions(ERROR_CODES.DELEGATE_PROVIDER_ERROR, providerCode !== undefined ? [details, String(providerCode)] : [details], cause));
|
|
595
|
-
}
|
|
596
|
-
}
|
|
606
|
+
// ============== RPC transport ==============
|
|
597
607
|
export class RPCNoDataReceivedError extends QvacErrorBase {
|
|
598
608
|
constructor(cause) {
|
|
599
609
|
super(createErrorOptions(ERROR_CODES.RPC_NO_DATA_RECEIVED, undefined, cause));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AssessModelFitRequest, AssessModelFitResponse } from '../schemas/assess-model-fit.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs a pre-download fit assessment worker-side.
|
|
4
|
+
*
|
|
5
|
+
* This lives on the worker because that is where the two things it needs
|
|
6
|
+
* already are: the resource collector for a fresh memory sample, and the
|
|
7
|
+
* runtime's own platform/arch pair. No model bytes are read and nothing is
|
|
8
|
+
* loaded.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleAssessModelFit(request: AssessModelFitRequest): AssessModelFitResponse;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import os from 'bare-os';
|
|
2
|
+
import { getResourceCollector } from '../resources/instance.js';
|
|
3
|
+
import { assessModelFitFromResources } from '../resources/model-fit/assess.js';
|
|
4
|
+
import { getPlatformCalibration } from '../resources/model-fit/calibration/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Runs a pre-download fit assessment worker-side.
|
|
7
|
+
*
|
|
8
|
+
* This lives on the worker because that is where the two things it needs
|
|
9
|
+
* already are: the resource collector for a fresh memory sample, and the
|
|
10
|
+
* runtime's own platform/arch pair. No model bytes are read and nothing is
|
|
11
|
+
* loaded.
|
|
12
|
+
*/
|
|
13
|
+
export function handleAssessModelFit(request) {
|
|
14
|
+
const platform = detectPlatform();
|
|
15
|
+
const result = assessModelFitFromResources({
|
|
16
|
+
models: request.models,
|
|
17
|
+
execution: request.execution,
|
|
18
|
+
resources: readResources(),
|
|
19
|
+
platform,
|
|
20
|
+
calibration: platform ? getPlatformCalibration(platform) : undefined
|
|
21
|
+
});
|
|
22
|
+
return { type: 'assessModelFit', ...result };
|
|
23
|
+
}
|
|
24
|
+
function readResources() {
|
|
25
|
+
const collector = getResourceCollector();
|
|
26
|
+
if (!collector) {
|
|
27
|
+
const failed = { status: 'failed', reason: 'resource collector is not initialized' };
|
|
28
|
+
return {
|
|
29
|
+
capabilities: {
|
|
30
|
+
cpu: failed,
|
|
31
|
+
memory: { totalBytes: failed },
|
|
32
|
+
gpus: failed
|
|
33
|
+
},
|
|
34
|
+
sample: {
|
|
35
|
+
sampledAt: Date.now(),
|
|
36
|
+
cpu: failed,
|
|
37
|
+
memory: {
|
|
38
|
+
usedBytes: failed,
|
|
39
|
+
totalBytes: failed,
|
|
40
|
+
processUsedBytes: failed,
|
|
41
|
+
processAvailableBytes: failed
|
|
42
|
+
},
|
|
43
|
+
gpus: failed
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { capabilities: collector.getCapabilities(), sample: collector.sample() };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Maps the runtime's platform and architecture onto a calibration target.
|
|
51
|
+
*
|
|
52
|
+
* @returns `undefined` for any pair this feature has no calibration target for,
|
|
53
|
+
* which assesses as `unknown` rather than borrowing another platform's
|
|
54
|
+
* coefficients.
|
|
55
|
+
*/
|
|
56
|
+
function detectPlatform() {
|
|
57
|
+
const key = `${os.platform()}-${os.arch()}`;
|
|
58
|
+
switch (key) {
|
|
59
|
+
case 'darwin-arm64':
|
|
60
|
+
case 'darwin-x64':
|
|
61
|
+
case 'linux-arm64':
|
|
62
|
+
case 'linux-x64':
|
|
63
|
+
case 'win32-x64':
|
|
64
|
+
// Listed for completeness rather than reach: no engine addon is built for
|
|
65
|
+
// win32-arm64 (`@qvac/llm-llamacpp/prebuilds` has no such target, and no
|
|
66
|
+
// windows-arm runner exists to build one), so nothing on that platform can
|
|
67
|
+
// load a model today. Calibrating it needs that build first, not a fixture.
|
|
68
|
+
case 'win32-arm64':
|
|
69
|
+
case 'android-arm64':
|
|
70
|
+
case 'ios-arm64':
|
|
71
|
+
return key;
|
|
72
|
+
default:
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cancel as cancelByModelId } from '../plugins/ops/cancel.js';
|
|
2
2
|
import { getRequestRegistry } from '../runtime/index.js';
|
|
3
|
-
import { markClearCacheForRequest } from '
|
|
3
|
+
import { markClearCacheForRequest } from './load-model/download-manager.js';
|
|
4
4
|
import { getEngineLogger } from '../logging/index.js';
|
|
5
5
|
const logger = getEngineLogger();
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toolCallbackResultSchema } from '../schemas/completion-stream.js';
|
|
2
2
|
import { aggregateEvents } from '../utils/aggregate-events.js';
|
|
3
3
|
import { CompletionFailedError } from '../errors/index.js';
|
|
4
|
-
import { dispatchPluginStream } from '
|
|
4
|
+
import { dispatchPluginStream } from './plugin-dispatch.js';
|
|
5
5
|
const DEFAULT_MAX_TOOL_TURNS = 8;
|
|
6
6
|
// Generous ceiling on one client-side tool execution: long enough for a slow
|
|
7
7
|
// MCP round trip, short enough that a client that stopped reading can't pin a
|
|
@@ -51,8 +51,8 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
53
|
import { PROFILING_KEY, OPERATION_EVENT_KEY } from '../schemas/index.js';
|
|
54
|
-
import { resolveModelPath, resolveModelPathWithStats } from '
|
|
55
|
-
import { buildDownloadProfilingFields } from '
|
|
54
|
+
import { resolveModelPath, resolveModelPathWithStats } from './load-model/resolve.js';
|
|
55
|
+
import { buildDownloadProfilingFields } from './load-model/types.js';
|
|
56
56
|
import { nowMs, generateProfileId } from '../profiling/clock.js';
|
|
57
57
|
import { getEngineLogger } from '../logging/index.js';
|
|
58
58
|
import { getRequestRegistry, withRequestContext } from '../runtime/index.js';
|
|
@@ -62,7 +62,8 @@ const logger = getEngineLogger();
|
|
|
62
62
|
export async function handleDownloadAsset(request, progressCallback) {
|
|
63
63
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
64
64
|
try {
|
|
65
|
-
const { assetSrc, seed } = request;
|
|
65
|
+
const { assetSrc, seed, requireHttpChecksum, requireSecureTransport } = request;
|
|
66
|
+
const security = { requireHttpChecksum, requireSecureTransport };
|
|
66
67
|
const profilingMeta = request[PROFILING_KEY];
|
|
67
68
|
const profilingEnabled = profilingMeta?.enabled !== false && !!profilingMeta;
|
|
68
69
|
const requestId = request.requestId ?? generateRandomRequestId();
|
|
@@ -88,12 +89,12 @@ export async function handleDownloadAsset(request, progressCallback) {
|
|
|
88
89
|
let sourceType;
|
|
89
90
|
let downloadStats;
|
|
90
91
|
if (profilingEnabled) {
|
|
91
|
-
const result = await resolveModelPathWithStats(assetSrc, progressCallback, seed, ctx.signal, hooks);
|
|
92
|
+
const result = await resolveModelPathWithStats(assetSrc, progressCallback, seed, ctx.signal, hooks, undefined, security);
|
|
92
93
|
sourceType = result.sourceType;
|
|
93
94
|
downloadStats = result.downloadStats;
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
|
-
await resolveModelPath(assetSrc, progressCallback, seed, ctx.signal, hooks);
|
|
97
|
+
await resolveModelPath(assetSrc, progressCallback, seed, ctx.signal, hooks, undefined, security);
|
|
97
98
|
}
|
|
98
99
|
const response = {
|
|
99
100
|
type: 'downloadAsset',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dispatchPluginReply } from '
|
|
1
|
+
import { dispatchPluginReply } from './plugin-dispatch.js';
|
|
2
2
|
import { startFinetune } from '../plugins/builtin/llamacpp-completion/ops/finetune.js';
|
|
3
3
|
export async function handleFinetune(request, progressCallback) {
|
|
4
4
|
if (progressCallback &&
|
|
@@ -10,17 +10,6 @@ export function handleGetLoadedModelInfo(request) {
|
|
|
10
10
|
if (!entry) {
|
|
11
11
|
throw new ModelNotFoundError(modelId);
|
|
12
12
|
}
|
|
13
|
-
if (entry.isDelegated) {
|
|
14
|
-
const info = {
|
|
15
|
-
modelId: entry.id,
|
|
16
|
-
isDelegated: true,
|
|
17
|
-
handlers: [],
|
|
18
|
-
providerInfo: {
|
|
19
|
-
providerPublicKey: entry.delegated.providerPublicKey
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
return { type: 'getLoadedModelInfo', info };
|
|
23
|
-
}
|
|
24
13
|
const plugin = getPlugin(entry.local.modelType);
|
|
25
14
|
if (!plugin) {
|
|
26
15
|
logger.warn(`getLoadedModelInfo: no plugin registered for modelType "${entry.local.modelType}" on loaded model "${modelId}"`);
|
|
@@ -28,7 +17,6 @@ export function handleGetLoadedModelInfo(request) {
|
|
|
28
17
|
const handlers = plugin ? Object.keys(plugin.handlers) : [];
|
|
29
18
|
const info = {
|
|
30
19
|
modelId: entry.id,
|
|
31
|
-
isDelegated: false,
|
|
32
20
|
modelType: entry.local.modelType,
|
|
33
21
|
handlers,
|
|
34
22
|
loadedAt: entry.local.loadedAt,
|
|
@@ -23,7 +23,7 @@ export async function handleGetModelInfo(request) {
|
|
|
23
23
|
const loadedInstances = [];
|
|
24
24
|
for (const id of loadedModelIds) {
|
|
25
25
|
const entry = getModelEntry(id);
|
|
26
|
-
if (!entry
|
|
26
|
+
if (!entry)
|
|
27
27
|
continue;
|
|
28
28
|
const matchesByName = entry.local.name && entry.local.name === name;
|
|
29
29
|
const matchesByPath = !!matchPath && entry.local.path === matchPath;
|
|
@@ -35,6 +35,14 @@ export function handleGetSystemResources(request) {
|
|
|
35
35
|
totalBytes: {
|
|
36
36
|
status: 'failed',
|
|
37
37
|
reason: 'CPU resource collector is not initialized'
|
|
38
|
+
},
|
|
39
|
+
processUsedBytes: {
|
|
40
|
+
status: 'failed',
|
|
41
|
+
reason: 'resource collector is not initialized'
|
|
42
|
+
},
|
|
43
|
+
processAvailableBytes: {
|
|
44
|
+
status: 'failed',
|
|
45
|
+
reason: 'resource collector is not initialized'
|
|
38
46
|
}
|
|
39
47
|
},
|
|
40
48
|
gpus: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelProgressUpdate } from '../../schemas/index.js';
|
|
2
2
|
import { AbortController, type AbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { DisposableScope } from '../../runtime/disposable-scope.js';
|
|
4
|
-
import type { DownloadHooks } from '
|
|
4
|
+
import type { DownloadHooks } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Per-subscriber binding to a registry-tracked request.
|
|
7
7
|
* `startOrJoinDownload` is request-aware: each caller (the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelProgressUpdate } from '../../schemas/index.js';
|
|
2
|
-
import type { DownloadStats, DownloadResult, DownloadHooks, ResolveResult } from '
|
|
3
|
-
import type { ExplicitRegistryMetadata } from '
|
|
4
|
-
export declare function downloadModelFromHttpWithStats(url: string, progressCallback?: (progress: ModelProgressUpdate) => void, downloadHooks?: DownloadHooks): Promise<DownloadResult>;
|
|
2
|
+
import type { DownloadStats, DownloadResult, DownloadHooks, DownloadSecurityOptions, ResolveResult } from './types.js';
|
|
3
|
+
import type { ExplicitRegistryMetadata } from './registry-metadata.js';
|
|
4
|
+
export declare function downloadModelFromHttpWithStats(url: string, progressCallback?: (progress: ModelProgressUpdate) => void, downloadHooks?: DownloadHooks, security?: DownloadSecurityOptions): Promise<DownloadResult>;
|
|
5
5
|
export declare function downloadModelFromRegistryWithStats(registryPath: string, registrySource: string, progressCallback?: (progress: ModelProgressUpdate) => void, expectedChecksum?: string, downloadHooks?: DownloadHooks, explicitMetadata?: ExplicitRegistryMetadata): Promise<DownloadResult>;
|
|
6
6
|
export declare function downloadModelFromHyperdriveWithStats(hyperdriveKey: string, modelFileName: string, seed?: boolean, progressCallback?: (progress: ModelProgressUpdate) => void, downloadHooks?: DownloadHooks): Promise<DownloadResult>;
|
|
7
7
|
export declare function mergeDownloadStats(results: ResolveResult[]): DownloadStats | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { downloadModelFromHttp } from '
|
|
2
|
-
import { downloadModelFromRegistry } from '
|
|
3
|
-
import { downloadModelFromHyperdrive } from '
|
|
1
|
+
import { downloadModelFromHttp } from './http.js';
|
|
2
|
+
import { downloadModelFromRegistry } from './registry.js';
|
|
3
|
+
import { downloadModelFromHyperdrive } from './hyperdrive.js';
|
|
4
4
|
import { nowMs } from '../../profiling/index.js';
|
|
5
5
|
function createStatsCollector() {
|
|
6
6
|
return {
|
|
@@ -74,11 +74,11 @@ function computeStats(collector) {
|
|
|
74
74
|
}
|
|
75
75
|
return Object.keys(stats).length > 0 ? stats : undefined;
|
|
76
76
|
}
|
|
77
|
-
export async function downloadModelFromHttpWithStats(url, progressCallback, downloadHooks) {
|
|
77
|
+
export async function downloadModelFromHttpWithStats(url, progressCallback, downloadHooks, security) {
|
|
78
78
|
const collector = createStatsCollector();
|
|
79
79
|
const hooks = { ...downloadHooks, ...createStatsHooks(collector) };
|
|
80
80
|
const wrappedCallback = wrapProgressCallback(collector, progressCallback);
|
|
81
|
-
const path = await downloadModelFromHttp(url, wrappedCallback, hooks);
|
|
81
|
+
const path = await downloadModelFromHttp(url, wrappedCallback, hooks, security);
|
|
82
82
|
const stats = computeStats(collector);
|
|
83
83
|
return stats ? { path, stats } : { path };
|
|
84
84
|
}
|
|
@@ -52,13 +52,13 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
52
52
|
});
|
|
53
53
|
import { normalizeModelType, PROFILING_KEY, OPERATION_EVENT_KEY } from '../../schemas/index.js';
|
|
54
54
|
import { loadModel } from '../../plugins/ops/load-model.js';
|
|
55
|
-
import { createResolveSession } from '
|
|
55
|
+
import { createResolveSession } from './resolve-session.js';
|
|
56
56
|
import { nowMs, generateProfileId } from '../../profiling/clock.js';
|
|
57
57
|
import { getModelEntry, updateModelConfig } from '../../runtime/model-registry.js';
|
|
58
58
|
import { generateShortHash, canonicalConfigString, transformConfigForReload } from '../../utils/index.js';
|
|
59
|
-
import { buildDownloadProfilingFields } from '
|
|
59
|
+
import { buildDownloadProfilingFields } from './types.js';
|
|
60
60
|
import { readBackendDiagnostics } from '../../profiling/backend-diagnostics.js';
|
|
61
|
-
import { ConfigReloadNotSupportedError, InferenceCancelledError, ModelTypeMismatchError,
|
|
61
|
+
import { ConfigReloadNotSupportedError, InferenceCancelledError, ModelTypeMismatchError, ModelNotFoundError, ModelLoadFailedError, PluginLoadConfigValidationFailedError, PluginNotFoundError } from '../../errors/index.js';
|
|
62
62
|
import { getEngineLogger } from '../../logging/index.js';
|
|
63
63
|
import { formatZodError } from '../../utils/zod-error.js';
|
|
64
64
|
import { getPlugin } from '../../plugins/index.js';
|
|
@@ -74,7 +74,7 @@ export async function handleLoadModel(request, progressCallback) {
|
|
|
74
74
|
if (isReloadConfigRequest(request)) {
|
|
75
75
|
return handleConfigReload(request);
|
|
76
76
|
}
|
|
77
|
-
const { modelSrc, modelName, seed, fallbackSrc } = request;
|
|
77
|
+
const { modelSrc, modelName, seed, fallbackSrc, requireHttpChecksum, requireSecureTransport } = request;
|
|
78
78
|
const canonicalModelType = normalizeModelType(request.modelType);
|
|
79
79
|
const profilingMeta = request[PROFILING_KEY];
|
|
80
80
|
const profilingEnabled = profilingMeta?.enabled !== false && !!profilingMeta;
|
|
@@ -111,7 +111,8 @@ export async function handleLoadModel(request, progressCallback) {
|
|
|
111
111
|
signal: ctx.signal,
|
|
112
112
|
scope: ctx.scope,
|
|
113
113
|
requestId
|
|
114
|
-
}
|
|
114
|
+
},
|
|
115
|
+
security: { requireHttpChecksum, requireSecureTransport }
|
|
115
116
|
});
|
|
116
117
|
const primaryResolve = session.resolvePrimaryModelPath(modelSrc, fallbackSrc);
|
|
117
118
|
let resolvedModelPath;
|
|
@@ -247,9 +248,6 @@ async function handleConfigReload(request) {
|
|
|
247
248
|
if (!entry) {
|
|
248
249
|
throw new ModelNotFoundError(modelId);
|
|
249
250
|
}
|
|
250
|
-
if (entry.isDelegated) {
|
|
251
|
-
throw new ModelIsDelegatedError(modelId);
|
|
252
|
-
}
|
|
253
251
|
const storedModelType = entry.local.modelType;
|
|
254
252
|
const normalizedRequestType = normalizeModelType(modelType);
|
|
255
253
|
if (storedModelType !== normalizedRequestType) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DownloadHooks } from './types.js';
|
|
2
|
+
export declare function isHuggingFaceUrl(url: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Whether an HTTP download's transport must be secure (plaintext / HTTPS→HTTP
|
|
5
|
+
* downgrades refused, loopback exempt). Hugging Face is always enforced so a
|
|
6
|
+
* downgrade can't sidestep its Hub SHA-256 attestation; `requireSecureTransport`
|
|
7
|
+
* extends the same enforcement to every HTTP source.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shouldEnforceSecureTransport(url: string, requireSecureTransport: boolean): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Enforce the download integrity policy for a freshly downloaded HTTP file.
|
|
12
|
+
*
|
|
13
|
+
* A Hugging Face download carries the Hub's SHA-256 (captured from the resolve
|
|
14
|
+
* hop), so it is always verified and a mismatch fails. When no trusted checksum
|
|
15
|
+
* is available, the behavior depends on `requireChecksum`: a source that should
|
|
16
|
+
* be verifiable (Hugging Face without a usable hash) is rejected under the flag;
|
|
17
|
+
* a source with no checksum source at all (non-Hugging-Face) always downloads,
|
|
18
|
+
* with a warning that it was unverified.
|
|
19
|
+
*/
|
|
20
|
+
export declare function verifyHttpModelFile(url: string, filePath: string, hubSha256: string | undefined, requireChecksum: boolean, hooks?: DownloadHooks): Promise<void>;
|