@qvac/sdk 0.14.1 → 0.15.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 +27 -11
- package/README.md +34 -35
- package/dist/client/api/batch-completion.d.ts +15 -0
- package/dist/client/api/batch-completion.js +332 -0
- package/dist/client/api/bci-transcribe.d.ts +1 -1
- package/dist/client/api/bci-transcribe.js +31 -31
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +18 -18
- package/dist/client/api/classify.d.ts +1 -1
- package/dist/client/api/classify.js +9 -6
- package/dist/client/api/client-request-id.js +1 -1
- package/dist/client/api/completion-stream.d.ts +3 -3
- package/dist/client/api/completion-stream.js +18 -18
- package/dist/client/api/delete-cache.js +9 -9
- package/dist/client/api/diffusion.d.ts +1 -1
- package/dist/client/api/diffusion.js +17 -11
- package/dist/client/api/download-asset.d.ts +1 -1
- package/dist/client/api/download-asset.js +11 -11
- package/dist/client/api/embed.d.ts +1 -1
- package/dist/client/api/embed.js +10 -10
- package/dist/client/api/finetune.d.ts +1 -1
- package/dist/client/api/finetune.js +25 -27
- package/dist/client/api/get-loaded-model-info.d.ts +2 -2
- package/dist/client/api/get-loaded-model-info.js +8 -8
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/get-model-info.js +7 -7
- package/dist/client/api/heartbeat.d.ts +2 -2
- package/dist/client/api/heartbeat.js +7 -7
- package/dist/client/api/index.d.ts +33 -32
- package/dist/client/api/index.js +33 -32
- package/dist/client/api/invoke-plugin.d.ts +1 -1
- package/dist/client/api/invoke-plugin.js +10 -10
- package/dist/client/api/load-model.d.ts +1 -1
- package/dist/client/api/load-model.js +32 -32
- package/dist/client/api/logging-stream.d.ts +1 -1
- package/dist/client/api/logging-stream.js +6 -6
- package/dist/client/api/ocr.d.ts +1 -1
- package/dist/client/api/ocr.js +11 -11
- package/dist/client/api/provide.d.ts +1 -1
- package/dist/client/api/provide.js +7 -7
- package/dist/client/api/rag.d.ts +1 -1
- package/dist/client/api/rag.js +65 -66
- package/dist/client/api/registry.d.ts +1 -1
- package/dist/client/api/registry.js +8 -8
- package/dist/client/api/resume.js +5 -5
- package/dist/client/api/state.d.ts +1 -1
- package/dist/client/api/state.js +5 -5
- package/dist/client/api/stop-provider.js +6 -6
- package/dist/client/api/subscribe-logs.d.ts +1 -1
- package/dist/client/api/subscribe-logs.js +3 -3
- package/dist/client/api/suspend.js +5 -5
- package/dist/client/api/text-to-speech.d.ts +1 -1
- package/dist/client/api/text-to-speech.js +37 -39
- package/dist/client/api/transcribe.d.ts +2 -2
- package/dist/client/api/transcribe.js +44 -45
- package/dist/client/api/translate.d.ts +1 -1
- package/dist/client/api/translate.js +14 -14
- package/dist/client/api/unload-model.d.ts +1 -1
- package/dist/client/api/unload-model.js +11 -11
- package/dist/client/api/upscale.d.ts +1 -1
- package/dist/client/api/upscale.js +9 -9
- package/dist/client/api/video.d.ts +1 -1
- package/dist/client/api/video.js +16 -14
- package/dist/client/api/vla-helpers.d.ts +2 -2
- package/dist/client/api/vla-helpers.js +6 -11
- package/dist/client/api/vla.d.ts +1 -1
- package/dist/client/api/vla.js +13 -13
- package/dist/client/config-loader/config-utils.d.ts +1 -1
- package/dist/client/config-loader/config-utils.js +3 -3
- package/dist/client/config-loader/resolve-config.bare.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.bare.js +11 -11
- package/dist/client/config-loader/resolve-config.expo.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.expo.js +6 -6
- package/dist/client/config-loader/resolve-config.node.d.ts +1 -1
- package/dist/client/config-loader/resolve-config.node.js +27 -27
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/init-hooks.d.ts +1 -1
- package/dist/client/init-hooks.js +12 -12
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/logging-stream-registry.js +6 -6
- package/dist/client/parse-input.d.ts +1 -1
- package/dist/client/parse-input.js +3 -3
- package/dist/client/plugins-factory.d.ts +2 -2
- package/dist/client/plugins-factory.js +2 -2
- package/dist/client/rpc/bare-client.d.ts +2 -1
- package/dist/client/rpc/bare-client.js +37 -39
- package/dist/client/rpc/ensure-worker-ready.js +4 -4
- package/dist/client/rpc/expo-device-info.d.ts +1 -1
- package/dist/client/rpc/expo-device-info.js +11 -11
- package/dist/client/rpc/expo-rpc-client.d.ts +2 -1
- package/dist/client/rpc/expo-rpc-client.js +38 -47
- package/dist/client/rpc/node-rpc-client.d.ts +2 -1
- package/dist/client/rpc/node-rpc-client.js +103 -75
- package/dist/client/rpc/profiling/index.d.ts +1 -1
- package/dist/client/rpc/profiling/index.js +1 -1
- package/dist/client/rpc/profiling/profiler.d.ts +2 -2
- package/dist/client/rpc/profiling/profiler.js +31 -34
- package/dist/client/rpc/rpc-client.d.ts +2 -2
- package/dist/client/rpc/rpc-client.js +113 -72
- package/dist/client/rpc/rpc-error.d.ts +1 -1
- package/dist/client/rpc/rpc-error.js +14 -14
- package/dist/commands/bundle/bare-pack.d.ts +1 -1
- package/dist/commands/bundle/bare-pack.js +20 -20
- package/dist/commands/bundle/constants.js +21 -21
- package/dist/commands/bundle/entry-gen.js +4 -4
- package/dist/commands/bundle/index.js +45 -47
- package/dist/commands/bundle/manifest.d.ts +1 -1
- package/dist/commands/bundle/manifest.js +44 -46
- package/dist/commands/bundle/plugins.d.ts +2 -2
- package/dist/commands/bundle/plugins.js +7 -7
- package/dist/commands/bundle/resolve-sdk-import.js +6 -13
- package/dist/commands/index.d.ts +4 -4
- package/dist/commands/index.js +2 -2
- package/dist/commands/verify/abi.d.ts +9 -9
- package/dist/commands/verify/abi.js +31 -31
- package/dist/commands/verify/addon-source.d.ts +1 -1
- package/dist/commands/verify/addon-source.js +13 -14
- package/dist/commands/verify/bundle-source.d.ts +1 -1
- package/dist/commands/verify/bundle-source.js +7 -7
- package/dist/commands/verify/index.d.ts +3 -3
- package/dist/commands/verify/index.js +18 -17
- package/dist/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/commands/verify/node-modules-source.js +11 -11
- package/dist/commands/verify/prebuilds.d.ts +3 -3
- package/dist/commands/verify/prebuilds.js +8 -8
- package/dist/constants/audio.d.ts +1 -1
- package/dist/constants/audio.js +1 -1
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +2 -2
- package/dist/constants/registry.js +1 -1
- package/dist/examples/audio/mic-input.d.ts +1 -1
- package/dist/examples/audio/mic-input.js +31 -31
- package/dist/examples/batch-completion.d.ts +38 -0
- package/dist/examples/batch-completion.js +100 -0
- package/dist/examples/bci/bci-filesystem-streaming.js +20 -20
- package/dist/examples/bci/bci-filesystem.js +17 -17
- package/dist/examples/cache-management.js +32 -32
- package/dist/examples/cancel-by-request-id.js +11 -11
- package/dist/examples/classification/classify-image.js +5 -5
- package/dist/examples/completion-events.js +16 -18
- package/dist/examples/completion-stop-reason.js +13 -13
- package/dist/examples/concurrent-completion-collision.js +20 -20
- package/dist/examples/config/blind-relay/blind-relay.config.js +4 -4
- package/dist/examples/config/default/default.config.js +2 -2
- package/dist/examples/config/plugins/plugins.config.js +2 -2
- package/dist/examples/config-reload.js +14 -14
- package/dist/examples/default-config-usage.js +10 -13
- package/dist/examples/delegated-inference/composite.js +23 -23
- package/dist/examples/delegated-inference/consumer-profiled.js +19 -19
- package/dist/examples/delegated-inference/consumer.js +11 -11
- package/dist/examples/delegated-inference/provider.js +24 -24
- package/dist/examples/diffusion-esrgan-upscale.js +19 -19
- package/dist/examples/diffusion-flux2-klein-img2img.js +17 -17
- package/dist/examples/diffusion-flux2-klein.js +14 -14
- package/dist/examples/diffusion-img2img.js +13 -13
- package/dist/examples/diffusion-img2vid.js +22 -23
- package/dist/examples/diffusion-simple.js +7 -7
- package/dist/examples/diffusion-txt2img.js +13 -14
- package/dist/examples/diffusion-txt2vid.js +18 -18
- package/dist/examples/download-with-blind-relays.js +7 -8
- package/dist/examples/download-with-cancel.js +9 -9
- package/dist/examples/embed-multi-gpu.js +9 -9
- package/dist/examples/embed-p2p.js +24 -24
- package/dist/examples/finetune/llamacpp-finetune.js +21 -21
- package/dist/examples/kv-cache-cleanup.js +34 -34
- package/dist/examples/kv-cache-custom-key.js +30 -30
- package/dist/examples/kv-cache-example.js +18 -20
- package/dist/examples/llamacpp-cache.js +33 -33
- package/dist/examples/llamacpp-dynamic-tools.js +38 -38
- package/dist/examples/llamacpp-filesystem.js +13 -15
- package/dist/examples/llamacpp-http.js +12 -14
- package/dist/examples/llamacpp-multi-gpu.js +12 -12
- package/dist/examples/llamacpp-multimodal.js +16 -16
- package/dist/examples/llamacpp-p2p.js +11 -11
- package/dist/examples/llamacpp-sharded.js +12 -12
- package/dist/examples/llamacpp-structured-output.js +37 -37
- package/dist/examples/logging-file-transport.js +19 -21
- package/dist/examples/logging-global.js +8 -8
- package/dist/examples/logging-streaming.js +16 -18
- package/dist/examples/mcp-websearch.js +44 -44
- package/dist/examples/multi-model-demo.js +33 -33
- package/dist/examples/ocr-fasttext.js +17 -17
- package/dist/examples/parallel-download.js +11 -13
- package/dist/examples/plugins.js +43 -43
- package/dist/examples/profiling/basic.js +34 -36
- package/dist/examples/profiling/per-call.js +16 -16
- package/dist/examples/quickstart.bare.js +4 -6
- package/dist/examples/quickstart.js +7 -7
- package/dist/examples/rag/rag-chromadb.js +26 -26
- package/dist/examples/rag/rag-hyperdb/cancellation.js +19 -20
- package/dist/examples/rag/rag-hyperdb/ingest.js +19 -19
- package/dist/examples/rag/rag-hyperdb/pipeline.js +26 -26
- package/dist/examples/rag/rag-hyperdb/workspaces.js +46 -46
- package/dist/examples/rag/rag-lancedb.js +29 -32
- package/dist/examples/rag/rag-sqlite.js +25 -25
- package/dist/examples/registry-query.js +15 -15
- package/dist/examples/seed-p2p.js +8 -8
- package/dist/examples/suspend-resume.js +20 -20
- package/dist/examples/tools/llamacpp-native-tools.js +25 -25
- package/dist/examples/tools/llamacpp-tools-gemma4.js +14 -14
- package/dist/examples/tools/llamacpp-tools-harmony-multiturn.js +15 -15
- package/dist/examples/tools/llamacpp-tools-pythonic.js +15 -15
- package/dist/examples/tools/llamacpp-tools-qwen35.js +14 -14
- package/dist/examples/tools/shared.d.ts +2 -2
- package/dist/examples/tools/shared.js +17 -17
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +12 -12
- package/dist/examples/transcription/parakeet-microphone-record.js +19 -19
- package/dist/examples/transcription/parakeet-microphone-stream.js +23 -23
- package/dist/examples/transcription/parakeet-sortformer-streaming.js +18 -28
- package/dist/examples/transcription/parakeet-sortformer.js +21 -21
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +13 -13
- package/dist/examples/transcription/whispercpp-filesystem-streaming.js +34 -34
- package/dist/examples/transcription/whispercpp-filesystem.js +19 -19
- package/dist/examples/transcription/whispercpp-microphone-conversation.js +27 -27
- package/dist/examples/transcription/whispercpp-microphone-record.js +21 -21
- package/dist/examples/transcription/whispercpp-prompt.js +18 -18
- package/dist/examples/translation/translation-bergamot-batch.js +17 -17
- package/dist/examples/translation/translation-bergamot-pivot.js +16 -16
- package/dist/examples/translation/translation-bergamot.js +11 -11
- package/dist/examples/translation/translation-indic.js +10 -10
- package/dist/examples/translation/translation-llm-afriquegemma.js +10 -10
- package/dist/examples/translation/translation-llm-context.js +10 -10
- package/dist/examples/translation/translation-llm.js +13 -13
- package/dist/examples/translation/translation-stream.js +11 -11
- package/dist/examples/tts/chatterbox-enhanced.d.ts +2 -0
- package/dist/examples/tts/chatterbox-enhanced.js +55 -0
- package/dist/examples/tts/chatterbox-multilingual.d.ts +2 -0
- package/dist/examples/tts/chatterbox-multilingual.js +54 -0
- package/dist/examples/tts/chatterbox.js +18 -18
- package/dist/examples/tts/llm-to-tts-streaming.js +30 -30
- package/dist/examples/tts/supertonic-enhanced.d.ts +2 -0
- package/dist/examples/tts/supertonic-enhanced.js +57 -0
- package/dist/examples/tts/supertonic-multilingual.js +19 -19
- package/dist/examples/tts/supertonic.js +18 -18
- package/dist/examples/tts/utils.js +24 -32
- package/dist/examples/vla-pi05.js +14 -14
- package/dist/examples/vla-smolvla.js +14 -14
- package/dist/examples/voice-assistant/voice-assistant.js +46 -46
- package/dist/expo/plugins/find-in-ancestor-node-modules.js +3 -3
- package/dist/expo/plugins/get-project-root.d.ts +2 -2
- package/dist/expo/plugins/get-project-root.js +1 -1
- package/dist/expo/plugins/index.d.ts +11 -11
- package/dist/expo/plugins/index.js +10 -10
- package/dist/expo/plugins/resolve-sdk-package-dir.js +7 -11
- package/dist/expo/plugins/withAndroidArchitecture.d.ts +1 -1
- package/dist/expo/plugins/withAndroidArchitecture.js +12 -12
- package/dist/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
- package/dist/expo/plugins/withAndroidNdkVersion.js +9 -9
- package/dist/expo/plugins/withDeviceInfo.d.ts +1 -1
- package/dist/expo/plugins/withDeviceInfo.js +13 -13
- package/dist/expo/plugins/withMobileBundle.d.ts +1 -1
- package/dist/expo/plugins/withMobileBundle.js +34 -42
- package/dist/expo/plugins/withOpenCL.d.ts +1 -1
- package/dist/expo/plugins/withOpenCL.js +14 -16
- package/dist/expo/plugins/withQvacSDK.d.ts +1 -1
- package/dist/expo/plugins/withQvacSDK.js +12 -12
- package/dist/index.d.ts +16 -16
- package/dist/index.js +16 -17
- package/dist/logging/addon.d.ts +1 -1
- package/dist/logging/addon.js +13 -13
- package/dist/logging/base-logger.d.ts +2 -2
- package/dist/logging/base-logger.js +6 -6
- package/dist/logging/client-logger.d.ts +1 -1
- package/dist/logging/client-logger.js +3 -3
- package/dist/logging/index.d.ts +9 -9
- package/dist/logging/index.js +8 -8
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.js +4 -4
- package/dist/logging/namespaces.d.ts +1 -1
- package/dist/logging/namespaces.js +5 -5
- package/dist/logging/registry.d.ts +2 -2
- package/dist/logging/registry.js +3 -3
- package/dist/logging/server-logger.d.ts +1 -1
- package/dist/logging/server-logger.js +2 -2
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/stream-logger.js +4 -4
- package/dist/logging/transport.d.ts +1 -1
- package/dist/logging/types.d.ts +1 -1
- package/dist/logging/utils.d.ts +2 -2
- package/dist/logging/utils.js +40 -41
- package/dist/models/registry/index.d.ts +1 -1
- package/dist/models/registry/index.js +5 -5
- package/dist/models/registry/models.d.ts +429 -122
- package/dist/models/registry/models.js +13693 -13369
- package/dist/models/update-models/codegen.d.ts +1 -1
- package/dist/models/update-models/codegen.js +8 -8
- package/dist/models/update-models/companions.d.ts +6 -1
- package/dist/models/update-models/companions.js +104 -39
- package/dist/models/update-models/history.d.ts +1 -1
- package/dist/models/update-models/history.js +11 -11
- package/dist/models/update-models/index.js +32 -34
- package/dist/models/update-models/naming.d.ts +2 -2
- package/dist/models/update-models/naming.js +177 -186
- package/dist/models/update-models/processing.d.ts +2 -2
- package/dist/models/update-models/processing.js +17 -19
- package/dist/models/update-models/registry.d.ts +2 -2
- package/dist/models/update-models/registry.js +9 -9
- package/dist/models/update-models/shards.d.ts +1 -1
- package/dist/models/update-models/shards.js +3 -3
- package/dist/models/update-models/types.d.ts +1 -1
- package/dist/models/update-models/utils.js +5 -5
- package/dist/pear/pre.js +84 -84
- package/dist/profiling/aggregator.d.ts +1 -1
- package/dist/profiling/aggregator.js +6 -6
- package/dist/profiling/clock.d.ts +1 -1
- package/dist/profiling/clock.js +10 -10
- package/dist/profiling/controller.d.ts +2 -2
- package/dist/profiling/controller.js +11 -12
- package/dist/profiling/envelope.d.ts +1 -1
- package/dist/profiling/envelope.js +4 -6
- package/dist/profiling/events.d.ts +2 -2
- package/dist/profiling/events.js +8 -10
- package/dist/profiling/exporters.d.ts +1 -1
- package/dist/profiling/exporters.js +81 -79
- package/dist/profiling/index.d.ts +8 -8
- package/dist/profiling/index.js +7 -7
- package/dist/profiling/model-execution.js +2 -1
- package/dist/profiling/ring-buffer.js +2 -2
- package/dist/profiling/types.d.ts +3 -3
- package/dist/schemas/archive.d.ts +1 -1
- package/dist/schemas/archive.js +8 -14
- package/dist/schemas/batch-completion-stream.d.ts +463 -0
- package/dist/schemas/batch-completion-stream.js +124 -0
- package/dist/schemas/bci-config.d.ts +1 -1
- package/dist/schemas/bci-config.js +7 -7
- package/dist/schemas/bci.d.ts +3 -3
- package/dist/schemas/bci.js +25 -31
- package/dist/schemas/cancel.d.ts +6 -1
- package/dist/schemas/cancel.js +33 -34
- package/dist/schemas/classification.d.ts +1 -1
- package/dist/schemas/classification.js +7 -7
- package/dist/schemas/common.d.ts +194 -25
- package/dist/schemas/common.js +40 -37
- package/dist/schemas/completion-event.d.ts +11 -8
- package/dist/schemas/completion-event.js +27 -26
- package/dist/schemas/completion-stream.d.ts +4 -3
- package/dist/schemas/completion-stream.js +51 -67
- package/dist/schemas/delegate.d.ts +1 -1
- package/dist/schemas/delegate.js +7 -7
- package/dist/schemas/delete-cache.d.ts +1 -1
- package/dist/schemas/delete-cache.js +8 -8
- package/dist/schemas/download-asset.d.ts +2 -2
- package/dist/schemas/download-asset.js +21 -21
- package/dist/schemas/embed.d.ts +3 -3
- package/dist/schemas/embed.js +16 -27
- package/dist/schemas/engine-addon-map.d.ts +2 -2
- package/dist/schemas/engine-addon-map.js +24 -24
- package/dist/schemas/error.d.ts +1 -1
- package/dist/schemas/error.js +12 -13
- package/dist/schemas/finetune.d.ts +1 -1
- package/dist/schemas/finetune.js +35 -41
- package/dist/schemas/get-loaded-model-info.d.ts +1 -1
- package/dist/schemas/get-loaded-model-info.js +10 -10
- package/dist/schemas/get-model-info.d.ts +1 -1
- package/dist/schemas/get-model-info.js +48 -91
- package/dist/schemas/heartbeat.d.ts +1 -1
- package/dist/schemas/heartbeat.js +6 -6
- package/dist/schemas/index.d.ts +52 -51
- package/dist/schemas/index.js +52 -51
- package/dist/schemas/json-schema.d.ts +1 -1
- package/dist/schemas/llamacpp-config.d.ts +33 -25
- package/dist/schemas/llamacpp-config.js +43 -30
- package/dist/schemas/load-model.d.ts +160 -128
- package/dist/schemas/load-model.js +120 -126
- package/dist/schemas/logging-stream.d.ts +1 -1
- package/dist/schemas/logging-stream.js +6 -12
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-src-utils.d.ts +1 -1
- package/dist/schemas/model-src-utils.js +13 -13
- package/dist/schemas/model-types.d.ts +1 -1
- package/dist/schemas/model-types.js +27 -27
- package/dist/schemas/ocr.d.ts +1 -1
- package/dist/schemas/ocr.js +18 -18
- package/dist/schemas/path-validation.d.ts +1 -1
- package/dist/schemas/path-validation.js +4 -4
- package/dist/schemas/plugin.d.ts +9 -10
- package/dist/schemas/plugin.js +47 -47
- package/dist/schemas/profiling.d.ts +1 -1
- package/dist/schemas/profiling.js +16 -16
- package/dist/schemas/provide.d.ts +1 -1
- package/dist/schemas/provide.js +8 -8
- package/dist/schemas/rag.d.ts +3 -3
- package/dist/schemas/rag.js +65 -70
- package/dist/schemas/registry.d.ts +1 -1
- package/dist/schemas/registry.js +44 -66
- package/dist/schemas/reload-config.d.ts +1 -1
- package/dist/schemas/reload-config.js +14 -18
- package/dist/schemas/resume.d.ts +1 -1
- package/dist/schemas/resume.js +3 -3
- package/dist/schemas/runtime-context.d.ts +1 -1
- package/dist/schemas/runtime-context.js +4 -4
- package/dist/schemas/sdcpp-config.d.ts +9 -9
- package/dist/schemas/sdcpp-config.js +298 -300
- package/dist/schemas/sdk-config.d.ts +55 -43
- package/dist/schemas/sdk-config.js +25 -29
- package/dist/schemas/sdk-errors-client.d.ts +1 -1
- package/dist/schemas/sdk-errors-client.js +80 -80
- package/dist/schemas/sdk-errors-registry.js +1 -1
- package/dist/schemas/sdk-errors-server.d.ts +1 -1
- package/dist/schemas/sdk-errors-server.js +200 -199
- package/dist/schemas/shard.d.ts +1 -1
- package/dist/schemas/shard.js +4 -4
- package/dist/schemas/state.d.ts +1 -1
- package/dist/schemas/state.js +5 -10
- package/dist/schemas/stop-provide.d.ts +1 -1
- package/dist/schemas/stop-provide.js +4 -4
- package/dist/schemas/suspend.d.ts +1 -1
- package/dist/schemas/suspend.js +3 -3
- package/dist/schemas/text-to-speech.d.ts +455 -3
- package/dist/schemas/text-to-speech.js +146 -110
- package/dist/schemas/tools.d.ts +1 -1
- package/dist/schemas/tools.js +17 -24
- package/dist/schemas/transcription-config.d.ts +1 -1
- package/dist/schemas/transcription-config.js +18 -18
- package/dist/schemas/transcription.d.ts +5 -5
- package/dist/schemas/transcription.js +31 -33
- package/dist/schemas/translate.d.ts +3 -3
- package/dist/schemas/translate.js +38 -67
- package/dist/schemas/translation-config.d.ts +1 -1
- package/dist/schemas/translation-config.js +116 -123
- package/dist/schemas/unload-model.d.ts +1 -1
- package/dist/schemas/unload-model.js +6 -6
- package/dist/schemas/vla.d.ts +1 -1
- package/dist/schemas/vla.js +30 -30
- package/dist/scripts/run-security-tests.js +9 -10
- package/dist/scripts/run-unit-tests.js +11 -12
- package/dist/server/bare/delegate-connect-diagnostics.js +13 -19
- package/dist/server/bare/delegate-rpc-client.d.ts +2 -2
- package/dist/server/bare/delegate-rpc-client.js +32 -34
- package/dist/server/bare/hyperswarm.d.ts +3 -3
- package/dist/server/bare/hyperswarm.js +14 -14
- package/dist/server/bare/ops/bci-transcribe.d.ts +1 -1
- package/dist/server/bare/ops/bci-transcribe.js +44 -44
- package/dist/server/bare/ops/cancel.d.ts +2 -2
- package/dist/server/bare/ops/cancel.js +6 -6
- package/dist/server/bare/ops/embed.d.ts +1 -1
- package/dist/server/bare/ops/embed.js +26 -16
- package/dist/server/bare/ops/kv-cache-utils.d.ts +1 -1
- package/dist/server/bare/ops/kv-cache-utils.js +17 -19
- package/dist/server/bare/ops/load-model.d.ts +2 -2
- package/dist/server/bare/ops/load-model.js +14 -18
- package/dist/server/bare/ops/transcribe.d.ts +3 -3
- package/dist/server/bare/ops/transcribe.js +62 -62
- package/dist/server/bare/ops/translate.d.ts +1 -1
- package/dist/server/bare/ops/translate.js +39 -30
- package/dist/server/bare/ops/unload-model.d.ts +1 -1
- package/dist/server/bare/ops/unload-model.js +12 -12
- package/dist/server/bare/plugins/bci-whispercpp-transcription/args.d.ts +2 -2
- package/dist/server/bare/plugins/bci-whispercpp-transcription/args.js +3 -3
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.d.ts +2 -2
- package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.js +33 -33
- package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.d.ts +1 -1
- package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.js +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 +8 -8
- package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-classification/plugin.js +14 -14
- 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 +27 -26
- package/dist/server/bare/plugins/ggml-ocr/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-ocr/plugin.js +38 -38
- 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 +3 -3
- 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 +23 -23
- package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/ggml-vla/plugin.js +15 -15
- package/dist/server/bare/plugins/index.d.ts +11 -11
- package/dist/server/bare/plugins/index.js +11 -11
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-cancelled.d.ts +23 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-cancelled.js +30 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.d.ts +32 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.js +99 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +1 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +8 -8
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.d.ts +3 -2
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.js +4 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +22 -4
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +55 -59
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +5 -5
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +2 -2
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +34 -34
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +7 -7
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +19 -23
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +4 -6
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +186 -17
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +235 -70
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +1 -1
- package/dist/server/bare/plugins/llamacpp-completion/transform.js +15 -15
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +3 -3
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +27 -29
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +38 -39
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +1 -1
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.js +19 -22
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +36 -36
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +15 -17
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +11 -11
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +1 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +42 -44
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +4 -4
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +69 -63
- 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 +19 -21
- 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 +22 -24
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +3 -2
- package/dist/server/bare/plugins/tts-ggml/plugin.js +95 -49
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +52 -52
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/chunk.js +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +4 -4
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +3 -3
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +4 -4
- 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 +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +5 -5
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +2 -2
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +3 -3
- package/dist/server/bare/rag-hyperdb/handlers/search.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.js +3 -3
- 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 +3 -3
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +20 -20
- package/dist/server/bare/registry/config-registry.d.ts +1 -1
- package/dist/server/bare/registry/config-registry.js +13 -16
- package/dist/server/bare/registry/logging-stream-registry.d.ts +1 -1
- package/dist/server/bare/registry/logging-stream-registry.js +2 -2
- package/dist/server/bare/registry/model-config-registry.d.ts +2 -2
- package/dist/server/bare/registry/model-config-registry.js +6 -6
- package/dist/server/bare/registry/model-config-utils.d.ts +2 -2
- package/dist/server/bare/registry/model-config-utils.js +35 -35
- package/dist/server/bare/registry/model-registry.d.ts +3 -3
- package/dist/server/bare/registry/model-registry.js +11 -11
- package/dist/server/bare/registry/registry-client.d.ts +1 -1
- package/dist/server/bare/registry/registry-client.js +18 -18
- package/dist/server/bare/registry/runtime-context-registry.d.ts +1 -1
- package/dist/server/bare/registry/runtime-context-registry.js +3 -3
- package/dist/server/bare/runtime/disposable-scope.js +3 -3
- 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 +4 -4
- package/dist/server/bare/runtime/request-id.js +1 -1
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +1 -1
- package/dist/server/bare/runtime/request-registry-singleton.js +23 -4
- package/dist/server/bare/runtime/request-registry.d.ts +27 -12
- package/dist/server/bare/runtime/request-registry.js +39 -34
- package/dist/server/bare/runtime/with-request-context.d.ts +1 -1
- package/dist/server/bare/runtime/with-request-context.js +11 -11
- package/dist/server/bare/runtime-lifecycle.d.ts +1 -1
- package/dist/server/bare/runtime-lifecycle.js +27 -31
- package/dist/server/bare/types/addon-responses.d.ts +5 -4
- package/dist/server/bare/utils/audio-input.d.ts +2 -2
- package/dist/server/bare/utils/audio-input.js +7 -7
- package/dist/server/bare/utils/transcribe-metadata.d.ts +1 -1
- package/dist/server/bare/utils/transcribe-metadata.js +4 -4
- package/dist/server/bare/utils/tts-stats.d.ts +1 -1
- package/dist/server/bare/utils/tts-stats.js +3 -3
- package/dist/server/env.js +8 -8
- package/dist/server/error-handlers.d.ts +3 -3
- package/dist/server/error-handlers.js +11 -11
- package/dist/server/plugins/index.d.ts +1 -1
- package/dist/server/plugins/index.js +1 -1
- package/dist/server/plugins/registry.d.ts +1 -1
- package/dist/server/plugins/registry.js +12 -14
- package/dist/server/rpc/create-server.d.ts +1 -1
- package/dist/server/rpc/create-server.js +11 -12
- package/dist/server/rpc/delegate-transport.d.ts +3 -3
- package/dist/server/rpc/delegate-transport.js +43 -44
- package/dist/server/rpc/handle-request.d.ts +1 -1
- package/dist/server/rpc/handle-request.js +28 -30
- package/dist/server/rpc/handler-registry.d.ts +1 -1
- package/dist/server/rpc/handler-registry.js +97 -92
- package/dist/server/rpc/handler-selection.d.ts +3 -3
- package/dist/server/rpc/handler-selection.js +3 -3
- package/dist/server/rpc/handler-utils.d.ts +7 -7
- package/dist/server/rpc/handler-utils.js +32 -35
- package/dist/server/rpc/handlers/batch-completion-stream.d.ts +78 -0
- package/dist/server/rpc/handlers/batch-completion-stream.js +4 -0
- package/dist/server/rpc/handlers/bci-transcribe-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/bci-transcribe-stream.js +2 -2
- package/dist/server/rpc/handlers/bci-transcribe.d.ts +1 -1
- package/dist/server/rpc/handlers/bci-transcribe.js +2 -2
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/cancel-delegated.js +13 -13
- package/dist/server/rpc/handlers/cancelHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/cancelHandler.js +11 -11
- package/dist/server/rpc/handlers/classify.d.ts +1 -1
- package/dist/server/rpc/handlers/classify.js +2 -2
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/completion-stream-delegated.js +14 -14
- package/dist/server/rpc/handlers/completion-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/completion-stream.js +2 -2
- package/dist/server/rpc/handlers/delete-cache.d.ts +1 -1
- package/dist/server/rpc/handlers/delete-cache.js +10 -10
- package/dist/server/rpc/handlers/diffusion-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/diffusion-stream.js +2 -2
- package/dist/server/rpc/handlers/download-asset.d.ts +1 -1
- package/dist/server/rpc/handlers/download-asset.js +20 -20
- package/dist/server/rpc/handlers/embed.d.ts +1 -1
- package/dist/server/rpc/handlers/embed.js +2 -2
- package/dist/server/rpc/handlers/finetune.d.ts +1 -1
- package/dist/server/rpc/handlers/finetune.js +8 -6
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +1 -1
- package/dist/server/rpc/handlers/get-loaded-model-info.js +9 -9
- package/dist/server/rpc/handlers/get-model-info.d.ts +1 -1
- package/dist/server/rpc/handlers/get-model-info.js +20 -20
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/heartbeat-delegated.js +7 -7
- package/dist/server/rpc/handlers/heartbeat.d.ts +1 -1
- package/dist/server/rpc/handlers/heartbeat.js +1 -1
- package/dist/server/rpc/handlers/index.d.ts +33 -31
- package/dist/server/rpc/handlers/index.js +34 -32
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +4 -4
- package/dist/server/rpc/handlers/load-model/download-manager.js +19 -17
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +4 -3
- package/dist/server/rpc/handlers/load-model/download-stats.js +9 -11
- package/dist/server/rpc/handlers/load-model/handler.d.ts +1 -1
- package/dist/server/rpc/handlers/load-model/handler.js +42 -43
- package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/http.js +100 -107
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +72 -74
- package/dist/server/rpc/handlers/load-model/index.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/index.js +2 -2
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/registry-client-options.js +2 -3
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +5 -5
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +19 -21
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +6 -6
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +16 -18
- package/dist/server/rpc/handlers/load-model/registry-metadata.d.ts +11 -0
- package/dist/server/rpc/handlers/load-model/registry-metadata.js +23 -0
- package/dist/server/rpc/handlers/load-model/registry.d.ts +4 -3
- package/dist/server/rpc/handlers/load-model/registry.js +50 -56
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/resolve-session.js +7 -7
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +36 -35
- package/dist/server/rpc/handlers/load-model/types.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/types.js +7 -7
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model-delegated.js +31 -30
- package/dist/server/rpc/handlers/logging-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/logging-stream.js +3 -3
- package/dist/server/rpc/handlers/ocr-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/ocr-stream.js +2 -2
- package/dist/server/rpc/handlers/plugin-dispatch.js +9 -9
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +1 -1
- package/dist/server/rpc/handlers/plugin-invoke.js +16 -16
- package/dist/server/rpc/handlers/provideHandler/connection.d.ts +1 -1
- package/dist/server/rpc/handlers/provideHandler/connection.js +16 -16
- package/dist/server/rpc/handlers/provideHandler/handler.d.ts +1 -1
- package/dist/server/rpc/handlers/provideHandler/handler.js +18 -18
- package/dist/server/rpc/handlers/provideHandler/proxy.d.ts +1 -1
- package/dist/server/rpc/handlers/provideHandler/proxy.js +11 -11
- package/dist/server/rpc/handlers/provideHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/provideHandler.js +1 -1
- package/dist/server/rpc/handlers/rag.d.ts +1 -1
- package/dist/server/rpc/handlers/rag.js +50 -50
- package/dist/server/rpc/handlers/registry.d.ts +1 -1
- package/dist/server/rpc/handlers/registry.js +34 -36
- package/dist/server/rpc/handlers/resume.d.ts +1 -1
- package/dist/server/rpc/handlers/resume.js +3 -3
- package/dist/server/rpc/handlers/state.d.ts +1 -1
- package/dist/server/rpc/handlers/state.js +3 -3
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +1 -1
- package/dist/server/rpc/handlers/stopProvideHandler.js +7 -7
- package/dist/server/rpc/handlers/suspend.d.ts +1 -1
- package/dist/server/rpc/handlers/suspend.js +3 -3
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/text-to-speech-stream.js +2 -2
- package/dist/server/rpc/handlers/text-to-speech.d.ts +1 -1
- package/dist/server/rpc/handlers/text-to-speech.js +2 -2
- package/dist/server/rpc/handlers/transcribe-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/transcribe-stream.js +2 -2
- package/dist/server/rpc/handlers/transcribe.d.ts +1 -1
- package/dist/server/rpc/handlers/transcribe.js +2 -2
- package/dist/server/rpc/handlers/translate.d.ts +1 -1
- package/dist/server/rpc/handlers/translate.js +2 -2
- package/dist/server/rpc/handlers/unload-model-delegated.d.ts +1 -1
- package/dist/server/rpc/handlers/unload-model-delegated.js +10 -10
- package/dist/server/rpc/handlers/unload-model.d.ts +1 -1
- package/dist/server/rpc/handlers/unload-model.js +10 -10
- package/dist/server/rpc/handlers/upscale-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/upscale-stream.js +2 -2
- package/dist/server/rpc/handlers/video-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/video-stream.js +2 -2
- package/dist/server/rpc/index.d.ts +2 -2
- package/dist/server/rpc/index.js +2 -2
- package/dist/server/rpc/profiling/context.d.ts +1 -1
- package/dist/server/rpc/profiling/context.js +9 -10
- package/dist/server/rpc/profiling/delegation-profiler.d.ts +2 -2
- package/dist/server/rpc/profiling/delegation-profiler.js +23 -24
- package/dist/server/rpc/profiling/index.d.ts +4 -4
- package/dist/server/rpc/profiling/index.js +4 -4
- package/dist/server/rpc/profiling/operation-metrics.d.ts +2 -2
- package/dist/server/rpc/profiling/operation-metrics.js +102 -102
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +1 -1
- package/dist/server/rpc/profiling/operation-wrappers.js +16 -14
- package/dist/server/rpc/profiling/profiler.d.ts +2 -2
- package/dist/server/rpc/profiling/profiler.js +9 -13
- package/dist/server/rpc/rpc-utils.js +1 -4
- package/dist/server/rpc/transport-selector.d.ts +1 -1
- package/dist/server/rpc/transport-selector.js +4 -4
- package/dist/server/utils/archive.js +27 -29
- package/dist/server/utils/audio/decoder.d.ts +2 -2
- package/dist/server/utils/audio/decoder.js +11 -11
- package/dist/server/utils/cache/auto-history.d.ts +1 -1
- package/dist/server/utils/cache/auto-history.js +5 -5
- package/dist/server/utils/cache/paths.d.ts +2 -2
- package/dist/server/utils/cache/paths.js +14 -14
- package/dist/server/utils/checksum.d.ts +1 -1
- package/dist/server/utils/checksum.js +10 -12
- package/dist/server/utils/clear-storage.d.ts +1 -1
- package/dist/server/utils/clear-storage.js +8 -11
- package/dist/server/utils/completion-normalizer.d.ts +1 -1
- package/dist/server/utils/completion-normalizer.js +106 -113
- package/dist/server/utils/config-transform.d.ts +1 -1
- package/dist/server/utils/config-transform.js +2 -2
- package/dist/server/utils/expand-gguf-shards.js +4 -4
- package/dist/server/utils/formatting.js +6 -12
- package/dist/server/utils/gguf-tensor-extractor.js +17 -21
- package/dist/server/utils/index.d.ts +11 -11
- package/dist/server/utils/index.js +11 -11
- package/dist/server/utils/multi-gpu-mobile.js +1 -1
- package/dist/server/utils/path-security.d.ts +1 -1
- package/dist/server/utils/path-security.js +6 -6
- package/dist/server/utils/qvac-paths.js +3 -3
- package/dist/server/utils/response-format.d.ts +1 -1
- package/dist/server/utils/response-format.js +4 -4
- package/dist/server/utils/shard-utils.d.ts +1 -1
- package/dist/server/utils/shard-utils.js +14 -16
- package/dist/server/utils/tool-integration.d.ts +1 -1
- package/dist/server/utils/tool-integration.js +5 -9
- package/dist/server/utils/tools/dialect.d.ts +1 -1
- package/dist/server/utils/tools/dialect.js +7 -7
- package/dist/server/utils/tools/index.d.ts +2 -2
- package/dist/server/utils/tools/index.js +2 -2
- package/dist/server/utils/tools/parser.d.ts +1 -1
- package/dist/server/utils/tools/parser.js +14 -14
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +2 -2
- package/dist/server/utils/tools/parsers/gemma4native.js +13 -8
- package/dist/server/utils/tools/parsers/harmony.d.ts +2 -2
- package/dist/server/utils/tools/parsers/harmony.js +9 -11
- package/dist/server/utils/tools/parsers/hermes.d.ts +2 -2
- package/dist/server/utils/tools/parsers/hermes.js +16 -16
- package/dist/server/utils/tools/parsers/json.d.ts +2 -2
- package/dist/server/utils/tools/parsers/json.js +14 -14
- package/dist/server/utils/tools/parsers/pythonic.d.ts +2 -2
- package/dist/server/utils/tools/parsers/pythonic.js +43 -43
- package/dist/server/utils/tools/parsers/qwen35.d.ts +2 -2
- package/dist/server/utils/tools/parsers/qwen35.js +20 -20
- package/dist/server/utils/tools/shared.d.ts +1 -1
- package/dist/server/utils/tools/shared.js +10 -12
- package/dist/server/utils/worker-lock.js +10 -10
- package/dist/server/worker-core.d.ts +1 -1
- package/dist/server/worker-core.js +44 -43
- package/dist/server/worker.js +9 -9
- package/dist/utils/aggregate-events.d.ts +2 -2
- package/dist/utils/aggregate-events.js +17 -19
- package/dist/utils/cache-normalize.js +1 -4
- package/dist/utils/encoding.js +1 -1
- package/dist/utils/errors-base.d.ts +1 -1
- package/dist/utils/errors-base.js +1 -1
- package/dist/utils/errors-client.d.ts +1 -1
- package/dist/utils/errors-client.js +5 -5
- package/dist/utils/errors-server.d.ts +3 -3
- package/dist/utils/errors-server.js +19 -18
- package/dist/utils/load-model-validation.js +3 -3
- package/dist/utils/mcp-adapter.d.ts +4 -4
- package/dist/utils/mcp-adapter.js +31 -38
- package/dist/utils/path-sanitize.js +14 -17
- package/dist/utils/tool-helpers.d.ts +2 -2
- package/dist/utils/tool-helpers.js +25 -26
- package/dist/utils/withTimeout.d.ts +7 -0
- package/dist/utils/withTimeout.js +11 -1
- package/dist/utils/zod-error.d.ts +1 -1
- package/dist/utils/zod-error.js +1 -1
- package/electron-forge/index.cjs +274 -317
- package/expo/plugins/patches/android-link.mjs +25 -30
- package/expo/plugins/patches/ios-link.mjs +25 -30
- package/package.json +17 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadModel, completion, unloadModel, QWEN3_600M_INST_Q4
|
|
1
|
+
import { loadModel, completion, unloadModel, QWEN3_600M_INST_Q4 } from '@qvac/sdk';
|
|
2
2
|
// Demonstrates per-request structured output via `responseFormat`.
|
|
3
3
|
// Three modes are exercised against the same model so you can eyeball the
|
|
4
4
|
// difference between free-form text, free-form JSON, and a strict JSON Schema.
|
|
@@ -6,24 +6,24 @@ import { loadModel, completion, unloadModel, QWEN3_600M_INST_Q4, } from "@qvac/s
|
|
|
6
6
|
// Usage:
|
|
7
7
|
// bun run examples/llamacpp-structured-output.ts
|
|
8
8
|
const PERSON_SCHEMA = {
|
|
9
|
-
type:
|
|
9
|
+
type: 'object',
|
|
10
10
|
properties: {
|
|
11
|
-
name: { type:
|
|
12
|
-
age: { type:
|
|
13
|
-
occupation: { type:
|
|
11
|
+
name: { type: 'string' },
|
|
12
|
+
age: { type: 'integer' },
|
|
13
|
+
occupation: { type: 'string' }
|
|
14
14
|
},
|
|
15
|
-
required: [
|
|
16
|
-
additionalProperties: false
|
|
15
|
+
required: ['name', 'age', 'occupation'],
|
|
16
|
+
additionalProperties: false
|
|
17
17
|
};
|
|
18
18
|
const HISTORY = [
|
|
19
19
|
{
|
|
20
|
-
role:
|
|
21
|
-
content:
|
|
20
|
+
role: 'system',
|
|
21
|
+
content: 'You extract structured information about people from short bios. /no_think'
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
role:
|
|
25
|
-
content: "Hi, I'm Alice, I'm 30 years old and I work as a data engineer."
|
|
26
|
-
}
|
|
24
|
+
role: 'user',
|
|
25
|
+
content: "Hi, I'm Alice, I'm 30 years old and I work as a data engineer."
|
|
26
|
+
}
|
|
27
27
|
];
|
|
28
28
|
// `json_object` mode only enforces that the output is *some* valid JSON object
|
|
29
29
|
// — it doesn't pin the keys. Small models (Qwen3-0.6B in this example) will
|
|
@@ -34,13 +34,13 @@ const HISTORY = [
|
|
|
34
34
|
// grammar itself forces the keys.
|
|
35
35
|
const JSON_OBJECT_HISTORY = [
|
|
36
36
|
{
|
|
37
|
-
role:
|
|
38
|
-
content: 'You extract structured information about people from short bios and reply ONLY with a JSON object containing "name", "age", and "occupation". /no_think'
|
|
37
|
+
role: 'system',
|
|
38
|
+
content: 'You extract structured information about people from short bios and reply ONLY with a JSON object containing "name", "age", and "occupation". /no_think'
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
role:
|
|
42
|
-
content: "Hi, I'm Alice, I'm 30 years old and I work as a data engineer."
|
|
43
|
-
}
|
|
41
|
+
role: 'user',
|
|
42
|
+
content: "Hi, I'm Alice, I'm 30 years old and I work as a data engineer."
|
|
43
|
+
}
|
|
44
44
|
];
|
|
45
45
|
// Drains the run via the canonical `events` / `final` surface and returns the
|
|
46
46
|
// content text. `tokenStream` / `text` / `stats` still work but are legacy and
|
|
@@ -48,11 +48,11 @@ const JSON_OBJECT_HISTORY = [
|
|
|
48
48
|
// await `final.contentText` for the aggregated result.
|
|
49
49
|
async function runToContent(run) {
|
|
50
50
|
for await (const event of run.events) {
|
|
51
|
-
if (event.type ===
|
|
51
|
+
if (event.type === 'contentDelta')
|
|
52
52
|
process.stdout.write(event.text);
|
|
53
53
|
}
|
|
54
54
|
const final = await run.final;
|
|
55
|
-
process.stdout.write(
|
|
55
|
+
process.stdout.write('\n');
|
|
56
56
|
return final.contentText;
|
|
57
57
|
}
|
|
58
58
|
try {
|
|
@@ -63,49 +63,49 @@ try {
|
|
|
63
63
|
const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
|
|
64
64
|
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
65
65
|
if (p.percentage >= 100)
|
|
66
|
-
process.stderr.write(
|
|
67
|
-
}
|
|
66
|
+
process.stderr.write('\n');
|
|
67
|
+
}
|
|
68
68
|
});
|
|
69
69
|
console.log(`\n▸ Model loaded: ${modelId}\n`);
|
|
70
|
-
console.log(
|
|
70
|
+
console.log('▸ --- 1. responseFormat: text (baseline, free-form) ---');
|
|
71
71
|
await runToContent(completion({
|
|
72
72
|
modelId,
|
|
73
73
|
history: HISTORY,
|
|
74
74
|
stream: true,
|
|
75
|
-
responseFormat: { type:
|
|
75
|
+
responseFormat: { type: 'text' }
|
|
76
76
|
}));
|
|
77
|
-
console.log(
|
|
77
|
+
console.log('\n▸ --- 2. responseFormat: json_object (any valid JSON) ---');
|
|
78
78
|
const jsonObjectOut = await runToContent(completion({
|
|
79
79
|
modelId,
|
|
80
80
|
history: JSON_OBJECT_HISTORY,
|
|
81
81
|
stream: true,
|
|
82
|
-
responseFormat: { type:
|
|
82
|
+
responseFormat: { type: 'json_object' }
|
|
83
83
|
}));
|
|
84
|
-
console.log(
|
|
85
|
-
console.log(
|
|
84
|
+
console.log('▸ parsed:', JSON.parse(jsonObjectOut.trim()));
|
|
85
|
+
console.log('\n▸ --- 3. responseFormat: json_schema (strict shape) ---');
|
|
86
86
|
const jsonSchemaOut = await runToContent(completion({
|
|
87
87
|
modelId,
|
|
88
88
|
history: HISTORY,
|
|
89
89
|
stream: true,
|
|
90
90
|
responseFormat: {
|
|
91
|
-
type:
|
|
91
|
+
type: 'json_schema',
|
|
92
92
|
json_schema: {
|
|
93
|
-
name:
|
|
94
|
-
schema: PERSON_SCHEMA
|
|
95
|
-
}
|
|
96
|
-
}
|
|
93
|
+
name: 'person',
|
|
94
|
+
schema: PERSON_SCHEMA
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
97
|
}));
|
|
98
98
|
// Output is guaranteed schema-valid JSON: object with exactly
|
|
99
99
|
// {name: string, age: integer, occupation: string}, no extras.
|
|
100
100
|
const parsed = JSON.parse(jsonSchemaOut.trim());
|
|
101
|
-
console.log(
|
|
102
|
-
console.log(
|
|
101
|
+
console.log('▸ parsed:', parsed);
|
|
102
|
+
console.log('▸ schema-valid:', typeof parsed.name === 'string' &&
|
|
103
103
|
Number.isInteger(parsed.age) &&
|
|
104
|
-
typeof parsed.occupation ===
|
|
105
|
-
Object.keys(parsed).sort().join(
|
|
104
|
+
typeof parsed.occupation === 'string' &&
|
|
105
|
+
Object.keys(parsed).sort().join(',') === 'age,name,occupation');
|
|
106
106
|
await unloadModel({ modelId });
|
|
107
107
|
}
|
|
108
108
|
catch (error) {
|
|
109
|
-
console.error(
|
|
109
|
+
console.error('✖', error);
|
|
110
110
|
process.exit(1);
|
|
111
111
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getLogger, loadModel, completion, unloadModel, LLAMA_3_2_1B_INST_Q4_0, VERBOSITY
|
|
2
|
-
import { writeFileSync, appendFileSync } from
|
|
3
|
-
import { join } from
|
|
1
|
+
import { getLogger, loadModel, completion, unloadModel, LLAMA_3_2_1B_INST_Q4_0, VERBOSITY } from '@qvac/sdk';
|
|
2
|
+
import { writeFileSync, appendFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
4
|
try {
|
|
5
|
-
const logFile = join(process.cwd(),
|
|
5
|
+
const logFile = join(process.cwd(), 'model-logs.txt');
|
|
6
6
|
// Clear previous logs
|
|
7
|
-
writeFileSync(logFile,
|
|
7
|
+
writeFileSync(logFile, '');
|
|
8
8
|
// Create logger with file transport
|
|
9
|
-
const logger = getLogger(
|
|
10
|
-
level:
|
|
9
|
+
const logger = getLogger('llm-file-demo', {
|
|
10
|
+
level: 'debug',
|
|
11
11
|
enableConsole: false, // Disable console output (logs go to file only). Set to true for both console + file
|
|
12
12
|
transports: [
|
|
13
13
|
// File transport - append logs to file
|
|
@@ -15,42 +15,40 @@ try {
|
|
|
15
15
|
const timestamp = new Date().toISOString();
|
|
16
16
|
const logLine = `[${timestamp}] ${level.toUpperCase()} ${namespace}: ${message}\n`;
|
|
17
17
|
appendFileSync(logFile, logLine);
|
|
18
|
-
}
|
|
19
|
-
]
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
20
|
});
|
|
21
|
-
logger.info(
|
|
21
|
+
logger.info('Starting model demo with file logging');
|
|
22
22
|
// Load model with integrated logging
|
|
23
23
|
const modelId = await loadModel({
|
|
24
24
|
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
25
25
|
modelConfig: {
|
|
26
26
|
ctx_size: 2048,
|
|
27
27
|
temp: 0.7,
|
|
28
|
-
verbosity: VERBOSITY.DEBUG
|
|
28
|
+
verbosity: VERBOSITY.DEBUG
|
|
29
29
|
},
|
|
30
|
-
logger
|
|
30
|
+
logger // All model logs will be captured
|
|
31
31
|
});
|
|
32
32
|
logger.info(`Model loaded: ${modelId}`);
|
|
33
33
|
// Run a simple completion
|
|
34
|
-
logger.info(
|
|
35
|
-
const messages = [
|
|
36
|
-
|
|
37
|
-
];
|
|
38
|
-
let responseText = "";
|
|
34
|
+
logger.info('Starting completion...');
|
|
35
|
+
const messages = [{ role: 'user', content: 'Tell me a short joke about programming.' }];
|
|
36
|
+
let responseText = '';
|
|
39
37
|
const result = completion({ modelId, history: messages, stream: true });
|
|
40
38
|
for await (const token of result.tokenStream) {
|
|
41
39
|
responseText += token;
|
|
42
40
|
process.stdout.write(token);
|
|
43
41
|
}
|
|
44
|
-
console.log(
|
|
42
|
+
console.log('\n');
|
|
45
43
|
logger.info(`Completion finished, ${responseText.length} characters generated`);
|
|
46
44
|
// Unload model
|
|
47
45
|
await unloadModel({ modelId });
|
|
48
|
-
logger.info(
|
|
46
|
+
logger.info('Model unloaded successfully');
|
|
49
47
|
// Show user where logs were saved
|
|
50
48
|
console.log(`▸ Logs saved to ${logFile}`);
|
|
51
|
-
console.log(
|
|
49
|
+
console.log('▸ Inspect it to see detailed model operation logs');
|
|
52
50
|
}
|
|
53
51
|
catch (error) {
|
|
54
|
-
console.error(
|
|
52
|
+
console.error('✖', error);
|
|
55
53
|
process.exit(1);
|
|
56
54
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// transport on both the client and the worker, so the only logs printed are
|
|
3
3
|
// the ones our handler below receives.
|
|
4
4
|
const configDir = import.meta.dirname ?? process.cwd();
|
|
5
|
-
process.env[
|
|
6
|
-
const { loadModel, completion, unloadModel, subscribeServerLogs, LLAMA_3_2_1B_INST_Q4_0 } = await import(
|
|
5
|
+
process.env['QVAC_CONFIG_PATH'] = `${configDir}/config/logging/logging.config.json`;
|
|
6
|
+
const { loadModel, completion, unloadModel, subscribeServerLogs, LLAMA_3_2_1B_INST_Q4_0 } = await import('@qvac/sdk');
|
|
7
7
|
try {
|
|
8
|
-
console.log(
|
|
8
|
+
console.log('▸ Starting global logging demo...\n');
|
|
9
9
|
// One subscription captures every server-side log (SDK, models, RAG, …)
|
|
10
10
|
// without having to know any stream IDs ahead of time.
|
|
11
11
|
const unsubscribe = subscribeServerLogs((log) => {
|
|
@@ -13,14 +13,14 @@ try {
|
|
|
13
13
|
});
|
|
14
14
|
const modelId = await loadModel({
|
|
15
15
|
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
16
|
-
modelConfig: { ctx_size: 2048 }
|
|
16
|
+
modelConfig: { ctx_size: 2048 }
|
|
17
17
|
});
|
|
18
18
|
const result = completion({
|
|
19
19
|
modelId,
|
|
20
|
-
history: [{ role:
|
|
21
|
-
stream: true
|
|
20
|
+
history: [{ role: 'user', content: 'Count from 1 to 5.' }],
|
|
21
|
+
stream: true
|
|
22
22
|
});
|
|
23
|
-
console.log(
|
|
23
|
+
console.log('▸ Response:\n');
|
|
24
24
|
for await (const token of result.tokenStream) {
|
|
25
25
|
process.stdout.write(token);
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ try {
|
|
|
28
28
|
unsubscribe();
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
console.error(
|
|
31
|
+
console.error('✖', error);
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { loadModel, completion, unloadModel, loggingStream, SDK_LOG_ID, LLAMA_3_2_1B_INST_Q4_0, GTE_LARGE_FP16, VERBOSITY, embed
|
|
1
|
+
import { loadModel, completion, unloadModel, loggingStream, SDK_LOG_ID, LLAMA_3_2_1B_INST_Q4_0, GTE_LARGE_FP16, VERBOSITY, embed } from '@qvac/sdk';
|
|
2
2
|
try {
|
|
3
|
-
console.log(
|
|
3
|
+
console.log('▸ Streaming SDK and model logs');
|
|
4
4
|
// Note: To configure logging (level and console output), use config file:
|
|
5
5
|
// { "loggerLevel": "debug", "loggerConsoleOutput": false } in qvac.config.json/js/ts
|
|
6
6
|
// Subscribe to SDK server logs in background
|
|
7
|
-
console.log(
|
|
7
|
+
console.log('▸ Subscribing to SDK server logs');
|
|
8
8
|
(async () => {
|
|
9
9
|
for await (const log of loggingStream({ id: SDK_LOG_ID })) {
|
|
10
10
|
console.log(`[SDK] [${log.level.toUpperCase()}] [${log.namespace}] ${log.message}`);
|
|
@@ -13,19 +13,19 @@ try {
|
|
|
13
13
|
// Stream terminated - normal on shutdown
|
|
14
14
|
});
|
|
15
15
|
// Load models
|
|
16
|
-
console.log(
|
|
16
|
+
console.log('▸ Loading models');
|
|
17
17
|
const llmModelId = await loadModel({
|
|
18
18
|
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
19
19
|
modelConfig: {
|
|
20
20
|
ctx_size: 2048,
|
|
21
21
|
temp: 0.7,
|
|
22
|
-
verbosity: VERBOSITY.ERROR
|
|
23
|
-
}
|
|
22
|
+
verbosity: VERBOSITY.ERROR // Only log errors, remaining logs are captured by loggingStream
|
|
23
|
+
}
|
|
24
24
|
});
|
|
25
25
|
const embedModelId = await loadModel({
|
|
26
|
-
modelSrc: GTE_LARGE_FP16
|
|
26
|
+
modelSrc: GTE_LARGE_FP16
|
|
27
27
|
});
|
|
28
|
-
console.log(
|
|
28
|
+
console.log('▸ Subscribing to model logs');
|
|
29
29
|
(async () => {
|
|
30
30
|
for await (const log of loggingStream({ id: llmModelId })) {
|
|
31
31
|
const timestamp = new Date(log.timestamp).toISOString();
|
|
@@ -42,29 +42,27 @@ try {
|
|
|
42
42
|
})().catch(() => {
|
|
43
43
|
// Stream terminated - this is normal when model unloads
|
|
44
44
|
});
|
|
45
|
-
const messages = [
|
|
46
|
-
{ role: "user", content: "Count from 1 to 5 and explain each number." },
|
|
47
|
-
];
|
|
45
|
+
const messages = [{ role: 'user', content: 'Count from 1 to 5 and explain each number.' }];
|
|
48
46
|
const result = completion({
|
|
49
47
|
modelId: llmModelId,
|
|
50
48
|
history: messages,
|
|
51
|
-
stream: true
|
|
49
|
+
stream: true
|
|
52
50
|
});
|
|
53
51
|
const { embedding } = await embed({
|
|
54
52
|
modelId: embedModelId,
|
|
55
|
-
text: messages[0]?.content ??
|
|
53
|
+
text: messages[0]?.content ?? 'Hello, world!'
|
|
56
54
|
});
|
|
57
|
-
console.log(
|
|
55
|
+
console.log('▸ Response');
|
|
58
56
|
for await (const token of result.tokenStream) {
|
|
59
57
|
process.stdout.write(token);
|
|
60
58
|
}
|
|
61
|
-
console.log(
|
|
62
|
-
console.log(
|
|
63
|
-
console.log(
|
|
59
|
+
console.log('Embedding (first 20 elements)', embedding.slice(0, 20));
|
|
60
|
+
console.log('Embeddings length', embedding.length);
|
|
61
|
+
console.log('▸ Three streams running: [SDK] server, [LLM] inference, [EMBED] embedding');
|
|
64
62
|
await unloadModel({ modelId: llmModelId, clearStorage: false });
|
|
65
63
|
await unloadModel({ modelId: embedModelId, clearStorage: false });
|
|
66
64
|
}
|
|
67
65
|
catch (error) {
|
|
68
|
-
console.error(
|
|
66
|
+
console.error('✖', error);
|
|
69
67
|
process.exit(1);
|
|
70
68
|
}
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Run with: bun run examples/mcp-websearch.ts
|
|
11
11
|
*/
|
|
12
|
-
import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4
|
|
12
|
+
import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '../index.js';
|
|
13
13
|
// MCP SDK is a user-installed optional dependency
|
|
14
14
|
// Install with: bun add @modelcontextprotocol/sdk
|
|
15
15
|
// eslint-disable-next-line import/no-unresolved
|
|
16
|
-
import { Client } from
|
|
16
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
17
17
|
// eslint-disable-next-line import/no-unresolved
|
|
18
|
-
import { StdioClientTransport } from
|
|
18
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
19
19
|
function parseSearchResults(mcpResult) {
|
|
20
20
|
try {
|
|
21
21
|
const result = mcpResult;
|
|
22
22
|
// Extract text content from MCP response
|
|
23
|
-
const textContent = result.content?.find((c) => c.type ===
|
|
23
|
+
const textContent = result.content?.find((c) => c.type === 'text');
|
|
24
24
|
if (!textContent?.text) {
|
|
25
25
|
return JSON.stringify(mcpResult);
|
|
26
26
|
}
|
|
@@ -28,55 +28,55 @@ function parseSearchResults(mcpResult) {
|
|
|
28
28
|
const rawResults = JSON.parse(textContent.text);
|
|
29
29
|
// Extract just the useful fields (title, url, snippet)
|
|
30
30
|
const cleanResults = rawResults.slice(0, 5).map((r) => ({
|
|
31
|
-
title: r.title ??
|
|
32
|
-
url: r.url ??
|
|
33
|
-
snippet: r.snippet ??
|
|
31
|
+
title: r.title ?? 'Unknown',
|
|
32
|
+
url: r.url ?? '',
|
|
33
|
+
snippet: r.snippet ?? ''
|
|
34
34
|
}));
|
|
35
35
|
// Format as concise text for LLM
|
|
36
36
|
return cleanResults
|
|
37
37
|
.map((r, i) => `[${i + 1}] ${r.title}\n URL: ${r.url}\n ${r.snippet}`)
|
|
38
|
-
.join(
|
|
38
|
+
.join('\n\n');
|
|
39
39
|
}
|
|
40
40
|
catch {
|
|
41
41
|
// If parsing fails, return a truncated version
|
|
42
|
-
const str = typeof mcpResult ===
|
|
42
|
+
const str = typeof mcpResult === 'string' ? mcpResult : JSON.stringify(mcpResult);
|
|
43
43
|
return str.slice(0, 2000);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
let mcpClient = null;
|
|
47
47
|
try {
|
|
48
|
-
console.log(
|
|
48
|
+
console.log('▸ MCP DuckDuckGo Search Example\n');
|
|
49
49
|
// ============================================================
|
|
50
50
|
// STEP 1: Connect to DuckDuckGo MCP server
|
|
51
51
|
// ============================================================
|
|
52
|
-
console.log(
|
|
52
|
+
console.log('▸ Starting DuckDuckGo MCP server...');
|
|
53
53
|
mcpClient = new Client({
|
|
54
|
-
name:
|
|
55
|
-
version:
|
|
54
|
+
name: 'qvac-ddg-example',
|
|
55
|
+
version: '1.0.0'
|
|
56
56
|
});
|
|
57
57
|
const transport = new StdioClientTransport({
|
|
58
|
-
command:
|
|
59
|
-
args: [
|
|
58
|
+
command: 'npx',
|
|
59
|
+
args: ['-y', '@oevortex/ddg_search']
|
|
60
60
|
});
|
|
61
61
|
await mcpClient.connect(transport);
|
|
62
|
-
console.log(
|
|
62
|
+
console.log('▸ MCP server connected\n');
|
|
63
63
|
// ============================================================
|
|
64
64
|
// STEP 2: Load model
|
|
65
65
|
// ============================================================
|
|
66
|
-
console.log(
|
|
66
|
+
console.log('▸ Loading model...');
|
|
67
67
|
const modelId = await loadModel({
|
|
68
68
|
modelSrc: QWEN3_1_7B_INST_Q4,
|
|
69
69
|
modelConfig: {
|
|
70
70
|
ctx_size: 4096,
|
|
71
|
-
tools: true
|
|
71
|
+
tools: true
|
|
72
72
|
},
|
|
73
73
|
onProgress: (p) => {
|
|
74
74
|
const mb = (n) => (n / 1e6).toFixed(1);
|
|
75
75
|
const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
|
|
76
76
|
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
77
77
|
if (p.percentage >= 100)
|
|
78
|
-
process.stderr.write(
|
|
79
|
-
}
|
|
78
|
+
process.stderr.write('\n');
|
|
79
|
+
}
|
|
80
80
|
});
|
|
81
81
|
console.log(`\n▸ Model loaded\n`);
|
|
82
82
|
// ============================================================
|
|
@@ -84,35 +84,35 @@ try {
|
|
|
84
84
|
// ============================================================
|
|
85
85
|
const history = [
|
|
86
86
|
{
|
|
87
|
-
role:
|
|
87
|
+
role: 'system',
|
|
88
88
|
content: `You are a helpful assistant with access to web search.
|
|
89
89
|
Use the search tool when you need current information.
|
|
90
|
-
Always cite your sources with the URL
|
|
90
|
+
Always cite your sources with the URL.`
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
|
-
role:
|
|
94
|
-
content:
|
|
95
|
-
}
|
|
93
|
+
role: 'user',
|
|
94
|
+
content: 'What is the current weather in New York City?'
|
|
95
|
+
}
|
|
96
96
|
];
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
97
|
+
console.log('▸ Asking AI to search the web...\n');
|
|
98
|
+
console.log('▸ AI Response:');
|
|
99
99
|
// Pass MCP client directly to completion - tools are adapted internally!
|
|
100
100
|
const result = completion({
|
|
101
101
|
modelId,
|
|
102
102
|
history,
|
|
103
103
|
stream: true,
|
|
104
|
-
mcp: [{ client: mcpClient, includeResources: false }]
|
|
104
|
+
mcp: [{ client: mcpClient, includeResources: false }]
|
|
105
105
|
});
|
|
106
106
|
for await (const token of result.tokenStream) {
|
|
107
107
|
process.stdout.write(token);
|
|
108
108
|
}
|
|
109
109
|
const toolCalls = await result.toolCalls;
|
|
110
|
-
console.log(
|
|
110
|
+
console.log('\n');
|
|
111
111
|
// ============================================================
|
|
112
112
|
// STEP 4: Execute tool calls using call() - automatic MCP routing!
|
|
113
113
|
// ============================================================
|
|
114
114
|
if (toolCalls.length > 0) {
|
|
115
|
-
console.log(
|
|
115
|
+
console.log('▸ Executing search...\n');
|
|
116
116
|
const toolResults = [];
|
|
117
117
|
for (const toolCall of toolCalls) {
|
|
118
118
|
console.log(`▸ ${toolCall.name}(${JSON.stringify(toolCall.arguments)})`);
|
|
@@ -126,49 +126,49 @@ Always cite your sources with the URL.`,
|
|
|
126
126
|
const cleanResult = parseSearchResults(mcpResult);
|
|
127
127
|
console.log(`▸ Got search results:`);
|
|
128
128
|
console.log(cleanResult
|
|
129
|
-
.split(
|
|
129
|
+
.split('\n')
|
|
130
130
|
.map((l) => ` ${l}`)
|
|
131
|
-
.join(
|
|
131
|
+
.join('\n'));
|
|
132
132
|
console.log();
|
|
133
133
|
toolResults.push({ id: toolCall.id, result: cleanResult });
|
|
134
134
|
}
|
|
135
135
|
// ============================================================
|
|
136
136
|
// STEP 5: Continue with search results
|
|
137
137
|
// ============================================================
|
|
138
|
-
console.log(
|
|
138
|
+
console.log('▸ Getting AI response with search results...\n');
|
|
139
139
|
history.push({
|
|
140
|
-
role:
|
|
141
|
-
content: await result.text
|
|
140
|
+
role: 'assistant',
|
|
141
|
+
content: await result.text
|
|
142
142
|
});
|
|
143
143
|
for (const tr of toolResults) {
|
|
144
144
|
history.push({
|
|
145
|
-
role:
|
|
146
|
-
content: tr.result
|
|
145
|
+
role: 'tool',
|
|
146
|
+
content: tr.result
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
console.log(
|
|
149
|
+
console.log('▸ Final Response:');
|
|
150
150
|
const finalResult = completion({
|
|
151
151
|
modelId,
|
|
152
152
|
history,
|
|
153
153
|
stream: true,
|
|
154
|
-
mcp: [{ client: mcpClient, includeResources: false }]
|
|
154
|
+
mcp: [{ client: mcpClient, includeResources: false }]
|
|
155
155
|
});
|
|
156
156
|
for await (const token of finalResult.tokenStream) {
|
|
157
157
|
process.stdout.write(token);
|
|
158
158
|
}
|
|
159
|
-
console.log(
|
|
159
|
+
console.log('\n');
|
|
160
160
|
}
|
|
161
161
|
// ============================================================
|
|
162
162
|
// Cleanup
|
|
163
163
|
// ============================================================
|
|
164
|
-
console.log(
|
|
164
|
+
console.log('▸ Cleaning up...');
|
|
165
165
|
await unloadModel({ modelId, clearStorage: false });
|
|
166
|
-
console.log(
|
|
167
|
-
console.log(
|
|
166
|
+
console.log('▸ Done\n');
|
|
167
|
+
console.log('▸ Example completed!');
|
|
168
168
|
process.exit(0);
|
|
169
169
|
}
|
|
170
170
|
catch (error) {
|
|
171
|
-
console.error(
|
|
171
|
+
console.error('✖', error);
|
|
172
172
|
process.exit(1);
|
|
173
173
|
}
|
|
174
174
|
finally {
|