@qvac/inference 0.18.1 → 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/rag/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { chunk } from '
|
|
2
|
-
export { ingest } from '
|
|
3
|
-
export { saveEmbeddings } from '
|
|
4
|
-
export { search } from '
|
|
5
|
-
export { deleteEmbeddings } from '
|
|
6
|
-
export { reindex } from '
|
|
7
|
-
export { listWorkspaces } from '
|
|
8
|
-
export { closeWorkspace } from '
|
|
9
|
-
export { deleteWorkspace } from '
|
|
10
|
-
export { closeAllRagInstances, DEFAULT_WORKSPACE, type RagWorkspaceInfo } from '
|
|
11
|
-
export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey } from '
|
|
1
|
+
export { chunk } from './handlers/chunk.js';
|
|
2
|
+
export { ingest } from './handlers/ingest.js';
|
|
3
|
+
export { saveEmbeddings } from './handlers/save-embeddings.js';
|
|
4
|
+
export { search } from './handlers/search.js';
|
|
5
|
+
export { deleteEmbeddings } from './handlers/delete-embeddings.js';
|
|
6
|
+
export { reindex } from './handlers/reindex.js';
|
|
7
|
+
export { listWorkspaces } from './handlers/list-workspaces.js';
|
|
8
|
+
export { closeWorkspace } from './handlers/close-workspace.js';
|
|
9
|
+
export { deleteWorkspace } from './handlers/delete-workspace.js';
|
|
10
|
+
export { closeAllRagInstances, DEFAULT_WORKSPACE, type RagWorkspaceInfo } from './rag-workspace-manager.js';
|
|
11
|
+
export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey } from './rag-operation-manager.js';
|
package/dist/rag/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { chunk } from '
|
|
2
|
-
export { ingest } from '
|
|
3
|
-
export { saveEmbeddings } from '
|
|
4
|
-
export { search } from '
|
|
5
|
-
export { deleteEmbeddings } from '
|
|
6
|
-
export { reindex } from '
|
|
7
|
-
export { listWorkspaces } from '
|
|
8
|
-
export { closeWorkspace } from '
|
|
9
|
-
export { deleteWorkspace } from '
|
|
10
|
-
export { closeAllRagInstances, DEFAULT_WORKSPACE } from '
|
|
11
|
-
export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey } from '
|
|
1
|
+
export { chunk } from './handlers/chunk.js';
|
|
2
|
+
export { ingest } from './handlers/ingest.js';
|
|
3
|
+
export { saveEmbeddings } from './handlers/save-embeddings.js';
|
|
4
|
+
export { search } from './handlers/search.js';
|
|
5
|
+
export { deleteEmbeddings } from './handlers/delete-embeddings.js';
|
|
6
|
+
export { reindex } from './handlers/reindex.js';
|
|
7
|
+
export { listWorkspaces } from './handlers/list-workspaces.js';
|
|
8
|
+
export { closeWorkspace } from './handlers/close-workspace.js';
|
|
9
|
+
export { deleteWorkspace } from './handlers/delete-workspace.js';
|
|
10
|
+
export { closeAllRagInstances, DEFAULT_WORKSPACE } from './rag-workspace-manager.js';
|
|
11
|
+
export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey } from './rag-operation-manager.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RAG, HyperDBAdapter, type EmbeddingFunction } from '@qvac/rag';
|
|
1
|
+
import { RAG, HyperDBAdapter, TurboVecAdapter, type EmbeddingFunction } from '@qvac/rag';
|
|
2
|
+
type RagDbAdapter = HyperDBAdapter | TurboVecAdapter;
|
|
2
3
|
export declare const DEFAULT_WORKSPACE = "default";
|
|
3
4
|
export declare function hasRagWorkspaceStorage(workspace?: string): boolean;
|
|
4
|
-
export declare function getRagDbAdapter(workspace?: string): Promise<
|
|
5
|
+
export declare function getRagDbAdapter(workspace?: string): Promise<RagDbAdapter>;
|
|
5
6
|
export declare function getRagInstance(modelId: string, embeddingFunction: EmbeddingFunction, workspace?: string): Promise<RAG>;
|
|
6
7
|
export declare function closeRagInstance(workspace?: string): Promise<void>;
|
|
7
8
|
export declare function closeAllRagInstances(): Promise<void>;
|
|
@@ -12,3 +13,4 @@ export interface RagWorkspaceInfo {
|
|
|
12
13
|
export declare function listWorkspaces(): RagWorkspaceInfo[];
|
|
13
14
|
export declare function isWorkspaceLoaded(workspace: string): boolean;
|
|
14
15
|
export declare function deleteWorkspace(workspace: string): Promise<boolean>;
|
|
16
|
+
export {};
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { RAG, HyperDBAdapter } from '@qvac/rag';
|
|
1
|
+
import { RAG, ERR_CODES, HyperDBAdapter, QvacErrorRAG, TurboVecAdapter } from '@qvac/rag';
|
|
2
2
|
import Corestore from 'corestore';
|
|
3
3
|
import fs, { promises as fsPromises } from 'bare-fs';
|
|
4
4
|
import path from 'bare-path';
|
|
5
|
-
import { getConfiguredCacheDir } from '../runtime/state.js';
|
|
6
|
-
import { RAGWorkspaceModelMismatchError, RAGWorkspaceNotOpenError } from '../errors/index.js';
|
|
5
|
+
import { getConfig, getConfiguredCacheDir } from '../runtime/state.js';
|
|
6
|
+
import { PathTraversalError, RAGWorkspaceInUseError, RAGWorkspaceModelMismatchError, RAGWorkspaceNotOpenError } from '../errors/index.js';
|
|
7
7
|
import { validateAndJoinPath } from '../utils/path-security.js';
|
|
8
8
|
import { createStreamLogger, getEngineLogger, RAG_NAMESPACE } from '../logging/index.js';
|
|
9
|
-
import { cancelAllRagOperations } from '
|
|
9
|
+
import { cancelAllRagOperations } from './rag-operation-manager.js';
|
|
10
10
|
import { registerCorestore, unregisterCorestore } from '../runtime/runtime-lifecycle.js';
|
|
11
|
+
import { getTurboVecIndexProvider } from '../plugins/registry.js';
|
|
11
12
|
const logger = getEngineLogger();
|
|
13
|
+
const WORKSPACE_MARKER_FILE = '.qvac-rag-workspace.json';
|
|
14
|
+
const WORKSPACE_MARKER_VERSION = 1;
|
|
12
15
|
const ragWorkspaces = new Map();
|
|
16
|
+
// Track workspace opens in progress. Concurrent callers wait for the same
|
|
17
|
+
// attempt, so one failed open cannot remove another caller's workspace.
|
|
18
|
+
const openingWorkspaces = new Map();
|
|
19
|
+
let isCleaningUp = false;
|
|
13
20
|
export const DEFAULT_WORKSPACE = 'default';
|
|
14
21
|
function getWorkspaceKey(workspace) {
|
|
15
22
|
return workspace ?? DEFAULT_WORKSPACE;
|
|
@@ -18,8 +25,148 @@ function getRagBaseDir() {
|
|
|
18
25
|
const cacheDir = getConfiguredCacheDir();
|
|
19
26
|
return path.join(path.dirname(cacheDir), 'rag-hyperdb');
|
|
20
27
|
}
|
|
28
|
+
function getRagIndexBaseDir() {
|
|
29
|
+
const cacheDir = getConfiguredCacheDir();
|
|
30
|
+
return path.join(path.dirname(cacheDir), 'rag-turbovec');
|
|
31
|
+
}
|
|
32
|
+
function getWorkspacePath(basePath, workspace) {
|
|
33
|
+
const workspacePath = validateAndJoinPath(basePath, workspace);
|
|
34
|
+
if (workspacePath === path.resolve(basePath)) {
|
|
35
|
+
throw new PathTraversalError(workspace, basePath);
|
|
36
|
+
}
|
|
37
|
+
return workspacePath;
|
|
38
|
+
}
|
|
21
39
|
function getStorePath(workspace) {
|
|
22
|
-
return
|
|
40
|
+
return getWorkspacePath(getRagBaseDir(), workspace);
|
|
41
|
+
}
|
|
42
|
+
function getIndexPath(workspace) {
|
|
43
|
+
return getWorkspacePath(getRagIndexBaseDir(), workspace);
|
|
44
|
+
}
|
|
45
|
+
async function createWorkspaceDirectory(directoryPath) {
|
|
46
|
+
await fsPromises.mkdir(path.dirname(directoryPath), { recursive: true });
|
|
47
|
+
try {
|
|
48
|
+
await fsPromises.mkdir(directoryPath);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error.code === 'EEXIST')
|
|
53
|
+
return false;
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function cleanupCreatedWorkspacePaths(storePath, indexPath, createdStore, createdIndex) {
|
|
58
|
+
const removals = [];
|
|
59
|
+
if (createdStore)
|
|
60
|
+
removals.push(fsPromises.rm(storePath, { recursive: true, force: true }));
|
|
61
|
+
if (createdIndex)
|
|
62
|
+
removals.push(fsPromises.rm(indexPath, { recursive: true, force: true }));
|
|
63
|
+
await Promise.all(removals);
|
|
64
|
+
}
|
|
65
|
+
function missingIndexProviderError(workspace) {
|
|
66
|
+
return new QvacErrorRAG({
|
|
67
|
+
code: ERR_CODES.DEPENDENCY_REQUIRED,
|
|
68
|
+
adds: `RAG workspace '${workspace}' needs a TurboVec index provider; register a plugin that exposes the turbovecIndexProvider capability`
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// A pinned workspace scans HyperDB while its plugin is missing. If a plugin is
|
|
72
|
+
// registered later, the next create/load attempt (for example, reindex/reopen)
|
|
73
|
+
// uses it; existing searches do not switch providers automatically.
|
|
74
|
+
function createUnavailableIndexProvider(workspace) {
|
|
75
|
+
return {
|
|
76
|
+
create(options) {
|
|
77
|
+
const indexProvider = getTurboVecIndexProvider();
|
|
78
|
+
if (indexProvider)
|
|
79
|
+
return indexProvider.create(options);
|
|
80
|
+
throw missingIndexProviderError(workspace);
|
|
81
|
+
},
|
|
82
|
+
load(snapshotPath) {
|
|
83
|
+
const indexProvider = getTurboVecIndexProvider();
|
|
84
|
+
if (indexProvider)
|
|
85
|
+
return indexProvider.load(snapshotPath);
|
|
86
|
+
throw missingIndexProviderError(workspace);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createRagDbAdapter(corestore, workspace, adapterType, isPinned) {
|
|
91
|
+
if (adapterType === 'hyperdb') {
|
|
92
|
+
return new HyperDBAdapter({
|
|
93
|
+
store: corestore,
|
|
94
|
+
dbName: workspace
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const indexProvider = getTurboVecIndexProvider();
|
|
98
|
+
if (!indexProvider && !isPinned) {
|
|
99
|
+
throw missingIndexProviderError(workspace);
|
|
100
|
+
}
|
|
101
|
+
if (!indexProvider) {
|
|
102
|
+
logger.warn(`RAG workspace '${workspace}' is pinned to TurboVec but no index provider is registered; searches will scan the store directly`);
|
|
103
|
+
}
|
|
104
|
+
return new TurboVecAdapter({
|
|
105
|
+
store: corestore,
|
|
106
|
+
dbName: workspace,
|
|
107
|
+
indexProvider: indexProvider || createUnavailableIndexProvider(workspace),
|
|
108
|
+
checkpointDir: getIndexPath(workspace)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function unreadableMarkerError(markerPath, cause) {
|
|
112
|
+
return new QvacErrorRAG({
|
|
113
|
+
code: ERR_CODES.DB_OPERATION_FAILED,
|
|
114
|
+
adds: `RAG workspace adapter marker could not be read (${markerPath}); retry once the file is accessible`,
|
|
115
|
+
cause: cause instanceof Error ? cause : undefined
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function parseWorkspaceMarker(contents) {
|
|
119
|
+
let marker;
|
|
120
|
+
try {
|
|
121
|
+
marker = JSON.parse(contents);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (marker === null || typeof marker !== 'object' || Array.isArray(marker))
|
|
127
|
+
return null;
|
|
128
|
+
if (marker.version !== WORKSPACE_MARKER_VERSION)
|
|
129
|
+
return null;
|
|
130
|
+
if (marker.adapterType !== 'hyperdb' && marker.adapterType !== 'turbovec')
|
|
131
|
+
return null;
|
|
132
|
+
return marker.adapterType;
|
|
133
|
+
}
|
|
134
|
+
function getRequestedAdapterType() {
|
|
135
|
+
return getConfig().ragTurbovec === true ? 'turbovec' : 'hyperdb';
|
|
136
|
+
}
|
|
137
|
+
function detectExistingAdapterType(workspace) {
|
|
138
|
+
return fs.existsSync(getIndexPath(workspace)) ? 'turbovec' : 'hyperdb';
|
|
139
|
+
}
|
|
140
|
+
async function readWorkspaceAdapterType(storePath) {
|
|
141
|
+
const markerPath = path.join(storePath, WORKSPACE_MARKER_FILE);
|
|
142
|
+
let contents;
|
|
143
|
+
try {
|
|
144
|
+
contents = await fsPromises.readFile(markerPath, 'utf8');
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error.code === 'ENOENT') {
|
|
148
|
+
return { adapterType: null, present: false };
|
|
149
|
+
}
|
|
150
|
+
// Do not guess the adapter when the marker cannot be read. Let the caller
|
|
151
|
+
// fix the file and try again.
|
|
152
|
+
throw unreadableMarkerError(markerPath, error);
|
|
153
|
+
}
|
|
154
|
+
const adapterType = parseWorkspaceMarker(contents);
|
|
155
|
+
if (!adapterType) {
|
|
156
|
+
logger.warn(`Unrecognized RAG workspace marker at ${markerPath}; detecting the adapter from the workspace layout`);
|
|
157
|
+
}
|
|
158
|
+
return { adapterType, present: true };
|
|
159
|
+
}
|
|
160
|
+
async function writeWorkspaceAdapterType(storePath, adapterType) {
|
|
161
|
+
const markerPath = path.join(storePath, WORKSPACE_MARKER_FILE);
|
|
162
|
+
const temporaryPath = `${markerPath}.tmp-${Date.now()}`;
|
|
163
|
+
const marker = {
|
|
164
|
+
version: WORKSPACE_MARKER_VERSION,
|
|
165
|
+
adapterType
|
|
166
|
+
};
|
|
167
|
+
await fsPromises.mkdir(storePath, { recursive: true });
|
|
168
|
+
await fsPromises.writeFile(temporaryPath, `${JSON.stringify(marker)}\n`);
|
|
169
|
+
await fsPromises.rename(temporaryPath, markerPath);
|
|
23
170
|
}
|
|
24
171
|
export function hasRagWorkspaceStorage(workspace) {
|
|
25
172
|
const key = getWorkspaceKey(workspace);
|
|
@@ -33,13 +180,93 @@ async function getOrCreateWorkspaceEntry(workspace) {
|
|
|
33
180
|
if (existing) {
|
|
34
181
|
return existing;
|
|
35
182
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
183
|
+
const opening = openingWorkspaces.get(key);
|
|
184
|
+
if (opening) {
|
|
185
|
+
return opening;
|
|
186
|
+
}
|
|
187
|
+
const attempt = openWorkspaceEntry(key).finally(() => {
|
|
188
|
+
openingWorkspaces.delete(key);
|
|
41
189
|
});
|
|
42
|
-
|
|
190
|
+
openingWorkspaces.set(key, attempt);
|
|
191
|
+
return attempt;
|
|
192
|
+
}
|
|
193
|
+
async function openWorkspaceEntry(key) {
|
|
194
|
+
const storePath = getStorePath(key);
|
|
195
|
+
const indexPath = getIndexPath(key);
|
|
196
|
+
let createdStore = false;
|
|
197
|
+
let createdIndex = false;
|
|
198
|
+
let corestore;
|
|
199
|
+
let dbAdapter;
|
|
200
|
+
try {
|
|
201
|
+
createdStore = await createWorkspaceDirectory(storePath);
|
|
202
|
+
const marker = await readWorkspaceAdapterType(storePath);
|
|
203
|
+
const adapterType = marker.adapterType ??
|
|
204
|
+
(createdStore ? getRequestedAdapterType() : detectExistingAdapterType(key));
|
|
205
|
+
if (adapterType === 'turbovec') {
|
|
206
|
+
createdIndex = await createWorkspaceDirectory(indexPath);
|
|
207
|
+
}
|
|
208
|
+
corestore = new Corestore(storePath);
|
|
209
|
+
const isPinned = marker.adapterType !== null || !createdStore;
|
|
210
|
+
dbAdapter = createRagDbAdapter(corestore, key, adapterType, isPinned);
|
|
211
|
+
await dbAdapter.ready();
|
|
212
|
+
if (!marker.present) {
|
|
213
|
+
try {
|
|
214
|
+
await writeWorkspaceAdapterType(storePath, adapterType);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
if (createdStore)
|
|
218
|
+
throw error;
|
|
219
|
+
logger.warn(`Failed to write the RAG workspace adapter marker for existing workspace '${key}'; continuing without it:`, error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (dbAdapter) {
|
|
225
|
+
try {
|
|
226
|
+
await dbAdapter.close();
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// Keep the adapter initialization error as the primary failure.
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (corestore) {
|
|
233
|
+
try {
|
|
234
|
+
await corestore.close();
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Keep the adapter initialization error as the primary failure.
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
await cleanupCreatedWorkspacePaths(storePath, indexPath, createdStore, createdIndex);
|
|
242
|
+
}
|
|
243
|
+
catch (cleanupError) {
|
|
244
|
+
logger.warn(`Failed to clean up newly created RAG workspace '${key}':`, cleanupError);
|
|
245
|
+
}
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
if (isCleaningUp) {
|
|
249
|
+
let closeError;
|
|
250
|
+
try {
|
|
251
|
+
await dbAdapter.close();
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (error instanceof Error)
|
|
255
|
+
closeError = error;
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
await corestore.close();
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (!closeError && error instanceof Error)
|
|
262
|
+
closeError = error;
|
|
263
|
+
}
|
|
264
|
+
throw new QvacErrorRAG({
|
|
265
|
+
code: ERR_CODES.DB_OPERATION_FAILED,
|
|
266
|
+
adds: `RAG workspace '${key}' open was cancelled during cleanup`,
|
|
267
|
+
cause: closeError
|
|
268
|
+
});
|
|
269
|
+
}
|
|
43
270
|
registerCorestore(corestore, {
|
|
44
271
|
label: `rag-workspace:${key}`,
|
|
45
272
|
createdAt: Date.now()
|
|
@@ -75,8 +302,26 @@ export async function getRagInstance(modelId, embeddingFunction, workspace) {
|
|
|
75
302
|
entry.modelId = modelId;
|
|
76
303
|
return rag;
|
|
77
304
|
}
|
|
305
|
+
const OPEN_SETTLE_TIMEOUT_MS = 10_000;
|
|
306
|
+
async function waitForSettledOpen(key, opening) {
|
|
307
|
+
const settled = opening.then(() => true, () => true);
|
|
308
|
+
let timer;
|
|
309
|
+
const timedOut = new Promise((resolve) => {
|
|
310
|
+
timer = setTimeout(() => resolve(false), OPEN_SETTLE_TIMEOUT_MS);
|
|
311
|
+
});
|
|
312
|
+
const didSettle = await Promise.race([settled, timedOut]);
|
|
313
|
+
if (timer !== undefined)
|
|
314
|
+
clearTimeout(timer);
|
|
315
|
+
if (!didSettle) {
|
|
316
|
+
logger.warn(`Abandoned the in-flight open of RAG workspace '${key}' after ${OPEN_SETTLE_TIMEOUT_MS}ms`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
78
319
|
export async function closeRagInstance(workspace) {
|
|
79
320
|
const key = getWorkspaceKey(workspace);
|
|
321
|
+
const opening = openingWorkspaces.get(key);
|
|
322
|
+
if (opening) {
|
|
323
|
+
await waitForSettledOpen(key, opening);
|
|
324
|
+
}
|
|
80
325
|
const entry = ragWorkspaces.get(key);
|
|
81
326
|
if (!entry) {
|
|
82
327
|
throw new RAGWorkspaceNotOpenError(key);
|
|
@@ -89,13 +334,14 @@ export async function closeRagInstance(workspace) {
|
|
|
89
334
|
unregisterCorestore(entry.corestore);
|
|
90
335
|
ragWorkspaces.delete(key);
|
|
91
336
|
}
|
|
92
|
-
let isCleaningUp = false;
|
|
93
337
|
export async function closeAllRagInstances() {
|
|
94
338
|
if (isCleaningUp)
|
|
95
339
|
return;
|
|
96
340
|
isCleaningUp = true;
|
|
97
341
|
try {
|
|
98
342
|
cancelAllRagOperations();
|
|
343
|
+
const openingAttempts = Array.from(openingWorkspaces.entries());
|
|
344
|
+
await Promise.all(openingAttempts.map(([key, attempt]) => waitForSettledOpen(key, attempt)));
|
|
99
345
|
const closures = Array.from(ragWorkspaces.entries()).map(async ([key, entry]) => {
|
|
100
346
|
if (entry.rag) {
|
|
101
347
|
await entry.rag.close();
|
|
@@ -130,14 +376,21 @@ export function listWorkspaces() {
|
|
|
130
376
|
}
|
|
131
377
|
export function isWorkspaceLoaded(workspace) {
|
|
132
378
|
const key = getWorkspaceKey(workspace);
|
|
133
|
-
return ragWorkspaces.has(key);
|
|
379
|
+
return ragWorkspaces.has(key) || openingWorkspaces.has(key);
|
|
134
380
|
}
|
|
135
381
|
export async function deleteWorkspace(workspace) {
|
|
136
382
|
const key = getWorkspaceKey(workspace);
|
|
137
383
|
const storePath = getStorePath(key);
|
|
138
|
-
|
|
384
|
+
const indexPath = getIndexPath(key);
|
|
385
|
+
if (isWorkspaceLoaded(key)) {
|
|
386
|
+
throw new RAGWorkspaceInUseError(key);
|
|
387
|
+
}
|
|
388
|
+
if (!fs.existsSync(storePath) && !fs.existsSync(indexPath)) {
|
|
139
389
|
return false;
|
|
140
390
|
}
|
|
141
|
-
await
|
|
391
|
+
await Promise.all([
|
|
392
|
+
fsPromises.rm(storePath, { recursive: true, force: true }),
|
|
393
|
+
fsPromises.rm(indexPath, { recursive: true, force: true })
|
|
394
|
+
]);
|
|
142
395
|
return true;
|
|
143
396
|
}
|
package/dist/registry.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { dispatchPluginReply, dispatchPluginStream } from './handlers/plugin-dispatch.js';
|
|
2
|
-
import { getModelEntry } from './runtime/model-registry.js';
|
|
3
2
|
import { handleLoadModel } from './handlers/load-model/index.js';
|
|
4
|
-
import { handleLoadModelDelegated } from './p2p/load-model-delegated.js';
|
|
5
|
-
import { handleCompletionStreamDelegated } from './p2p/completion-stream-delegated.js';
|
|
6
3
|
import { handleUnloadModel } from './handlers/unload-model.js';
|
|
7
|
-
import { handleUnloadModelDelegated } from './p2p/unload-model-delegated.js';
|
|
8
4
|
import { handleLoggingStream } from './handlers/logging-stream.js';
|
|
9
5
|
import { cancelHandler } from './handlers/cancelHandler.js';
|
|
10
|
-
import { provideHandler } from './p2p/provideHandler.js';
|
|
11
|
-
import { stopProvideHandler } from './p2p/stopProvideHandler.js';
|
|
12
6
|
import { handleRag } from './rag/handler.js';
|
|
13
7
|
import { handleDeleteCache } from './handlers/delete-cache.js';
|
|
14
8
|
import { handleDownloadAsset } from './handlers/download-asset.js';
|
|
15
9
|
import { handleGetModelInfo } from './handlers/get-model-info.js';
|
|
16
10
|
import { handleGetLoadedModelInfo } from './handlers/get-loaded-model-info.js';
|
|
17
11
|
import { handleGetSystemResources } from './handlers/get-system-resources.js';
|
|
12
|
+
import { handleAssessModelFit } from './handlers/assess-model-fit.js';
|
|
18
13
|
import { handleHeartbeat } from './handlers/heartbeat.js';
|
|
19
|
-
import { handleHeartbeatDelegated } from './p2p/heartbeat-delegated.js';
|
|
20
14
|
import { handleFinetune } from './handlers/finetune.js';
|
|
21
15
|
import { handleCompletionOrchestrate } from './handlers/completion-orchestrate.js';
|
|
22
|
-
import { handleCancelDelegated } from './p2p/cancel-delegated.js';
|
|
23
16
|
import { handlePluginInvoke, handlePluginInvokeStream } from './handlers/plugin-invoke.js';
|
|
24
17
|
import { handleModelRegistryList, handleModelRegistrySearch, handleModelRegistryGetModel } from './handlers/registry.js';
|
|
25
18
|
import { handleSuspend } from './handlers/suspend.js';
|
|
@@ -47,64 +40,26 @@ function finetuneSupportsProgress(request) {
|
|
|
47
40
|
return false;
|
|
48
41
|
return ['start', 'resume', undefined].includes(request.operation);
|
|
49
42
|
}
|
|
50
|
-
function isModelDelegated(request) {
|
|
51
|
-
if (!('modelId' in request))
|
|
52
|
-
return false;
|
|
53
|
-
const entry = getModelEntry(request.modelId);
|
|
54
|
-
return entry?.isDelegated ?? false;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Should the cancel be forwarded to a delegated provider?
|
|
58
|
-
*
|
|
59
|
-
* The cancel envelope has two operations:
|
|
60
|
-
*
|
|
61
|
-
* - `request` — targeted cancel by `requestId`. Always handled locally: the
|
|
62
|
-
* process-singleton `RequestRegistry` is the source of truth for active
|
|
63
|
-
* requests (delegated handlers register their own requests on it the same
|
|
64
|
-
* way local ones do), so a `requestId` cancel always lands on the right
|
|
65
|
-
* place without a hop through the provider. Returning `false` keeps it on
|
|
66
|
-
* the local cancel handler, which routes through the registry and (for
|
|
67
|
-
* downloads) the `markClearCacheForRequest` helper.
|
|
68
|
-
*
|
|
69
|
-
* - `broad` — abort every in-flight request on a model. Forwarded to the
|
|
70
|
-
* delegated provider iff the targeted model itself is delegated; the
|
|
71
|
-
* provider then runs the same broad-cancel sweep on its side. Broad cancels
|
|
72
|
-
* for non-delegated models stay local.
|
|
73
|
-
*/
|
|
74
|
-
function isCancelDelegated(request) {
|
|
75
|
-
if (request.type !== 'cancel')
|
|
76
|
-
return false;
|
|
77
|
-
if (request.operation !== 'broad')
|
|
78
|
-
return false;
|
|
79
|
-
return isModelDelegated(request);
|
|
80
|
-
}
|
|
81
43
|
export const registry = {
|
|
82
44
|
// Reply
|
|
83
45
|
heartbeat: {
|
|
84
46
|
type: 'reply',
|
|
85
|
-
handler: handleHeartbeat
|
|
86
|
-
delegatedHandler: handleHeartbeatDelegated,
|
|
87
|
-
isDelegated: (r) => r.type === 'heartbeat' && !!r.delegate
|
|
47
|
+
handler: handleHeartbeat
|
|
88
48
|
},
|
|
89
49
|
unloadModel: {
|
|
90
50
|
type: 'reply',
|
|
91
|
-
handler: handleUnloadModel
|
|
92
|
-
delegatedHandler: handleUnloadModelDelegated,
|
|
93
|
-
isDelegated: isModelDelegated
|
|
51
|
+
handler: handleUnloadModel
|
|
94
52
|
},
|
|
95
53
|
embed: { type: 'reply', pluginOp: true, handler: pluginReply('embed') },
|
|
96
54
|
cancel: {
|
|
97
55
|
type: 'reply',
|
|
98
|
-
handler: cancelHandler
|
|
99
|
-
delegatedHandler: handleCancelDelegated,
|
|
100
|
-
isDelegated: isCancelDelegated
|
|
56
|
+
handler: cancelHandler
|
|
101
57
|
},
|
|
102
|
-
provide: { type: 'reply', handler: provideHandler },
|
|
103
|
-
stopProvide: { type: 'reply', handler: stopProvideHandler },
|
|
104
58
|
deleteCache: { type: 'reply', handler: handleDeleteCache },
|
|
105
59
|
getModelInfo: { type: 'reply', handler: handleGetModelInfo },
|
|
106
60
|
getLoadedModelInfo: { type: 'reply', handler: handleGetLoadedModelInfo },
|
|
107
61
|
getSystemResources: { type: 'reply', handler: handleGetSystemResources },
|
|
62
|
+
assessModelFit: { type: 'reply', handler: handleAssessModelFit },
|
|
108
63
|
pluginInvoke: { type: 'reply', handler: handlePluginInvoke },
|
|
109
64
|
modelRegistryList: { type: 'reply', handler: handleModelRegistryList },
|
|
110
65
|
modelRegistrySearch: { type: 'reply', handler: handleModelRegistrySearch },
|
|
@@ -115,8 +70,6 @@ export const registry = {
|
|
|
115
70
|
loadModel: {
|
|
116
71
|
type: 'reply',
|
|
117
72
|
handler: handleLoadModel,
|
|
118
|
-
delegatedHandler: handleLoadModelDelegated,
|
|
119
|
-
isDelegated: (r) => r.type === 'loadModel' && !!r.delegate,
|
|
120
73
|
supportsProgress: true
|
|
121
74
|
},
|
|
122
75
|
downloadAsset: { type: 'reply', handler: handleDownloadAsset, supportsProgress: true },
|
|
@@ -126,13 +79,8 @@ export const registry = {
|
|
|
126
79
|
completionStream: {
|
|
127
80
|
type: 'stream',
|
|
128
81
|
pluginOp: true,
|
|
129
|
-
handler: pluginStream('completionStream')
|
|
130
|
-
delegatedHandler: handleCompletionStreamDelegated,
|
|
131
|
-
isDelegated: isModelDelegated
|
|
82
|
+
handler: pluginStream('completionStream')
|
|
132
83
|
},
|
|
133
|
-
// Deliberately no delegated handler: tool callbacks execute code on the
|
|
134
|
-
// client machine, so only the user's own local worker may orchestrate
|
|
135
|
-
// (see completionOrchestrateResponseSchema's contract note).
|
|
136
84
|
completionOrchestrate: { type: 'duplex', handler: handleCompletionOrchestrate },
|
|
137
85
|
batchCompletionStream: {
|
|
138
86
|
type: 'stream',
|
|
@@ -148,6 +96,8 @@ export const registry = {
|
|
|
148
96
|
audioGenStream: { type: 'stream', pluginOp: true, handler: pluginStream('audioGenStream') },
|
|
149
97
|
videoStream: { type: 'stream', pluginOp: true, handler: pluginStream('videoStream') },
|
|
150
98
|
upscaleStream: { type: 'stream', pluginOp: true, handler: pluginStream('upscaleStream') },
|
|
99
|
+
worldStepStream: { type: 'stream', pluginOp: true, handler: pluginStream('worldStepStream') },
|
|
100
|
+
worldSceneStream: { type: 'stream', pluginOp: true, handler: pluginStream('worldSceneStream') },
|
|
151
101
|
classify: { type: 'stream', pluginOp: true, handler: pluginStream('classify') },
|
|
152
102
|
loggingStream: { type: 'stream', handler: handleLoggingStream },
|
|
153
103
|
pluginInvokeStream: { type: 'stream', handler: handlePluginInvokeStream },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResourceCollectorDependencies, ResourceMetric, ResourceProvenance } from '
|
|
1
|
+
import type { ResourceCollectorDependencies, ResourceMetric, ResourceProvenance } from './types.js';
|
|
2
2
|
export declare function createSystemResourceCollector(dependencies: ResourceCollectorDependencies): {
|
|
3
3
|
getCapabilities: () => {
|
|
4
4
|
cpu: {
|
|
@@ -506,6 +506,8 @@ export declare function createSystemResourceCollector(dependencies: ResourceColl
|
|
|
506
506
|
sampledAt: number;
|
|
507
507
|
cpu: ResourceMetric<number>;
|
|
508
508
|
memory: {
|
|
509
|
+
processUsedBytes: ResourceMetric<number>;
|
|
510
|
+
processAvailableBytes: ResourceMetric<number>;
|
|
509
511
|
usedBytes: ResourceMetric<number>;
|
|
510
512
|
totalBytes: ResourceMetric<number>;
|
|
511
513
|
};
|