@qvac/sdk 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +87 -84
- package/README.md +65 -0
- package/dist/client/api/audio-gen-result.d.ts +4 -0
- package/dist/client/api/audio-gen-result.js +132 -0
- package/dist/client/api/audio-gen.d.ts +29 -0
- package/dist/client/api/audio-gen.js +31 -0
- package/dist/client/api/batch-completion.d.ts +2 -2
- package/dist/client/api/batch-completion.js +2 -2
- package/dist/client/api/bci-transcribe.d.ts +1 -1
- package/dist/client/api/bci-transcribe.js +3 -3
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +1 -1
- package/dist/client/api/classify.d.ts +1 -1
- package/dist/client/api/classify.js +1 -1
- package/dist/client/api/completion-stream.d.ts +3 -3
- package/dist/client/api/completion-stream.js +3 -3
- package/dist/client/api/delete-cache.js +1 -1
- package/dist/client/api/diffusion.d.ts +1 -1
- package/dist/client/api/diffusion.js +1 -1
- package/dist/client/api/download-asset.d.ts +1 -1
- package/dist/client/api/download-asset.js +3 -3
- package/dist/client/api/embed.d.ts +1 -1
- package/dist/client/api/embed.js +2 -2
- package/dist/client/api/finetune.d.ts +1 -1
- package/dist/client/api/finetune.js +2 -2
- package/dist/client/api/get-loaded-model-info.d.ts +2 -2
- package/dist/client/api/get-loaded-model-info.js +1 -1
- package/dist/client/api/get-model-info.d.ts +2 -2
- package/dist/client/api/get-model-info.js +1 -1
- package/dist/client/api/get-system-resources.d.ts +3 -0
- package/dist/client/api/get-system-resources.js +16 -0
- package/dist/client/api/heartbeat.d.ts +2 -2
- package/dist/client/api/heartbeat.js +1 -1
- package/dist/client/api/index.d.ts +35 -33
- package/dist/client/api/index.js +2 -0
- package/dist/client/api/invoke-plugin.d.ts +1 -1
- package/dist/client/api/invoke-plugin.js +1 -1
- package/dist/client/api/load-model.d.ts +2 -2
- package/dist/client/api/load-model.js +4 -4
- package/dist/client/api/logging-stream.d.ts +1 -1
- package/dist/client/api/logging-stream.js +1 -1
- package/dist/client/api/ocr.d.ts +10 -1
- package/dist/client/api/ocr.js +10 -1
- package/dist/client/api/provide.d.ts +1 -1
- package/dist/client/api/provide.js +1 -1
- package/dist/client/api/rag.d.ts +1 -1
- package/dist/client/api/rag.js +2 -2
- package/dist/client/api/registry.d.ts +1 -1
- package/dist/client/api/registry.js +1 -1
- package/dist/client/api/resume.js +1 -1
- package/dist/client/api/state.d.ts +1 -1
- package/dist/client/api/state.js +1 -1
- package/dist/client/api/stop-provider.js +1 -1
- package/dist/client/api/subscribe-logs.d.ts +1 -1
- package/dist/client/api/suspend.js +1 -1
- package/dist/client/api/text-to-speech.d.ts +3 -2
- package/dist/client/api/text-to-speech.js +31 -9
- package/dist/client/api/transcribe.d.ts +1 -1
- package/dist/client/api/transcribe.js +2 -2
- package/dist/client/api/translate.d.ts +1 -1
- package/dist/client/api/translate.js +7 -18
- package/dist/client/api/unload-model.d.ts +1 -1
- package/dist/client/api/unload-model.js +2 -2
- package/dist/client/api/upscale.d.ts +1 -1
- package/dist/client/api/upscale.js +1 -1
- package/dist/client/api/video.d.ts +8 -5
- package/dist/client/api/video.js +9 -6
- package/dist/client/api/vla.d.ts +15 -11
- package/dist/client/api/vla.js +14 -10
- package/dist/client/config-loader/config-utils.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.bare.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.expo.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.node.d.ts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/init-hooks.d.ts +1 -1
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/plugins-factory.d.ts +2 -2
- package/dist/client/plugins-factory.js +1 -1
- package/dist/client/rpc/bare-client.d.ts +1 -1
- package/dist/client/rpc/bare-client.js +3 -3
- package/dist/client/rpc/expo-rpc-client.js +3 -3
- package/dist/client/rpc/node-rpc-client.js +2 -2
- package/dist/client/rpc/profiling/index.d.ts +1 -1
- package/dist/client/rpc/profiling/profiler.d.ts +2 -2
- package/dist/client/rpc/profiling/profiler.js +4 -0
- package/dist/client/rpc/rpc-client.d.ts +1 -1
- package/dist/client/rpc/rpc-client.js +7 -4
- package/dist/client/rpc/rpc-error.d.ts +1 -1
- package/dist/client/rpc/rpc-error.js +7 -1
- package/dist/commands/bundle/bare-pack.d.ts +1 -1
- package/dist/commands/bundle/constants.js +1 -0
- package/dist/commands/bundle/entry-gen.js +1 -1
- package/dist/commands/bundle/index.js +6 -6
- package/dist/commands/bundle/manifest.d.ts +1 -1
- package/dist/commands/bundle/plugins.d.ts +2 -2
- package/dist/commands/bundle/plugins.js +1 -1
- package/dist/commands/index.d.ts +4 -4
- package/dist/commands/index.js +2 -2
- package/dist/commands/verify/abi.d.ts +1 -1
- package/dist/commands/verify/abi.js +1 -1
- package/dist/commands/verify/bundle-source.d.ts +1 -1
- package/dist/commands/verify/bundle-source.js +2 -2
- package/dist/commands/verify/index.d.ts +3 -3
- package/dist/commands/verify/index.js +5 -5
- package/dist/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/commands/verify/node-modules-source.js +1 -1
- package/dist/commands/verify/prebuilds.d.ts +2 -1
- package/dist/commands/verify/prebuilds.js +8 -11
- package/dist/commands/verify/resource-collectors.d.ts +88 -0
- package/dist/commands/verify/resource-collectors.js +261 -0
- package/dist/constants/audio.js +1 -1
- package/dist/constants/index.d.ts +2 -2
- package/dist/examples/{transcription → asr}/parakeet-ctc-filesystem.js +2 -3
- package/dist/examples/{transcription → asr}/parakeet-microphone-record.js +2 -2
- package/dist/examples/{transcription → asr}/parakeet-microphone-stream.js +2 -2
- package/dist/examples/{transcription → asr}/parakeet-sortformer-streaming.js +2 -2
- package/dist/examples/{transcription → asr}/parakeet-sortformer.js +1 -1
- package/dist/examples/asr/parakeet-tdt-filesystem-chunked.d.ts +2 -0
- package/dist/examples/asr/parakeet-tdt-filesystem-chunked.js +203 -0
- package/dist/examples/{transcription → asr}/parakeet-tdt-filesystem.js +2 -2
- package/dist/examples/{transcription → asr}/whispercpp-filesystem-streaming.js +1 -1
- package/dist/examples/{transcription → asr}/whispercpp-filesystem.js +1 -1
- package/dist/examples/{transcription → asr}/whispercpp-microphone-conversation.js +1 -1
- package/dist/examples/{transcription → asr}/whispercpp-microphone-record.js +2 -2
- package/dist/examples/{transcription → asr}/whispercpp-prompt.js +1 -1
- package/dist/examples/audiogen/generate-music.d.ts +2 -0
- package/dist/examples/audiogen/generate-music.js +112 -0
- package/dist/examples/cache-management.js +1 -1
- package/dist/examples/config-reload.js +1 -1
- package/dist/examples/diffusion-ideogram.d.ts +2 -0
- package/dist/examples/diffusion-ideogram.js +108 -0
- package/dist/examples/diffusion-img2vid-ltx.d.ts +2 -0
- package/dist/examples/diffusion-img2vid-ltx.js +98 -0
- package/dist/examples/diffusion-txt2vid-ltx.d.ts +2 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +92 -0
- package/dist/examples/diffusion-txt2vid-wan22.d.ts +2 -0
- package/dist/examples/diffusion-txt2vid-wan22.js +96 -0
- package/dist/examples/logging-streaming.js +5 -1
- package/dist/examples/quickstart.bare.js +1 -1
- package/dist/examples/rag/rag-mongodb.d.ts +2 -0
- package/dist/examples/rag/rag-mongodb.js +180 -0
- package/dist/examples/tools/llamacpp-tools-auto-dialect.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-auto-dialect.js +77 -0
- package/dist/examples/tts/parler.d.ts +2 -0
- package/dist/examples/tts/parler.js +51 -0
- package/dist/examples/vla-groot.d.ts +2 -0
- package/dist/examples/vla-groot.js +120 -0
- package/dist/examples/voice-assistant/voice-assistant.js +2 -2
- package/dist/expo/plugins/index.d.ts +11 -11
- package/dist/expo/plugins/withDeviceInfo.js +2 -2
- package/dist/expo/plugins/withMobileBundle.js +3 -3
- package/dist/index.d.ts +16 -16
- package/dist/index.js +4 -4
- package/dist/logging/addon.d.ts +1 -1
- package/dist/logging/base-logger.d.ts +1 -1
- package/dist/logging/base-logger.js +1 -1
- package/dist/logging/client-logger.d.ts +1 -1
- package/dist/logging/index.d.ts +9 -9
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/namespaces.d.ts +1 -1
- package/dist/logging/registry.d.ts +1 -1
- package/dist/logging/server-logger.d.ts +1 -1
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/transport.d.ts +1 -1
- package/dist/logging/utils.d.ts +1 -1
- package/dist/logging/utils.js +1 -1
- package/dist/models/registry/index.d.ts +1 -1
- package/dist/models/registry/models.d.ts +6443 -9832
- package/dist/models/registry/models.js +4076 -7658
- package/dist/models/update-models/codegen.d.ts +1 -1
- package/dist/models/update-models/companions.d.ts +1 -1
- package/dist/models/update-models/history.d.ts +1 -1
- package/dist/models/update-models/history.js +4 -4
- package/dist/models/update-models/naming.d.ts +1 -1
- package/dist/models/update-models/naming.js +12 -2
- package/dist/models/update-models/processing.d.ts +1 -1
- package/dist/models/update-models/processing.js +1 -1
- package/dist/models/update-models/registry.d.ts +2 -2
- package/dist/models/update-models/shards.d.ts +1 -1
- package/dist/models/update-models/types.d.ts +1 -1
- package/dist/pear/pre.js +2 -0
- package/dist/profiling/aggregator.d.ts +1 -1
- package/dist/profiling/backend-diagnostics.d.ts +8 -0
- package/dist/profiling/backend-diagnostics.js +21 -0
- package/dist/profiling/controller.d.ts +4 -2
- package/dist/profiling/controller.js +8 -0
- package/dist/profiling/envelope.d.ts +3 -2
- package/dist/profiling/envelope.js +13 -2
- package/dist/profiling/events.d.ts +2 -2
- package/dist/profiling/exporters.d.ts +1 -1
- package/dist/profiling/index.d.ts +9 -8
- package/dist/profiling/index.js +3 -2
- package/dist/profiling/types.d.ts +6 -0
- package/dist/schemas/audio-gen.d.ts +253 -0
- package/dist/schemas/audio-gen.js +69 -0
- package/dist/schemas/batch-completion-stream.d.ts +11 -6
- package/dist/schemas/bci-config.d.ts +2 -0
- package/dist/schemas/bci.d.ts +1 -1
- package/dist/schemas/cancel.d.ts +5 -0
- package/dist/schemas/cancel.js +1 -0
- package/dist/schemas/common.d.ts +1938 -58
- package/dist/schemas/common.js +9 -1
- package/dist/schemas/completion-event.d.ts +5 -2
- package/dist/schemas/completion-event.js +3 -0
- package/dist/schemas/completion-stream.d.ts +195 -3
- package/dist/schemas/completion-stream.js +72 -2
- package/dist/schemas/constants-registry.d.ts +69 -0
- package/dist/schemas/constants-registry.js +52 -0
- package/dist/schemas/delete-cache.js +7 -3
- package/dist/schemas/download-asset.d.ts +8 -4
- package/dist/schemas/engine-addon-map.d.ts +3 -1
- package/dist/schemas/engine-addon-map.js +6 -2
- package/dist/schemas/finetune.js +6 -3
- package/dist/schemas/get-loaded-model-info.d.ts +18 -0
- package/dist/schemas/get-loaded-model-info.js +14 -6
- package/dist/schemas/get-model-info.d.ts +2 -0
- package/dist/schemas/get-model-info.js +1 -0
- package/dist/schemas/index.d.ts +53 -51
- package/dist/schemas/index.js +4 -2
- package/dist/schemas/llamacpp-config.d.ts +30 -6
- package/dist/schemas/llamacpp-config.js +1 -6
- package/dist/schemas/load-model.d.ts +7654 -2919
- package/dist/schemas/load-model.js +45 -6
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-src-utils.d.ts +10 -2
- package/dist/schemas/model-types.d.ts +19 -1
- package/dist/schemas/model-types.js +11 -0
- package/dist/schemas/ocr.d.ts +2 -0
- package/dist/schemas/plugin.d.ts +17 -8
- package/dist/schemas/plugin.js +16 -6
- package/dist/schemas/profiling.d.ts +587 -0
- package/dist/schemas/profiling.js +22 -0
- package/dist/schemas/registry.d.ts +18 -0
- package/dist/schemas/registry.js +2 -0
- package/dist/schemas/reload-config.d.ts +10 -2
- package/dist/schemas/reload-config.js +3 -1
- package/dist/schemas/sdcpp-config.d.ts +296 -0
- package/dist/schemas/sdcpp-config.js +165 -17
- package/dist/schemas/sdk-config.d.ts +958 -40
- package/dist/schemas/sdk-errors-server.js +3 -1
- package/dist/schemas/system-resources.d.ts +3967 -0
- package/dist/schemas/system-resources.js +149 -0
- package/dist/schemas/text-to-speech.d.ts +340 -6
- package/dist/schemas/text-to-speech.js +136 -17
- package/dist/schemas/tools.d.ts +1 -1
- package/dist/schemas/tools.js +2 -1
- package/dist/schemas/transcription-config.d.ts +2 -0
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/schemas/translate.js +12 -6
- package/dist/schemas/translation-config.d.ts +30 -10
- package/dist/schemas/vla.d.ts +10 -0
- package/dist/schemas/vla.js +31 -11
- package/dist/scripts/check-resource-collectors-packaging.d.ts +33 -0
- package/dist/scripts/check-resource-collectors-packaging.js +136 -0
- package/dist/scripts/contract/build-contract.d.ts +38 -0
- package/dist/scripts/contract/build-contract.js +620 -0
- package/dist/scripts/contract/build-error-codes.d.ts +17 -0
- package/dist/scripts/contract/build-error-codes.js +17 -0
- package/dist/scripts/contract/build-model-type-maps.d.ts +22 -0
- package/dist/scripts/contract/build-model-type-maps.js +16 -0
- package/dist/scripts/contract/build-models-registry.d.ts +17 -0
- package/dist/scripts/contract/build-models-registry.js +31 -0
- package/dist/scripts/contract/plugin-contract.d.ts +23 -0
- package/dist/scripts/contract/plugin-contract.js +28 -0
- package/dist/scripts/export-contract.d.ts +2 -0
- package/dist/scripts/export-contract.js +27 -0
- package/dist/scripts/export-plugin-contract.d.ts +2 -0
- package/dist/scripts/export-plugin-contract.js +18 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +1 -1
- package/dist/server/bare/delegate-rpc-client.js +3 -3
- package/dist/server/bare/hyperswarm.d.ts +1 -1
- package/dist/server/bare/hyperswarm.js +2 -2
- package/dist/server/bare/ops/bci-transcribe.d.ts +1 -1
- package/dist/server/bare/ops/bci-transcribe.js +4 -4
- package/dist/server/bare/ops/cancel.d.ts +2 -2
- package/dist/server/bare/ops/cancel.js +2 -2
- package/dist/server/bare/ops/embed.d.ts +1 -1
- package/dist/server/bare/ops/embed.js +3 -3
- package/dist/server/bare/ops/kv-cache-retention.d.ts +12 -0
- package/dist/server/bare/ops/kv-cache-retention.js +121 -0
- package/dist/server/bare/ops/kv-cache-utils.d.ts +2 -1
- package/dist/server/bare/ops/kv-cache-utils.js +26 -5
- package/dist/server/bare/ops/load-model.d.ts +2 -2
- package/dist/server/bare/ops/load-model.js +7 -5
- package/dist/server/bare/ops/transcribe.d.ts +2 -2
- package/dist/server/bare/ops/transcribe.js +20 -40
- package/dist/server/bare/ops/translate.d.ts +1 -1
- package/dist/server/bare/ops/translate.js +21 -12
- package/dist/server/bare/ops/unload-model.d.ts +1 -1
- package/dist/server/bare/ops/unload-model.js +5 -5
- package/dist/server/bare/plugins/asr-ggml/config.d.ts +32 -0
- package/dist/server/bare/plugins/asr-ggml/config.js +46 -0
- package/dist/server/bare/plugins/asr-ggml/logging.d.ts +11 -0
- package/dist/server/bare/plugins/asr-ggml/logging.js +12 -0
- package/dist/server/bare/plugins/audiogen-ggml/config.d.ts +18 -0
- package/dist/server/bare/plugins/audiogen-ggml/config.js +23 -0
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-stream.d.ts +3 -0
- package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-stream.js +162 -0
- package/dist/server/bare/plugins/audiogen-ggml/plugin.d.ts +213 -0
- package/dist/server/bare/plugins/audiogen-ggml/plugin.js +58 -0
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.d.ts +8 -5
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.js +4 -4
- package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-classification/ops/classify.js +1 -1
- package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +2 -2
- package/dist/server/bare/plugins/ggml-classification/plugin.js +1 -1
- package/dist/server/bare/plugins/ggml-ocr/ops/ocr-stream.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-ocr/ops/ocr-stream.js +2 -2
- package/dist/server/bare/plugins/ggml-ocr/plugin.d.ts +4 -2
- package/dist/server/bare/plugins/ggml-ocr/plugin.js +4 -25
- package/dist/server/bare/plugins/ggml-ocr/resolve-config.d.ts +6 -0
- package/dist/server/bare/plugins/ggml-ocr/resolve-config.js +73 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +1 -1
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +1 -1
- package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +8 -3
- package/dist/server/bare/plugins/ggml-vla/plugin.js +1 -1
- package/dist/server/bare/plugins/index.d.ts +12 -11
- package/dist/server/bare/plugins/index.js +1 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.d.ts +3 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.js +5 -5
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.d.ts +11 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.js +16 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +3 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +26 -35
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +1 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +3 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +20 -10
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +217 -80
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +8 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +8 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +20 -8
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +16 -16
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +1 -1
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +8 -3
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +5 -5
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +12 -2
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +3 -3
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +1 -1
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +6 -6
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +13 -20
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +4 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +40 -5
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +155 -5
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +109 -23
- package/dist/server/bare/plugins/tts-ggml/ops/parler-options.d.ts +7 -0
- package/dist/server/bare/plugins/tts-ggml/ops/parler-options.js +30 -0
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech-stream.d.ts +2 -2
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech-stream.js +8 -5
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech.d.ts +2 -2
- package/dist/server/bare/plugins/tts-ggml/ops/text-to-speech.js +16 -22
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +120 -5
- package/dist/server/bare/plugins/tts-ggml/plugin.js +63 -5
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +8 -6
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +17 -25
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/reindex.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.js +2 -2
- package/dist/server/bare/rag-hyperdb/index.d.ts +11 -11
- package/dist/server/bare/rag-hyperdb/index.js +11 -11
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +4 -4
- package/dist/server/bare/registry/config-registry.d.ts +1 -1
- package/dist/server/bare/registry/config-registry.js +1 -1
- package/dist/server/bare/registry/model-config-registry.d.ts +2 -2
- package/dist/server/bare/registry/model-config-registry.js +4 -4
- package/dist/server/bare/registry/model-config-utils.d.ts +1 -1
- package/dist/server/bare/registry/model-config-utils.js +3 -0
- package/dist/server/bare/registry/model-registry.d.ts +15 -4
- package/dist/server/bare/registry/registry-client.js +2 -2
- package/dist/server/bare/registry/runtime-context-registry.d.ts +1 -1
- package/dist/server/bare/resources/collector.d.ts +644 -0
- package/dist/server/bare/resources/collector.js +226 -0
- package/dist/server/bare/resources/native.d.ts +3 -0
- package/dist/server/bare/resources/native.js +35 -0
- package/dist/server/bare/resources/normalize.d.ts +13 -0
- package/dist/server/bare/resources/normalize.js +73 -0
- package/dist/server/bare/resources/types.d.ts +66 -0
- package/dist/server/bare/resources/types.js +1 -0
- package/dist/server/bare/resources/worker-collector.d.ts +5 -0
- package/dist/server/bare/resources/worker-collector.js +15 -0
- package/dist/server/bare/runtime/index.d.ts +7 -7
- package/dist/server/bare/runtime/index.js +3 -3
- package/dist/server/bare/runtime/request-context.d.ts +2 -2
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +1 -1
- package/dist/server/bare/runtime/request-registry-singleton.js +11 -1
- package/dist/server/bare/runtime/request-registry.d.ts +2 -2
- package/dist/server/bare/runtime/request-registry.js +1 -1
- package/dist/server/bare/runtime/with-request-context.d.ts +1 -1
- package/dist/server/bare/runtime-lifecycle.d.ts +1 -1
- package/dist/server/bare/types/addon-responses.d.ts +8 -34
- package/dist/server/bare/utils/asr-events.d.ts +15 -0
- package/dist/server/bare/utils/asr-events.js +30 -0
- package/dist/server/bare/utils/audio-input.d.ts +1 -1
- package/dist/server/bare/utils/audio-input.js +1 -1
- package/dist/server/bare/utils/transcribe-metadata.d.ts +1 -1
- package/dist/server/bare/utils/tts-stats.d.ts +9 -5
- package/dist/server/bare/utils/tts-stats.js +6 -0
- package/dist/server/error-handlers.d.ts +1 -1
- package/dist/server/plugins/index.d.ts +1 -1
- package/dist/server/plugins/registry.d.ts +1 -1
- package/dist/server/plugins/registry.js +35 -8
- package/dist/server/rpc/create-server.js +23 -1
- package/dist/server/rpc/delegate-transport.d.ts +2 -2
- package/dist/server/rpc/delegate-transport.js +5 -10
- package/dist/server/rpc/handle-request.js +3 -3
- package/dist/server/rpc/handler-registry.d.ts +1 -1
- package/dist/server/rpc/handler-registry.js +45 -36
- package/dist/server/rpc/handler-selection.d.ts +2 -2
- package/dist/server/rpc/handler-utils.d.ts +2 -2
- package/dist/server/rpc/handler-utils.js +5 -5
- package/dist/server/rpc/handlers/audio-gen-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/audio-gen-stream.js +4 -0
- package/dist/server/rpc/handlers/batch-completion-stream.d.ts +3 -1
- package/dist/server/rpc/handlers/batch-completion-stream.js +1 -1
- package/dist/server/rpc/handlers/bci-transcribe-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/bci-transcribe-stream.js +1 -1
- package/dist/server/rpc/handlers/bci-transcribe.d.ts +1 -1
- package/dist/server/rpc/handlers/bci-transcribe.js +1 -1
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/cancel-delegated.js +3 -3
- package/dist/server/rpc/handlers/cancelHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/cancelHandler.js +3 -3
- package/dist/server/rpc/handlers/classify.d.ts +1 -1
- package/dist/server/rpc/handlers/classify.js +1 -1
- package/dist/server/rpc/handlers/completion-orchestrate.d.ts +42 -0
- package/dist/server/rpc/handlers/completion-orchestrate.js +190 -0
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/completion-stream-delegated.js +3 -3
- package/dist/server/rpc/handlers/completion-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/completion-stream.js +1 -1
- package/dist/server/rpc/handlers/delete-cache.d.ts +1 -1
- package/dist/server/rpc/handlers/delete-cache.js +1 -1
- package/dist/server/rpc/handlers/diffusion-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/diffusion-stream.js +1 -1
- package/dist/server/rpc/handlers/download-asset.d.ts +1 -1
- package/dist/server/rpc/handlers/download-asset.js +4 -4
- package/dist/server/rpc/handlers/embed.d.ts +1 -1
- package/dist/server/rpc/handlers/embed.js +1 -1
- package/dist/server/rpc/handlers/finetune.d.ts +1 -1
- package/dist/server/rpc/handlers/finetune.js +2 -2
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +1 -1
- package/dist/server/rpc/handlers/get-loaded-model-info.js +10 -4
- package/dist/server/rpc/handlers/get-model-info.d.ts +1 -1
- package/dist/server/rpc/handlers/get-model-info.js +4 -4
- package/dist/server/rpc/handlers/get-system-resources.d.ts +3 -0
- package/dist/server/rpc/handlers/get-system-resources.js +53 -0
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/heartbeat-delegated.js +2 -2
- package/dist/server/rpc/handlers/heartbeat.d.ts +1 -1
- package/dist/server/rpc/handlers/index.d.ts +38 -32
- package/dist/server/rpc/handlers/index.js +6 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/download-manager.js +1 -1
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/handler.d.ts +1 -1
- package/dist/server/rpc/handlers/load-model/handler.js +12 -8
- package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/http.js +4 -4
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +5 -5
- package/dist/server/rpc/handlers/load-model/index.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +1 -1
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +3 -3
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +4 -4
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +3 -3
- package/dist/server/rpc/handlers/load-model/registry-metadata.d.ts +1 -1
- package/dist/server/rpc/handlers/load-model/registry.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/registry.js +6 -6
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/resolve-session.js +3 -3
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/resolve.js +2 -2
- package/dist/server/rpc/handlers/load-model/types.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model-delegated.js +3 -3
- package/dist/server/rpc/handlers/logging-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/logging-stream.js +1 -1
- package/dist/server/rpc/handlers/ocr-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/ocr-stream.js +1 -1
- package/dist/server/rpc/handlers/plugin-dispatch.js +3 -3
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +1 -1
- package/dist/server/rpc/handlers/plugin-invoke.js +3 -3
- package/dist/server/rpc/handlers/provideHandler/connection.js +1 -1
- package/dist/server/rpc/handlers/provideHandler/handler.d.ts +1 -1
- package/dist/server/rpc/handlers/provideHandler/handler.js +1 -1
- package/dist/server/rpc/handlers/provideHandler/proxy.js +1 -1
- package/dist/server/rpc/handlers/provideHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/rag.d.ts +1 -1
- package/dist/server/rpc/handlers/rag.js +4 -4
- package/dist/server/rpc/handlers/registry.d.ts +1 -1
- package/dist/server/rpc/handlers/registry.js +1 -1
- package/dist/server/rpc/handlers/resume.d.ts +1 -1
- package/dist/server/rpc/handlers/resume.js +1 -1
- package/dist/server/rpc/handlers/state.d.ts +1 -1
- package/dist/server/rpc/handlers/state.js +1 -1
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/stopProvideHandler.js +1 -1
- package/dist/server/rpc/handlers/suspend.d.ts +1 -1
- package/dist/server/rpc/handlers/suspend.js +1 -1
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/text-to-speech-stream.js +1 -1
- package/dist/server/rpc/handlers/text-to-speech.d.ts +1 -1
- package/dist/server/rpc/handlers/text-to-speech.js +1 -1
- package/dist/server/rpc/handlers/transcribe-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/transcribe-stream.js +1 -1
- package/dist/server/rpc/handlers/transcribe.d.ts +1 -1
- package/dist/server/rpc/handlers/transcribe.js +1 -1
- package/dist/server/rpc/handlers/translate.d.ts +1 -1
- package/dist/server/rpc/handlers/translate.js +1 -1
- package/dist/server/rpc/handlers/unload-model-delegated.d.ts +1 -1
- package/dist/server/rpc/handlers/unload-model-delegated.js +5 -5
- package/dist/server/rpc/handlers/unload-model.d.ts +1 -1
- package/dist/server/rpc/handlers/unload-model.js +3 -3
- package/dist/server/rpc/handlers/upscale-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/upscale-stream.js +1 -1
- package/dist/server/rpc/handlers/video-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/video-stream.js +1 -1
- package/dist/server/rpc/index.d.ts +2 -2
- package/dist/server/rpc/method-shapes.d.ts +53 -0
- package/dist/server/rpc/method-shapes.js +50 -0
- package/dist/server/rpc/profiling/backend-diagnostics.d.ts +3 -0
- package/dist/server/rpc/profiling/backend-diagnostics.js +16 -0
- package/dist/server/rpc/profiling/context.d.ts +1 -1
- package/dist/server/rpc/profiling/delegation-profiler.d.ts +2 -2
- package/dist/server/rpc/profiling/index.d.ts +4 -4
- package/dist/server/rpc/profiling/operation-metrics.d.ts +2 -2
- package/dist/server/rpc/profiling/operation-metrics.js +29 -1
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +1 -1
- package/dist/server/rpc/profiling/operation-wrappers.js +51 -13
- package/dist/server/rpc/profiling/profiler.d.ts +2 -2
- package/dist/server/rpc/transport-selector.d.ts +1 -1
- package/dist/server/utils/archive.js +1 -1
- package/dist/server/utils/audio/decoder.d.ts +1 -1
- package/dist/server/utils/audio/decoder.js +1 -1
- package/dist/server/utils/cache/auto-history.d.ts +1 -1
- package/dist/server/utils/cache/auto-history.js +13 -9
- package/dist/server/utils/cache/paths.d.ts +1 -1
- package/dist/server/utils/cache/paths.js +6 -6
- package/dist/server/utils/checksum.d.ts +1 -1
- package/dist/server/utils/completion-normalizer.d.ts +2 -1
- package/dist/server/utils/completion-normalizer.js +31 -1
- package/dist/server/utils/config-transform.d.ts +1 -1
- package/dist/server/utils/config-transform.js +5 -7
- package/dist/server/utils/index.d.ts +11 -11
- package/dist/server/utils/path-security.d.ts +1 -1
- package/dist/server/utils/qvac-paths.js +1 -1
- package/dist/server/utils/response-format.d.ts +1 -1
- package/dist/server/utils/shard-utils.d.ts +1 -1
- package/dist/server/utils/tool-integration.d.ts +1 -1
- package/dist/server/utils/tool-integration.js +2 -2
- package/dist/server/utils/tools/dialect.d.ts +1 -1
- package/dist/server/utils/tools/dialect.js +2 -0
- package/dist/server/utils/tools/index.d.ts +2 -2
- package/dist/server/utils/tools/parser.d.ts +1 -1
- package/dist/server/utils/tools/parser.js +16 -8
- package/dist/server/utils/tools/parsers/dsml.d.ts +4 -0
- package/dist/server/utils/tools/parsers/dsml.js +176 -0
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +2 -2
- package/dist/server/utils/tools/parsers/gemma4native.js +1 -1
- package/dist/server/utils/tools/parsers/harmony.d.ts +2 -2
- package/dist/server/utils/tools/parsers/harmony.js +1 -1
- package/dist/server/utils/tools/parsers/hermes.d.ts +2 -2
- package/dist/server/utils/tools/parsers/hermes.js +1 -1
- package/dist/server/utils/tools/parsers/json.d.ts +2 -2
- package/dist/server/utils/tools/parsers/json.js +1 -1
- package/dist/server/utils/tools/parsers/pythonic.d.ts +2 -2
- package/dist/server/utils/tools/parsers/pythonic.js +1 -1
- package/dist/server/utils/tools/parsers/qwen35.d.ts +2 -2
- package/dist/server/utils/tools/parsers/qwen35.js +1 -1
- package/dist/server/utils/tools/shared.d.ts +1 -1
- package/dist/server/utils/worker-lock.js +1 -1
- package/dist/server/worker-core.js +14 -10
- package/dist/server/worker.js +4 -3
- package/dist/utils/aggregate-events.d.ts +2 -2
- package/dist/utils/aggregate-events.js +2 -2
- package/dist/utils/errors-client.d.ts +0 -3
- package/dist/utils/errors-client.js +0 -5
- package/dist/utils/errors-server.d.ts +1 -1
- package/dist/utils/mcp-adapter.d.ts +4 -4
- package/dist/utils/mcp-adapter.js +1 -1
- package/dist/utils/tool-helpers.d.ts +1 -1
- package/dist/utils/tool-helpers.js +1 -1
- package/docs/system-resources-support-matrix.md +103 -0
- package/package.json +37 -19
- /package/dist/examples/{transcription → asr}/parakeet-ctc-filesystem.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/parakeet-microphone-record.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/parakeet-microphone-stream.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/parakeet-sortformer-streaming.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/parakeet-sortformer.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/parakeet-tdt-filesystem.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/whispercpp-filesystem-streaming.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/whispercpp-filesystem.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/whispercpp-microphone-conversation.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/whispercpp-microphone-record.d.ts +0 -0
- /package/dist/examples/{transcription → asr}/whispercpp-prompt.d.ts +0 -0
|
@@ -1,54 +1,27 @@
|
|
|
1
1
|
import { promises as fsPromises } from 'bare-fs';
|
|
2
2
|
import path from 'bare-path';
|
|
3
|
-
import { findMatchingCache, generateConfigHash, getCacheFilePath, getCurrentCacheInfo, renameCacheFile, deleteCache as deleteCacheUtil } from '
|
|
4
|
-
import {
|
|
3
|
+
import { findMatchingCache, generateConfigHash, getCacheFilePath, getCurrentCacheInfo, pruneEmptyCacheDirectories, renameCacheFile, deleteCache as deleteCacheUtil } from '../../../../../server/bare/ops/kv-cache-utils.js';
|
|
4
|
+
import { isCachePathWithinDirectory, markAutoCacheKey, planAutoCacheEvictions, removeAutoCacheMarker, removeAutoCacheMarkerIfMissing } from '../../../../../server/bare/ops/kv-cache-retention.js';
|
|
5
|
+
import { isMobile } from '../../../../../server/bare/registry/runtime-context-registry.js';
|
|
6
|
+
import { getKVCacheDir } from '../../../../../server/utils/index.js';
|
|
7
|
+
import { logCacheSaveError, logCacheStatus } from '../../../../../server/bare/plugins/llamacpp-completion/ops/cache-logger.js';
|
|
5
8
|
import { getServerLogger } from '../../../../../logging/index.js';
|
|
6
9
|
// Used by cross-model paths that have no `RequestContext` (e.g.
|
|
7
10
|
// `deleteKvCacheState`). Per-session call sites receive a logger from
|
|
8
11
|
// the caller — typically `withRequestContext(...)`.
|
|
9
12
|
const moduleLogger = getServerLogger();
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* Coordinates five KV-cache state layers:
|
|
12
15
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
16
|
+
* 1. `cachedMessageCounts` — saved message boundaries.
|
|
17
|
+
* 2. `initializedCaches` — caches primed in this worker.
|
|
18
|
+
* 3. On-disk `.bin` files written by the addon.
|
|
19
|
+
* 4. `activeCachePaths` — per-path refs that block in-flight eviction.
|
|
20
|
+
* 5. `.auto-cache-<key>` markers — SDK-generated cache ownership.
|
|
15
21
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* we know this cache is primed" tracker.
|
|
20
|
-
* 3. On-disk `.bin` files written by the addon.
|
|
21
|
-
*
|
|
22
|
-
* Without a single owner, every cancel / zero-token / rename-failed /
|
|
23
|
-
* tool-call exit would need to touch all three; any branch that forgets
|
|
24
|
-
* a layer produces three-layer drift bugs.
|
|
25
|
-
*
|
|
26
|
-
* `KvCacheSession` collapses the three layers behind one object with
|
|
27
|
-
* three operations:
|
|
28
|
-
*
|
|
29
|
-
* - `beginTurn` — resolves the cache file path, primes the system
|
|
30
|
-
* prompt cache if missing (delegated to a caller-supplied closure
|
|
31
|
-
* so the session doesn't depend on the model addon), marks the
|
|
32
|
-
* cache initialized, and returns a `TurnHandle` carrying the
|
|
33
|
-
* resolved path + the snapshot of the on-disk saved count.
|
|
34
|
-
* - `commitTurn` — records the new saved count (for custom-key
|
|
35
|
-
* turns) or renames the addon's pre-response file to the
|
|
36
|
-
* post-response path and records the count there (for auto-cache
|
|
37
|
-
* turns). Flips the turn's internal `committed` flag so the
|
|
38
|
-
* deferred `rollback` becomes a no-op on the happy path.
|
|
39
|
-
* - `rollback` — atomically deletes the on-disk file, clears the
|
|
40
|
-
* in-memory init entry, and forgets the saved count. **All three
|
|
41
|
-
* layers, always, in one place.** Handlers call it once via
|
|
42
|
-
* `ctx.scope.defer(() => session.rollback(turn))`; `commitTurn`
|
|
43
|
-
* short-circuits it on success.
|
|
44
|
-
*
|
|
45
|
-
* The module-level `deleteKvCacheState(...)` function (below) provides
|
|
46
|
-
* an administrative cross-model delete API for the
|
|
47
|
-
* `handleDeleteCache` RPC handler.
|
|
48
|
-
*
|
|
49
|
-
* The module-scoped `cachedMessageCounts` and `initializedCaches` maps
|
|
50
|
-
* are *private* to this file — no other module reaches into them.
|
|
51
|
-
* Callers that need cache-status info do so through the session API.
|
|
22
|
+
* Every turn must finish through `commitTurn` or `rollback` so all
|
|
23
|
+
* inference state stays aligned, the active-path ref is released, and
|
|
24
|
+
* marker metadata follows the cache directory lifecycle.
|
|
52
25
|
*/
|
|
53
26
|
// ----- module-scoped state. The session is the single mutation point
|
|
54
27
|
// for the in-memory KV-cache bookkeeping. -----
|
|
@@ -70,9 +43,101 @@ const cachedMessageCounts = new Map();
|
|
|
70
43
|
* older worker runs still hit the lazy-load path in `beginTurn`.
|
|
71
44
|
*/
|
|
72
45
|
const initializedCaches = new Set();
|
|
46
|
+
const activeCachePaths = new Map();
|
|
47
|
+
const DESKTOP_AUTO_CACHE_MAX_BYTES = 4 * 1024 * 1024 * 1024;
|
|
48
|
+
const MOBILE_AUTO_CACHE_MAX_BYTES = 512 * 1024 * 1024;
|
|
49
|
+
const AUTO_CACHE_MAX_IDLE_MS = 24 * 60 * 60 * 1000;
|
|
50
|
+
const AUTO_CACHE_SWEEP_INTERVAL_MS = 5 * 60 * 1000;
|
|
51
|
+
let lastAutoCacheSweepMs = 0;
|
|
52
|
+
let autoCacheSweepInFlight = null;
|
|
53
|
+
let cacheStateLockTail = Promise.resolve();
|
|
73
54
|
function initRegistryKey(modelId, configHash, cacheKey) {
|
|
74
55
|
return `${modelId}:${configHash}:${cacheKey}`;
|
|
75
56
|
}
|
|
57
|
+
function markCachePathActive(cachePath) {
|
|
58
|
+
activeCachePaths.set(cachePath, (activeCachePaths.get(cachePath) ?? 0) + 1);
|
|
59
|
+
}
|
|
60
|
+
function releaseCachePath(cachePath) {
|
|
61
|
+
const count = activeCachePaths.get(cachePath);
|
|
62
|
+
if (count === undefined)
|
|
63
|
+
return;
|
|
64
|
+
if (count === 1) {
|
|
65
|
+
activeCachePaths.delete(cachePath);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
activeCachePaths.set(cachePath, count - 1);
|
|
69
|
+
}
|
|
70
|
+
function isCacheKeyActive(cacheKey) {
|
|
71
|
+
const cacheDirectory = path.join(getKVCacheDir(), cacheKey);
|
|
72
|
+
return Array.from(activeCachePaths.keys()).some((cachePath) => isCachePathWithinDirectory(cacheDirectory, cachePath));
|
|
73
|
+
}
|
|
74
|
+
function getAutoCacheMaxBytes() {
|
|
75
|
+
return isMobile() ? MOBILE_AUTO_CACHE_MAX_BYTES : DESKTOP_AUTO_CACHE_MAX_BYTES;
|
|
76
|
+
}
|
|
77
|
+
async function withCacheStateLock(operation) {
|
|
78
|
+
const previous = cacheStateLockTail;
|
|
79
|
+
let releaseLock = () => { };
|
|
80
|
+
cacheStateLockTail = new Promise((resolve) => {
|
|
81
|
+
releaseLock = resolve;
|
|
82
|
+
});
|
|
83
|
+
await previous;
|
|
84
|
+
try {
|
|
85
|
+
return await operation();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
releaseLock();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function maybeSweepAutoCaches(logger, overrides) {
|
|
92
|
+
const nowMs = overrides?.nowMs ?? Date.now();
|
|
93
|
+
if (autoCacheSweepInFlight !== null) {
|
|
94
|
+
await autoCacheSweepInFlight;
|
|
95
|
+
if (!overrides?.force)
|
|
96
|
+
return;
|
|
97
|
+
return maybeSweepAutoCaches(logger, overrides);
|
|
98
|
+
}
|
|
99
|
+
if (!overrides?.force && nowMs - lastAutoCacheSweepMs < AUTO_CACHE_SWEEP_INTERVAL_MS)
|
|
100
|
+
return;
|
|
101
|
+
lastAutoCacheSweepMs = nowMs;
|
|
102
|
+
const sweep = async () => {
|
|
103
|
+
try {
|
|
104
|
+
const cacheKeys = await planAutoCacheEvictions({
|
|
105
|
+
activeCachePaths: Array.from(activeCachePaths.keys()),
|
|
106
|
+
maxBytes: overrides?.maxBytes ?? getAutoCacheMaxBytes(),
|
|
107
|
+
maxIdleMs: overrides?.maxIdleMs ?? AUTO_CACHE_MAX_IDLE_MS,
|
|
108
|
+
nowMs
|
|
109
|
+
});
|
|
110
|
+
let evictionCount = 0;
|
|
111
|
+
await withCacheStateLock(async () => {
|
|
112
|
+
for (const cacheKey of cacheKeys) {
|
|
113
|
+
if (isCacheKeyActive(cacheKey))
|
|
114
|
+
continue;
|
|
115
|
+
await deleteKvCacheState({ kvCacheKey: cacheKey });
|
|
116
|
+
evictionCount++;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (evictionCount > 0) {
|
|
120
|
+
logger.debug(`[kv-cache] Evicted ${evictionCount} inactive auto-cache entries`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
logger.warn(`[kv-cache] Auto-cache retention sweep failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const sweepPromise = sweep();
|
|
128
|
+
autoCacheSweepInFlight = sweepPromise;
|
|
129
|
+
try {
|
|
130
|
+
await sweepPromise;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
autoCacheSweepInFlight = null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function scheduleAutoCacheSweep(logger) {
|
|
137
|
+
void maybeSweepAutoCaches(logger).catch((error) => {
|
|
138
|
+
logger.warn(`[kv-cache] Failed to schedule auto-cache retention sweep: ${error instanceof Error ? error.message : String(error)}`);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
76
141
|
// ----- factory -----
|
|
77
142
|
/**
|
|
78
143
|
* Construct a session bound to one `(modelId, turn-owning request)`
|
|
@@ -86,7 +151,7 @@ export function createKvCacheSession(modelId, options) {
|
|
|
86
151
|
// WeakMap so handles drop their state once the handler scope releases
|
|
87
152
|
// the reference; the module-scoped maps above survive.
|
|
88
153
|
const turnState = new WeakMap();
|
|
89
|
-
function makeHandle(cachePath, registryKey) {
|
|
154
|
+
function makeHandle(cachePath, registryKey, autoCacheKey) {
|
|
90
155
|
const handle = {
|
|
91
156
|
cachePath,
|
|
92
157
|
savedCount: cachedMessageCounts.get(cachePath) ?? 0
|
|
@@ -94,36 +159,45 @@ export function createKvCacheSession(modelId, options) {
|
|
|
94
159
|
turnState.set(handle, {
|
|
95
160
|
cachePath,
|
|
96
161
|
registryKey,
|
|
162
|
+
...(autoCacheKey !== undefined && { autoCacheKey }),
|
|
97
163
|
committed: false,
|
|
98
164
|
rolledBack: false
|
|
99
165
|
});
|
|
166
|
+
markCachePathActive(cachePath);
|
|
100
167
|
return handle;
|
|
101
168
|
}
|
|
102
169
|
async function beginCustom(input) {
|
|
103
170
|
const cachePath = await getCacheFilePath(modelId, input.configHash, input.customKey);
|
|
104
171
|
const registryKey = initRegistryKey(modelId, input.configHash, input.customKey);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
172
|
+
const handle = makeHandle(cachePath, registryKey);
|
|
173
|
+
try {
|
|
174
|
+
// In-memory registry check first — the addon defers disk writes, so
|
|
175
|
+
// a freshly-primed cache may not yet exist on disk. If the
|
|
176
|
+
// in-memory flag isn't set, fall back to a filesystem probe so
|
|
177
|
+
// caches surviving across worker restarts still hit the reuse path.
|
|
178
|
+
let exists = initializedCaches.has(registryKey);
|
|
179
|
+
if (!exists) {
|
|
180
|
+
try {
|
|
181
|
+
await fsPromises.access(cachePath);
|
|
182
|
+
exists = true;
|
|
183
|
+
initializedCaches.add(registryKey);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
exists = false;
|
|
187
|
+
}
|
|
115
188
|
}
|
|
116
|
-
|
|
117
|
-
|
|
189
|
+
logCacheStatus(input.customKey, exists);
|
|
190
|
+
if (!exists) {
|
|
191
|
+
await input.primeIfMissing(cachePath);
|
|
192
|
+
await verifyPrimedFile(cachePath, logger);
|
|
193
|
+
initializedCaches.add(registryKey);
|
|
118
194
|
}
|
|
195
|
+
return handle;
|
|
119
196
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
await verifyPrimedFile(cachePath, logger);
|
|
124
|
-
initializedCaches.add(registryKey);
|
|
197
|
+
catch (error) {
|
|
198
|
+
releaseCachePath(cachePath);
|
|
199
|
+
throw error;
|
|
125
200
|
}
|
|
126
|
-
return makeHandle(cachePath, registryKey);
|
|
127
201
|
}
|
|
128
202
|
async function beginAuto(input) {
|
|
129
203
|
// The pre-response cache key is derived from
|
|
@@ -131,19 +205,34 @@ export function createKvCacheSession(modelId, options) {
|
|
|
131
205
|
// internally. The post-response key (used after a successful turn)
|
|
132
206
|
// is computed by the caller and passed to `commitTurn` as
|
|
133
207
|
// `targetCachePath`.
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
208
|
+
const setup = await withCacheStateLock(async () => {
|
|
209
|
+
const existingCache = await findMatchingCache(modelId, input.configHash, input.history);
|
|
210
|
+
const cacheInfo = existingCache ?? (await getCurrentCacheInfo(modelId, input.configHash, input.history));
|
|
211
|
+
const registryKey = initRegistryKey(modelId, input.configHash, cacheInfo.cacheKey);
|
|
212
|
+
return {
|
|
213
|
+
cacheExists: existingCache !== null,
|
|
214
|
+
cachePath: cacheInfo.cachePath,
|
|
215
|
+
cacheKey: cacheInfo.cacheKey,
|
|
216
|
+
registryKey,
|
|
217
|
+
handle: makeHandle(cacheInfo.cachePath, registryKey, cacheInfo.cacheKey)
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
const { cacheExists, cachePath, cacheKey, registryKey, handle } = setup;
|
|
140
221
|
logCacheStatus('auto', cacheExists);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
222
|
+
try {
|
|
223
|
+
if (!cacheExists) {
|
|
224
|
+
await input.primeIfMissing(cachePath);
|
|
225
|
+
await verifyPrimedFile(cachePath, logger);
|
|
226
|
+
initializedCaches.add(registryKey);
|
|
227
|
+
}
|
|
228
|
+
return handle;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
releaseCachePath(cachePath);
|
|
232
|
+
await pruneEmptyCacheDirectories(cachePath);
|
|
233
|
+
await removeAutoCacheMarkerIfMissing(cacheKey);
|
|
234
|
+
throw error;
|
|
145
235
|
}
|
|
146
|
-
return makeHandle(cachePath, registryKey);
|
|
147
236
|
}
|
|
148
237
|
async function beginTurn(input) {
|
|
149
238
|
if (input.kind === 'custom')
|
|
@@ -174,24 +263,42 @@ export function createKvCacheSession(modelId, options) {
|
|
|
174
263
|
return;
|
|
175
264
|
}
|
|
176
265
|
state.committed = true;
|
|
266
|
+
releaseCachePath(state.cachePath);
|
|
177
267
|
return;
|
|
178
268
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
269
|
+
const sourceCachePath = state.cachePath;
|
|
270
|
+
const sourceCacheKey = state.autoCacheKey;
|
|
271
|
+
const targetCacheKey = path.basename(path.dirname(path.dirname(result.targetCachePath)));
|
|
272
|
+
const renamed = await withCacheStateLock(async () => {
|
|
273
|
+
markCachePathActive(result.targetCachePath);
|
|
274
|
+
await fsPromises.mkdir(path.dirname(result.targetCachePath), { recursive: true });
|
|
275
|
+
await markAutoCacheKey(targetCacheKey);
|
|
276
|
+
if (!(await renameCacheFile(sourceCachePath, result.targetCachePath))) {
|
|
277
|
+
releaseCachePath(result.targetCachePath);
|
|
278
|
+
await pruneEmptyCacheDirectories(result.targetCachePath);
|
|
279
|
+
await removeAutoCacheMarkerIfMissing(targetCacheKey);
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
releaseCachePath(sourceCachePath);
|
|
283
|
+
state.cachePath = result.targetCachePath;
|
|
284
|
+
state.autoCacheKey = targetCacheKey;
|
|
285
|
+
await pruneEmptyCacheDirectories(sourceCachePath);
|
|
286
|
+
if (sourceCacheKey !== undefined) {
|
|
287
|
+
await removeAutoCacheMarkerIfMissing(sourceCacheKey);
|
|
288
|
+
}
|
|
289
|
+
cachedMessageCounts.delete(sourceCachePath);
|
|
290
|
+
initializedCaches.delete(state.registryKey);
|
|
291
|
+
return true;
|
|
292
|
+
});
|
|
293
|
+
if (!renamed) {
|
|
294
|
+
logger.warn(`[kv-cache] Auto cache rename failed; rolling back. from=${sourceCachePath} to=${result.targetCachePath}`);
|
|
184
295
|
await runRollback(state);
|
|
185
296
|
return;
|
|
186
297
|
}
|
|
187
|
-
// The source path's entry is gone (the file moved). Drop it and
|
|
188
|
-
// record the new count at the rename target.
|
|
189
|
-
cachedMessageCounts.delete(state.cachePath);
|
|
190
298
|
const ok = await verifySaveAndRecord(result.targetCachePath, result.messageCount);
|
|
191
299
|
if (!ok) {
|
|
192
300
|
// Rename succeeded but the file isn't where we expected. Roll
|
|
193
301
|
// back via the target path instead of the (now-empty) source.
|
|
194
|
-
state.cachePath = result.targetCachePath;
|
|
195
302
|
await runRollback(state);
|
|
196
303
|
return;
|
|
197
304
|
}
|
|
@@ -200,6 +307,8 @@ export function createKvCacheSession(modelId, options) {
|
|
|
200
307
|
// is committed and won't roll back. Future turns compute fresh
|
|
201
308
|
// paths.
|
|
202
309
|
state.committed = true;
|
|
310
|
+
releaseCachePath(state.cachePath);
|
|
311
|
+
scheduleAutoCacheSweep(logger);
|
|
203
312
|
}
|
|
204
313
|
async function rollback(turn) {
|
|
205
314
|
const state = turnState.get(turn);
|
|
@@ -220,9 +329,16 @@ export function createKvCacheSession(modelId, options) {
|
|
|
220
329
|
catch (unlinkError) {
|
|
221
330
|
logger.warn(`[kv-cache] Failed to remove cache file during rollback; next turn may load stale KV state. path=${state.cachePath} error=${unlinkError instanceof Error ? unlinkError.message : String(unlinkError)}`);
|
|
222
331
|
}
|
|
332
|
+
await pruneEmptyCacheDirectories(state.cachePath);
|
|
333
|
+
if (state.autoCacheKey !== undefined) {
|
|
334
|
+
await removeAutoCacheMarkerIfMissing(state.autoCacheKey);
|
|
335
|
+
}
|
|
223
336
|
initializedCaches.delete(state.registryKey);
|
|
224
337
|
cachedMessageCounts.delete(state.cachePath);
|
|
338
|
+
releaseCachePath(state.cachePath);
|
|
225
339
|
state.rolledBack = true;
|
|
340
|
+
if (state.autoCacheKey !== undefined)
|
|
341
|
+
scheduleAutoCacheSweep(logger);
|
|
226
342
|
}
|
|
227
343
|
function dropStaleSavedCount(turn) {
|
|
228
344
|
const state = turnState.get(turn);
|
|
@@ -282,6 +398,9 @@ export async function deleteKvCacheState(target) {
|
|
|
282
398
|
kvCacheKey: target.kvCacheKey,
|
|
283
399
|
...(target.modelId !== undefined && { modelId: target.modelId })
|
|
284
400
|
});
|
|
401
|
+
if (target.modelId === undefined) {
|
|
402
|
+
await removeAutoCacheMarker(target.kvCacheKey);
|
|
403
|
+
}
|
|
285
404
|
// Prefix-cleanup the in-memory counts. The on-disk directory tree
|
|
286
405
|
// is `{kvCacheRoot}/{kvCacheKey}[/{modelId}]/`, so every entry in
|
|
287
406
|
// `cachedMessageCounts` whose key is the removed directory itself
|
|
@@ -335,6 +454,7 @@ async function verifyPrimedFile(cachePath, logger) {
|
|
|
335
454
|
catch (statError) {
|
|
336
455
|
// ENOENT is the common case here — addon prime returned without
|
|
337
456
|
// calling save (most often: signal abort during prefill).
|
|
457
|
+
await pruneEmptyCacheDirectories(cachePath);
|
|
338
458
|
throw new Error(`[kv-cache] prime closure resolved but no cache file was written. path=${cachePath} cause=${statError instanceof Error ? statError.message : String(statError)}`);
|
|
339
459
|
}
|
|
340
460
|
if (stats.size === 0) {
|
|
@@ -343,6 +463,7 @@ async function verifyPrimedFile(cachePath, logger) {
|
|
|
343
463
|
// primary "prime didn't persist" condition.
|
|
344
464
|
try {
|
|
345
465
|
await fsPromises.unlink(cachePath);
|
|
466
|
+
await pruneEmptyCacheDirectories(cachePath);
|
|
346
467
|
}
|
|
347
468
|
catch (unlinkError) {
|
|
348
469
|
logger.warn(`[kv-cache] Failed to remove empty primed cache file. path=${cachePath} error=${unlinkError instanceof Error ? unlinkError.message : String(unlinkError)}`);
|
|
@@ -432,9 +553,25 @@ export const __kvCacheSessionTestHooks = {
|
|
|
432
553
|
markInitializedForTest(modelId, configHash, cacheKey) {
|
|
433
554
|
initializedCaches.add(initRegistryKey(modelId, configHash, cacheKey));
|
|
434
555
|
},
|
|
556
|
+
getLastAutoCacheSweepMsForTest() {
|
|
557
|
+
return lastAutoCacheSweepMs;
|
|
558
|
+
},
|
|
559
|
+
setLastAutoCacheSweepMsForTest(value) {
|
|
560
|
+
lastAutoCacheSweepMs = value;
|
|
561
|
+
},
|
|
435
562
|
resetForTest() {
|
|
436
563
|
cachedMessageCounts.clear();
|
|
437
564
|
initializedCaches.clear();
|
|
565
|
+
activeCachePaths.clear();
|
|
566
|
+
lastAutoCacheSweepMs = 0;
|
|
567
|
+
autoCacheSweepInFlight = null;
|
|
568
|
+
cacheStateLockTail = Promise.resolve();
|
|
569
|
+
},
|
|
570
|
+
waitForAutoCacheSweepForTest() {
|
|
571
|
+
return autoCacheSweepInFlight ?? Promise.resolve();
|
|
572
|
+
},
|
|
573
|
+
sweepAutoCachesForTest(options) {
|
|
574
|
+
return maybeSweepAutoCaches(moduleLogger, { ...options, force: true });
|
|
438
575
|
}
|
|
439
576
|
};
|
|
440
577
|
// Re-export `generateConfigHash` from the path utilities so callers of
|
|
@@ -32,6 +32,13 @@ export interface HistorySliceDecision {
|
|
|
32
32
|
*/
|
|
33
33
|
clearStaleCount: boolean;
|
|
34
34
|
}
|
|
35
|
+
interface CacheCommitContext {
|
|
36
|
+
aborted: boolean;
|
|
37
|
+
producedTokens: boolean;
|
|
38
|
+
generatedTokens?: number | undefined;
|
|
39
|
+
predict?: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
export declare function shouldCommitCachedTurn(context: CacheCommitContext): boolean;
|
|
35
42
|
/**
|
|
36
43
|
* Pure slice decision for `prepareMessagesForCache`.
|
|
37
44
|
*
|
|
@@ -46,4 +53,5 @@ export interface HistorySliceDecision {
|
|
|
46
53
|
* than handing the model an empty payload.
|
|
47
54
|
*/
|
|
48
55
|
export declare function decideCachedHistorySlice(savedCount: number, cacheExists: boolean, history: HistoryMessage[]): HistorySliceDecision;
|
|
56
|
+
export {};
|
|
49
57
|
//# sourceMappingURL=kv-cache-state.d.ts.map
|
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
* layers (saved counts, init flags, on-disk files). Only the pure
|
|
15
15
|
* slice-decision helper remains here.
|
|
16
16
|
*/
|
|
17
|
+
export function shouldCommitCachedTurn(context) {
|
|
18
|
+
const { aborted, producedTokens, generatedTokens, predict } = context;
|
|
19
|
+
const stoppedByBudget = predict !== undefined &&
|
|
20
|
+
predict > 0 &&
|
|
21
|
+
generatedTokens !== undefined &&
|
|
22
|
+
generatedTokens >= predict;
|
|
23
|
+
return !aborted && producedTokens && !stoppedByBudget;
|
|
24
|
+
}
|
|
17
25
|
/**
|
|
18
26
|
* Pure slice decision for `prepareMessagesForCache`.
|
|
19
27
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateModelParams, type PluginModelResult, type ResolveContext, type LlmConfigInput } from '../../../../schemas/index';
|
|
1
|
+
import { type CreateModelParams, type PluginModelResult, type ResolveContext, type LlmConfigInput } from '../../../../schemas/index.js';
|
|
2
2
|
export declare const llmPlugin: {
|
|
3
3
|
modelType: "llamacpp-completion";
|
|
4
4
|
displayName: string;
|
|
@@ -15,7 +15,12 @@ export declare const llmPlugin: {
|
|
|
15
15
|
predict: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<-1>, import("zod").ZodLiteral<-2>, import("zod").ZodNumber]>>;
|
|
16
16
|
system_prompt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
17
|
no_mmap: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
18
|
-
verbosity: import("zod").ZodOptional<import("zod").
|
|
18
|
+
verbosity: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
19
|
+
readonly ERROR: 0;
|
|
20
|
+
readonly WARN: 1;
|
|
21
|
+
readonly INFO: 2;
|
|
22
|
+
readonly DEBUG: 3;
|
|
23
|
+
}>>;
|
|
19
24
|
presence_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
20
25
|
frequency_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
21
26
|
repeat_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -55,6 +60,7 @@ export declare const llmPlugin: {
|
|
|
55
60
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
56
61
|
embeddings: "embeddings";
|
|
57
62
|
diffusion: "diffusion";
|
|
63
|
+
audiogen: "audiogen";
|
|
58
64
|
tts: "tts";
|
|
59
65
|
ocr: "ocr";
|
|
60
66
|
vla: "vla";
|
|
@@ -68,6 +74,7 @@ export declare const llmPlugin: {
|
|
|
68
74
|
"parakeet-transcription": "parakeet-transcription";
|
|
69
75
|
"ggml-ocr": "ggml-ocr";
|
|
70
76
|
"sdcpp-generation": "sdcpp-generation";
|
|
77
|
+
"audiogen-ggml": "audiogen-ggml";
|
|
71
78
|
"ggml-vla": "ggml-vla";
|
|
72
79
|
"ggml-classification": "ggml-classification";
|
|
73
80
|
llm: "llm";
|
|
@@ -156,7 +163,7 @@ export declare const llmPlugin: {
|
|
|
156
163
|
}>;
|
|
157
164
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
158
165
|
handlers: {
|
|
159
|
-
batchCompletionStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
166
|
+
batchCompletionStream: import("../../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
160
167
|
modelId: import("zod").ZodString;
|
|
161
168
|
stream: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
162
169
|
captureThinking: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -168,6 +175,7 @@ export declare const llmPlugin: {
|
|
|
168
175
|
harmony: "harmony";
|
|
169
176
|
qwen35: "qwen35";
|
|
170
177
|
gemma4: "gemma4";
|
|
178
|
+
dsml: "dsml";
|
|
171
179
|
}>>;
|
|
172
180
|
requestId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
173
181
|
prompts: import("zod").ZodArray<import("zod").ZodObject<{
|
|
@@ -220,7 +228,7 @@ export declare const llmPlugin: {
|
|
|
220
228
|
integer: "integer";
|
|
221
229
|
}>;
|
|
222
230
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
223
|
-
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString
|
|
231
|
+
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>>;
|
|
224
232
|
}, import("zod/v4/core").$strip>>;
|
|
225
233
|
required: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
226
234
|
}, import("zod/v4/core").$strip>;
|
|
@@ -275,6 +283,7 @@ export declare const llmPlugin: {
|
|
|
275
283
|
cacheTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
276
284
|
promptTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
277
285
|
generatedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
286
|
+
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
278
287
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
279
288
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
280
289
|
gpu: "gpu";
|
|
@@ -311,6 +320,7 @@ export declare const llmPlugin: {
|
|
|
311
320
|
cacheTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
312
321
|
promptTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
313
322
|
generatedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
323
|
+
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
314
324
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
315
325
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
316
326
|
gpu: "gpu";
|
|
@@ -318,7 +328,7 @@ export declare const llmPlugin: {
|
|
|
318
328
|
}>>;
|
|
319
329
|
}, import("zod/v4/core").$strip>>;
|
|
320
330
|
}, import("zod/v4/core").$strict>>;
|
|
321
|
-
completionStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
331
|
+
completionStream: import("../../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
322
332
|
history: import("zod").ZodArray<import("zod").ZodObject<{
|
|
323
333
|
role: import("zod").ZodString;
|
|
324
334
|
content: import("zod").ZodString;
|
|
@@ -343,7 +353,7 @@ export declare const llmPlugin: {
|
|
|
343
353
|
integer: "integer";
|
|
344
354
|
}>;
|
|
345
355
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
346
|
-
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString
|
|
356
|
+
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>>;
|
|
347
357
|
}, import("zod/v4/core").$strip>>;
|
|
348
358
|
required: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
349
359
|
}, import("zod/v4/core").$strip>;
|
|
@@ -371,6 +381,7 @@ export declare const llmPlugin: {
|
|
|
371
381
|
harmony: "harmony";
|
|
372
382
|
qwen35: "qwen35";
|
|
373
383
|
gemma4: "gemma4";
|
|
384
|
+
dsml: "dsml";
|
|
374
385
|
}>>;
|
|
375
386
|
responseFormat: import("zod").ZodOptional<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
376
387
|
type: import("zod").ZodLiteral<"text">;
|
|
@@ -432,6 +443,7 @@ export declare const llmPlugin: {
|
|
|
432
443
|
cacheTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
433
444
|
promptTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
434
445
|
generatedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
446
|
+
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
435
447
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
436
448
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
437
449
|
gpu: "gpu";
|
|
@@ -462,7 +474,7 @@ export declare const llmPlugin: {
|
|
|
462
474
|
}, import("zod/v4/core").$strip>>;
|
|
463
475
|
}, import("zod/v4/core").$strict>]>>;
|
|
464
476
|
}, import("zod/v4/core").$strict>>;
|
|
465
|
-
finetune: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
477
|
+
finetune: import("../../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
466
478
|
modelId: import("zod").ZodString;
|
|
467
479
|
options: import("zod").ZodObject<{
|
|
468
480
|
trainDatasetDir: import("zod").ZodString;
|
|
@@ -613,7 +625,7 @@ export declare const llmPlugin: {
|
|
|
613
625
|
epochs_completed: import("zod").ZodNumber;
|
|
614
626
|
}, import("zod/v4/core").$strict>>;
|
|
615
627
|
}, import("zod/v4/core").$strict>>;
|
|
616
|
-
translate: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
628
|
+
translate: import("../../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
617
629
|
modelId: import("zod").ZodString;
|
|
618
630
|
text: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
|
|
619
631
|
stream: import("zod").ZodBoolean;
|
|
@@ -51,27 +51,27 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
53
|
import LlmLlamacpp from '@qvac/llm-llamacpp';
|
|
54
|
-
import llmAddonLogging from '@qvac/llm-llamacpp/addonLogging
|
|
54
|
+
import llmAddonLogging from '@qvac/llm-llamacpp/addonLogging';
|
|
55
55
|
import { definePlugin, defineHandler, finetuneRequestSchema, batchCompletionStreamRequestSchema, batchCompletionStreamResponseSchema, completionStreamRequestSchema, completionStreamResponseSchema, finetuneResponseSchema, translateRequestSchema, translateResponseSchema, ModelType, llmConfigBaseSchema, ADDON_LLM } from '../../../../schemas/index.js';
|
|
56
56
|
import { createStreamLogger, registerAddonLogger } from '../../../../logging/index.js';
|
|
57
|
-
import { expandGGUFIntoShards } from '
|
|
58
|
-
import { completion } from '
|
|
59
|
-
import { batchCompletion } from '
|
|
60
|
-
import { finetune } from '
|
|
61
|
-
import { translate } from '
|
|
62
|
-
import { transformLlmConfig } from '
|
|
57
|
+
import { expandGGUFIntoShards } from '../../../../server/utils/index.js';
|
|
58
|
+
import { completion } from '../../../../server/bare/plugins/llamacpp-completion/ops/completion-stream.js';
|
|
59
|
+
import { batchCompletion } from '../../../../server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.js';
|
|
60
|
+
import { finetune } from '../../../../server/bare/plugins/llamacpp-completion/ops/finetune.js';
|
|
61
|
+
import { translate } from '../../../../server/bare/ops/translate.js';
|
|
62
|
+
import { transformLlmConfig } from '../../../../server/bare/plugins/llamacpp-completion/transform.js';
|
|
63
63
|
import { attachModelExecutionMs } from '../../../../profiling/model-execution.js';
|
|
64
|
-
import { getModelConfig } from '
|
|
65
|
-
import { createCompletionNormalizer } from '
|
|
66
|
-
import { detectToolDialect } from '
|
|
67
|
-
import { getRequestRegistry, withRequestContext } from '
|
|
68
|
-
import { generateServerRequestId } from '
|
|
64
|
+
import { getModelConfig } from '../../../../server/bare/registry/model-registry.js';
|
|
65
|
+
import { createCompletionNormalizer } from '../../../../server/utils/completion-normalizer.js';
|
|
66
|
+
import { detectToolDialect } from '../../../../server/utils/tool-integration.js';
|
|
67
|
+
import { getRequestRegistry, withRequestContext } from '../../../../server/bare/runtime/index.js';
|
|
68
|
+
import { generateServerRequestId } from '../../../../server/bare/runtime/request-id.js';
|
|
69
69
|
import { getServerLogger } from '../../../../logging/index.js';
|
|
70
70
|
import { ContextOverflowError } from '../../../../utils/errors-server.js';
|
|
71
|
-
import { isAddonContextOverflowError, parseContextOverflowMessage } from '
|
|
72
|
-
import { isAddonCancelledError } from '
|
|
73
|
-
import { isMobile } from '
|
|
74
|
-
import { stripMultiGpuKeys } from '
|
|
71
|
+
import { isAddonContextOverflowError, parseContextOverflowMessage } from '../../../../server/bare/plugins/llamacpp-completion/ops/context-overflow.js';
|
|
72
|
+
import { isAddonCancelledError } from '../../../../server/bare/plugins/llamacpp-completion/ops/batch-cancelled.js';
|
|
73
|
+
import { isMobile } from '../../../../server/bare/registry/runtime-context-registry.js';
|
|
74
|
+
import { stripMultiGpuKeys } from '../../../../server/utils/multi-gpu-mobile.js';
|
|
75
75
|
function createLlmModel(modelId, modelPath, llmConfig, projectionModelPath) {
|
|
76
76
|
const logger = createStreamLogger(modelId, ModelType.llamacppCompletion);
|
|
77
77
|
registerAddonLogger(modelId, ModelType.llamacppCompletion, logger);
|