@qvac/sdk 0.18.2 → 0.19.1
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 +104 -82
- package/README.md +46 -10
- package/bare-imports.json +2 -3
- package/dist/examples/abot-world.d.ts +2 -0
- package/dist/examples/abot-world.js +124 -0
- package/dist/examples/asr/parakeet-unified-filesystem.d.ts +2 -0
- package/dist/examples/asr/parakeet-unified-filesystem.js +50 -0
- package/dist/examples/assess-model-fit.d.ts +14 -0
- package/dist/examples/assess-model-fit.js +76 -0
- package/dist/examples/audiogen/generate-cover.js +2 -1
- package/dist/examples/audiogen/generate-music-minimax.d.ts +2 -0
- package/dist/examples/audiogen/generate-music-minimax.js +117 -0
- package/dist/examples/audiogen/generate-music.js +2 -1
- package/dist/examples/cache-management.js +1 -2
- package/dist/examples/classification/classify-image.js +1 -3
- package/dist/examples/config-reload.js +1 -1
- package/dist/examples/diffusion-ic-lora-ltx.d.ts +2 -0
- package/dist/examples/diffusion-ic-lora-ltx.js +76 -0
- package/dist/examples/kv-cache-cleanup.js +5 -2
- package/dist/examples/mcp-websearch.js +1 -3
- package/dist/examples/model-fit-ui/server.d.ts +24 -0
- package/dist/examples/model-fit-ui/server.js +218 -0
- package/dist/examples/multi-job-completion.d.ts +2 -3
- package/dist/examples/multi-job-completion.js +2 -3
- package/dist/examples/parallel-download.js +4 -4
- package/dist/examples/plugins.js +1 -1
- package/dist/examples/profiling/basic.js +0 -1
- package/dist/examples/system-resources.js +2 -0
- package/dist/examples/translation/translation-bergamot-batch-stream.d.ts +2 -0
- package/dist/examples/translation/translation-bergamot-batch-stream.js +43 -0
- package/dist/examples/translation/translation-bergamot-batch.js +2 -5
- package/dist/examples/vla-groot.js +1 -1
- package/dist/scripts/check-resource-collectors-packaging.d.ts +2 -2
- package/dist/scripts/check-resource-collectors-packaging.js +3 -3
- package/dist/scripts/contract/build-contract.d.ts +1 -1
- package/dist/scripts/contract/build-contract.js +5 -5
- package/dist/scripts/contract/build-error-codes.js +3 -3
- package/dist/scripts/contract/build-model-type-maps.js +1 -2
- package/dist/scripts/contract/build-models-registry.d.ts +2 -2
- package/dist/scripts/contract/build-models-registry.js +2 -2
- package/dist/scripts/contract/constants-registry.d.ts +86 -0
- package/dist/scripts/contract/constants-registry.js +62 -0
- package/dist/scripts/contract/method-shapes.d.ts +53 -0
- package/dist/scripts/contract/method-shapes.js +50 -0
- package/dist/scripts/contract/plugin-contract.d.ts +1 -1
- package/dist/scripts/contract/plugin-contract.js +1 -1
- package/dist/scripts/enforce-inference-peer-dependencies.d.ts +2 -0
- package/dist/scripts/enforce-inference-peer-dependencies.js +39 -0
- package/dist/scripts/export-contract.js +1 -1
- package/dist/scripts/export-plugin-contract.js +1 -1
- package/dist/scripts/run-unit-tests.js +6 -1
- package/dist/src/client/api/assess-model-fit.d.ts +17 -0
- package/dist/src/client/api/assess-model-fit.js +40 -0
- package/dist/src/client/api/audio-gen-result.d.ts +4 -0
- package/dist/src/client/api/audio-gen-result.js +143 -0
- package/dist/src/client/api/audio-gen.d.ts +66 -0
- package/dist/src/client/api/audio-gen.js +68 -0
- package/dist/src/client/api/batch-completion.d.ts +28 -0
- package/dist/src/client/api/batch-completion.js +345 -0
- package/dist/src/client/api/bci-transcribe.d.ts +57 -0
- package/dist/src/client/api/bci-transcribe.js +173 -0
- package/dist/src/client/api/cancel.d.ts +35 -0
- package/dist/src/client/api/cancel.js +83 -0
- package/dist/src/client/api/classify.d.ts +25 -0
- package/dist/src/client/api/classify.js +48 -0
- package/dist/src/client/api/completion-stream.d.ts +107 -0
- package/dist/src/client/api/completion-stream.js +351 -0
- package/dist/src/client/api/delete-cache.d.ts +36 -0
- package/dist/src/client/api/delete-cache.js +59 -0
- package/dist/src/client/api/diffusion.d.ts +93 -0
- package/dist/src/client/api/diffusion.js +177 -0
- package/dist/src/client/api/download-asset.d.ts +52 -0
- package/dist/src/client/api/download-asset.js +89 -0
- package/dist/src/client/api/embed.d.ts +42 -0
- package/dist/src/client/api/embed.js +30 -0
- package/dist/src/client/api/finetune.d.ts +92 -0
- package/dist/src/client/api/finetune.js +144 -0
- package/dist/src/client/api/get-loaded-model-info.d.ts +26 -0
- package/dist/src/client/api/get-loaded-model-info.js +37 -0
- package/dist/src/client/api/get-model-info.d.ts +11 -0
- package/dist/src/client/api/get-model-info.js +22 -0
- package/dist/src/client/api/get-system-resources.d.ts +3 -0
- package/dist/src/client/api/get-system-resources.js +17 -0
- package/dist/src/client/api/heartbeat.d.ts +13 -0
- package/dist/src/client/api/heartbeat.js +21 -0
- package/dist/src/client/api/index.d.ts +37 -0
- package/dist/src/client/api/index.js +36 -0
- package/dist/src/client/api/invoke-plugin.d.ts +31 -0
- package/dist/src/client/api/invoke-plugin.js +54 -0
- package/dist/src/client/api/load-model.d.ts +184 -0
- package/dist/src/client/api/load-model.js +128 -0
- package/dist/src/client/api/logging-stream.d.ts +24 -0
- package/dist/src/client/api/logging-stream.js +36 -0
- package/dist/src/client/api/ocr.d.ts +40 -0
- package/dist/src/client/api/ocr.js +97 -0
- package/dist/src/client/api/rag.d.ts +257 -0
- package/dist/src/client/api/rag.js +490 -0
- package/dist/src/client/api/registry.d.ts +40 -0
- package/dist/src/client/api/registry.js +63 -0
- package/dist/src/client/api/resume.d.ts +27 -0
- package/dist/src/client/api/resume.js +33 -0
- package/dist/src/client/api/state.d.ts +23 -0
- package/dist/src/client/api/state.js +29 -0
- package/dist/src/client/api/subscribe-logs.d.ts +28 -0
- package/dist/src/client/api/suspend.d.ts +27 -0
- package/dist/src/client/api/suspend.js +33 -0
- package/dist/src/client/api/text-to-speech.d.ts +74 -0
- package/dist/src/client/api/text-to-speech.js +463 -0
- package/dist/src/client/api/transcribe.d.ts +93 -0
- package/dist/src/client/api/transcribe.js +295 -0
- package/dist/src/client/api/translate.d.ts +51 -0
- package/dist/src/client/api/translate.js +133 -0
- package/dist/src/client/api/unload-model.d.ts +18 -0
- package/dist/src/client/api/unload-model.js +42 -0
- package/dist/src/client/api/upscale.d.ts +45 -0
- package/dist/src/client/api/upscale.js +99 -0
- package/dist/src/client/api/video-request.d.ts +208 -0
- package/dist/src/client/api/video-request.js +18 -0
- package/dist/src/client/api/video.d.ts +107 -0
- package/dist/src/client/api/video.js +187 -0
- package/dist/src/client/api/vla-helpers.d.ts +59 -0
- package/dist/src/client/api/vla-helpers.js +139 -0
- package/dist/src/client/api/vla.d.ts +114 -0
- package/dist/src/client/api/vla.js +166 -0
- package/dist/src/client/api/world-result.d.ts +72 -0
- package/dist/src/client/api/world-result.js +296 -0
- package/dist/src/client/api/world.d.ts +144 -0
- package/dist/src/client/api/world.js +71 -0
- package/dist/src/client/config-loader/config-utils.d.ts +5 -0
- package/dist/src/client/config-loader/config-utils.js +18 -0
- package/dist/src/client/config-loader/resolve-config.expo.js +60 -0
- package/dist/src/client/config-loader/resolve-config.node.js +198 -0
- package/dist/src/client/init-hooks.d.ts +21 -0
- package/dist/src/client/init-hooks.js +62 -0
- package/dist/src/client/plugins-factory.d.ts +7 -0
- package/dist/src/client/plugins-factory.js +9 -0
- package/dist/src/client/rpc/bare-client.d.ts +6 -0
- package/dist/src/client/rpc/bare-client.js +21 -0
- package/dist/src/client/rpc/expo-rpc-client.js +195 -0
- package/dist/src/client/rpc/init-timeout.d.ts +26 -0
- package/dist/src/client/rpc/init-timeout.js +25 -0
- package/dist/src/client/rpc/node-rpc-client.js +525 -0
- package/dist/src/client/rpc/profiling/profiler.d.ts +27 -0
- package/dist/src/client/rpc/profiling/profiler.js +134 -0
- package/dist/src/client/rpc/rpc-client.d.ts +19 -0
- package/dist/src/client/rpc/rpc-client.js +550 -0
- package/dist/src/client/rpc/rpc-error.d.ts +28 -0
- package/dist/src/client/rpc/rpc-error.js +159 -0
- package/dist/src/client/rpc/worker-startup-error.d.ts +12 -0
- package/dist/src/client/rpc/worker-startup-error.js +13 -0
- package/dist/src/commands/bundle/entry-gen.js +54 -0
- package/dist/src/commands/bundle/index.js +148 -0
- package/dist/src/commands/bundle/plugins.d.ts +9 -0
- package/dist/src/commands/bundle/plugins.js +51 -0
- package/dist/src/commands/bundle/resolve-sdk-import.js +58 -0
- package/dist/src/commands/index.d.ts +5 -0
- package/dist/src/commands/index.js +2 -0
- package/dist/src/commands/verify/abi.d.ts +52 -0
- package/dist/src/commands/verify/abi.js +125 -0
- package/dist/src/commands/verify/bundle-source.d.ts +12 -0
- package/dist/src/commands/verify/bundle-source.js +53 -0
- package/dist/src/commands/verify/index.d.ts +59 -0
- package/dist/src/commands/verify/index.js +372 -0
- package/dist/src/commands/verify/node-modules-source.d.ts +11 -0
- package/dist/src/commands/verify/node-modules-source.js +76 -0
- package/dist/src/commands/verify/prebuilds.d.ts +16 -0
- package/dist/src/commands/verify/prebuilds.js +36 -0
- package/dist/src/commands/verify/resource-collectors.js +261 -0
- package/dist/src/deprecate.d.ts +2 -0
- package/dist/src/deprecate.js +9 -0
- package/dist/src/expo/plugins/withAndroidNdkVersion.js +31 -0
- package/dist/src/expo/plugins/withDeviceInfo.js +49 -0
- package/dist/src/expo/plugins/withMobileBundle.d.ts +31 -0
- package/dist/src/expo/plugins/withMobileBundle.js +163 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/index.js +59 -0
- package/dist/src/logging/addon.d.ts +6 -0
- package/dist/src/logging/logging-stream-registry.js +137 -0
- package/dist/src/logging/namespaces.d.ts +7 -0
- package/dist/src/logging/namespaces.js +8 -0
- package/dist/src/logging/registry.d.ts +31 -0
- package/dist/src/logging/registry.js +62 -0
- package/dist/src/logging/stream-logger.js +12 -0
- package/dist/src/logging/utils.d.ts +6 -0
- package/dist/src/models/registry/index.d.ts +2 -0
- package/dist/src/models/registry/index.js +4 -0
- package/dist/src/pear/pre.js +446 -0
- package/dist/src/plugin-ids.d.ts +14 -0
- package/dist/src/plugin-ids.js +27 -0
- package/dist/src/plugin-utils.d.ts +2 -0
- package/dist/src/plugin-utils.js +4 -0
- package/dist/src/schemas/public.d.ts +3 -0
- package/dist/src/schemas/public.js +11 -0
- package/dist/src/schemas/sdk-errors-client.d.ts +41 -0
- package/dist/src/schemas/sdk-errors-client.js +192 -0
- package/dist/src/schemas/sdk-errors-server.d.ts +101 -0
- package/dist/src/schemas/sdk-errors-server.js +540 -0
- package/dist/src/server/error-handlers.js +32 -0
- package/dist/src/server/plugins/index.d.ts +2 -0
- package/dist/src/server/plugins/index.js +1 -0
- package/dist/src/server/rpc/profiling/context.d.ts +17 -0
- package/dist/src/server/rpc/profiling/context.js +31 -0
- package/dist/src/server/rpc/profiling/index.d.ts +2 -0
- package/dist/src/server/rpc/profiling/index.js +1 -0
- package/dist/src/server/rpc/profiling/profiler.d.ts +13 -0
- package/dist/src/server/rpc/profiling/profiler.js +78 -0
- package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
- package/dist/src/server/utils/qvac-paths.js +5 -0
- package/dist/src/server/utils/worker-lock.js +67 -0
- package/dist/src/utils/aggregate-events.d.ts +26 -0
- package/dist/src/utils/aggregate-events.js +73 -0
- package/dist/src/utils/errors-client.d.ts +181 -0
- package/dist/src/utils/errors-client.js +305 -0
- package/dist/src/utils/errors-server.d.ts +380 -0
- package/dist/src/utils/errors-server.js +621 -0
- package/dist/src/utils/load-model-validation.js +17 -0
- package/dist/src/utils/mcp-adapter.d.ts +12 -0
- package/dist/src/utils/mcp-adapter.js +96 -0
- package/dist/src/utils/tool-helpers.d.ts +25 -0
- package/dist/src/utils/tool-helpers.js +111 -0
- package/dist/src/worker/create-server.js +46 -0
- package/dist/src/worker/handle-request.js +180 -0
- package/dist/src/worker/handler-utils.d.ts +16 -0
- package/dist/src/worker/handler-utils.js +41 -0
- package/dist/src/worker/index.d.ts +5 -0
- package/dist/src/worker/index.js +45 -0
- package/dist/src/worker/legacy-worker-entry.d.ts +2 -0
- package/dist/src/worker/legacy-worker-entry.js +3 -0
- package/dist/src/worker/lifecycle.d.ts +23 -0
- package/dist/src/worker/lifecycle.js +141 -0
- package/dist/src/worker/plugins/audiogen-ggml.d.ts +2 -0
- package/dist/src/worker/plugins/audiogen-ggml.js +1 -0
- package/dist/src/worker/plugins/bci-whispercpp-transcription.d.ts +2 -0
- package/dist/src/worker/plugins/bci-whispercpp-transcription.js +1 -0
- package/dist/src/worker/plugins/ggml-classification.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-classification.js +1 -0
- package/dist/src/worker/plugins/ggml-ocr.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-ocr.js +1 -0
- package/dist/src/worker/plugins/ggml-vla.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-vla.js +1 -0
- package/dist/src/worker/plugins/llamacpp-completion.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-completion.js +1 -0
- package/dist/src/worker/plugins/llamacpp-embedding.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-embedding.js +1 -0
- package/dist/src/worker/plugins/nmtcpp-translation.d.ts +2 -0
- package/dist/src/worker/plugins/nmtcpp-translation.js +1 -0
- package/dist/src/worker/plugins/parakeet-transcription.d.ts +2 -0
- package/dist/src/worker/plugins/parakeet-transcription.js +1 -0
- package/dist/src/worker/plugins/sdcpp-generation.d.ts +2 -0
- package/dist/src/worker/plugins/sdcpp-generation.js +1 -0
- package/dist/src/worker/plugins/tts-ggml.d.ts +2 -0
- package/dist/src/worker/plugins/tts-ggml.js +1 -0
- package/dist/src/worker/plugins/whispercpp-transcription.d.ts +2 -0
- package/dist/src/worker/plugins/whispercpp-transcription.js +1 -0
- package/dist/src/worker/worker-core.d.ts +7 -0
- package/dist/src/worker/worker-core.js +8 -0
- package/docs/system-resources-support-matrix.md +46 -27
- package/package.json +82 -87
- package/dist/client/api/audio-gen-result.d.ts +0 -4
- package/dist/client/api/audio-gen-result.js +0 -132
- package/dist/client/api/audio-gen.d.ts +0 -46
- package/dist/client/api/audio-gen.js +0 -48
- package/dist/client/api/batch-completion.d.ts +0 -15
- package/dist/client/api/batch-completion.js +0 -332
- package/dist/client/api/bci-transcribe.d.ts +0 -57
- package/dist/client/api/bci-transcribe.js +0 -173
- package/dist/client/api/cancel.d.ts +0 -35
- package/dist/client/api/cancel.js +0 -83
- package/dist/client/api/classify.d.ts +0 -23
- package/dist/client/api/classify.js +0 -46
- package/dist/client/api/completion-stream.d.ts +0 -107
- package/dist/client/api/completion-stream.js +0 -351
- package/dist/client/api/delete-cache.d.ts +0 -30
- package/dist/client/api/delete-cache.js +0 -49
- package/dist/client/api/diffusion.d.ts +0 -93
- package/dist/client/api/diffusion.js +0 -175
- package/dist/client/api/download-asset.d.ts +0 -50
- package/dist/client/api/download-asset.js +0 -87
- package/dist/client/api/embed.d.ts +0 -42
- package/dist/client/api/embed.js +0 -30
- package/dist/client/api/finetune.d.ts +0 -92
- package/dist/client/api/finetune.js +0 -144
- package/dist/client/api/get-loaded-model-info.d.ts +0 -25
- package/dist/client/api/get-loaded-model-info.js +0 -36
- package/dist/client/api/get-model-info.d.ts +0 -44
- package/dist/client/api/get-model-info.js +0 -22
- package/dist/client/api/get-system-resources.d.ts +0 -3
- package/dist/client/api/get-system-resources.js +0 -16
- package/dist/client/api/heartbeat.d.ts +0 -30
- package/dist/client/api/heartbeat.js +0 -38
- package/dist/client/api/index.d.ts +0 -36
- package/dist/client/api/index.js +0 -35
- package/dist/client/api/invoke-plugin.d.ts +0 -31
- package/dist/client/api/invoke-plugin.js +0 -54
- package/dist/client/api/load-model.d.ts +0 -178
- package/dist/client/api/load-model.js +0 -130
- package/dist/client/api/logging-stream.d.ts +0 -24
- package/dist/client/api/logging-stream.js +0 -36
- package/dist/client/api/ocr.d.ts +0 -40
- package/dist/client/api/ocr.js +0 -97
- package/dist/client/api/provide.d.ts +0 -24
- package/dist/client/api/provide.js +0 -33
- package/dist/client/api/rag.d.ts +0 -252
- package/dist/client/api/rag.js +0 -485
- package/dist/client/api/registry.d.ts +0 -40
- package/dist/client/api/registry.js +0 -63
- package/dist/client/api/resume.d.ts +0 -30
- package/dist/client/api/resume.js +0 -36
- package/dist/client/api/state.d.ts +0 -23
- package/dist/client/api/state.js +0 -29
- package/dist/client/api/stop-provider.d.ts +0 -21
- package/dist/client/api/stop-provider.js +0 -31
- package/dist/client/api/subscribe-logs.d.ts +0 -28
- package/dist/client/api/suspend.d.ts +0 -31
- package/dist/client/api/suspend.js +0 -37
- package/dist/client/api/text-to-speech.d.ts +0 -66
- package/dist/client/api/text-to-speech.js +0 -455
- package/dist/client/api/transcribe.d.ts +0 -93
- package/dist/client/api/transcribe.js +0 -295
- package/dist/client/api/translate.d.ts +0 -49
- package/dist/client/api/translate.js +0 -125
- package/dist/client/api/unload-model.d.ts +0 -18
- package/dist/client/api/unload-model.js +0 -44
- package/dist/client/api/upscale.d.ts +0 -45
- package/dist/client/api/upscale.js +0 -99
- package/dist/client/api/video.d.ts +0 -87
- package/dist/client/api/video.js +0 -175
- package/dist/client/api/vla-helpers.d.ts +0 -45
- package/dist/client/api/vla-helpers.js +0 -125
- package/dist/client/api/vla.d.ts +0 -114
- package/dist/client/api/vla.js +0 -166
- package/dist/client/config-loader/config-utils.d.ts +0 -5
- package/dist/client/config-loader/config-utils.js +0 -18
- package/dist/client/config-loader/resolve-config.bare.d.ts +0 -9
- package/dist/client/config-loader/resolve-config.bare.js +0 -74
- package/dist/client/config-loader/resolve-config.expo.js +0 -62
- package/dist/client/config-loader/resolve-config.node.js +0 -199
- package/dist/client/init-hooks.d.ts +0 -21
- package/dist/client/init-hooks.js +0 -66
- package/dist/client/plugins-factory.d.ts +0 -8
- package/dist/client/plugins-factory.js +0 -10
- package/dist/client/rpc/bare-client.d.ts +0 -17
- package/dist/client/rpc/bare-client.js +0 -251
- package/dist/client/rpc/expo-rpc-client.js +0 -196
- package/dist/client/rpc/node-rpc-client.js +0 -505
- package/dist/client/rpc/profiling/profiler.d.ts +0 -27
- package/dist/client/rpc/profiling/profiler.js +0 -140
- package/dist/client/rpc/rpc-client.d.ts +0 -19
- package/dist/client/rpc/rpc-client.js +0 -551
- package/dist/client/rpc/rpc-error.d.ts +0 -28
- package/dist/client/rpc/rpc-error.js +0 -150
- package/dist/commands/bundle/entry-gen.js +0 -54
- package/dist/commands/bundle/index.js +0 -148
- package/dist/commands/bundle/plugins.d.ts +0 -9
- package/dist/commands/bundle/plugins.js +0 -51
- package/dist/commands/bundle/resolve-sdk-import.js +0 -53
- package/dist/commands/index.d.ts +0 -5
- package/dist/commands/index.js +0 -2
- package/dist/commands/verify/abi.d.ts +0 -52
- package/dist/commands/verify/abi.js +0 -125
- package/dist/commands/verify/bundle-source.d.ts +0 -12
- package/dist/commands/verify/bundle-source.js +0 -53
- package/dist/commands/verify/index.d.ts +0 -59
- package/dist/commands/verify/index.js +0 -372
- package/dist/commands/verify/node-modules-source.d.ts +0 -11
- package/dist/commands/verify/node-modules-source.js +0 -76
- package/dist/commands/verify/prebuilds.d.ts +0 -16
- package/dist/commands/verify/prebuilds.js +0 -36
- package/dist/commands/verify/resource-collectors.js +0 -261
- package/dist/constants/audio.d.ts +0 -2
- package/dist/constants/audio.js +0 -1
- package/dist/constants/index.d.ts +0 -3
- package/dist/constants/index.js +0 -2
- package/dist/constants/registry.d.ts +0 -2
- package/dist/constants/registry.js +0 -1
- package/dist/examples/delegated-inference/composite.d.ts +0 -2
- package/dist/examples/delegated-inference/composite.js +0 -96
- package/dist/examples/delegated-inference/consumer-profiled.d.ts +0 -2
- package/dist/examples/delegated-inference/consumer-profiled.js +0 -59
- package/dist/examples/delegated-inference/consumer.d.ts +0 -2
- package/dist/examples/delegated-inference/consumer.js +0 -55
- package/dist/examples/delegated-inference/provider.d.ts +0 -2
- package/dist/examples/delegated-inference/provider.js +0 -52
- package/dist/examples/quickstart.bare.d.ts +0 -2
- package/dist/examples/quickstart.bare.js +0 -16
- package/dist/expo/plugins/withAndroidNdkVersion.js +0 -31
- package/dist/expo/plugins/withDeviceInfo.js +0 -49
- package/dist/expo/plugins/withMobileBundle.d.ts +0 -12
- package/dist/expo/plugins/withMobileBundle.js +0 -117
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -44
- package/dist/logging/addon.d.ts +0 -6
- package/dist/logging/namespaces.d.ts +0 -7
- package/dist/logging/namespaces.js +0 -8
- package/dist/logging/registry.d.ts +0 -31
- package/dist/logging/registry.js +0 -62
- package/dist/logging/stream-logger.js +0 -12
- package/dist/logging/utils.d.ts +0 -6
- package/dist/models/registry/index.d.ts +0 -19
- package/dist/models/registry/index.js +0 -21
- package/dist/models/registry/models.d.ts +0 -23457
- package/dist/models/registry/models.js +0 -24713
- package/dist/pear/pre.js +0 -446
- package/dist/profiling/aggregator.d.ts +0 -15
- package/dist/profiling/aggregator.js +0 -100
- package/dist/profiling/backend-diagnostics.d.ts +0 -8
- package/dist/profiling/backend-diagnostics.js +0 -21
- package/dist/profiling/clock.d.ts +0 -12
- package/dist/profiling/clock.js +0 -51
- package/dist/profiling/controller.d.ts +0 -35
- package/dist/profiling/controller.js +0 -130
- package/dist/profiling/envelope.d.ts +0 -11
- package/dist/profiling/envelope.js +0 -45
- package/dist/profiling/events.d.ts +0 -20
- package/dist/profiling/events.js +0 -35
- package/dist/profiling/exporters.d.ts +0 -10
- package/dist/profiling/exporters.js +0 -243
- package/dist/profiling/index.d.ts +0 -86
- package/dist/profiling/index.js +0 -81
- package/dist/profiling/model-execution.d.ts +0 -16
- package/dist/profiling/model-execution.js +0 -34
- package/dist/profiling/ring-buffer.d.ts +0 -19
- package/dist/profiling/ring-buffer.js +0 -83
- package/dist/profiling/types.d.ts +0 -53
- package/dist/profiling/types.js +0 -1
- package/dist/schemas/archive.d.ts +0 -9
- package/dist/schemas/archive.js +0 -11
- package/dist/schemas/audio-gen.d.ts +0 -356
- package/dist/schemas/audio-gen.js +0 -200
- package/dist/schemas/batch-completion-stream.d.ts +0 -468
- package/dist/schemas/batch-completion-stream.js +0 -124
- package/dist/schemas/bci-config.d.ts +0 -75
- package/dist/schemas/bci-config.js +0 -58
- package/dist/schemas/bci.d.ts +0 -179
- package/dist/schemas/bci.js +0 -89
- package/dist/schemas/cancel.d.ts +0 -209
- package/dist/schemas/cancel.js +0 -140
- package/dist/schemas/classification.d.ts +0 -53
- package/dist/schemas/classification.js +0 -33
- package/dist/schemas/common.d.ts +0 -6960
- package/dist/schemas/common.js +0 -138
- package/dist/schemas/completion-event.d.ts +0 -249
- package/dist/schemas/completion-event.js +0 -94
- package/dist/schemas/completion-stream.d.ts +0 -476
- package/dist/schemas/completion-stream.js +0 -236
- package/dist/schemas/constants-registry.d.ts +0 -83
- package/dist/schemas/constants-registry.js +0 -65
- package/dist/schemas/delegate.d.ts +0 -16
- package/dist/schemas/delegate.js +0 -32
- package/dist/schemas/delete-cache.d.ts +0 -17
- package/dist/schemas/delete-cache.js +0 -21
- package/dist/schemas/download-asset.d.ts +0 -225
- package/dist/schemas/download-asset.js +0 -71
- package/dist/schemas/embed.d.ts +0 -42
- package/dist/schemas/embed.js +0 -35
- package/dist/schemas/engine-addon-map.d.ts +0 -21
- package/dist/schemas/engine-addon-map.js +0 -78
- package/dist/schemas/error.d.ts +0 -44
- package/dist/schemas/error.js +0 -67
- package/dist/schemas/finetune.d.ts +0 -622
- package/dist/schemas/finetune.js +0 -163
- package/dist/schemas/get-loaded-model-info.d.ts +0 -70
- package/dist/schemas/get-loaded-model-info.js +0 -52
- package/dist/schemas/get-model-info.d.ts +0 -130
- package/dist/schemas/get-model-info.js +0 -91
- package/dist/schemas/heartbeat.d.ts +0 -16
- package/dist/schemas/heartbeat.js +0 -10
- package/dist/schemas/index.d.ts +0 -55
- package/dist/schemas/index.js +0 -55
- package/dist/schemas/json-schema.d.ts +0 -16
- package/dist/schemas/json-schema.js +0 -2
- package/dist/schemas/llamacpp-config.d.ts +0 -404
- package/dist/schemas/llamacpp-config.js +0 -219
- package/dist/schemas/load-model.d.ts +0 -28991
- package/dist/schemas/load-model.js +0 -647
- package/dist/schemas/logging-stream.d.ts +0 -34
- package/dist/schemas/logging-stream.js +0 -17
- package/dist/schemas/mcp-adapter.d.ts +0 -47
- package/dist/schemas/mcp-adapter.js +0 -1
- package/dist/schemas/model-src-utils.d.ts +0 -193
- package/dist/schemas/model-src-utils.js +0 -61
- package/dist/schemas/model-types.d.ts +0 -276
- package/dist/schemas/model-types.js +0 -223
- package/dist/schemas/ocr.d.ts +0 -138
- package/dist/schemas/ocr.js +0 -59
- package/dist/schemas/path-validation.d.ts +0 -10
- package/dist/schemas/path-validation.js +0 -22
- package/dist/schemas/plugin.d.ts +0 -342
- package/dist/schemas/plugin.js +0 -242
- package/dist/schemas/profiling.d.ts +0 -696
- package/dist/schemas/profiling.js +0 -100
- package/dist/schemas/provide.d.ts +0 -41
- package/dist/schemas/provide.js +0 -22
- package/dist/schemas/public.d.ts +0 -3
- package/dist/schemas/public.js +0 -6
- package/dist/schemas/rag.d.ts +0 -302
- package/dist/schemas/rag.js +0 -212
- package/dist/schemas/registry.d.ts +0 -454
- package/dist/schemas/registry.js +0 -104
- package/dist/schemas/reload-config.d.ts +0 -586
- package/dist/schemas/reload-config.js +0 -42
- package/dist/schemas/resume.d.ts +0 -10
- package/dist/schemas/resume.js +0 -7
- package/dist/schemas/runtime-context.d.ts +0 -19
- package/dist/schemas/runtime-context.js +0 -7
- package/dist/schemas/sdcpp-config.d.ts +0 -1127
- package/dist/schemas/sdcpp-config.js +0 -748
- package/dist/schemas/sdk-config.d.ts +0 -5059
- package/dist/schemas/sdk-config.js +0 -167
- package/dist/schemas/sdk-errors-client.d.ts +0 -44
- package/dist/schemas/sdk-errors-client.js +0 -208
- package/dist/schemas/sdk-errors-registry.d.ts +0 -6
- package/dist/schemas/sdk-errors-registry.js +0 -8
- package/dist/schemas/sdk-errors-server.d.ts +0 -102
- package/dist/schemas/sdk-errors-server.js +0 -534
- package/dist/schemas/shard.d.ts +0 -21
- package/dist/schemas/shard.js +0 -17
- package/dist/schemas/state.d.ts +0 -23
- package/dist/schemas/state.js +0 -9
- package/dist/schemas/stop-provide.d.ts +0 -12
- package/dist/schemas/stop-provide.js +0 -11
- package/dist/schemas/suspend.d.ts +0 -10
- package/dist/schemas/suspend.js +0 -7
- package/dist/schemas/system-resources.d.ts +0 -3967
- package/dist/schemas/system-resources.js +0 -149
- package/dist/schemas/text-to-speech.d.ts +0 -2329
- package/dist/schemas/text-to-speech.js +0 -554
- package/dist/schemas/tools.d.ts +0 -65
- package/dist/schemas/tools.js +0 -37
- package/dist/schemas/transcription-config.d.ts +0 -164
- package/dist/schemas/transcription-config.js +0 -162
- package/dist/schemas/transcription.d.ts +0 -264
- package/dist/schemas/transcription.js +0 -145
- package/dist/schemas/translate.d.ts +0 -139
- package/dist/schemas/translate.js +0 -103
- package/dist/schemas/translation-config.d.ts +0 -1032
- package/dist/schemas/translation-config.js +0 -170
- package/dist/schemas/unload-model.d.ts +0 -22
- package/dist/schemas/unload-model.js +0 -18
- package/dist/schemas/vla.d.ts +0 -194
- package/dist/schemas/vla.js +0 -254
- package/dist/scripts/run-security-tests.d.ts +0 -2
- package/dist/scripts/run-security-tests.js +0 -21
- package/dist/server/bare/delegate-connect-diagnostics.d.ts +0 -9
- package/dist/server/bare/delegate-connect-diagnostics.js +0 -38
- package/dist/server/bare/delegate-rpc-client.d.ts +0 -10
- package/dist/server/bare/delegate-rpc-client.js +0 -219
- package/dist/server/bare/hyperswarm.d.ts +0 -10
- package/dist/server/bare/hyperswarm.js +0 -103
- package/dist/server/bare/ops/bci-transcribe.d.ts +0 -13
- package/dist/server/bare/ops/bci-transcribe.js +0 -248
- package/dist/server/bare/ops/cancel.d.ts +0 -29
- package/dist/server/bare/ops/cancel.js +0 -46
- package/dist/server/bare/ops/embed.d.ts +0 -16
- package/dist/server/bare/ops/embed.js +0 -193
- package/dist/server/bare/ops/kv-cache-retention.d.ts +0 -12
- package/dist/server/bare/ops/kv-cache-retention.js +0 -132
- package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -22
- package/dist/server/bare/ops/kv-cache-utils.js +0 -148
- package/dist/server/bare/ops/load-model.d.ts +0 -9
- package/dist/server/bare/ops/load-model.js +0 -82
- package/dist/server/bare/ops/transcribe.d.ts +0 -20
- package/dist/server/bare/ops/transcribe.js +0 -349
- package/dist/server/bare/ops/translate-stats.d.ts +0 -5
- package/dist/server/bare/ops/translate-stats.js +0 -11
- package/dist/server/bare/ops/translate.d.ts +0 -8
- package/dist/server/bare/ops/translate.js +0 -284
- package/dist/server/bare/ops/unload-model.d.ts +0 -3
- package/dist/server/bare/ops/unload-model.js +0 -51
- package/dist/server/bare/plugins/asr-ggml/config.d.ts +0 -32
- package/dist/server/bare/plugins/asr-ggml/config.js +0 -46
- package/dist/server/bare/plugins/asr-ggml/logging.d.ts +0 -11
- package/dist/server/bare/plugins/asr-ggml/logging.js +0 -12
- package/dist/server/bare/plugins/audiogen-ggml/config.d.ts +0 -18
- package/dist/server/bare/plugins/audiogen-ggml/config.js +0 -23
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-input.d.ts +0 -20
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-input.js +0 -153
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-stream.d.ts +0 -3
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-stream.js +0 -213
- package/dist/server/bare/plugins/audiogen-ggml/plugin.d.ts +0 -241
- package/dist/server/bare/plugins/audiogen-ggml/plugin.js +0 -58
- package/dist/server/bare/plugins/bci-whispercpp-transcription/args.d.ts +0 -3
- package/dist/server/bare/plugins/bci-whispercpp-transcription/args.js +0 -13
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.d.ts +0 -174
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.js +0 -111
- package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.d.ts +0 -75
- package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.js +0 -11
- package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +0 -6
- package/dist/server/bare/plugins/ggml-classification/ops/classify.js +0 -30
- package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +0 -32
- package/dist/server/bare/plugins/ggml-classification/plugin.js +0 -55
- package/dist/server/bare/plugins/ggml-ocr/ops/ocr-stream.d.ts +0 -8
- package/dist/server/bare/plugins/ggml-ocr/ops/ocr-stream.js +0 -119
- package/dist/server/bare/plugins/ggml-ocr/plugin.d.ts +0 -103
- package/dist/server/bare/plugins/ggml-ocr/plugin.js +0 -112
- package/dist/server/bare/plugins/ggml-ocr/resolve-config.d.ts +0 -6
- package/dist/server/bare/plugins/ggml-ocr/resolve-config.js +0 -73
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +0 -3
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +0 -12
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +0 -3
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +0 -79
- package/dist/server/bare/plugins/ggml-vla/ops/vla-set-embodiment.d.ts +0 -3
- package/dist/server/bare/plugins/ggml-vla/ops/vla-set-embodiment.js +0 -9
- package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +0 -103
- package/dist/server/bare/plugins/ggml-vla/plugin.js +0 -74
- package/dist/server/bare/plugins/index.d.ts +0 -13
- package/dist/server/bare/plugins/index.js +0 -12
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.d.ts +0 -32
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.js +0 -100
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +0 -7
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +0 -36
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.d.ts +0 -27
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.js +0 -58
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +0 -47
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +0 -382
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +0 -29
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +0 -65
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +0 -11
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +0 -299
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +0 -190
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +0 -746
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +0 -58
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +0 -58
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +0 -672
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +0 -503
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +0 -10
- package/dist/server/bare/plugins/llamacpp-completion/transform.js +0 -28
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +0 -77
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +0 -100
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +0 -458
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +0 -144
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +0 -32
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.js +0 -114
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +0 -134
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +0 -141
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +0 -3
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +0 -63
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +0 -3
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +0 -40
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +0 -6
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +0 -238
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +0 -758
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +0 -310
- package/dist/server/bare/plugins/tts-ggml/ops/parler-options.d.ts +0 -7
- package/dist/server/bare/plugins/tts-ggml/ops/parler-options.js +0 -50
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech-stream.d.ts +0 -7
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech-stream.js +0 -104
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech.d.ts +0 -7
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech.js +0 -89
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +0 -495
- package/dist/server/bare/plugins/tts-ggml/plugin.js +0 -436
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +0 -347
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +0 -178
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/chunk.js +0 -7
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +0 -11
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +0 -14
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +0 -19
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.js +0 -4
- package/dist/server/bare/rag-hyperdb/handlers/reindex.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +0 -16
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +0 -15
- package/dist/server/bare/rag-hyperdb/handlers/search.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/search.js +0 -16
- package/dist/server/bare/rag-hyperdb/index.d.ts +0 -12
- package/dist/server/bare/rag-hyperdb/index.js +0 -11
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +0 -29
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +0 -76
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.d.ts +0 -15
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +0 -143
- package/dist/server/bare/registry/config-registry.d.ts +0 -14
- package/dist/server/bare/registry/config-registry.js +0 -90
- package/dist/server/bare/registry/logging-stream-registry.js +0 -137
- package/dist/server/bare/registry/model-config-registry.d.ts +0 -4
- package/dist/server/bare/registry/model-config-registry.js +0 -15
- package/dist/server/bare/registry/model-config-utils.d.ts +0 -15
- package/dist/server/bare/registry/model-config-utils.js +0 -128
- package/dist/server/bare/registry/model-registry.d.ts +0 -76
- package/dist/server/bare/registry/model-registry.js +0 -130
- package/dist/server/bare/registry/registry-client.d.ts +0 -5
- package/dist/server/bare/registry/registry-client.js +0 -118
- package/dist/server/bare/registry/runtime-context-registry.d.ts +0 -7
- package/dist/server/bare/registry/runtime-context-registry.js +0 -26
- package/dist/server/bare/resources/collector.d.ts +0 -644
- package/dist/server/bare/resources/collector.js +0 -226
- package/dist/server/bare/resources/native.d.ts +0 -3
- package/dist/server/bare/resources/native.js +0 -35
- package/dist/server/bare/resources/normalize.d.ts +0 -13
- package/dist/server/bare/resources/normalize.js +0 -73
- package/dist/server/bare/resources/types.d.ts +0 -66
- package/dist/server/bare/resources/types.js +0 -1
- package/dist/server/bare/resources/worker-collector.d.ts +0 -5
- package/dist/server/bare/resources/worker-collector.js +0 -15
- package/dist/server/bare/runtime/disposable-scope.d.ts +0 -36
- package/dist/server/bare/runtime/disposable-scope.js +0 -69
- package/dist/server/bare/runtime/index.d.ts +0 -8
- package/dist/server/bare/runtime/index.js +0 -3
- package/dist/server/bare/runtime/request-context.d.ts +0 -49
- package/dist/server/bare/runtime/request-context.js +0 -1
- package/dist/server/bare/runtime/request-id.d.ts +0 -12
- package/dist/server/bare/runtime/request-id.js +0 -14
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +0 -4
- package/dist/server/bare/runtime/request-registry-singleton.js +0 -77
- package/dist/server/bare/runtime/request-registry.d.ts +0 -222
- package/dist/server/bare/runtime/request-registry.js +0 -715
- package/dist/server/bare/runtime/with-request-context.d.ts +0 -22
- package/dist/server/bare/runtime/with-request-context.js +0 -53
- package/dist/server/bare/runtime-lifecycle.d.ts +0 -38
- package/dist/server/bare/runtime-lifecycle.js +0 -163
- package/dist/server/bare/types/addon-responses.d.ts +0 -51
- package/dist/server/bare/types/addon-responses.js +0 -1
- package/dist/server/bare/utils/asr-events.d.ts +0 -15
- package/dist/server/bare/utils/asr-events.js +0 -30
- package/dist/server/bare/utils/audio-input.d.ts +0 -10
- package/dist/server/bare/utils/audio-input.js +0 -33
- package/dist/server/bare/utils/transcribe-metadata.d.ts +0 -21
- package/dist/server/bare/utils/transcribe-metadata.js +0 -28
- package/dist/server/bare/utils/tts-stats.d.ts +0 -26
- package/dist/server/bare/utils/tts-stats.js +0 -16
- package/dist/server/error-handlers.js +0 -32
- package/dist/server/plugins/index.d.ts +0 -2
- package/dist/server/plugins/index.js +0 -1
- package/dist/server/plugins/registry.d.ts +0 -10
- package/dist/server/plugins/registry.js +0 -107
- package/dist/server/rpc/create-server.js +0 -46
- package/dist/server/rpc/delegate-transport.d.ts +0 -19
- package/dist/server/rpc/delegate-transport.js +0 -237
- package/dist/server/rpc/handle-request.js +0 -172
- package/dist/server/rpc/handler-registry.d.ts +0 -3
- package/dist/server/rpc/handler-registry.js +0 -179
- package/dist/server/rpc/handler-selection.d.ts +0 -9
- package/dist/server/rpc/handler-selection.js +0 -14
- package/dist/server/rpc/handler-utils.d.ts +0 -30
- package/dist/server/rpc/handler-utils.js +0 -183
- package/dist/server/rpc/handlers/audio-gen-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/audio-gen-stream.js +0 -4
- package/dist/server/rpc/handlers/batch-completion-stream.d.ts +0 -80
- package/dist/server/rpc/handlers/batch-completion-stream.js +0 -4
- package/dist/server/rpc/handlers/bci-transcribe-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/bci-transcribe-stream.js +0 -4
- package/dist/server/rpc/handlers/bci-transcribe.d.ts +0 -3
- package/dist/server/rpc/handlers/bci-transcribe.js +0 -4
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/cancel-delegated.js +0 -66
- package/dist/server/rpc/handlers/cancelHandler.d.ts +0 -32
- package/dist/server/rpc/handlers/cancelHandler.js +0 -69
- package/dist/server/rpc/handlers/classify.d.ts +0 -3
- package/dist/server/rpc/handlers/classify.js +0 -4
- package/dist/server/rpc/handlers/completion-orchestrate.d.ts +0 -42
- package/dist/server/rpc/handlers/completion-orchestrate.js +0 -190
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +0 -5
- package/dist/server/rpc/handlers/completion-stream-delegated.js +0 -51
- package/dist/server/rpc/handlers/completion-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/completion-stream.js +0 -4
- package/dist/server/rpc/handlers/delete-cache.d.ts +0 -12
- package/dist/server/rpc/handlers/delete-cache.js +0 -37
- package/dist/server/rpc/handlers/diffusion-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/diffusion-stream.js +0 -4
- package/dist/server/rpc/handlers/download-asset.d.ts +0 -3
- package/dist/server/rpc/handlers/download-asset.js +0 -146
- package/dist/server/rpc/handlers/embed.d.ts +0 -3
- package/dist/server/rpc/handlers/embed.js +0 -4
- package/dist/server/rpc/handlers/finetune.d.ts +0 -3
- package/dist/server/rpc/handlers/finetune.js +0 -18
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +0 -3
- package/dist/server/rpc/handlers/get-loaded-model-info.js +0 -45
- package/dist/server/rpc/handlers/get-model-info.d.ts +0 -3
- package/dist/server/rpc/handlers/get-model-info.js +0 -173
- package/dist/server/rpc/handlers/get-system-resources.d.ts +0 -3
- package/dist/server/rpc/handlers/get-system-resources.js +0 -53
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/heartbeat-delegated.js +0 -32
- package/dist/server/rpc/handlers/heartbeat.d.ts +0 -3
- package/dist/server/rpc/handlers/heartbeat.js +0 -3
- package/dist/server/rpc/handlers/index.d.ts +0 -76
- package/dist/server/rpc/handlers/index.js +0 -75
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +0 -98
- package/dist/server/rpc/handlers/load-model/download-manager.js +0 -308
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +0 -8
- package/dist/server/rpc/handlers/load-model/download-stats.js +0 -126
- package/dist/server/rpc/handlers/load-model/handler.d.ts +0 -3
- package/dist/server/rpc/handlers/load-model/handler.js +0 -287
- package/dist/server/rpc/handlers/load-model/http.d.ts +0 -4
- package/dist/server/rpc/handlers/load-model/http.js +0 -856
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +0 -5
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +0 -561
- package/dist/server/rpc/handlers/load-model/index.d.ts +0 -3
- package/dist/server/rpc/handlers/load-model/index.js +0 -2
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +0 -27
- package/dist/server/rpc/handlers/load-model/registry-client-options.js +0 -18
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +0 -23
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +0 -206
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +0 -24
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +0 -112
- package/dist/server/rpc/handlers/load-model/registry-metadata.d.ts +0 -11
- package/dist/server/rpc/handlers/load-model/registry-metadata.js +0 -23
- package/dist/server/rpc/handlers/load-model/registry.d.ts +0 -5
- package/dist/server/rpc/handlers/load-model/registry.js +0 -298
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +0 -34
- package/dist/server/rpc/handlers/load-model/resolve-session.js +0 -62
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +0 -16
- package/dist/server/rpc/handlers/load-model/resolve.js +0 -237
- package/dist/server/rpc/handlers/load-model/types.d.ts +0 -60
- package/dist/server/rpc/handlers/load-model/types.js +0 -28
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +0 -7
- package/dist/server/rpc/handlers/load-model-delegated.js +0 -132
- package/dist/server/rpc/handlers/logging-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/logging-stream.js +0 -39
- package/dist/server/rpc/handlers/ocr-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/ocr-stream.js +0 -4
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +0 -3
- package/dist/server/rpc/handlers/plugin-dispatch.js +0 -63
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +0 -4
- package/dist/server/rpc/handlers/plugin-invoke.js +0 -81
- package/dist/server/rpc/handlers/provideHandler/connection.d.ts +0 -3
- package/dist/server/rpc/handlers/provideHandler/connection.js +0 -38
- package/dist/server/rpc/handlers/provideHandler/handler.d.ts +0 -3
- package/dist/server/rpc/handlers/provideHandler/handler.js +0 -66
- package/dist/server/rpc/handlers/provideHandler/proxy.d.ts +0 -3
- package/dist/server/rpc/handlers/provideHandler/proxy.js +0 -24
- package/dist/server/rpc/handlers/provideHandler.d.ts +0 -2
- package/dist/server/rpc/handlers/provideHandler.js +0 -2
- package/dist/server/rpc/handlers/rag.d.ts +0 -3
- package/dist/server/rpc/handlers/rag.js +0 -272
- package/dist/server/rpc/handlers/registry.d.ts +0 -5
- package/dist/server/rpc/handlers/registry.js +0 -155
- package/dist/server/rpc/handlers/resume.d.ts +0 -3
- package/dist/server/rpc/handlers/resume.js +0 -11
- package/dist/server/rpc/handlers/state.d.ts +0 -3
- package/dist/server/rpc/handlers/state.js +0 -7
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +0 -3
- package/dist/server/rpc/handlers/stopProvideHandler.js +0 -29
- package/dist/server/rpc/handlers/suspend.d.ts +0 -3
- package/dist/server/rpc/handlers/suspend.js +0 -11
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/text-to-speech-stream.js +0 -4
- package/dist/server/rpc/handlers/text-to-speech.d.ts +0 -3
- package/dist/server/rpc/handlers/text-to-speech.js +0 -4
- package/dist/server/rpc/handlers/transcribe-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/transcribe-stream.js +0 -4
- package/dist/server/rpc/handlers/transcribe.d.ts +0 -3
- package/dist/server/rpc/handlers/transcribe.js +0 -4
- package/dist/server/rpc/handlers/translate.d.ts +0 -3
- package/dist/server/rpc/handlers/translate.js +0 -4
- package/dist/server/rpc/handlers/unload-model-delegated.d.ts +0 -3
- package/dist/server/rpc/handlers/unload-model-delegated.js +0 -32
- package/dist/server/rpc/handlers/unload-model.d.ts +0 -3
- package/dist/server/rpc/handlers/unload-model.js +0 -29
- package/dist/server/rpc/handlers/upscale-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/upscale-stream.js +0 -4
- package/dist/server/rpc/handlers/video-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/video-stream.js +0 -4
- package/dist/server/rpc/index.d.ts +0 -3
- package/dist/server/rpc/index.js +0 -2
- package/dist/server/rpc/method-shapes.d.ts +0 -53
- package/dist/server/rpc/method-shapes.js +0 -50
- package/dist/server/rpc/profiling/backend-diagnostics.d.ts +0 -3
- package/dist/server/rpc/profiling/backend-diagnostics.js +0 -16
- package/dist/server/rpc/profiling/context.d.ts +0 -18
- package/dist/server/rpc/profiling/context.js +0 -37
- package/dist/server/rpc/profiling/delegation-profiler.d.ts +0 -32
- package/dist/server/rpc/profiling/delegation-profiler.js +0 -153
- package/dist/server/rpc/profiling/index.d.ts +0 -5
- package/dist/server/rpc/profiling/index.js +0 -4
- package/dist/server/rpc/profiling/operation-metrics.d.ts +0 -25
- package/dist/server/rpc/profiling/operation-metrics.js +0 -361
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +0 -18
- package/dist/server/rpc/profiling/operation-wrappers.js +0 -196
- package/dist/server/rpc/profiling/profiler.d.ts +0 -13
- package/dist/server/rpc/profiling/profiler.js +0 -93
- package/dist/server/rpc/rpc-utils.d.ts +0 -5
- package/dist/server/rpc/transport-selector.d.ts +0 -3
- package/dist/server/rpc/transport-selector.js +0 -18
- package/dist/server/utils/archive.d.ts +0 -4
- package/dist/server/utils/archive.js +0 -177
- package/dist/server/utils/audio/decoder.d.ts +0 -41
- package/dist/server/utils/audio/decoder.js +0 -108
- package/dist/server/utils/cache/auto-history.d.ts +0 -4
- package/dist/server/utils/cache/auto-history.js +0 -26
- package/dist/server/utils/cache/paths.d.ts +0 -43
- package/dist/server/utils/cache/paths.js +0 -133
- package/dist/server/utils/cache/types.d.ts +0 -8
- package/dist/server/utils/cache/types.js +0 -1
- package/dist/server/utils/checksum.d.ts +0 -4
- package/dist/server/utils/checksum.js +0 -30
- package/dist/server/utils/clear-storage.d.ts +0 -5
- package/dist/server/utils/clear-storage.js +0 -14
- package/dist/server/utils/completion-normalizer.d.ts +0 -18
- package/dist/server/utils/completion-normalizer.js +0 -453
- package/dist/server/utils/config-transform.d.ts +0 -6
- package/dist/server/utils/config-transform.js +0 -27
- package/dist/server/utils/formatting.d.ts +0 -19
- package/dist/server/utils/formatting.js +0 -56
- package/dist/server/utils/gguf-tensor-extractor.d.ts +0 -15
- package/dist/server/utils/gguf-tensor-extractor.js +0 -310
- package/dist/server/utils/index.d.ts +0 -11
- package/dist/server/utils/index.js +0 -10
- package/dist/server/utils/multi-gpu-mobile.d.ts +0 -5
- package/dist/server/utils/multi-gpu-mobile.js +0 -10
- package/dist/server/utils/path-security.d.ts +0 -12
- package/dist/server/utils/path-security.js +0 -25
- package/dist/server/utils/qvac-paths.js +0 -5
- package/dist/server/utils/response-format.d.ts +0 -3
- package/dist/server/utils/response-format.js +0 -20
- package/dist/server/utils/shard-utils.d.ts +0 -49
- package/dist/server/utils/shard-utils.js +0 -137
- package/dist/server/utils/tool-integration.d.ts +0 -17
- package/dist/server/utils/tool-integration.js +0 -20
- package/dist/server/utils/tools/dialect.d.ts +0 -8
- package/dist/server/utils/tools/dialect.js +0 -20
- package/dist/server/utils/tools/index.d.ts +0 -3
- package/dist/server/utils/tools/index.js +0 -2
- package/dist/server/utils/tools/parser.d.ts +0 -6
- package/dist/server/utils/tools/parser.js +0 -69
- package/dist/server/utils/tools/parsers/dsml.d.ts +0 -4
- package/dist/server/utils/tools/parsers/dsml.js +0 -176
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +0 -4
- package/dist/server/utils/tools/parsers/gemma4native.js +0 -65
- package/dist/server/utils/tools/parsers/harmony.d.ts +0 -4
- package/dist/server/utils/tools/parsers/harmony.js +0 -57
- package/dist/server/utils/tools/parsers/hermes.d.ts +0 -4
- package/dist/server/utils/tools/parsers/hermes.js +0 -122
- package/dist/server/utils/tools/parsers/json.d.ts +0 -6
- package/dist/server/utils/tools/parsers/json.js +0 -115
- package/dist/server/utils/tools/parsers/pythonic.d.ts +0 -4
- package/dist/server/utils/tools/parsers/pythonic.js +0 -267
- package/dist/server/utils/tools/parsers/qwen35.d.ts +0 -4
- package/dist/server/utils/tools/parsers/qwen35.js +0 -124
- package/dist/server/utils/tools/shared.d.ts +0 -18
- package/dist/server/utils/tools/shared.js +0 -52
- package/dist/server/utils/worker-lock.js +0 -67
- package/dist/server/worker-core.d.ts +0 -23
- package/dist/server/worker-core.js +0 -206
- package/dist/server/worker.d.ts +0 -5
- package/dist/server/worker.js +0 -34
- package/dist/utils/aggregate-events.d.ts +0 -26
- package/dist/utils/aggregate-events.js +0 -73
- package/dist/utils/errors-client.d.ts +0 -178
- package/dist/utils/errors-client.js +0 -310
- package/dist/utils/errors-server.d.ts +0 -376
- package/dist/utils/errors-server.js +0 -610
- package/dist/utils/load-model-validation.js +0 -18
- package/dist/utils/mcp-adapter.d.ts +0 -12
- package/dist/utils/mcp-adapter.js +0 -96
- package/dist/utils/tool-helpers.d.ts +0 -25
- package/dist/utils/tool-helpers.js +0 -111
- /package/dist/{client → src/client}/api/client-request-id.d.ts +0 -0
- /package/dist/{client → src/client}/api/client-request-id.js +0 -0
- /package/dist/{client → src/client}/api/subscribe-logs.js +0 -0
- /package/dist/{client → src/client}/config-loader/resolve-config.expo.d.ts +0 -0
- /package/dist/{client → src/client}/config-loader/resolve-config.node.d.ts +0 -0
- /package/dist/{client → src/client}/index.d.ts +0 -0
- /package/dist/{client → src/client}/index.js +0 -0
- /package/dist/{client → src/client}/logging-stream-registry.d.ts +0 -0
- /package/dist/{client → src/client}/logging-stream-registry.js +0 -0
- /package/dist/{client → src/client}/parse-input.d.ts +0 -0
- /package/dist/{client → src/client}/parse-input.js +0 -0
- /package/dist/{client → src/client}/rpc/ensure-worker-ready.d.ts +0 -0
- /package/dist/{client → src/client}/rpc/ensure-worker-ready.js +0 -0
- /package/dist/{client → src/client}/rpc/expo-device-info.d.ts +0 -0
- /package/dist/{client → src/client}/rpc/expo-device-info.js +0 -0
- /package/dist/{client → src/client}/rpc/expo-rpc-client.d.ts +0 -0
- /package/dist/{client → src/client}/rpc/node-rpc-client.d.ts +0 -0
- /package/dist/{client → src/client}/rpc/profiling/index.d.ts +0 -0
- /package/dist/{client → src/client}/rpc/profiling/index.js +0 -0
- /package/dist/{commands → src/commands}/bundle/bare-pack.d.ts +0 -0
- /package/dist/{commands → src/commands}/bundle/bare-pack.js +0 -0
- /package/dist/{commands → src/commands}/bundle/constants.d.ts +0 -0
- /package/dist/{commands → src/commands}/bundle/constants.js +0 -0
- /package/dist/{commands → src/commands}/bundle/entry-gen.d.ts +0 -0
- /package/dist/{commands → src/commands}/bundle/index.d.ts +0 -0
- /package/dist/{commands → src/commands}/bundle/manifest.d.ts +0 -0
- /package/dist/{commands → src/commands}/bundle/manifest.js +0 -0
- /package/dist/{commands → src/commands}/bundle/resolve-sdk-import.d.ts +0 -0
- /package/dist/{commands → src/commands}/verify/addon-source.d.ts +0 -0
- /package/dist/{commands → src/commands}/verify/addon-source.js +0 -0
- /package/dist/{commands → src/commands}/verify/resource-collectors.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/find-in-ancestor-node-modules.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/find-in-ancestor-node-modules.js +0 -0
- /package/dist/{expo → src/expo}/plugins/get-project-root.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/get-project-root.js +0 -0
- /package/dist/{expo → src/expo}/plugins/index.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/index.js +0 -0
- /package/dist/{expo → src/expo}/plugins/resolve-sdk-package-dir.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/resolve-sdk-package-dir.js +0 -0
- /package/dist/{expo → src/expo}/plugins/withAndroidArchitecture.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/withAndroidArchitecture.js +0 -0
- /package/dist/{expo → src/expo}/plugins/withAndroidNdkVersion.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/withDeviceInfo.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/withOpenCL.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/withOpenCL.js +0 -0
- /package/dist/{expo → src/expo}/plugins/withQvacSDK.d.ts +0 -0
- /package/dist/{expo → src/expo}/plugins/withQvacSDK.js +0 -0
- /package/dist/{logging → src/logging}/addon.js +0 -0
- /package/dist/{logging → src/logging}/base-logger.d.ts +0 -0
- /package/dist/{logging → src/logging}/base-logger.js +0 -0
- /package/dist/{logging → src/logging}/client-logger.d.ts +0 -0
- /package/dist/{logging → src/logging}/client-logger.js +0 -0
- /package/dist/{logging → src/logging}/index.d.ts +0 -0
- /package/dist/{logging → src/logging}/index.js +0 -0
- /package/dist/{logging → src/logging}/logger.d.ts +0 -0
- /package/dist/{logging → src/logging}/logger.js +0 -0
- /package/dist/{server/bare/registry → src/logging}/logging-stream-registry.d.ts +0 -0
- /package/dist/{logging → src/logging}/server-logger.d.ts +0 -0
- /package/dist/{logging → src/logging}/server-logger.js +0 -0
- /package/dist/{logging → src/logging}/stream-logger.d.ts +0 -0
- /package/dist/{logging → src/logging}/transport.d.ts +0 -0
- /package/dist/{logging → src/logging}/transport.js +0 -0
- /package/dist/{logging → src/logging}/types.d.ts +0 -0
- /package/dist/{logging → src/logging}/types.js +0 -0
- /package/dist/{logging → src/logging}/utils.js +0 -0
- /package/dist/{pear → src/pear}/pre.d.ts +0 -0
- /package/dist/{server → src/server}/env.d.ts +0 -0
- /package/dist/{server → src/server}/env.js +0 -0
- /package/dist/{server → src/server}/error-handlers.d.ts +0 -0
- /package/dist/{server → src/server}/rpc/progress-throttle.d.ts +0 -0
- /package/dist/{server → src/server}/rpc/progress-throttle.js +0 -0
- /package/dist/{server → src/server}/rpc/rpc-utils.js +0 -0
- /package/dist/{server → src/server}/utils/qvac-paths.d.ts +0 -0
- /package/dist/{server → src/server}/utils/worker-lock.d.ts +0 -0
- /package/dist/{utils → src/utils}/cache-normalize.d.ts +0 -0
- /package/dist/{utils → src/utils}/cache-normalize.js +0 -0
- /package/dist/{utils → src/utils}/decorate-promise.d.ts +0 -0
- /package/dist/{utils → src/utils}/decorate-promise.js +0 -0
- /package/dist/{utils → src/utils}/encoding.d.ts +0 -0
- /package/dist/{utils → src/utils}/encoding.js +0 -0
- /package/dist/{utils → src/utils}/errors-base.d.ts +0 -0
- /package/dist/{utils → src/utils}/errors-base.js +0 -0
- /package/dist/{utils → src/utils}/global-singleton.d.ts +0 -0
- /package/dist/{utils → src/utils}/global-singleton.js +0 -0
- /package/dist/{utils → src/utils}/load-model-validation.d.ts +0 -0
- /package/dist/{utils → src/utils}/object.d.ts +0 -0
- /package/dist/{utils → src/utils}/object.js +0 -0
- /package/dist/{utils → src/utils}/path-sanitize.d.ts +0 -0
- /package/dist/{utils → src/utils}/path-sanitize.js +0 -0
- /package/dist/{utils → src/utils}/withTimeout.d.ts +0 -0
- /package/dist/{utils → src/utils}/withTimeout.js +0 -0
- /package/dist/{utils → src/utils}/zod-error.d.ts +0 -0
- /package/dist/{utils → src/utils}/zod-error.js +0 -0
- /package/dist/{server/rpc → src/worker}/create-server.d.ts +0 -0
- /package/dist/{server/rpc → src/worker}/handle-request.d.ts +0 -0
- /package/{electron-forge → src/electron-forge}/index.cjs +0 -0
- /package/{expo → src/expo}/plugins/patches/android-link.mjs +0 -0
- /package/{expo → src/expo}/plugins/patches/ios-link.mjs +0 -0
|
@@ -1,715 +0,0 @@
|
|
|
1
|
-
import { AbortController } from 'bare-abort-controller';
|
|
2
|
-
import { createDisposableScope } from '../../../server/bare/runtime/disposable-scope.js';
|
|
3
|
-
import { RequestIdConflictError, RequestRejectedByPolicyError } from '../../../utils/errors-server.js';
|
|
4
|
-
import { getServerLogger } from '../../../logging/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* Tuning knobs for the "cancelled-before-begin" bookkeeping set.
|
|
7
|
-
*
|
|
8
|
-
* The race window is bounded by the client-to-server round-trip: a
|
|
9
|
-
* `cancel({ requestId })` issued by the client at the same time as the
|
|
10
|
-
* matching `completion(...)` either lands first (and we need to remember
|
|
11
|
-
* it long enough for the server's `begin(...)` to follow) or lands
|
|
12
|
-
* second (and we never touch this set). 30 seconds is overkill for a
|
|
13
|
-
* 500ms round-trip but gives slow networks / pause-the-debugger
|
|
14
|
-
* scenarios enough slack while still bounding worst-case retention.
|
|
15
|
-
*
|
|
16
|
-
* The size cap protects against a buggy or malicious client firing a
|
|
17
|
-
* stream of cancels for ids that never get a `begin(...)` follow-up —
|
|
18
|
-
* each `cancel({ requestId })` that doesn't match an in-flight context
|
|
19
|
-
* inserts one entry, so without a cap the worker would grow the map
|
|
20
|
-
* unbounded. At the cap, the oldest entry is evicted.
|
|
21
|
-
*
|
|
22
|
-
* Tweak with care: both bounds appear in the registry race test
|
|
23
|
-
* (`bounded cancel-before-begin set does not grow past its cap`).
|
|
24
|
-
*/
|
|
25
|
-
const CANCEL_BEFORE_BEGIN_MAX_ENTRIES = 128;
|
|
26
|
-
const CANCEL_BEFORE_BEGIN_TTL_MS = 30_000;
|
|
27
|
-
/**
|
|
28
|
-
* Default cap on waiters queued per `(lane, modelId)` when a policy uses
|
|
29
|
-
* `onOverflow: "queue"` without an explicit `maxQueueDepthPerModel`.
|
|
30
|
-
* Bounds memory so a misbehaving client firing a flood of same-model
|
|
31
|
-
* requests can't grow the queue without limit — the (depth + 1)th begin
|
|
32
|
-
* rejects with `RequestRejectedByPolicyError` instead of enqueuing.
|
|
33
|
-
*/
|
|
34
|
-
const DEFAULT_MAX_QUEUE_DEPTH_PER_MODEL = 64;
|
|
35
|
-
export function createRequestRegistry(options) {
|
|
36
|
-
const entries = new Map();
|
|
37
|
-
const policies = new Map();
|
|
38
|
-
const logger = options?.logger ?? getServerLogger();
|
|
39
|
-
/**
|
|
40
|
-
* Per-`(kind, modelId)` admission semaphores. Keyed by
|
|
41
|
-
* `slotKey(kind, modelId)`. Absent until the first gated `begin(...)`
|
|
42
|
-
* for that key; removed again the moment the key is idle.
|
|
43
|
-
*/
|
|
44
|
-
const keyStates = new Map();
|
|
45
|
-
/**
|
|
46
|
-
* Reverse index from a queued waiter's `requestId` to its slot so
|
|
47
|
-
* `cancel({ requestId })` can pull a still-queued request out of the
|
|
48
|
-
* FIFO in O(1) without scanning every `KeyState`.
|
|
49
|
-
*/
|
|
50
|
-
const waitersById = new Map();
|
|
51
|
-
/**
|
|
52
|
-
* Ids reserved synchronously at `begin(...)` start and cleared once the entry
|
|
53
|
-
* lands in `entries` (or the begin throws). A same-tick second `begin(...)`
|
|
54
|
-
* with the same id runs before the first reaches `entries`/`waitersById`, so
|
|
55
|
-
* without this it would slip past the duplicate check and both would execute.
|
|
56
|
-
*/
|
|
57
|
-
const reservedIds = new Set();
|
|
58
|
-
// Models being torn down: a begin(...) for one starts aborted. The barrier
|
|
59
|
-
// half of cancelAndDrain — catches begins its scan can't see yet.
|
|
60
|
-
const drainingModels = new Set();
|
|
61
|
-
// Entries whose disposal has started but not finished. disposeEntry removes
|
|
62
|
-
// from `entries` before unwinding, so a drain must consult this too or it
|
|
63
|
-
// would return while a request is still tearing down natively.
|
|
64
|
-
const disposingEntries = new Set();
|
|
65
|
-
// Request ids whose entry is mid-disposal. disposeEntry drops the id from
|
|
66
|
-
// `entries` before its async scope unwinds; without this the id looks free
|
|
67
|
-
// during that gap, so a same-id begin could activate concurrently with the
|
|
68
|
-
// still-tearing-down request and a cancel would land as a cancel-before-begin
|
|
69
|
-
// tripwire that aborts a later reuse. Held until teardown completes.
|
|
70
|
-
const disposingIds = new Set();
|
|
71
|
-
function logLifecycle(event, ctx, durationMs) {
|
|
72
|
-
const modelId = ctx.modelId !== undefined ? ctx.modelId : '-';
|
|
73
|
-
const base = `[request-lifecycle] ${event} requestId=${ctx.requestId} kind=${ctx.kind} modelId=${modelId} state=${ctx.state}`;
|
|
74
|
-
const line = durationMs !== undefined ? `${base} durationMs=${durationMs}` : base;
|
|
75
|
-
// `failed` end emits at `warn` so log shippers can alert on
|
|
76
|
-
// `level>=warn` for this prefix without parsing `state=failed`
|
|
77
|
-
// out of the message body. Everything else stays at `info`.
|
|
78
|
-
if (event === 'end' && ctx.state === 'failed') {
|
|
79
|
-
logger.warn(line);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
logger.info(line);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* "Cancelled-before-begin" tripwire. A
|
|
87
|
-
* `cancel({ requestId })` whose target isn't yet in `entries` records
|
|
88
|
-
* the id here; the subsequent `begin({ requestId: <same id> })` then
|
|
89
|
-
* aborts the new controller before returning. Map order is insertion
|
|
90
|
-
* order — the iterator's first key is the oldest entry, which makes
|
|
91
|
-
* the size-cap eviction free.
|
|
92
|
-
*
|
|
93
|
-
* Invariants:
|
|
94
|
-
* - Every read path (`begin`, `cancel`-by-id) calls
|
|
95
|
-
* `pruneCancelBeforeBeginExpired()` first so a 30s+ stale entry
|
|
96
|
-
* never decides a fresh `begin(...)`.
|
|
97
|
-
* - Insertion enforces the size cap by evicting the oldest entry
|
|
98
|
-
* when at capacity — a malicious client cannot grow this map
|
|
99
|
-
* unbounded.
|
|
100
|
-
* - On a successful `begin(...)` match, the entry is consumed
|
|
101
|
-
* (removed) so a second `begin(...)` with the same id (which
|
|
102
|
-
* would itself throw `RequestIdConflictError`) doesn't see a
|
|
103
|
-
* phantom pre-cancel.
|
|
104
|
-
*/
|
|
105
|
-
const cancelledBeforeBegin = new Map();
|
|
106
|
-
function pruneCancelBeforeBeginExpired(now = Date.now()) {
|
|
107
|
-
if (cancelledBeforeBegin.size === 0)
|
|
108
|
-
return;
|
|
109
|
-
const cutoff = now - CANCEL_BEFORE_BEGIN_TTL_MS;
|
|
110
|
-
for (const [id, entry] of cancelledBeforeBegin) {
|
|
111
|
-
if (entry.at > cutoff)
|
|
112
|
-
break; // Insertion order ⇒ rest are newer.
|
|
113
|
-
cancelledBeforeBegin.delete(id);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function recordCancelBeforeBegin(requestId, reason) {
|
|
117
|
-
const now = Date.now();
|
|
118
|
-
pruneCancelBeforeBeginExpired(now);
|
|
119
|
-
// Re-canceling an id that is already tracked refreshes its TTL but
|
|
120
|
-
// keeps the original reason — the first cancel "won" the race.
|
|
121
|
-
if (cancelledBeforeBegin.has(requestId)) {
|
|
122
|
-
const existing = cancelledBeforeBegin.get(requestId);
|
|
123
|
-
cancelledBeforeBegin.delete(requestId);
|
|
124
|
-
cancelledBeforeBegin.set(requestId, { ...existing, at: now });
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (cancelledBeforeBegin.size >= CANCEL_BEFORE_BEGIN_MAX_ENTRIES) {
|
|
128
|
-
const oldest = cancelledBeforeBegin.keys().next().value;
|
|
129
|
-
if (oldest !== undefined)
|
|
130
|
-
cancelledBeforeBegin.delete(oldest);
|
|
131
|
-
}
|
|
132
|
-
cancelledBeforeBegin.set(requestId, reason !== undefined ? { at: now, reason } : { at: now });
|
|
133
|
-
}
|
|
134
|
-
function consumeCancelBeforeBegin(requestId) {
|
|
135
|
-
pruneCancelBeforeBeginExpired();
|
|
136
|
-
const entry = cancelledBeforeBegin.get(requestId);
|
|
137
|
-
if (!entry)
|
|
138
|
-
return undefined;
|
|
139
|
-
cancelledBeforeBegin.delete(requestId);
|
|
140
|
-
return entry;
|
|
141
|
-
}
|
|
142
|
-
function slotKey(lane, modelId) {
|
|
143
|
-
// NUL separator can't appear in a lane (a closed-union kind or an
|
|
144
|
-
// SDK-controlled `sharedSlotGroup` label) or a modelId (sdkModelId is a
|
|
145
|
-
// generated handle), so the join is unambiguous.
|
|
146
|
-
return `${lane}\u0000${modelId}`;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Pull a waiter out of its queue and tidy up: clear its timeout, drop
|
|
150
|
-
* the reverse index, and delete the `KeyState` if that left it idle.
|
|
151
|
-
* Does NOT settle the waiter's promise — the caller decides whether the
|
|
152
|
-
* removal resolves (granted / graceful cancel) or rejects (timeout /
|
|
153
|
-
* teardown).
|
|
154
|
-
*/
|
|
155
|
-
function removeWaiter(key, waiter, drainAfter = true) {
|
|
156
|
-
if (waiter.timer !== undefined) {
|
|
157
|
-
clearTimeout(waiter.timer);
|
|
158
|
-
waiter.timer = undefined;
|
|
159
|
-
}
|
|
160
|
-
waitersById.delete(waiter.requestId);
|
|
161
|
-
const st = keyStates.get(key);
|
|
162
|
-
if (!st)
|
|
163
|
-
return;
|
|
164
|
-
const i = st.waiters.indexOf(waiter);
|
|
165
|
-
if (i >= 0)
|
|
166
|
-
st.waiters.splice(i, 1);
|
|
167
|
-
// Removing a queued writer can unblock the readers behind it, so drain
|
|
168
|
-
// (which also deletes the KeyState once idle). `cancelAll` passes false:
|
|
169
|
-
// it's tearing every waiter down, so granting one mid-sweep is wrong.
|
|
170
|
-
if (drainAfter)
|
|
171
|
-
drain(st, key);
|
|
172
|
-
else if (st.active <= 0 && !st.exclusiveActive && st.waiters.length === 0) {
|
|
173
|
-
keyStates.delete(key);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Admission gate. Resolves to the slot key the caller must release on
|
|
178
|
-
* dispose, or `undefined` when the request is ungated (no policy, no
|
|
179
|
-
* `modelId`, an unbounded limit, or an already-aborted parent — which we
|
|
180
|
-
* let through so the normal abort path produces a clean cancelled
|
|
181
|
-
* outcome rather than queuing a doomed request).
|
|
182
|
-
*
|
|
183
|
-
* When the key is at capacity it either rejects (`onOverflow: "reject"`,
|
|
184
|
-
* queue-depth cap, or `queueTimeoutMs`) or enqueues a FIFO waiter and
|
|
185
|
-
* awaits it. The releaser hands a freed slot to the oldest waiter
|
|
186
|
-
* (`resolve(true)`), so `active` is never decremented and re-incremented
|
|
187
|
-
* across a hand-off — that's what guarantees FIFO fairness with no
|
|
188
|
-
* acquire/release race in the single-threaded event loop.
|
|
189
|
-
*/
|
|
190
|
-
async function acquireSlot(opts) {
|
|
191
|
-
if (opts.modelId === undefined)
|
|
192
|
-
return { slotKey: undefined, exclusive: false };
|
|
193
|
-
const policy = policies.get(opts.kind);
|
|
194
|
-
if (!policy)
|
|
195
|
-
return { slotKey: undefined, exclusive: false };
|
|
196
|
-
// The per-request override (the model's own `parallel`) wins over the
|
|
197
|
-
// per-kind default. A non-finite effective cap disables gating entirely.
|
|
198
|
-
const requestedMax = opts.maxConcurrentPerModel ?? policy.maxConcurrent;
|
|
199
|
-
if (!Number.isFinite(requestedMax)) {
|
|
200
|
-
return { slotKey: undefined, exclusive: false };
|
|
201
|
-
}
|
|
202
|
-
const maxConcurrent = clampSlotCount(requestedMax);
|
|
203
|
-
// A parent (worker-shutdown) signal that's already aborted: don't
|
|
204
|
-
// queue behind live work that may never drain — let begin() proceed
|
|
205
|
-
// and abort immediately via the parentSignal path.
|
|
206
|
-
if (opts.parentSignal?.aborted)
|
|
207
|
-
return { slotKey: undefined, exclusive: false };
|
|
208
|
-
const modelId = opts.modelId;
|
|
209
|
-
// Lane precedence: the policy's shared group → the kind itself. A shared
|
|
210
|
-
// lane lets unrelated kinds contend for one slot pool per model.
|
|
211
|
-
const key = slotKey(policy.slotGroup ?? opts.kind, modelId);
|
|
212
|
-
let st = keyStates.get(key);
|
|
213
|
-
if (!st) {
|
|
214
|
-
st = { active: 0, waiters: [], exclusiveActive: false };
|
|
215
|
-
keyStates.set(key, st);
|
|
216
|
-
}
|
|
217
|
-
const exclusive = policy.exclusive;
|
|
218
|
-
// A reader admits below the lane's pinned cap (see `readerCap`); an exclusive
|
|
219
|
-
// writer needs the lane empty. A queued waiter (of any kind) blocks admission
|
|
220
|
-
// so a writer isn't starved by a steady reader stream. For reader-only lanes
|
|
221
|
-
// `waiters` is empty whenever `active < cap`, so this guard is a no-op there.
|
|
222
|
-
const readerCap = st.readerCap ?? maxConcurrent;
|
|
223
|
-
const canAdmit = st.waiters.length === 0 &&
|
|
224
|
-
!st.exclusiveActive &&
|
|
225
|
-
(exclusive ? st.active === 0 : st.active < readerCap);
|
|
226
|
-
if (canAdmit) {
|
|
227
|
-
if (exclusive) {
|
|
228
|
-
st.exclusiveActive = true;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
st.active++;
|
|
232
|
-
if (st.readerCap === undefined)
|
|
233
|
-
st.readerCap = maxConcurrent;
|
|
234
|
-
}
|
|
235
|
-
return { slotKey: key, exclusive };
|
|
236
|
-
}
|
|
237
|
-
if (policy.onOverflow === 'reject') {
|
|
238
|
-
throw new RequestRejectedByPolicyError(opts.requestId, opts.kind, modelId, `another ${opts.kind} request is already running on this model`);
|
|
239
|
-
}
|
|
240
|
-
if (st.waiters.length >= policy.maxQueueDepth) {
|
|
241
|
-
throw new RequestRejectedByPolicyError(opts.requestId, opts.kind, modelId, `request queue for this model is full (${st.waiters.length} waiting)`);
|
|
242
|
-
}
|
|
243
|
-
const queue = st;
|
|
244
|
-
const granted = await new Promise((resolve, reject) => {
|
|
245
|
-
const waiter = {
|
|
246
|
-
requestId: opts.requestId,
|
|
247
|
-
kind: opts.kind,
|
|
248
|
-
modelId,
|
|
249
|
-
enqueuedAt: Date.now(),
|
|
250
|
-
resolve,
|
|
251
|
-
reject,
|
|
252
|
-
timer: undefined,
|
|
253
|
-
exclusive,
|
|
254
|
-
cap: maxConcurrent
|
|
255
|
-
};
|
|
256
|
-
if (policy.queueTimeoutMs !== undefined) {
|
|
257
|
-
const timeoutMs = policy.queueTimeoutMs;
|
|
258
|
-
waiter.timer = setTimeout(() => {
|
|
259
|
-
removeWaiter(key, waiter);
|
|
260
|
-
reject(new RequestRejectedByPolicyError(opts.requestId, opts.kind, modelId, `timed out waiting ${timeoutMs}ms for a slot on this model`));
|
|
261
|
-
}, timeoutMs);
|
|
262
|
-
}
|
|
263
|
-
queue.waiters.push(waiter);
|
|
264
|
-
waitersById.set(opts.requestId, { key, waiter });
|
|
265
|
-
});
|
|
266
|
-
return granted ? { slotKey: key, exclusive } : { slotKey: undefined, exclusive: false };
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Grant the lane to as many FIFO-head waiters as now fit: an exclusive writer
|
|
270
|
-
* only when the lane is idle, readers up to each one's own cap. Stops at the
|
|
271
|
-
* first head that can't be admitted, so FIFO order holds. Deletes the
|
|
272
|
-
* `KeyState` once fully idle.
|
|
273
|
-
*/
|
|
274
|
-
function drain(st, key) {
|
|
275
|
-
while (st.waiters.length > 0) {
|
|
276
|
-
const head = st.waiters[0];
|
|
277
|
-
if (head === undefined)
|
|
278
|
-
break;
|
|
279
|
-
if (head.exclusive) {
|
|
280
|
-
if (st.exclusiveActive || st.active > 0)
|
|
281
|
-
break;
|
|
282
|
-
st.exclusiveActive = true;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
const readerCap = st.readerCap ?? head.cap;
|
|
286
|
-
if (st.exclusiveActive || st.active >= readerCap)
|
|
287
|
-
break;
|
|
288
|
-
st.active++;
|
|
289
|
-
if (st.readerCap === undefined)
|
|
290
|
-
st.readerCap = head.cap;
|
|
291
|
-
}
|
|
292
|
-
st.waiters.shift();
|
|
293
|
-
waitersById.delete(head.requestId);
|
|
294
|
-
if (head.timer !== undefined) {
|
|
295
|
-
clearTimeout(head.timer);
|
|
296
|
-
head.timer = undefined;
|
|
297
|
-
}
|
|
298
|
-
head.resolve(true);
|
|
299
|
-
}
|
|
300
|
-
if (st.active <= 0 && !st.exclusiveActive && st.waiters.length === 0) {
|
|
301
|
-
keyStates.delete(key);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Release a held slot, then hand the freed capacity to waiters. Called from
|
|
306
|
-
* `disposeEntry` after the scope has fully unwound, so its deferred teardown
|
|
307
|
-
* (for llama.cpp completion, disposing the run response that stops native
|
|
308
|
-
* decode) has run before the next same-model request is admitted.
|
|
309
|
-
*/
|
|
310
|
-
function releaseSlot(key, wasExclusive) {
|
|
311
|
-
const st = keyStates.get(key);
|
|
312
|
-
if (!st)
|
|
313
|
-
return;
|
|
314
|
-
if (wasExclusive)
|
|
315
|
-
st.exclusiveActive = false;
|
|
316
|
-
else
|
|
317
|
-
st.active--;
|
|
318
|
-
drain(st, key);
|
|
319
|
-
}
|
|
320
|
-
function cancelEntry(entry, reason) {
|
|
321
|
-
if (entry.controller.signal.aborted)
|
|
322
|
-
return false;
|
|
323
|
-
entry.ctx.state = 'cancelling';
|
|
324
|
-
entry.controller.abort(reason);
|
|
325
|
-
logLifecycle('cancel', entry.ctx);
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
async function disposeEntry(entry, outcome) {
|
|
329
|
-
if (entry.scope.disposed || entry.disposing)
|
|
330
|
-
return;
|
|
331
|
-
entry.disposing = true;
|
|
332
|
-
disposingEntries.add(entry);
|
|
333
|
-
// Keep the id reserved across async teardown so a same-id begin can't
|
|
334
|
-
// activate concurrently and a cancel can't strand a tripwire for a reuse.
|
|
335
|
-
disposingIds.add(entry.ctx.requestId);
|
|
336
|
-
entry.ctx.state = outcome;
|
|
337
|
-
entry.detachParent();
|
|
338
|
-
logLifecycle('end', entry.ctx, Date.now() - entry.startedAt);
|
|
339
|
-
// Pull the entry out before unwinding so observers (e.g. a `cancel(...)`
|
|
340
|
-
// racing with dispose) don't see a half-disposed context.
|
|
341
|
-
entries.delete(entry.ctx.requestId);
|
|
342
|
-
try {
|
|
343
|
-
await entry.scope[Symbol.asyncDispose]();
|
|
344
|
-
}
|
|
345
|
-
finally {
|
|
346
|
-
// Release the admission slot only after the scope has fully unwound:
|
|
347
|
-
// the shared llama.cpp context / addon job is torn down in scope
|
|
348
|
-
// cleanup, so the next queued same-model request must not be admitted
|
|
349
|
-
// (and start decoding) until this one has actually let go. `finally`
|
|
350
|
-
// guarantees the slot is freed even if a deferred cleanup throws,
|
|
351
|
-
// otherwise a throwing teardown would strand the queue forever.
|
|
352
|
-
if (entry.slotKey !== undefined)
|
|
353
|
-
releaseSlot(entry.slotKey, entry.exclusive);
|
|
354
|
-
disposingEntries.delete(entry);
|
|
355
|
-
// The id is free for reuse only now that native teardown is complete.
|
|
356
|
-
disposingIds.delete(entry.ctx.requestId);
|
|
357
|
-
// Signal any `cancelAndDrain` waiting on this request that its native
|
|
358
|
-
// teardown is complete.
|
|
359
|
-
entry.resolveDisposed();
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
async function begin(opts) {
|
|
363
|
-
// A request id is reserved for its whole lifecycle: the time it spends
|
|
364
|
-
// *queued* for an admission slot, while it is active, and while it is
|
|
365
|
-
// tearing down. `waitersById` holds the still-queued begins (not yet in
|
|
366
|
-
// `entries`) and `disposingIds` holds the ones whose async teardown hasn't
|
|
367
|
-
// finished, so a duplicate id must be rejected against all of them —
|
|
368
|
-
// otherwise a second begin with the same id would enqueue behind the first
|
|
369
|
-
// and overwrite its `waitersById` index (unreachable by `cancel(...)`), or
|
|
370
|
-
// activate while the prior request is still releasing its native context.
|
|
371
|
-
if (entries.has(opts.requestId) ||
|
|
372
|
-
waitersById.has(opts.requestId) ||
|
|
373
|
-
reservedIds.has(opts.requestId) ||
|
|
374
|
-
disposingIds.has(opts.requestId)) {
|
|
375
|
-
throw new RequestIdConflictError(opts.requestId);
|
|
376
|
-
}
|
|
377
|
-
// Reserve synchronously so a same-tick duplicate begin is rejected before
|
|
378
|
-
// this one reaches `entries`/`waitersById`. Cleared on every exit below.
|
|
379
|
-
reservedIds.add(opts.requestId);
|
|
380
|
-
// A request cancelled BEFORE begin must not queue for a slot on a saturated
|
|
381
|
-
// lane: consume its marker first and skip admission, so it resolves at once
|
|
382
|
-
// into an aborted context holding no slot instead of waiting for the holder.
|
|
383
|
-
let preCancel = consumeCancelBeforeBegin(opts.requestId);
|
|
384
|
-
// Admission control runs before allocation so a rejected begin leaves no
|
|
385
|
-
// controller / scope behind. This may await: a gated `(kind, modelId)` at
|
|
386
|
-
// capacity queues the begin FIFO and resolves once a slot frees (or rejects
|
|
387
|
-
// on overflow / queue-depth cap / timeout).
|
|
388
|
-
let slotKey;
|
|
389
|
-
let exclusive = false;
|
|
390
|
-
if (!preCancel) {
|
|
391
|
-
// Plain try/catch, not `.catch()`, so admission adds no extra microtask
|
|
392
|
-
// and observers still see the request registered on the same tick.
|
|
393
|
-
let acquired;
|
|
394
|
-
try {
|
|
395
|
-
acquired = await acquireSlot(opts);
|
|
396
|
-
}
|
|
397
|
-
catch (err) {
|
|
398
|
-
reservedIds.delete(opts.requestId);
|
|
399
|
-
throw err;
|
|
400
|
-
}
|
|
401
|
-
slotKey = acquired.slotKey;
|
|
402
|
-
exclusive = acquired.exclusive;
|
|
403
|
-
// The only interleaving point in this otherwise synchronous body is the
|
|
404
|
-
// await above. A duplicate id could (astronomically unlikely) have landed
|
|
405
|
-
// while we were queued — re-check and hand the just-acquired slot back
|
|
406
|
-
// rather than stranding it on the conflicting throw.
|
|
407
|
-
if (entries.has(opts.requestId)) {
|
|
408
|
-
if (slotKey !== undefined)
|
|
409
|
-
releaseSlot(slotKey, exclusive);
|
|
410
|
-
reservedIds.delete(opts.requestId);
|
|
411
|
-
throw new RequestIdConflictError(opts.requestId);
|
|
412
|
-
}
|
|
413
|
-
// A cancel that landed WHILE we were queued resolved acquireSlot with no
|
|
414
|
-
// slot and recorded a marker; consume it so the context starts aborted.
|
|
415
|
-
preCancel = consumeCancelBeforeBegin(opts.requestId);
|
|
416
|
-
}
|
|
417
|
-
// A begin arriving while its model is being torn down starts aborted — no
|
|
418
|
-
// native work against a model about to be freed.
|
|
419
|
-
const drainReason = opts.modelId !== undefined && drainingModels.has(opts.modelId) ? 'modelUnload' : undefined;
|
|
420
|
-
const controller = new AbortController();
|
|
421
|
-
const scope = createDisposableScope();
|
|
422
|
-
if (preCancel) {
|
|
423
|
-
controller.abort(preCancel.reason);
|
|
424
|
-
}
|
|
425
|
-
else if (drainReason) {
|
|
426
|
-
controller.abort(drainReason);
|
|
427
|
-
}
|
|
428
|
-
let detachParent = () => { };
|
|
429
|
-
if (opts.parentSignal) {
|
|
430
|
-
const parent = opts.parentSignal;
|
|
431
|
-
if (parent.aborted) {
|
|
432
|
-
controller.abort(parent.reason);
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
const onParentAbort = () => controller.abort(parent.reason);
|
|
436
|
-
parent.addEventListener('abort', onParentAbort, { once: true });
|
|
437
|
-
detachParent = () => parent.removeEventListener('abort', onParentAbort);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
const ctx = {
|
|
441
|
-
requestId: opts.requestId,
|
|
442
|
-
kind: opts.kind,
|
|
443
|
-
modelId: opts.modelId,
|
|
444
|
-
signal: controller.signal,
|
|
445
|
-
scope,
|
|
446
|
-
// Land the context in `cancelling` from the outset whenever the
|
|
447
|
-
// controller was already aborted by `begin(...)` itself — either
|
|
448
|
-
// the Stop-button race (`preCancel`) or a `parentSignal` that was
|
|
449
|
-
// already aborted at begin time. Both branches abort the
|
|
450
|
-
// controller above, so without this guard observers would see a
|
|
451
|
-
// momentarily-`running` context with an already-aborted signal.
|
|
452
|
-
state: preCancel || drainReason || opts.parentSignal?.aborted ? 'cancelling' : 'running'
|
|
453
|
-
};
|
|
454
|
-
let resolveDisposed = () => { };
|
|
455
|
-
const disposed = new Promise((resolve) => {
|
|
456
|
-
resolveDisposed = resolve;
|
|
457
|
-
});
|
|
458
|
-
const entry = {
|
|
459
|
-
ctx,
|
|
460
|
-
controller,
|
|
461
|
-
scope,
|
|
462
|
-
detachParent,
|
|
463
|
-
startedAt: Date.now(),
|
|
464
|
-
slotKey,
|
|
465
|
-
exclusive,
|
|
466
|
-
disposing: false,
|
|
467
|
-
disposed,
|
|
468
|
-
resolveDisposed
|
|
469
|
-
};
|
|
470
|
-
entries.set(opts.requestId, entry);
|
|
471
|
-
reservedIds.delete(opts.requestId);
|
|
472
|
-
logLifecycle('begin', ctx);
|
|
473
|
-
return {
|
|
474
|
-
get requestId() {
|
|
475
|
-
return ctx.requestId;
|
|
476
|
-
},
|
|
477
|
-
get kind() {
|
|
478
|
-
return ctx.kind;
|
|
479
|
-
},
|
|
480
|
-
get modelId() {
|
|
481
|
-
return ctx.modelId;
|
|
482
|
-
},
|
|
483
|
-
get signal() {
|
|
484
|
-
return ctx.signal;
|
|
485
|
-
},
|
|
486
|
-
get scope() {
|
|
487
|
-
return ctx.scope;
|
|
488
|
-
},
|
|
489
|
-
get state() {
|
|
490
|
-
return ctx.state;
|
|
491
|
-
},
|
|
492
|
-
set state(next) {
|
|
493
|
-
ctx.state = next;
|
|
494
|
-
},
|
|
495
|
-
[Symbol.asyncDispose]: async () => {
|
|
496
|
-
await disposeEntry(entry, derivedTerminalState(ctx));
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
function get(requestId) {
|
|
501
|
-
return entries.get(requestId)?.ctx ?? null;
|
|
502
|
-
}
|
|
503
|
-
function list() {
|
|
504
|
-
return Array.from(entries.values(), (e) => e.ctx);
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Cancel a still-queued waiter the same way the Stop-button race is
|
|
508
|
-
* handled: record a cancel-before-begin so its `begin(...)` — which
|
|
509
|
-
* resumes the instant we `resolve(false)` (without a slot) — observes the
|
|
510
|
-
* cancel and returns an already-aborted context. The request thus ends in
|
|
511
|
-
* a clean `cancelled` state rather than throwing.
|
|
512
|
-
*/
|
|
513
|
-
function cancelQueuedWaiterGracefully(key, waiter, reason) {
|
|
514
|
-
recordCancelBeforeBegin(waiter.requestId, reason);
|
|
515
|
-
removeWaiter(key, waiter);
|
|
516
|
-
waiter.resolve(false);
|
|
517
|
-
}
|
|
518
|
-
function cancel(target) {
|
|
519
|
-
let cancelled = 0;
|
|
520
|
-
if ('requestId' in target) {
|
|
521
|
-
const entry = entries.get(target.requestId);
|
|
522
|
-
if (entry) {
|
|
523
|
-
if (cancelEntry(entry, target.reason))
|
|
524
|
-
cancelled++;
|
|
525
|
-
return cancelled;
|
|
526
|
-
}
|
|
527
|
-
// Queued (still waiting for an admission slot)? It has no controller
|
|
528
|
-
// yet, so cancel it through the cancel-before-begin tripwire: pull it
|
|
529
|
-
// from the FIFO and let its begin() resume into an aborted context.
|
|
530
|
-
// Counted as one — unlike the pure race below, this targets a known
|
|
531
|
-
// in-flight (queued) begin, so the Stop button feels responsive
|
|
532
|
-
// instead of waiting for the slot to free first.
|
|
533
|
-
const queued = waitersById.get(target.requestId);
|
|
534
|
-
if (queued) {
|
|
535
|
-
cancelQueuedWaiterGracefully(queued.key, queued.waiter, target.reason);
|
|
536
|
-
return cancelled + 1;
|
|
537
|
-
}
|
|
538
|
-
// Mid-disposal: the request already reached a terminal outcome and is
|
|
539
|
-
// releasing its native context. There is nothing to cancel, and a
|
|
540
|
-
// cancel-before-begin marker would wrongly abort a later begin that
|
|
541
|
-
// reuses this id once teardown frees it.
|
|
542
|
-
if (disposingIds.has(target.requestId))
|
|
543
|
-
return cancelled;
|
|
544
|
-
// Stop-button race: the client beat its own
|
|
545
|
-
// `begin(...)`. Record the cancel so the next matching `begin`
|
|
546
|
-
// aborts immediately. The return value stays 0 — no in-flight
|
|
547
|
-
// request was matched, which is still the truth — but the
|
|
548
|
-
// *effective* cancel will land when the begin arrives.
|
|
549
|
-
recordCancelBeforeBegin(target.requestId, target.reason);
|
|
550
|
-
return cancelled;
|
|
551
|
-
}
|
|
552
|
-
for (const entry of entries.values()) {
|
|
553
|
-
if (entry.ctx.modelId !== target.modelId)
|
|
554
|
-
continue;
|
|
555
|
-
if (target.kind && entry.ctx.kind !== target.kind)
|
|
556
|
-
continue;
|
|
557
|
-
if (cancelEntry(entry, target.reason))
|
|
558
|
-
cancelled++;
|
|
559
|
-
}
|
|
560
|
-
// Queued waiters aren't in `entries`; drain the ones matching this
|
|
561
|
-
// model (and optional kind) so a broad `cancel({ modelId })` doesn't
|
|
562
|
-
// strand them behind a request that's being cancelled out from under
|
|
563
|
-
// them. Snapshot first — `removeWaiter` mutates `waitersById`.
|
|
564
|
-
for (const { key, waiter } of Array.from(waitersById.values())) {
|
|
565
|
-
if (waiter.modelId !== target.modelId)
|
|
566
|
-
continue;
|
|
567
|
-
if (target.kind && waiter.kind !== target.kind)
|
|
568
|
-
continue;
|
|
569
|
-
cancelQueuedWaiterGracefully(key, waiter, target.reason);
|
|
570
|
-
cancelled++;
|
|
571
|
-
}
|
|
572
|
-
return cancelled;
|
|
573
|
-
}
|
|
574
|
-
function cancelAll(reason) {
|
|
575
|
-
for (const entry of entries.values()) {
|
|
576
|
-
cancelEntry(entry, reason);
|
|
577
|
-
}
|
|
578
|
-
// Drain every queued waiter so a shutdown / model-unload sweep can't
|
|
579
|
-
// leave a `begin(...)` promise hung forever — which would in turn block
|
|
580
|
-
// the unload waiting on a request that never resolves. Unlike the
|
|
581
|
-
// targeted cancels above these *reject* rather than resolve-into-
|
|
582
|
-
// aborted: the model / worker they queued against is being torn down,
|
|
583
|
-
// so there is nothing left for them to run. Snapshot first —
|
|
584
|
-
// `removeWaiter` mutates `waitersById`.
|
|
585
|
-
for (const { key, waiter } of Array.from(waitersById.values())) {
|
|
586
|
-
removeWaiter(key, waiter, false);
|
|
587
|
-
waiter.reject(new RequestRejectedByPolicyError(waiter.requestId, waiter.kind, waiter.modelId, `queued request cancelled (${reason})`));
|
|
588
|
-
}
|
|
589
|
-
// Fire-and-forget the abort; each handler unwinds on its own dispose path.
|
|
590
|
-
return Promise.resolve();
|
|
591
|
-
}
|
|
592
|
-
// Cancel and drain every request for a model, then run `teardown` with the
|
|
593
|
-
// admission barrier held — any begin for the model (including one still
|
|
594
|
-
// suspended in admission) starts aborted — lifting it afterward. Scoped so the
|
|
595
|
-
// barrier can't be left raised.
|
|
596
|
-
async function withModelDraining(modelId, teardown) {
|
|
597
|
-
drainingModels.add(modelId);
|
|
598
|
-
try {
|
|
599
|
-
// Abort each active request and collect its disposal promise, so we wait
|
|
600
|
-
// for every handler's scope to fully unwind (native context freed, slot
|
|
601
|
-
// released) before teardown. Snapshot first — `disposeEntry` mutates
|
|
602
|
-
// `entries`.
|
|
603
|
-
const draining = [];
|
|
604
|
-
for (const entry of entries.values()) {
|
|
605
|
-
if (entry.ctx.modelId !== modelId)
|
|
606
|
-
continue;
|
|
607
|
-
cancelEntry(entry, 'modelUnload');
|
|
608
|
-
draining.push(entry.disposed);
|
|
609
|
-
}
|
|
610
|
-
// Requests already mid-disposal are out of `entries` but may still be
|
|
611
|
-
// tearing down natively — wait for them too.
|
|
612
|
-
for (const entry of disposingEntries) {
|
|
613
|
-
if (entry.ctx.modelId === modelId)
|
|
614
|
-
draining.push(entry.disposed);
|
|
615
|
-
}
|
|
616
|
-
// Queued waiters never held a slot, so just abort their begins.
|
|
617
|
-
for (const { key, waiter } of Array.from(waitersById.values())) {
|
|
618
|
-
if (waiter.modelId === modelId)
|
|
619
|
-
cancelQueuedWaiterGracefully(key, waiter, 'modelUnload');
|
|
620
|
-
}
|
|
621
|
-
await Promise.all(draining);
|
|
622
|
-
await teardown();
|
|
623
|
-
}
|
|
624
|
-
finally {
|
|
625
|
-
drainingModels.delete(modelId);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
async function end(requestId, outcome) {
|
|
629
|
-
const entry = entries.get(requestId);
|
|
630
|
-
if (!entry)
|
|
631
|
-
return;
|
|
632
|
-
await disposeEntry(entry, outcome);
|
|
633
|
-
}
|
|
634
|
-
function policy(opts) {
|
|
635
|
-
policies.set(opts.kind, normalizePolicy(opts));
|
|
636
|
-
}
|
|
637
|
-
return {
|
|
638
|
-
begin,
|
|
639
|
-
get,
|
|
640
|
-
list,
|
|
641
|
-
cancel,
|
|
642
|
-
cancelAll,
|
|
643
|
-
withModelDraining,
|
|
644
|
-
end,
|
|
645
|
-
policy,
|
|
646
|
-
// Test-only: lets the registry race tests assert the bound
|
|
647
|
-
// invariants on the internal "cancelled-before-begin" set without
|
|
648
|
-
// exposing it as a public surface. Kept off the `RequestRegistry`
|
|
649
|
-
// interface (typed via the augmented return type below) so handler
|
|
650
|
-
// code can't depend on it accidentally.
|
|
651
|
-
__cancelBeforeBeginSize: () => cancelledBeforeBegin.size,
|
|
652
|
-
// Test-only: the number of live per-`(kind, modelId)` admission
|
|
653
|
-
// states. Lets the queue tests assert the map empties on drain /
|
|
654
|
-
// dispose (no `KeyState` leak). Also off the public interface.
|
|
655
|
-
__keyStateSize: () => keyStates.size
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
// A finite slot count floored to an integer >= 1: a value below 1 would gate
|
|
659
|
-
// every request forever and a fractional one could over-admit. Callers gate on
|
|
660
|
-
// `Number.isFinite` first — Infinity means "ungated" and must stay Infinity.
|
|
661
|
-
function clampSlotCount(count) {
|
|
662
|
-
return Math.max(1, Math.floor(count));
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Resolve a `ConcurrencyPolicy` to concrete numbers, applying defaults and
|
|
666
|
-
* the deprecated `oneAtATimePerModel` alias. Done once at registration so
|
|
667
|
-
* the `begin(...)` hot path reads plain numbers.
|
|
668
|
-
*/
|
|
669
|
-
function normalizePolicy(opts) {
|
|
670
|
-
let maxConcurrent;
|
|
671
|
-
let onOverflow;
|
|
672
|
-
if (opts.maxConcurrentPerModel !== undefined) {
|
|
673
|
-
maxConcurrent = opts.maxConcurrentPerModel;
|
|
674
|
-
onOverflow = opts.onOverflow ?? 'queue';
|
|
675
|
-
}
|
|
676
|
-
else if (opts.oneAtATimePerModel === true) {
|
|
677
|
-
// Legacy alias: at most one in-flight per model, reject the rest.
|
|
678
|
-
maxConcurrent = 1;
|
|
679
|
-
onOverflow = opts.onOverflow ?? 'reject';
|
|
680
|
-
}
|
|
681
|
-
else {
|
|
682
|
-
// Nothing configured (includes `oneAtATimePerModel: false`) ⇒ no gating.
|
|
683
|
-
maxConcurrent = Infinity;
|
|
684
|
-
onOverflow = opts.onOverflow ?? 'queue';
|
|
685
|
-
}
|
|
686
|
-
if (Number.isFinite(maxConcurrent))
|
|
687
|
-
maxConcurrent = clampSlotCount(maxConcurrent);
|
|
688
|
-
return {
|
|
689
|
-
maxConcurrent,
|
|
690
|
-
onOverflow,
|
|
691
|
-
maxQueueDepth: opts.maxQueueDepthPerModel ?? DEFAULT_MAX_QUEUE_DEPTH_PER_MODEL,
|
|
692
|
-
queueTimeoutMs: opts.queueTimeoutMs,
|
|
693
|
-
slotGroup: opts.sharedSlotGroup,
|
|
694
|
-
exclusive: opts.exclusive === true
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Test-only knobs exported for `request-registry.test.ts` so the bound
|
|
699
|
-
* assertions can pin the documented limits without re-reading them via
|
|
700
|
-
* fragile string comparison. **Not part of the public SDK surface.**
|
|
701
|
-
*
|
|
702
|
-
* @internal
|
|
703
|
-
*/
|
|
704
|
-
export const __requestRegistryTestHooks = {
|
|
705
|
-
cancelBeforeBeginMaxEntries: CANCEL_BEFORE_BEGIN_MAX_ENTRIES,
|
|
706
|
-
cancelBeforeBeginTtlMs: CANCEL_BEFORE_BEGIN_TTL_MS,
|
|
707
|
-
defaultMaxQueueDepthPerModel: DEFAULT_MAX_QUEUE_DEPTH_PER_MODEL
|
|
708
|
-
};
|
|
709
|
-
function derivedTerminalState(ctx) {
|
|
710
|
-
if (ctx.state === 'failed')
|
|
711
|
-
return 'failed';
|
|
712
|
-
if (ctx.signal.aborted || ctx.state === 'cancelled')
|
|
713
|
-
return 'cancelled';
|
|
714
|
-
return 'completed';
|
|
715
|
-
}
|