@qvac/sdk 0.10.2 → 0.12.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 +1455 -29
- package/README.md +2 -0
- package/dist/client/api/cancel.d.ts +24 -32
- package/dist/client/api/cancel.js +58 -31
- package/dist/client/api/classify.d.ts +23 -0
- package/dist/client/api/classify.js +43 -0
- package/dist/client/api/client-request-id.d.ts +17 -0
- package/dist/client/api/client-request-id.js +27 -0
- package/dist/client/api/completion-stream.d.ts +1 -1
- package/dist/client/api/completion-stream.js +34 -3
- package/dist/client/api/diffusion.d.ts +46 -0
- package/dist/client/api/diffusion.js +50 -1
- package/dist/client/api/download-asset.d.ts +12 -2
- package/dist/client/api/download-asset.js +21 -3
- package/dist/client/api/embed.d.ts +8 -4
- package/dist/client/api/embed.js +14 -1
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/index.d.ts +5 -0
- package/dist/client/api/index.js +5 -0
- package/dist/client/api/load-model.d.ts +12 -4
- package/dist/client/api/load-model.js +49 -2
- package/dist/client/api/rag.d.ts +9 -3
- package/dist/client/api/rag.js +23 -3
- package/dist/client/api/transcribe.d.ts +23 -8
- package/dist/client/api/transcribe.js +69 -4
- package/dist/client/api/unload-model.d.ts +5 -2
- package/dist/client/api/unload-model.js +9 -4
- package/dist/client/api/upscale.d.ts +45 -0
- package/dist/client/api/upscale.js +99 -0
- package/dist/client/api/video.d.ts +64 -0
- package/dist/client/api/video.js +147 -0
- package/dist/client/api/vla-helpers.d.ts +45 -0
- package/dist/client/api/vla-helpers.js +130 -0
- package/dist/client/api/vla.d.ts +65 -0
- package/dist/client/api/vla.js +109 -0
- package/dist/client/config-loader/resolve-config.node.d.ts +16 -0
- package/dist/client/config-loader/resolve-config.node.js +77 -23
- package/dist/client/plugins-factory.d.ts +8 -0
- package/dist/client/plugins-factory.js +10 -0
- package/dist/client/rpc/bare-client.js +62 -66
- package/dist/client/rpc/ensure-worker-ready.d.ts +9 -0
- package/dist/client/rpc/ensure-worker-ready.js +17 -0
- package/dist/client/rpc/expo-rpc-client.js +2 -1
- package/dist/client/rpc/node-rpc-client.js +22 -8
- package/dist/client/rpc/rpc-client.d.ts +2 -2
- package/dist/client/rpc/rpc-client.js +10 -4
- package/dist/client/rpc/rpc-error.d.ts +9 -0
- package/dist/client/rpc/rpc-error.js +105 -0
- package/dist/commands/bundle/bare-pack.d.ts +13 -0
- package/dist/commands/bundle/bare-pack.js +54 -0
- package/dist/commands/bundle/constants.d.ts +7 -0
- package/dist/commands/bundle/constants.js +23 -0
- package/dist/commands/bundle/entry-gen.d.ts +2 -0
- package/dist/commands/bundle/entry-gen.js +48 -0
- package/dist/commands/bundle/index.d.ts +20 -0
- package/dist/commands/bundle/index.js +141 -0
- package/dist/commands/bundle/manifest.d.ts +21 -0
- package/dist/commands/bundle/manifest.js +193 -0
- package/dist/commands/bundle/plugins.d.ts +9 -0
- package/dist/commands/bundle/plugins.js +51 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/verify/abi.d.ts +52 -0
- package/dist/commands/verify/abi.js +125 -0
- package/dist/commands/verify/addon-source.d.ts +43 -0
- package/dist/commands/verify/addon-source.js +75 -0
- package/dist/commands/verify/bundle-source.d.ts +12 -0
- package/dist/commands/verify/bundle-source.js +53 -0
- package/dist/commands/verify/index.d.ts +59 -0
- package/dist/commands/verify/index.js +371 -0
- package/dist/commands/verify/node-modules-source.d.ts +11 -0
- package/dist/commands/verify/node-modules-source.js +76 -0
- package/dist/commands/verify/prebuilds.d.ts +15 -0
- package/dist/commands/verify/prebuilds.js +39 -0
- package/dist/examples/cancel-by-request-id.d.ts +38 -0
- package/dist/examples/cancel-by-request-id.js +103 -0
- package/dist/examples/classification/classify-image.d.ts +2 -0
- package/dist/examples/classification/classify-image.js +23 -0
- package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
- package/dist/examples/diffusion-esrgan-upscale.js +78 -0
- package/dist/examples/diffusion-txt2vid.d.ts +2 -0
- package/dist/examples/diffusion-txt2vid.js +81 -0
- package/dist/examples/download-with-cancel.js +10 -10
- package/dist/examples/embed-multi-gpu.d.ts +2 -0
- package/dist/examples/embed-multi-gpu.js +46 -0
- package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
- package/dist/examples/llamacpp-multi-gpu.js +57 -0
- package/dist/examples/plugins.js +3 -7
- package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
- package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-gemma4.js +73 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.js +69 -0
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +18 -12
- package/dist/examples/transcription/parakeet-microphone-record.js +7 -12
- package/dist/examples/transcription/parakeet-microphone-stream.d.ts +2 -0
- package/dist/examples/transcription/parakeet-microphone-stream.js +79 -0
- package/dist/examples/transcription/parakeet-sortformer-streaming.d.ts +2 -0
- package/dist/examples/transcription/parakeet-sortformer-streaming.js +121 -0
- package/dist/examples/transcription/parakeet-sortformer.js +58 -55
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +18 -15
- package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
- package/dist/examples/transcription/whispercpp-microphone-conversation.js +107 -0
- package/dist/examples/tts/chatterbox.js +7 -16
- package/dist/examples/tts/llm-to-tts-streaming.js +3 -10
- package/dist/examples/tts/supertonic-multilingual.js +4 -12
- package/dist/examples/tts/supertonic.js +5 -12
- package/dist/examples/vla-smolvla.d.ts +2 -0
- package/dist/examples/vla-smolvla.js +75 -0
- package/dist/examples/voice-assistant/voice-assistant.js +3 -10
- package/dist/expo/plugins/find-in-ancestor-node-modules.d.ts +14 -0
- package/dist/expo/plugins/find-in-ancestor-node-modules.js +24 -0
- package/dist/expo/plugins/get-project-root.d.ts +22 -0
- package/dist/expo/plugins/get-project-root.js +23 -0
- package/dist/expo/plugins/index.d.ts +4 -0
- package/dist/expo/plugins/index.js +4 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +9 -2
- package/dist/expo/plugins/resolve-sdk-package-dir.js +38 -11
- package/dist/expo/plugins/withDeviceInfo.js +2 -1
- package/dist/expo/plugins/withMobileBundle.d.ts +5 -4
- package/dist/expo/plugins/withMobileBundle.js +42 -58
- package/dist/index.d.ts +6 -2
- package/dist/index.js +23 -2
- package/dist/models/registry/models.d.ts +3725 -514
- package/dist/models/registry/models.js +7269 -3910
- package/dist/models/update-models/naming.js +22 -8
- package/dist/pear/pre.d.ts +3 -0
- package/dist/pear/pre.js +9 -2
- package/dist/schemas/cancel.d.ts +172 -28
- package/dist/schemas/cancel.js +120 -19
- package/dist/schemas/classification.d.ts +53 -0
- package/dist/schemas/classification.js +33 -0
- package/dist/schemas/common.d.ts +860 -1379
- package/dist/schemas/common.js +8 -1
- package/dist/schemas/completion-event.d.ts +17 -0
- package/dist/schemas/completion-event.js +12 -1
- package/dist/schemas/completion-stream.d.ts +16 -1
- package/dist/schemas/completion-stream.js +25 -7
- package/dist/schemas/download-asset.d.ts +25 -9
- package/dist/schemas/download-asset.js +17 -6
- package/dist/schemas/embed.d.ts +1 -0
- package/dist/schemas/embed.js +5 -0
- package/dist/schemas/engine-addon-map.d.ts +3 -0
- package/dist/schemas/engine-addon-map.js +18 -5
- package/dist/schemas/error.d.ts +31 -0
- package/dist/schemas/error.js +29 -1
- package/dist/schemas/finetune.d.ts +2 -0
- package/dist/schemas/finetune.js +5 -0
- package/dist/schemas/get-model-info.d.ts +10 -6
- package/dist/schemas/get-model-info.js +2 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/llamacpp-config.d.ts +64 -8
- package/dist/schemas/llamacpp-config.js +12 -0
- package/dist/schemas/load-model.d.ts +4644 -8605
- package/dist/schemas/load-model.js +90 -7
- package/dist/schemas/model-src-utils.d.ts +34 -14
- package/dist/schemas/model-types.d.ts +54 -14
- package/dist/schemas/model-types.js +28 -5
- package/dist/schemas/ocr.d.ts +8 -3
- package/dist/schemas/plugin.d.ts +60 -6
- package/dist/schemas/plugin.js +31 -5
- package/dist/schemas/rag.d.ts +9 -0
- package/dist/schemas/rag.js +17 -9
- package/dist/schemas/registry.d.ts +74 -30
- package/dist/schemas/registry.js +5 -0
- package/dist/schemas/reload-config.d.ts +34 -14
- package/dist/schemas/sdcpp-config.d.ts +445 -16
- package/dist/schemas/sdcpp-config.js +387 -26
- package/dist/schemas/sdk-config.d.ts +2431 -2723
- package/dist/schemas/sdk-config.js +16 -1
- package/dist/schemas/sdk-errors-client.d.ts +6 -0
- package/dist/schemas/sdk-errors-client.js +31 -1
- package/dist/schemas/sdk-errors-server.d.ts +8 -1
- package/dist/schemas/sdk-errors-server.js +45 -5
- package/dist/schemas/text-to-speech.d.ts +81 -698
- package/dist/schemas/text-to-speech.js +46 -19
- package/dist/schemas/transcription-config.d.ts +40 -229
- package/dist/schemas/transcription-config.js +76 -15
- package/dist/schemas/transcription.d.ts +108 -2
- package/dist/schemas/transcription.js +81 -0
- package/dist/schemas/translate.d.ts +2 -0
- package/dist/schemas/translate.js +13 -2
- package/dist/schemas/translation-config.d.ts +90 -40
- package/dist/schemas/unload-model.d.ts +2 -1
- package/dist/schemas/unload-model.js +4 -1
- package/dist/schemas/vla.d.ts +87 -0
- package/dist/schemas/vla.js +108 -0
- package/dist/scripts/run-unit-tests.js +22 -3
- package/dist/server/bare/ops/cancel.d.ts +27 -1
- package/dist/server/bare/ops/cancel.js +36 -10
- package/dist/server/bare/ops/embed.d.ts +3 -3
- package/dist/server/bare/ops/embed.js +144 -28
- package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
- package/dist/server/bare/ops/kv-cache-utils.js +8 -47
- package/dist/server/bare/ops/transcribe.d.ts +11 -5
- package/dist/server/bare/ops/transcribe.js +230 -50
- package/dist/server/bare/ops/translate.d.ts +1 -1
- package/dist/server/bare/ops/translate.js +197 -88
- package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +6 -0
- package/dist/server/bare/plugins/ggml-classification/ops/classify.js +30 -0
- package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +32 -0
- package/dist/server/bare/plugins/ggml-classification/plugin.js +55 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +3 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +12 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +3 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +75 -0
- package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +54 -0
- package/dist/server/bare/plugins/ggml-vla/plugin.js +57 -0
- package/dist/server/bare/plugins/index.d.ts +3 -1
- package/dist/server/bare/plugins/index.js +3 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +173 -172
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +29 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +65 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +36 -3
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +183 -85
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
- package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +42 -15
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +8 -3
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +73 -244
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +68 -96
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +199 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +288 -15
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +150 -7
- package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.js +2 -15
- package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.js +2 -1
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +75 -0
- package/dist/server/bare/plugins/tts-ggml/plugin.js +189 -0
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +47 -3
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +61 -14
- package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/index.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
- package/dist/server/bare/registry/model-config-utils.js +7 -0
- package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
- package/dist/server/bare/runtime/disposable-scope.js +69 -0
- package/dist/server/bare/runtime/index.d.ts +8 -0
- package/dist/server/bare/runtime/index.js +3 -0
- package/dist/server/bare/runtime/request-context.d.ts +49 -0
- package/dist/server/bare/runtime/request-context.js +1 -0
- package/dist/server/bare/runtime/request-id.d.ts +12 -0
- package/dist/server/bare/runtime/request-id.js +14 -0
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
- package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
- package/dist/server/bare/runtime/request-registry.d.ts +136 -0
- package/dist/server/bare/runtime/request-registry.js +297 -0
- package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
- package/dist/server/bare/runtime/with-request-context.js +53 -0
- package/dist/server/bare/runtime-lifecycle.js +9 -9
- package/dist/server/bare/types/addon-responses.d.ts +12 -1
- package/dist/server/env.js +4 -1
- package/dist/server/plugins/index.d.ts +1 -1
- package/dist/server/plugins/index.js +1 -1
- package/dist/server/plugins/registry.d.ts +1 -0
- package/dist/server/plugins/registry.js +5 -0
- package/dist/server/rpc/handler-registry.js +30 -7
- package/dist/server/rpc/handler-selection.d.ts +9 -0
- package/dist/server/rpc/handler-selection.js +14 -0
- package/dist/server/rpc/handler-utils.js +5 -13
- package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
- package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
- package/dist/server/rpc/handlers/cancelHandler.js +54 -22
- package/dist/server/rpc/handlers/classify.d.ts +3 -0
- package/dist/server/rpc/handlers/classify.js +4 -0
- package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
- package/dist/server/rpc/handlers/delete-cache.js +13 -15
- package/dist/server/rpc/handlers/download-asset.js +133 -40
- package/dist/server/rpc/handlers/index.d.ts +4 -0
- package/dist/server/rpc/handlers/index.js +4 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
- package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
- package/dist/server/rpc/handlers/load-model/handler.js +216 -98
- package/dist/server/rpc/handlers/load-model/http.js +3 -3
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
- package/dist/server/rpc/handlers/load-model/registry.js +1 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
- package/dist/server/rpc/handlers/load-model/resolve.js +18 -6
- package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
- package/dist/server/rpc/handlers/rag.js +133 -15
- package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/upscale-stream.js +4 -0
- package/dist/server/rpc/handlers/video-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/video-stream.js +4 -0
- package/dist/server/rpc/profiling/operation-metrics.js +23 -0
- package/dist/server/utils/completion-normalizer.js +8 -0
- package/dist/server/utils/config-transform.js +1 -1
- package/dist/server/utils/tools/dialect.js +4 -0
- package/dist/server/utils/tools/parser.js +16 -1
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
- package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
- package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
- package/dist/server/utils/tools/parsers/qwen35.js +120 -0
- package/dist/server/worker.js +14 -11
- package/dist/utils/aggregate-events.d.ts +9 -0
- package/dist/utils/aggregate-events.js +18 -3
- package/dist/utils/decorate-promise.d.ts +34 -0
- package/dist/utils/decorate-promise.js +35 -0
- package/dist/utils/errors-client.d.ts +18 -0
- package/dist/utils/errors-client.js +31 -0
- package/dist/utils/errors-server.d.ts +115 -2
- package/dist/utils/errors-server.js +148 -3
- package/package.json +68 -77
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -490
- package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -266
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
- /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.d.ts +0 -0
- /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.d.ts +0 -0
|
@@ -3,38 +3,35 @@ import { getModelEntry } from "../../bare/registry/model-registry.js";
|
|
|
3
3
|
import { getRPC } from "../../bare/delegate-rpc-client.js";
|
|
4
4
|
import { send } from "../delegate-transport.js";
|
|
5
5
|
const logger = getServerLogger();
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the delegated provider for a cancel request, if any.
|
|
8
|
+
*
|
|
9
|
+
* After the 0.11.0 wire-schema collapse the cancel envelope has only
|
|
10
|
+
* two operations. Only `broad` cancels delegate at the cancel layer —
|
|
11
|
+
* see `isCancelDelegated` in `handler-registry.ts` for the policy and
|
|
12
|
+
* the rationale.
|
|
13
|
+
*
|
|
14
|
+
* The targeted `request` arm is handled locally because the registry
|
|
15
|
+
* is worker-singleton and already holds the entry for delegated
|
|
16
|
+
* requests (the delegated handler registers its own context on the
|
|
17
|
+
* provider-facing side). For pre-0.11.0 behaviour where a `requestId`
|
|
18
|
+
* cancel against a delegated model needed to round-trip to the
|
|
19
|
+
* provider, hold onto the delegated `loadModel(...).requestId` and
|
|
20
|
+
* fire a broad cancel against the model id instead.
|
|
21
|
+
*/
|
|
6
22
|
function resolveDelegationTarget(request) {
|
|
7
|
-
if (request.operation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
}
|
|
20
|
-
if (request.operation === "downloadAsset" && request.delegate) {
|
|
21
|
-
const target = {
|
|
22
|
-
providerPublicKey: request.delegate.providerPublicKey,
|
|
23
|
-
};
|
|
24
|
-
if (request.delegate.timeout !== undefined) {
|
|
25
|
-
target.timeout = request.delegate.timeout;
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
function toProviderCancelRequest(request) {
|
|
32
|
-
if (request.operation !== "downloadAsset") {
|
|
33
|
-
return request;
|
|
23
|
+
if (request.operation !== "broad")
|
|
24
|
+
return null;
|
|
25
|
+
const entry = getModelEntry(request.modelId);
|
|
26
|
+
if (!entry?.isDelegated)
|
|
27
|
+
return null;
|
|
28
|
+
const target = {
|
|
29
|
+
providerPublicKey: entry.delegated.providerPublicKey,
|
|
30
|
+
};
|
|
31
|
+
if (entry.delegated.timeout !== undefined) {
|
|
32
|
+
target.timeout = entry.delegated.timeout;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
const { delegate: _delegate, ...providerRequest } = request;
|
|
37
|
-
return providerRequest;
|
|
34
|
+
return target;
|
|
38
35
|
}
|
|
39
36
|
export async function handleCancelDelegated(request, options) {
|
|
40
37
|
const target = resolveDelegationTarget(request);
|
|
@@ -55,7 +52,7 @@ export async function handleCancelDelegated(request, options) {
|
|
|
55
52
|
if (options?.profilingMeta) {
|
|
56
53
|
delegateOpts.profilingMeta = options.profilingMeta;
|
|
57
54
|
}
|
|
58
|
-
await send(
|
|
55
|
+
await send(request, rpc, delegateOpts);
|
|
59
56
|
return { type: "cancel", success: true };
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
@@ -1,3 +1,32 @@
|
|
|
1
1
|
import type { CancelRequest, CancelResponse } from "../../../schemas/cancel";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Cancel RPC entry point. The 5-arm `switch (request.operation)`
|
|
4
|
+
* dispatcher that lived here through 0.10.x was retired in 0.11.0:
|
|
5
|
+
* every long-running handler now registers itself on the
|
|
6
|
+
* worker-singleton `RequestRegistry`, so the cancel surface narrows to
|
|
7
|
+
* two paths that route through the same registry primitive:
|
|
8
|
+
*
|
|
9
|
+
* - `{ operation: "request", requestId, clearCache? }` — targeted
|
|
10
|
+
* cancel by client-generated id. Looks up the registry entry,
|
|
11
|
+
* fires its abort signal, optionally marks the underlying download
|
|
12
|
+
* transfer for cache clear. The "stop-button race" case (client
|
|
13
|
+
* cancel beats its own begin to the worker) is handled inside the
|
|
14
|
+
* registry via the cancel-before-begin tripwire.
|
|
15
|
+
*
|
|
16
|
+
* - `{ operation: "broad", modelId, kind? }` — abort every in-flight
|
|
17
|
+
* request on a model (optionally narrowed by `kind`). Used for
|
|
18
|
+
* model unload, app shutdown, and admin sweeps where the caller
|
|
19
|
+
* has no `requestId`. Delegates to the `cancel` bare op so the
|
|
20
|
+
* `ModelNotLoadedError` validation is shared with internal
|
|
21
|
+
* server-side broad cancels.
|
|
22
|
+
*
|
|
23
|
+
* Always returns `success: true` plus a `cancelled` count (the number
|
|
24
|
+
* of contexts this call flipped to `cancelling` — already-cancelled
|
|
25
|
+
* contexts are not counted). A targeted cancel with no in-flight
|
|
26
|
+
* match still returns `success: true, cancelled: 0`; the
|
|
27
|
+
* cancel-before-begin tripwire ensures the cancel is applied
|
|
28
|
+
* retroactively if a matching begin arrives within the registry's
|
|
29
|
+
* race window.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cancelHandler(request: CancelRequest): CancelResponse;
|
|
3
32
|
//# sourceMappingURL=cancelHandler.d.ts.map
|
|
@@ -1,30 +1,62 @@
|
|
|
1
|
-
import { cancel } from "../../bare/ops/cancel.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { cancel as cancelByModelId } from "../../bare/ops/cancel.js";
|
|
2
|
+
import { getRequestRegistry } from "../../bare/runtime/index.js";
|
|
3
|
+
import { markClearCacheForRequest } from "./load-model/download-manager.js";
|
|
4
4
|
import { getServerLogger } from "../../../logging/index.js";
|
|
5
5
|
const logger = getServerLogger();
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Cancel RPC entry point. The 5-arm `switch (request.operation)`
|
|
8
|
+
* dispatcher that lived here through 0.10.x was retired in 0.11.0:
|
|
9
|
+
* every long-running handler now registers itself on the
|
|
10
|
+
* worker-singleton `RequestRegistry`, so the cancel surface narrows to
|
|
11
|
+
* two paths that route through the same registry primitive:
|
|
12
|
+
*
|
|
13
|
+
* - `{ operation: "request", requestId, clearCache? }` — targeted
|
|
14
|
+
* cancel by client-generated id. Looks up the registry entry,
|
|
15
|
+
* fires its abort signal, optionally marks the underlying download
|
|
16
|
+
* transfer for cache clear. The "stop-button race" case (client
|
|
17
|
+
* cancel beats its own begin to the worker) is handled inside the
|
|
18
|
+
* registry via the cancel-before-begin tripwire.
|
|
19
|
+
*
|
|
20
|
+
* - `{ operation: "broad", modelId, kind? }` — abort every in-flight
|
|
21
|
+
* request on a model (optionally narrowed by `kind`). Used for
|
|
22
|
+
* model unload, app shutdown, and admin sweeps where the caller
|
|
23
|
+
* has no `requestId`. Delegates to the `cancel` bare op so the
|
|
24
|
+
* `ModelNotLoadedError` validation is shared with internal
|
|
25
|
+
* server-side broad cancels.
|
|
26
|
+
*
|
|
27
|
+
* Always returns `success: true` plus a `cancelled` count (the number
|
|
28
|
+
* of contexts this call flipped to `cancelling` — already-cancelled
|
|
29
|
+
* contexts are not counted). A targeted cancel with no in-flight
|
|
30
|
+
* match still returns `success: true, cancelled: 0`; the
|
|
31
|
+
* cancel-before-begin tripwire ensures the cancel is applied
|
|
32
|
+
* retroactively if a matching begin arrives within the registry's
|
|
33
|
+
* race window.
|
|
34
|
+
*/
|
|
35
|
+
export function cancelHandler(request) {
|
|
7
36
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
await cancel({ modelId: request.modelId });
|
|
12
|
-
break;
|
|
13
|
-
case "downloadAsset":
|
|
14
|
-
cancelTransfer(request.downloadKey, request.clearCache);
|
|
15
|
-
break;
|
|
16
|
-
case "rag": {
|
|
17
|
-
const cancelled = cancelRagOperation(request.workspace);
|
|
18
|
-
if (!cancelled) {
|
|
19
|
-
logger.warn(`No active RAG operation to cancel for workspace: ${request.workspace ?? DEFAULT_WORKSPACE}`);
|
|
20
|
-
}
|
|
21
|
-
break;
|
|
37
|
+
if (request.operation === "request") {
|
|
38
|
+
if (request.clearCache) {
|
|
39
|
+
markClearCacheForRequest(request.requestId);
|
|
22
40
|
}
|
|
41
|
+
const cancelled = getRequestRegistry().cancel({
|
|
42
|
+
requestId: request.requestId,
|
|
43
|
+
});
|
|
44
|
+
if (cancelled === 0) {
|
|
45
|
+
// info-level (not debug) because the decorated-promise pattern
|
|
46
|
+
// makes "no in-flight match" a common and user-visible case:
|
|
47
|
+
// a Stop button fired after the request settled but before
|
|
48
|
+
// the UI cleared lands here. The cancel-before-begin tripwire
|
|
49
|
+
// inside the registry already captured the cancel for any
|
|
50
|
+
// matching begin in flight; this log just helps operators
|
|
51
|
+
// debugging "my Stop button isn't working" without lowering
|
|
52
|
+
// the log level.
|
|
53
|
+
logger.info(`[cancel] no in-flight request matched requestId=${request.requestId}`);
|
|
54
|
+
}
|
|
55
|
+
return { type: "cancel", success: true, cancelled };
|
|
23
56
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
57
|
+
// operation === "broad"
|
|
58
|
+
const cancelled = cancelByModelId({ modelId: request.modelId }, request.kind ? { kind: request.kind } : undefined);
|
|
59
|
+
return { type: "cancel", success: true, cancelled };
|
|
28
60
|
}
|
|
29
61
|
catch (error) {
|
|
30
62
|
logger.error("Error during cancellation:", error);
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { DeleteCacheRequest, DeleteCacheResponse } from "../../../schemas/index";
|
|
2
|
+
/**
|
|
3
|
+
* RPC handler for `deleteCache(...)`. The three KV-cache bookkeeping
|
|
4
|
+
* layers (on-disk `.bin`, `initializedCaches`, `cachedMessageCounts`)
|
|
5
|
+
* are private to `kv-cache-session.ts`; this handler delegates to that
|
|
6
|
+
* module's single administrative entry point (`deleteKvCacheState`).
|
|
7
|
+
* The handler must have **zero** direct references to
|
|
8
|
+
* `fsPromises.unlink`, the `initializedCaches` set, or the
|
|
9
|
+
* `cachedMessageCounts` map.
|
|
10
|
+
*/
|
|
2
11
|
export declare function handleDeleteCache(request: DeleteCacheRequest): Promise<DeleteCacheResponse>;
|
|
3
12
|
//# sourceMappingURL=delete-cache.d.ts.map
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { clearCachedMessageCounts } from "../../bare/plugins/llamacpp-completion/ops/completion-stream.js";
|
|
1
|
+
import { deleteKvCacheState } from "../../bare/plugins/llamacpp-completion/ops/kv-cache-session.js";
|
|
3
2
|
import { getServerLogger } from "../../../logging/index.js";
|
|
4
3
|
const logger = getServerLogger();
|
|
4
|
+
/**
|
|
5
|
+
* RPC handler for `deleteCache(...)`. The three KV-cache bookkeeping
|
|
6
|
+
* layers (on-disk `.bin`, `initializedCaches`, `cachedMessageCounts`)
|
|
7
|
+
* are private to `kv-cache-session.ts`; this handler delegates to that
|
|
8
|
+
* module's single administrative entry point (`deleteKvCacheState`).
|
|
9
|
+
* The handler must have **zero** direct references to
|
|
10
|
+
* `fsPromises.unlink`, the `initializedCaches` set, or the
|
|
11
|
+
* `cachedMessageCounts` map.
|
|
12
|
+
*/
|
|
5
13
|
export async function handleDeleteCache(request) {
|
|
6
14
|
try {
|
|
7
15
|
if ("all" in request && request.all) {
|
|
8
|
-
await
|
|
9
|
-
clearCachedMessageCounts();
|
|
10
|
-
clearCacheRegistry();
|
|
16
|
+
await deleteKvCacheState({ all: true });
|
|
11
17
|
}
|
|
12
18
|
else if ("kvCacheKey" in request) {
|
|
13
|
-
|
|
19
|
+
await deleteKvCacheState({
|
|
14
20
|
kvCacheKey: request.kvCacheKey,
|
|
15
|
-
|
|
16
|
-
if (request.modelId !== undefined) {
|
|
17
|
-
params.modelId = request.modelId;
|
|
18
|
-
}
|
|
19
|
-
const removedPath = await deleteCacheUtil(params);
|
|
20
|
-
clearCachedMessageCounts(removedPath);
|
|
21
|
-
clearCacheRegistry({
|
|
22
|
-
cacheKey: request.kvCacheKey,
|
|
23
|
-
modelId: request.modelId,
|
|
21
|
+
...(request.modelId !== undefined && { modelId: request.modelId }),
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
return {
|
|
@@ -1,53 +1,146 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
1
53
|
import { PROFILING_KEY, OPERATION_EVENT_KEY, } from "../../../schemas/index.js";
|
|
2
54
|
import { resolveModelPath, resolveModelPathWithStats, } from "./load-model/resolve.js";
|
|
3
|
-
import { buildDownloadProfilingFields } from "./load-model/types.js";
|
|
55
|
+
import { buildDownloadProfilingFields, } from "./load-model/types.js";
|
|
4
56
|
import { nowMs, generateProfileId } from "../../../profiling/clock.js";
|
|
5
57
|
import { getServerLogger } from "../../../logging/index.js";
|
|
58
|
+
import { getRequestRegistry, withRequestContext, } from "../../bare/runtime/index.js";
|
|
59
|
+
import { generateServerRequestId } from "../../bare/runtime/request-id.js";
|
|
60
|
+
import { InferenceCancelledError } from "../../../utils/errors-server.js";
|
|
6
61
|
const logger = getServerLogger();
|
|
7
62
|
export async function handleDownloadAsset(request, progressCallback) {
|
|
8
|
-
const {
|
|
9
|
-
const profilingMeta = request[PROFILING_KEY];
|
|
10
|
-
const profilingEnabled = profilingMeta?.enabled !== false && !!profilingMeta;
|
|
63
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
11
64
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
65
|
+
const { assetSrc, seed } = request;
|
|
66
|
+
const profilingMeta = request[PROFILING_KEY];
|
|
67
|
+
const profilingEnabled = profilingMeta?.enabled !== false && !!profilingMeta;
|
|
68
|
+
const requestId = request.requestId ?? generateServerRequestId();
|
|
69
|
+
// `downloadAsset` is artifact-shaped, not model-shaped — there is no
|
|
70
|
+
// `modelId` to register on the registry entry. Cancel by `requestId`
|
|
71
|
+
// is the primary path; `cancel({ modelId })` is intentionally a
|
|
72
|
+
// non-match for this kind.
|
|
73
|
+
const ctx = __addDisposableResource(env_1, getRequestRegistry().begin({
|
|
74
|
+
requestId,
|
|
75
|
+
kind: "downloadAsset",
|
|
76
|
+
}), true);
|
|
77
|
+
const log = withRequestContext(getServerLogger(), ctx);
|
|
78
|
+
log.debug(`downloadAsset start assetSrc=${assetSrc}`);
|
|
79
|
+
const hooks = {
|
|
80
|
+
requestBinding: {
|
|
81
|
+
signal: ctx.signal,
|
|
82
|
+
scope: ctx.scope,
|
|
83
|
+
requestId,
|
|
84
|
+
},
|
|
27
85
|
};
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
86
|
+
try {
|
|
87
|
+
const totalDownloadStart = profilingEnabled ? nowMs() : 0;
|
|
88
|
+
let sourceType;
|
|
89
|
+
let downloadStats;
|
|
90
|
+
if (profilingEnabled) {
|
|
91
|
+
const result = await resolveModelPathWithStats(assetSrc, progressCallback, seed, ctx.signal, hooks);
|
|
92
|
+
sourceType = result.sourceType;
|
|
93
|
+
downloadStats = result.downloadStats;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
await resolveModelPath(assetSrc, progressCallback, seed, ctx.signal, hooks);
|
|
97
|
+
}
|
|
98
|
+
const response = {
|
|
99
|
+
type: "downloadAsset",
|
|
100
|
+
success: true,
|
|
101
|
+
assetId: assetSrc,
|
|
102
|
+
};
|
|
103
|
+
if (profilingEnabled) {
|
|
104
|
+
const totalDownloadTimeMs = nowMs() - totalDownloadStart;
|
|
105
|
+
const profileId = profilingMeta?.id ?? generateProfileId();
|
|
106
|
+
const { gauges, tags } = buildDownloadProfilingFields(downloadStats, sourceType);
|
|
107
|
+
gauges["totalDownloadTime"] = totalDownloadTimeMs;
|
|
108
|
+
const operationEvent = {
|
|
109
|
+
op: "downloadAsset",
|
|
110
|
+
kind: "handler",
|
|
111
|
+
ms: totalDownloadTimeMs,
|
|
112
|
+
profileId,
|
|
113
|
+
gauges: Object.keys(gauges).length > 0 ? gauges : undefined,
|
|
114
|
+
tags: Object.keys(tags).length > 0 ? tags : undefined,
|
|
115
|
+
};
|
|
116
|
+
response[OPERATION_EVENT_KEY] = operationEvent;
|
|
117
|
+
}
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
// Mirror the load-model handler's cancel contract: a typed cancel
|
|
122
|
+
// bubbles up as the rejection so client-side callers can branch on
|
|
123
|
+
// `instanceof InferenceCancelledError`. Every other error keeps
|
|
124
|
+
// the legacy `success: false` envelope.
|
|
125
|
+
if (error instanceof InferenceCancelledError) {
|
|
126
|
+
log.info(`downloadAsset cancelled requestId=${requestId}`);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
logger.error("Error downloading asset:", error);
|
|
130
|
+
return {
|
|
131
|
+
type: "downloadAsset",
|
|
132
|
+
success: false,
|
|
133
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
40
134
|
};
|
|
41
|
-
response[OPERATION_EVENT_KEY] = operationEvent;
|
|
42
135
|
}
|
|
43
|
-
return response;
|
|
44
136
|
}
|
|
45
|
-
catch (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
137
|
+
catch (e_1) {
|
|
138
|
+
env_1.error = e_1;
|
|
139
|
+
env_1.hasError = true;
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
const result_1 = __disposeResources(env_1);
|
|
143
|
+
if (result_1)
|
|
144
|
+
await result_1;
|
|
52
145
|
}
|
|
53
146
|
}
|
|
@@ -20,6 +20,8 @@ import { handleFinetune } from "./finetune";
|
|
|
20
20
|
import { handleOCRStream } from "./ocr-stream";
|
|
21
21
|
import { handleHeartbeat } from "./heartbeat";
|
|
22
22
|
import { handleDiffusionStream } from "./diffusion-stream";
|
|
23
|
+
import { handleVideoStream } from "./video-stream";
|
|
24
|
+
import { handleUpscaleStream } from "./upscale-stream";
|
|
23
25
|
import { handlePluginInvoke, handlePluginInvokeStream } from "./plugin-invoke";
|
|
24
26
|
import { handleModelRegistryList, handleModelRegistrySearch, handleModelRegistryGetModel } from "./registry";
|
|
25
27
|
import { handleSuspend } from "./suspend";
|
|
@@ -48,6 +50,8 @@ export declare const handlers: {
|
|
|
48
50
|
finetune: typeof handleFinetune;
|
|
49
51
|
ocrStream: typeof handleOCRStream;
|
|
50
52
|
diffusionStream: typeof handleDiffusionStream;
|
|
53
|
+
videoStream: typeof handleVideoStream;
|
|
54
|
+
upscaleStream: typeof handleUpscaleStream;
|
|
51
55
|
pluginInvoke: typeof handlePluginInvoke;
|
|
52
56
|
pluginInvokeStream: typeof handlePluginInvokeStream;
|
|
53
57
|
modelRegistryList: typeof handleModelRegistryList;
|
|
@@ -20,6 +20,8 @@ import { handleFinetune } from "./finetune.js";
|
|
|
20
20
|
import { handleOCRStream } from "./ocr-stream.js";
|
|
21
21
|
import { handleHeartbeat } from "./heartbeat.js";
|
|
22
22
|
import { handleDiffusionStream } from "./diffusion-stream.js";
|
|
23
|
+
import { handleVideoStream } from "./video-stream.js";
|
|
24
|
+
import { handleUpscaleStream } from "./upscale-stream.js";
|
|
23
25
|
import { handlePluginInvoke, handlePluginInvokeStream } from "./plugin-invoke.js";
|
|
24
26
|
import { handleModelRegistryList, handleModelRegistrySearch, handleModelRegistryGetModel, } from "./registry.js";
|
|
25
27
|
import { handleSuspend } from "./suspend.js";
|
|
@@ -48,6 +50,8 @@ export const handlers = {
|
|
|
48
50
|
finetune: handleFinetune,
|
|
49
51
|
ocrStream: handleOCRStream,
|
|
50
52
|
diffusionStream: handleDiffusionStream,
|
|
53
|
+
videoStream: handleVideoStream,
|
|
54
|
+
upscaleStream: handleUpscaleStream,
|
|
51
55
|
pluginInvoke: handlePluginInvoke,
|
|
52
56
|
pluginInvokeStream: handlePluginInvokeStream,
|
|
53
57
|
modelRegistryList: handleModelRegistryList,
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import type { ModelProgressUpdate } from "../../../../schemas/index";
|
|
2
|
-
import { AbortController } from "bare-abort-controller";
|
|
2
|
+
import { AbortController, type AbortSignal } from "bare-abort-controller";
|
|
3
|
+
import type { DisposableScope } from "../../../bare/runtime/disposable-scope";
|
|
3
4
|
import type { DownloadHooks } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Per-subscriber binding to a registry-tracked request.
|
|
7
|
+
* `startOrJoinDownload` is request-aware: each caller (the
|
|
8
|
+
* `await using ctx = registry.begin(...)` inside `handleLoadModel` /
|
|
9
|
+
* `handleDownloadAsset`) registers a subscriber bound to its
|
|
10
|
+
* `requestId`. A `cancel({ requestId })` against the registry aborts
|
|
11
|
+
* the subscriber's `ctx.signal`, which:
|
|
12
|
+
* - rejects this subscriber's promise so the awaiting handler unwinds;
|
|
13
|
+
* - removes this subscriber from `transfer.subscribers`;
|
|
14
|
+
* - tears down the transfer iff this was the last subscriber.
|
|
15
|
+
*
|
|
16
|
+
* The shared-transfer dedup logic in `startOrJoinDownload` is preserved
|
|
17
|
+
* — two callers requesting the same `downloadKey` still share one
|
|
18
|
+
* underlying download — but cancel is per-`requestId`-honest:
|
|
19
|
+
* cancelling one subscriber does not affect siblings on the same
|
|
20
|
+
* `downloadKey`.
|
|
21
|
+
*/
|
|
22
|
+
export interface SubscriberRequestBinding {
|
|
23
|
+
signal: AbortSignal;
|
|
24
|
+
scope: DisposableScope;
|
|
25
|
+
requestId: string;
|
|
26
|
+
}
|
|
4
27
|
export interface Subscriber {
|
|
5
28
|
id: string;
|
|
6
29
|
onProgress?: ((progress: ModelProgressUpdate) => void) | undefined;
|
|
@@ -8,6 +31,8 @@ export interface Subscriber {
|
|
|
8
31
|
resolve: (path: string) => void;
|
|
9
32
|
reject: (error: unknown) => void;
|
|
10
33
|
promise: Promise<string>;
|
|
34
|
+
/** Identity of the registry request this subscriber belongs to, if any. */
|
|
35
|
+
requestId?: string | undefined;
|
|
11
36
|
}
|
|
12
37
|
export interface Transfer {
|
|
13
38
|
downloadKey: string;
|
|
@@ -29,7 +54,40 @@ export interface StartOrJoinResult {
|
|
|
29
54
|
joined: boolean;
|
|
30
55
|
getCacheHit: () => boolean | undefined;
|
|
31
56
|
}
|
|
32
|
-
export declare function startOrJoinDownload(downloadKey: string, startDownload: (ctx: DownloadContext) => Promise<string>, onProgress?: (progress: ModelProgressUpdate) => void): StartOrJoinResult;
|
|
57
|
+
export declare function startOrJoinDownload(downloadKey: string, startDownload: (ctx: DownloadContext) => Promise<string>, onProgress?: (progress: ModelProgressUpdate) => void, request?: SubscriberRequestBinding): StartOrJoinResult;
|
|
58
|
+
/**
|
|
59
|
+
* Legacy cancel entry point. Callers (`cancelHandler`'s deprecated
|
|
60
|
+
* `case "downloadAsset"` arm, the shutdown sweep, intra-resolve
|
|
61
|
+
* cleanup) call this with a `downloadKey`. The single source of cancel
|
|
62
|
+
* routing is the request registry, so this function resolves each
|
|
63
|
+
* subscriber's request via `registry.cancel({ requestId })`.
|
|
64
|
+
*
|
|
65
|
+
* Subscribers without a `requestId` (legacy callers that didn't pass a
|
|
66
|
+
* registry binding) are settled directly with `DownloadCancelledError`
|
|
67
|
+
* so we don't leak the transfer if a legacy code path holds the only
|
|
68
|
+
* reference.
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Set `clearCache=true` on the transfer that owns the subscriber bound
|
|
72
|
+
* to `requestId`, so when the registry's targeted cancel removes that
|
|
73
|
+
* subscriber and we reach last-subscriber teardown, the partial
|
|
74
|
+
* download file is deleted instead of preserved for automatic resume.
|
|
75
|
+
*
|
|
76
|
+
* Lookup is O(transfers * subscribers); transfers are short-lived and
|
|
77
|
+
* subscriber counts per transfer are tiny in practice, so this is
|
|
78
|
+
* fine. Returns `true` if a matching subscriber was found, `false`
|
|
79
|
+
* otherwise — the cancel handler treats both cases identically (the
|
|
80
|
+
* registry cancel still fires) and the return value is informational.
|
|
81
|
+
*
|
|
82
|
+
* Added in 0.11.0 to support `cancel({ requestId, clearCache: true })`
|
|
83
|
+
* for download requests after the wire schema collapse removed the
|
|
84
|
+
* `{ operation: "downloadAsset", downloadKey, clearCache }` arm. The
|
|
85
|
+
* subscriber is the unit of `clearCache` even though the flag lives on
|
|
86
|
+
* the shared transfer: if any subscriber on the transfer asks for
|
|
87
|
+
* clearCache, the partial file is deleted when the last subscriber
|
|
88
|
+
* leaves, matching the pre-collapse behaviour.
|
|
89
|
+
*/
|
|
90
|
+
export declare function markClearCacheForRequest(requestId: string): boolean;
|
|
33
91
|
export declare function cancelTransfer(downloadKey: string, clearCache?: boolean): void;
|
|
34
92
|
export declare function createHyperdriveDownloadKey(hyperdriveKey: string, modelFileName: string): string;
|
|
35
93
|
export declare function createHttpDownloadKey(url: string): string;
|