@qvac/sdk 0.14.1 → 0.16.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 +47 -45
- 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 +10 -1
- package/dist/client/api/ocr.js +20 -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 -25
- 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 +8 -5
- package/dist/client/api/video.js +23 -18
- 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 +15 -11
- package/dist/client/api/vla.js +27 -23
- 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 +19 -13
- 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-ideogram.d.ts +2 -0
- package/dist/examples/diffusion-ideogram.js +108 -0
- package/dist/examples/diffusion-img2img.js +13 -13
- package/dist/examples/diffusion-img2vid-ltx.d.ts +2 -0
- package/dist/examples/diffusion-img2vid-ltx.js +98 -0
- 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-ltx.d.ts +2 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +92 -0
- 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 +19 -17
- 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-chunked.d.ts +2 -0
- package/dist/examples/transcription/parakeet-tdt-filesystem-chunked.js +203 -0
- 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-groot.d.ts +2 -0
- package/dist/examples/vla-groot.js +118 -0
- 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 +5622 -9241
- package/dist/models/registry/models.js +13215 -17030
- 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 +181 -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 +578 -28
- package/dist/schemas/common.js +42 -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 +190 -5
- package/dist/schemas/completion-stream.js +118 -67
- package/dist/schemas/constants-registry.d.ts +67 -0
- package/dist/schemas/constants-registry.js +51 -0
- 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 +15 -11
- 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 +3 -2
- package/dist/schemas/engine-addon-map.js +25 -25
- 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 +41 -44
- package/dist/schemas/get-loaded-model-info.d.ts +17 -1
- package/dist/schemas/get-loaded-model-info.js +22 -14
- 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 +57 -29
- package/dist/schemas/llamacpp-config.js +43 -35
- package/dist/schemas/load-model.d.ts +1537 -185
- package/dist/schemas/load-model.js +126 -129
- 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 +13 -14
- package/dist/schemas/plugin.js +51 -51
- 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 +16 -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 +248 -9
- package/dist/schemas/sdcpp-config.js +395 -291
- package/dist/schemas/sdk-config.d.ts +833 -71
- 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 +202 -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 +469 -3
- package/dist/schemas/text-to-speech.js +151 -109
- package/dist/schemas/tools.d.ts +2 -2
- package/dist/schemas/tools.js +18 -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 +49 -72
- 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 +11 -1
- package/dist/schemas/vla.js +52 -32
- 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/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 +53 -31
- 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 +4 -3
- 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 +33 -54
- 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 +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 +6 -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 +65 -80
- 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.d.ts +8 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +12 -6
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +193 -19
- 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 +9 -4
- 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 +3 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +71 -44
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +132 -4
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +148 -70
- 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 +18 -34
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +9 -2
- package/dist/server/bare/plugins/tts-ggml/plugin.js +97 -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 +7 -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 +9 -5
- package/dist/server/bare/utils/tts-stats.js +8 -2
- 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 +34 -13
- 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 +102 -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-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 +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 +15 -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 +35 -31
- package/dist/server/rpc/handlers/index.js +36 -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/method-shapes.d.ts +51 -0
- package/dist/server/rpc/method-shapes.js +48 -0
- 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 +122 -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 +15 -11
- 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 +21 -17
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import prettier from 'prettier';
|
|
4
|
+
import { requestSchema, responseSchema } from '../../schemas/common.js';
|
|
5
|
+
import { methodShapes } from '../../server/rpc/method-shapes.js';
|
|
6
|
+
import { constantsRegistry } from '../../schemas/constants-registry.js';
|
|
7
|
+
import { buildModelsRegistry } from './build-models-registry.js';
|
|
8
|
+
import { buildModelTypeMaps } from './build-model-type-maps.js';
|
|
9
|
+
import { buildErrorCodes } from './build-error-codes.js';
|
|
10
|
+
export const contractDir = new URL('../../contract/', import.meta.url);
|
|
11
|
+
export const callShapeByHandlerType = {
|
|
12
|
+
reply: 'request-reply',
|
|
13
|
+
stream: 'server-stream',
|
|
14
|
+
duplex: 'duplex'
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wire `type` literal(s) of a request/response schema. Union members all
|
|
18
|
+
* carry the same literal (one method can have several request variants),
|
|
19
|
+
* pipes are read on their input side, intersections on both sides.
|
|
20
|
+
*/
|
|
21
|
+
function wireTypesOf(schema) {
|
|
22
|
+
if (schema instanceof z.ZodObject) {
|
|
23
|
+
const typeField = schema.shape['type'];
|
|
24
|
+
if (typeField instanceof z.ZodLiteral) {
|
|
25
|
+
return Array.from(typeField.values).filter(function (value) {
|
|
26
|
+
return typeof value === 'string';
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
if (schema instanceof z.ZodUnion) {
|
|
32
|
+
const nested = schema.options.flatMap(function (option) {
|
|
33
|
+
return wireTypesOf(option);
|
|
34
|
+
});
|
|
35
|
+
return [...new Set(nested)];
|
|
36
|
+
}
|
|
37
|
+
if (schema instanceof z.ZodPipe) {
|
|
38
|
+
return wireTypesOf(schema.in);
|
|
39
|
+
}
|
|
40
|
+
if (schema instanceof z.ZodIntersection) {
|
|
41
|
+
const nested = [
|
|
42
|
+
...wireTypesOf(schema.def.left),
|
|
43
|
+
...wireTypesOf(schema.def.right)
|
|
44
|
+
];
|
|
45
|
+
return [...new Set(nested)];
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
function wireTypeOf(schema, context) {
|
|
50
|
+
const types = wireTypesOf(schema);
|
|
51
|
+
if (types.length !== 1) {
|
|
52
|
+
throw new Error(`Expected exactly one wire "type" literal for ${context}, found: [${types.join(', ')}]`);
|
|
53
|
+
}
|
|
54
|
+
return types[0];
|
|
55
|
+
}
|
|
56
|
+
function assertNoRefs(value, defName) {
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
for (const item of value)
|
|
59
|
+
assertNoRefs(item, defName);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (value !== null && typeof value === 'object') {
|
|
63
|
+
for (const [key, child] of Object.entries(value)) {
|
|
64
|
+
if (key === '$ref') {
|
|
65
|
+
throw new Error(`Schema for "${defName}" emitted a $ref (${String(child)}); ` +
|
|
66
|
+
'nesting it under $defs would break the pointer. Extend build-contract.ts to re-root refs.');
|
|
67
|
+
}
|
|
68
|
+
assertNoRefs(child, defName);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function mergeObjectSchemaParts(parts, defName) {
|
|
73
|
+
const properties = {};
|
|
74
|
+
const required = [];
|
|
75
|
+
for (const part of parts) {
|
|
76
|
+
if (part['type'] !== undefined && part['type'] !== 'object') {
|
|
77
|
+
throw new Error(`Cannot merge a non-object schema member while flattening "${defName}"`);
|
|
78
|
+
}
|
|
79
|
+
for (const [key, value] of Object.entries(part['properties'] ?? {})) {
|
|
80
|
+
if (key in properties && JSON.stringify(properties[key]) !== JSON.stringify(value)) {
|
|
81
|
+
throw new Error(`Conflicting definitions for property "${key}" while flattening "${defName}"`);
|
|
82
|
+
}
|
|
83
|
+
properties[key] = value;
|
|
84
|
+
}
|
|
85
|
+
for (const name of part['required'] ?? []) {
|
|
86
|
+
if (!required.includes(name))
|
|
87
|
+
required.push(name);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { type: 'object', properties, required };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Flattens `allOf: [commonFields, { oneOf/anyOf: [...variants] }]` (Zod's
|
|
94
|
+
* `.and()` of an object with a discriminated union) into a plain
|
|
95
|
+
* `oneOf`/`anyOf` with `commonFields` merged into every variant.
|
|
96
|
+
*
|
|
97
|
+
* Needed because JSON-Schema-consuming codegen (verified against
|
|
98
|
+
* datamodel-code-generator, the standard JSON-Schema -> pydantic tool) does
|
|
99
|
+
* not merge `allOf` branches when one of them is itself a union: it silently
|
|
100
|
+
* keeps only the first branch under the schema's title, dropping every
|
|
101
|
+
* variant-specific field. `allOf`-of-a-union is valid JSON Schema, but this
|
|
102
|
+
* is a known rough edge across JSON-Schema tooling generally, so flattening
|
|
103
|
+
* it here makes the contract more robust for every consumer, not a
|
|
104
|
+
* Python-specific workaround.
|
|
105
|
+
*
|
|
106
|
+
* Scoped to the one shape currently in use (exactly one `allOf` branch is a
|
|
107
|
+
* union, the rest are plain object schemas): anything else throws instead of
|
|
108
|
+
* silently emitting a schema some consumer will mis-generate from.
|
|
109
|
+
*/
|
|
110
|
+
function flattenAllOfWithUnion(json, defName) {
|
|
111
|
+
const allOf = json['allOf'];
|
|
112
|
+
if (!Array.isArray(allOf))
|
|
113
|
+
return json;
|
|
114
|
+
const isUnionMember = function (member) {
|
|
115
|
+
return (member !== null &&
|
|
116
|
+
typeof member === 'object' &&
|
|
117
|
+
(Array.isArray(member['oneOf']) ||
|
|
118
|
+
Array.isArray(member['anyOf'])));
|
|
119
|
+
};
|
|
120
|
+
const unionMembers = allOf.filter(isUnionMember);
|
|
121
|
+
const plainMembers = allOf.filter(function (member) {
|
|
122
|
+
return !isUnionMember(member);
|
|
123
|
+
});
|
|
124
|
+
if (unionMembers.length !== 1) {
|
|
125
|
+
throw new Error(`Schema for "${defName}" uses allOf with ${unionMembers.length} union branches; ` +
|
|
126
|
+
'only the single-union-branch shape is handled. Extend flattenAllOfWithUnion in build-contract.ts.');
|
|
127
|
+
}
|
|
128
|
+
const unionMember = unionMembers[0];
|
|
129
|
+
const unionKey = Array.isArray(unionMember['oneOf']) ? 'oneOf' : 'anyOf';
|
|
130
|
+
const arms = unionMember[unionKey];
|
|
131
|
+
const flattened = { ...json };
|
|
132
|
+
delete flattened['allOf'];
|
|
133
|
+
flattened[unionKey] = arms.map(function (arm) {
|
|
134
|
+
return mergeObjectSchemaParts([...plainMembers, arm], defName);
|
|
135
|
+
});
|
|
136
|
+
return flattened;
|
|
137
|
+
}
|
|
138
|
+
function isSchemaObject(node) {
|
|
139
|
+
return node !== null && typeof node === 'object' && !Array.isArray(node);
|
|
140
|
+
}
|
|
141
|
+
function unionArmsOf(node) {
|
|
142
|
+
if (Array.isArray(node['oneOf']))
|
|
143
|
+
return node['oneOf'];
|
|
144
|
+
if (Array.isArray(node['anyOf']))
|
|
145
|
+
return node['anyOf'];
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Collapses `oneOf`/`anyOf` arrays that carry exactly one arm into that arm
|
|
150
|
+
* directly, recursively from the leaves up. A single-arm union discriminates
|
|
151
|
+
* nothing, so naming it as a union (wrapper title + arm title) forces the
|
|
152
|
+
* arm into a name distinct from a wrapper it's identical to — e.g.
|
|
153
|
+
* `reloadConfigRequestSchema = z.union([reloadConfigWhisperRequestSchema])`
|
|
154
|
+
* produced both a `ReloadConfigRequest` (the wrapper) and a
|
|
155
|
+
* `ReloadConfigRequest2` (the lone arm) for what is really one type.
|
|
156
|
+
* Collapsing first means there's only ever one node here for titling to see.
|
|
157
|
+
* The wrapper's own explicit `title` (its `.meta()`), if any, wins over the
|
|
158
|
+
* arm's — it's the intentional public name for the schema export.
|
|
159
|
+
*/
|
|
160
|
+
function collapseSingleMemberUnions(node) {
|
|
161
|
+
if (!isSchemaObject(node))
|
|
162
|
+
return node;
|
|
163
|
+
const properties = node['properties'];
|
|
164
|
+
if (isSchemaObject(properties)) {
|
|
165
|
+
for (const key of Object.keys(properties)) {
|
|
166
|
+
properties[key] = collapseSingleMemberUnions(properties[key]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (node['items'] !== undefined) {
|
|
170
|
+
node['items'] = collapseSingleMemberUnions(node['items']);
|
|
171
|
+
}
|
|
172
|
+
if (isSchemaObject(node['additionalProperties'])) {
|
|
173
|
+
node['additionalProperties'] = collapseSingleMemberUnions(node['additionalProperties']);
|
|
174
|
+
}
|
|
175
|
+
const unionKey = Array.isArray(node['oneOf'])
|
|
176
|
+
? 'oneOf'
|
|
177
|
+
: Array.isArray(node['anyOf'])
|
|
178
|
+
? 'anyOf'
|
|
179
|
+
: undefined;
|
|
180
|
+
if (!unionKey)
|
|
181
|
+
return node;
|
|
182
|
+
const arms = node[unionKey].map(collapseSingleMemberUnions);
|
|
183
|
+
if (arms.length !== 1) {
|
|
184
|
+
node[unionKey] = arms;
|
|
185
|
+
return node;
|
|
186
|
+
}
|
|
187
|
+
const arm = arms[0];
|
|
188
|
+
const wrapperTitle = typeof node['title'] === 'string' ? node['title'] : undefined;
|
|
189
|
+
const wrapperRest = { ...node };
|
|
190
|
+
delete wrapperRest[unionKey];
|
|
191
|
+
if (!isSchemaObject(arm))
|
|
192
|
+
return wrapperTitle ? wrapperRest : arm;
|
|
193
|
+
const merged = { ...wrapperRest, ...arm };
|
|
194
|
+
if (wrapperTitle)
|
|
195
|
+
merged['title'] = wrapperTitle;
|
|
196
|
+
return merged;
|
|
197
|
+
}
|
|
198
|
+
function constValueOf(arm, key) {
|
|
199
|
+
const properties = arm['properties'];
|
|
200
|
+
const field = isSchemaObject(properties) ? properties[key] : undefined;
|
|
201
|
+
return isSchemaObject(field) && typeof field['const'] === 'string' ? field['const'] : undefined;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Property key that best discriminates a set of sibling union arms: the
|
|
205
|
+
* `const` string field, wherever present, that splits the arms into the most
|
|
206
|
+
* distinct groups — counting "arms with no const for this key at all" as one
|
|
207
|
+
* more group (they'll be disambiguated some other way; see `nameUnionArms`).
|
|
208
|
+
* Picks the *best* key rather than requiring perfection — two shortcomings
|
|
209
|
+
* otherwise cause bad names:
|
|
210
|
+
*
|
|
211
|
+
* - Requiring every arm to carry the key: `loadModel`'s custom-plugin
|
|
212
|
+
* catch-all arm has no `modelType` const, so demanding full coverage threw
|
|
213
|
+
* away `modelType` for the other 11 arms too.
|
|
214
|
+
* - Requiring the value to never repeat: `completionStream`'s event union
|
|
215
|
+
* has two arms both typed `completionDone` (success vs. error) — demanding
|
|
216
|
+
* perfect uniqueness rejected `type` for all 8 events, even though it
|
|
217
|
+
* cleanly separates the other 6. `nameUnionArms` recurses into the
|
|
218
|
+
* colliding pair to find a secondary key (`stopReason`) instead.
|
|
219
|
+
*
|
|
220
|
+
* Also deliberately not a fixed guess-list of names (`type`/`operation`/...):
|
|
221
|
+
* the wire method discriminator (`type`) is IDENTICAL across every arm of a
|
|
222
|
+
* single method's own operation union (e.g. every `rag` arm has
|
|
223
|
+
* `type: 'rag'`), so guessing by name picked the one field that never
|
|
224
|
+
* discriminates anything and produced `RagRequestRag`, `RagRequestRag2`, ...
|
|
225
|
+
* A key where every arm lands in one single group is rejected outright —
|
|
226
|
+
* it's exactly this "same value everywhere" (or "no arm has it") case.
|
|
227
|
+
*/
|
|
228
|
+
function pickDiscriminatorKey(arms) {
|
|
229
|
+
const candidateKeys = new Set();
|
|
230
|
+
for (const arm of arms) {
|
|
231
|
+
const properties = arm['properties'];
|
|
232
|
+
if (isSchemaObject(properties)) {
|
|
233
|
+
for (const key of Object.keys(properties))
|
|
234
|
+
candidateKeys.add(key);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
let bestKey;
|
|
238
|
+
let bestGroupCount = 1; // a key producing only 1 group discriminates nothing
|
|
239
|
+
for (const key of candidateKeys) {
|
|
240
|
+
const values = new Set();
|
|
241
|
+
let anyMissing = false;
|
|
242
|
+
for (const arm of arms) {
|
|
243
|
+
const value = constValueOf(arm, key);
|
|
244
|
+
if (value === undefined)
|
|
245
|
+
anyMissing = true;
|
|
246
|
+
else
|
|
247
|
+
values.add(value);
|
|
248
|
+
}
|
|
249
|
+
const groupCount = values.size + (anyMissing ? 1 : 0);
|
|
250
|
+
if (groupCount > bestGroupCount) {
|
|
251
|
+
bestKey = key;
|
|
252
|
+
bestGroupCount = groupCount;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return bestKey;
|
|
256
|
+
}
|
|
257
|
+
function ensureUniqueTitle(base, seenTitles) {
|
|
258
|
+
if (!seenTitles.has(base)) {
|
|
259
|
+
seenTitles.add(base);
|
|
260
|
+
return base;
|
|
261
|
+
}
|
|
262
|
+
let suffix = 2;
|
|
263
|
+
while (seenTitles.has(`${base}${suffix}`))
|
|
264
|
+
suffix++;
|
|
265
|
+
const unique = `${base}${suffix}`;
|
|
266
|
+
seenTitles.add(unique);
|
|
267
|
+
return unique;
|
|
268
|
+
}
|
|
269
|
+
/** Whether a schema node is itself substantial enough to need a title: an
|
|
270
|
+
* object, an enum, or a nested union (whose own arms will need names) —
|
|
271
|
+
* as opposed to a bare scalar (`{type: 'string'}`) or `{}` ("any"), which
|
|
272
|
+
* never get titled regardless of position. */
|
|
273
|
+
function needsOwnTitle(node) {
|
|
274
|
+
if (!isSchemaObject(node))
|
|
275
|
+
return false;
|
|
276
|
+
if (unionArmsOf(node))
|
|
277
|
+
return true;
|
|
278
|
+
const isEnum = Array.isArray(node['enum']);
|
|
279
|
+
const isObject = node['type'] === 'object' || isSchemaObject(node['properties']);
|
|
280
|
+
const hasConst = node['const'] !== undefined;
|
|
281
|
+
return (isEnum || isObject) && !hasConst;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Names each arm of a union: by the shared discriminator's value when the
|
|
285
|
+
* arms have one in common; else, if at most one arm actually needs a title
|
|
286
|
+
* (e.g. `string | { repeats: number }` — only the object arm does), that one
|
|
287
|
+
* arm gets the bare prefix with no suffix, since there's nothing to
|
|
288
|
+
* disambiguate; only when neither applies does it fall back to positional
|
|
289
|
+
* naming (1-based: `Foo1`, `Foo2`, ...).
|
|
290
|
+
*/
|
|
291
|
+
function nameUnionArms(arms, namePrefix) {
|
|
292
|
+
if (arms.length <= 1) {
|
|
293
|
+
return arms.map(function () {
|
|
294
|
+
return namePrefix;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const key = pickDiscriminatorKey(arms);
|
|
298
|
+
if (!key) {
|
|
299
|
+
if (arms.filter(needsOwnTitle).length <= 1) {
|
|
300
|
+
return arms.map(function () {
|
|
301
|
+
return namePrefix;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return arms.map(function (_arm, index) {
|
|
305
|
+
return `${namePrefix}${index + 1}`;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
// Group arms by their value for `key` (arms with no const for `key` share
|
|
309
|
+
// the `undefined` group). A key is only ever picked when it produces more
|
|
310
|
+
// than one group (see pickDiscriminatorKey), so every group here is
|
|
311
|
+
// strictly smaller than `arms` — groups with more than one member recurse
|
|
312
|
+
// to find a secondary discriminator instead of falling straight to
|
|
313
|
+
// `ensureUniqueTitle`'s numeric bump. This is what turns two arms sharing
|
|
314
|
+
// `type: 'completionDone'` into `...CompletionDoneError` (has a `stopReason`
|
|
315
|
+
// const) and bare `...CompletionDone` (the lone arm left without one)
|
|
316
|
+
// instead of `...CompletionDone` / `...CompletionDone2`.
|
|
317
|
+
const groupOrder = [];
|
|
318
|
+
const groups = new Map();
|
|
319
|
+
arms.forEach(function (arm, index) {
|
|
320
|
+
const value = constValueOf(arm, key);
|
|
321
|
+
if (!groups.has(value)) {
|
|
322
|
+
groupOrder.push(value);
|
|
323
|
+
groups.set(value, []);
|
|
324
|
+
}
|
|
325
|
+
groups.get(value)?.push(index);
|
|
326
|
+
});
|
|
327
|
+
const names = new Array(arms.length);
|
|
328
|
+
for (const value of groupOrder) {
|
|
329
|
+
const indexes = groups.get(value);
|
|
330
|
+
const groupPrefix = value !== undefined ? `${namePrefix}${toPascalCase(value)}` : namePrefix;
|
|
331
|
+
if (indexes.length === 1) {
|
|
332
|
+
names[indexes[0]] = groupPrefix;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const subNames = nameUnionArms(indexes.map(function (index) {
|
|
336
|
+
return arms[index];
|
|
337
|
+
}), groupPrefix);
|
|
338
|
+
indexes.forEach(function (armIndex, i) {
|
|
339
|
+
names[armIndex] = subNames[i];
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
return names;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Assigns a `title` to `node` (unless it already has one) and recurses into
|
|
346
|
+
* its properties/items/union arms, naming each by its property key or (for
|
|
347
|
+
* discriminated union arms) the arm's discriminator value — e.g.
|
|
348
|
+
* `completionStream.response`'s event union gets
|
|
349
|
+
* `CompletionStreamResponseEventsItemContentDelta` instead of a bare `Events3`.
|
|
350
|
+
*
|
|
351
|
+
* Without this, nested/inline Zod schemas reach codegen (verified against
|
|
352
|
+
* datamodel-code-generator, a JSON-Schema-to-pydantic tool) as
|
|
353
|
+
* positionally-numbered classes (`Stats13`, `Events7`) with no indication of
|
|
354
|
+
* what they represent.
|
|
355
|
+
*
|
|
356
|
+
* If `node` already carries a `title` (a schema author's explicit Zod
|
|
357
|
+
* `.meta({ title: ... })`, e.g. `FinetuneRunRequest`), that title wins over
|
|
358
|
+
* `namePrefix` — both for `node` itself and as the prefix for its own
|
|
359
|
+
* children — instead of being silently discarded the moment `node` also
|
|
360
|
+
* happens to be a union wrapper.
|
|
361
|
+
*/
|
|
362
|
+
function titleSchemaNode(node, namePrefix, seenTitles) {
|
|
363
|
+
if (!isSchemaObject(node))
|
|
364
|
+
return;
|
|
365
|
+
const existingTitle = typeof node['title'] === 'string' ? node['title'] : undefined;
|
|
366
|
+
if (existingTitle)
|
|
367
|
+
seenTitles.add(existingTitle);
|
|
368
|
+
const arms = unionArmsOf(node);
|
|
369
|
+
if (arms) {
|
|
370
|
+
const effectivePrefix = existingTitle ?? namePrefix;
|
|
371
|
+
const armNames = nameUnionArms(arms, effectivePrefix);
|
|
372
|
+
arms.forEach(function (arm, index) {
|
|
373
|
+
titleSchemaNode(arm, armNames[index], seenTitles);
|
|
374
|
+
});
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
// If namePrefix collided with an already-assigned title, ensureUniqueTitle
|
|
378
|
+
// bumps it (e.g. `...CompletionDone` -> `...CompletionDone2`). Children
|
|
379
|
+
// must be prefixed with that *final* title, not the pre-bump namePrefix —
|
|
380
|
+
// otherwise a child two levels down silently collides with an unrelated
|
|
381
|
+
// sibling's identically-(pre-bump-)named child instead of its own.
|
|
382
|
+
const assignedTitle = needsOwnTitle(node) && !existingTitle ? ensureUniqueTitle(namePrefix, seenTitles) : undefined;
|
|
383
|
+
if (assignedTitle)
|
|
384
|
+
node['title'] = assignedTitle;
|
|
385
|
+
const effectivePrefix = existingTitle ?? assignedTitle ?? namePrefix;
|
|
386
|
+
const properties = node['properties'];
|
|
387
|
+
if (isSchemaObject(properties)) {
|
|
388
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
389
|
+
titleSchemaNode(propSchema, `${effectivePrefix}${toPascalCase(key)}`, seenTitles);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (node['items'] !== undefined) {
|
|
393
|
+
titleSchemaNode(node['items'], `${effectivePrefix}Item`, seenTitles);
|
|
394
|
+
}
|
|
395
|
+
if (isSchemaObject(node['additionalProperties'])) {
|
|
396
|
+
titleSchemaNode(node['additionalProperties'], `${effectivePrefix}Value`, seenTitles);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Entry point for a def's root: the root already has `rootTitle` (assigned
|
|
400
|
+
* by the caller), so only its children need naming — recursing straight into
|
|
401
|
+
* `titleSchemaNode` would treat the root itself as untitled. */
|
|
402
|
+
function titleNestedSchemas(root, rootTitle, seenTitles) {
|
|
403
|
+
const arms = unionArmsOf(root);
|
|
404
|
+
if (arms) {
|
|
405
|
+
const armNames = nameUnionArms(arms, rootTitle);
|
|
406
|
+
arms.forEach(function (arm, index) {
|
|
407
|
+
titleSchemaNode(arm, armNames[index], seenTitles);
|
|
408
|
+
});
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const properties = root['properties'];
|
|
412
|
+
if (isSchemaObject(properties)) {
|
|
413
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
414
|
+
titleSchemaNode(propSchema, `${rootTitle}${toPascalCase(key)}`, seenTitles);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (root['items'] !== undefined) {
|
|
418
|
+
titleSchemaNode(root['items'], `${rootTitle}Item`, seenTitles);
|
|
419
|
+
}
|
|
420
|
+
if (isSchemaObject(root['additionalProperties'])) {
|
|
421
|
+
titleSchemaNode(root['additionalProperties'], `${rootTitle}Value`, seenTitles);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
export function toWireJsonSchema(schema, io, defName) {
|
|
425
|
+
const json = z.toJSONSchema(schema, {
|
|
426
|
+
target: 'draft-2020-12',
|
|
427
|
+
io,
|
|
428
|
+
unrepresentable: 'any'
|
|
429
|
+
});
|
|
430
|
+
delete json['$schema'];
|
|
431
|
+
const flattened = flattenAllOfWithUnion(json, defName);
|
|
432
|
+
const collapsed = collapseSingleMemberUnions(flattened);
|
|
433
|
+
assertNoRefs(collapsed, defName);
|
|
434
|
+
return collapsed;
|
|
435
|
+
}
|
|
436
|
+
function collectByWireType(options, side) {
|
|
437
|
+
const byType = new Map();
|
|
438
|
+
for (const [index, option] of options.entries()) {
|
|
439
|
+
const schema = option;
|
|
440
|
+
const wireType = wireTypeOf(schema, `${side} union member #${index}`);
|
|
441
|
+
if (byType.has(wireType)) {
|
|
442
|
+
throw new Error(`Duplicate ${side} schema for wire type "${wireType}"`);
|
|
443
|
+
}
|
|
444
|
+
byType.set(wireType, schema);
|
|
445
|
+
}
|
|
446
|
+
return byType;
|
|
447
|
+
}
|
|
448
|
+
function refTo(defName) {
|
|
449
|
+
return { $ref: `#/$defs/${defName}` };
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* PascalCase class name for a wire type, e.g. `loadModel` -> `LoadModel`,
|
|
453
|
+
* `finetune:progress` -> `FinetuneProgress`. Without a `title`, JSON Schema
|
|
454
|
+
* -> codegen (e.g. datamodel-code-generator) falls back to positional names
|
|
455
|
+
* like `Request1Model11` for nested unions — verified empirically against
|
|
456
|
+
* the actual generator, not assumed.
|
|
457
|
+
*/
|
|
458
|
+
function toPascalCase(name) {
|
|
459
|
+
return name
|
|
460
|
+
.split(/[:\-_]/)
|
|
461
|
+
.map(function (part) {
|
|
462
|
+
return part.length > 0 ? part.charAt(0).toUpperCase() + part.slice(1) : part;
|
|
463
|
+
})
|
|
464
|
+
.join('');
|
|
465
|
+
}
|
|
466
|
+
function classTitleFor(name, suffix) {
|
|
467
|
+
return `${toPascalCase(name)}${suffix}`;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* The 4 methods that can switch from a plain unary reply to a stream of
|
|
471
|
+
* responses when the caller opts in (`request.withProgress === true`):
|
|
472
|
+
* progress events and the final reply both arrive as stream frames,
|
|
473
|
+
* distinguished only by each payload's own `type` — see
|
|
474
|
+
* `server/rpc/handler-selection.ts` (`handlerSupportsProgress`) and
|
|
475
|
+
* `server/rpc/handler-registry.ts` for the source of truth this mirrors.
|
|
476
|
+
*
|
|
477
|
+
* `rag` and `finetune` gate progress further on the request's `operation`
|
|
478
|
+
* (see `ragSupportsProgress`/`finetuneSupportsProgress` in
|
|
479
|
+
* `handler-registry.ts`) — `condition` spells out that extra check so a
|
|
480
|
+
* contract consumer doesn't have to special-case it separately.
|
|
481
|
+
*/
|
|
482
|
+
const progressByMethod = {
|
|
483
|
+
loadModel: { condition: 'request.withProgress === true', responseType: 'modelProgress' },
|
|
484
|
+
downloadAsset: { condition: 'request.withProgress === true', responseType: 'modelProgress' },
|
|
485
|
+
rag: {
|
|
486
|
+
condition: "request.withProgress === true && ['ingest', 'saveEmbeddings', 'reindex'].includes(request.operation)",
|
|
487
|
+
responseType: 'rag:progress'
|
|
488
|
+
},
|
|
489
|
+
finetune: {
|
|
490
|
+
condition: "request.withProgress === true && ['start', 'resume', undefined].includes(request.operation)",
|
|
491
|
+
responseType: 'finetune:progress'
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
export function buildContract() {
|
|
495
|
+
const methodNames = Object.keys(methodShapes).sort();
|
|
496
|
+
const requestByType = collectByWireType(requestSchema.options, 'request');
|
|
497
|
+
const responseByType = collectByWireType(responseSchema.options, 'response');
|
|
498
|
+
for (const name of methodNames) {
|
|
499
|
+
if (!requestByType.has(name)) {
|
|
500
|
+
throw new Error(`Method "${name}" has no request schema in the request union`);
|
|
501
|
+
}
|
|
502
|
+
if (!responseByType.has(name)) {
|
|
503
|
+
throw new Error(`Method "${name}" has no response schema in the response union`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (const wireType of requestByType.keys()) {
|
|
507
|
+
if (!methodNames.includes(wireType)) {
|
|
508
|
+
throw new Error(`Request schema "${wireType}" has no entry in methodShapes`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const responseTypes = [...responseByType.keys()].sort();
|
|
512
|
+
for (const [methodName, progress] of Object.entries(progressByMethod)) {
|
|
513
|
+
if (!responseByType.has(progress.responseType)) {
|
|
514
|
+
throw new Error(`progressByMethod["${methodName}"] points at response type "${progress.responseType}", ` +
|
|
515
|
+
'which has no schema in the response union');
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const defs = {
|
|
519
|
+
request: {
|
|
520
|
+
title: 'AnyRequest',
|
|
521
|
+
description: 'Any request accepted by the server, in wire (pre-parse) shape.',
|
|
522
|
+
anyOf: methodNames.map(function (name) {
|
|
523
|
+
return refTo(`${name}.request`);
|
|
524
|
+
})
|
|
525
|
+
},
|
|
526
|
+
response: {
|
|
527
|
+
title: 'AnyResponse',
|
|
528
|
+
description: 'Any response emitted by the server, including progress updates and error envelopes.',
|
|
529
|
+
anyOf: responseTypes.map(function (type) {
|
|
530
|
+
return refTo(`${type}.response`);
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const defEntries = [];
|
|
535
|
+
for (const [type, schema] of requestByType) {
|
|
536
|
+
defEntries.push([`${type}.request`, schema, 'input', classTitleFor(type, 'Request')]);
|
|
537
|
+
}
|
|
538
|
+
for (const [type, schema] of responseByType) {
|
|
539
|
+
defEntries.push([`${type}.response`, schema, 'output', classTitleFor(type, 'Response')]);
|
|
540
|
+
}
|
|
541
|
+
// Public constants (@/schemas/constants-registry), merged into the same
|
|
542
|
+
// $defs as every request/response type via the same z.toJSONSchema call —
|
|
543
|
+
// not a separate artifact. `x-enum-varnames` preserves each entry's
|
|
544
|
+
// original key names (`ModelType.llamacppCompletion`, `PluginId.LLM`, ...)
|
|
545
|
+
// through codegen; plain JSON Schema `enum:` only carries values.
|
|
546
|
+
const constantVarNames = new Map();
|
|
547
|
+
for (const [name, schema] of Object.entries(constantsRegistry)) {
|
|
548
|
+
const defName = `constants.${name}`;
|
|
549
|
+
defEntries.push([defName, schema, 'output', name]);
|
|
550
|
+
constantVarNames.set(defName, Object.keys(schema.enum));
|
|
551
|
+
}
|
|
552
|
+
defEntries.sort(function (a, b) {
|
|
553
|
+
return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
554
|
+
});
|
|
555
|
+
// Seed with every top-level title up front so nested-schema titles (assigned
|
|
556
|
+
// below, per def) can never collide with a top-level def title regardless
|
|
557
|
+
// of iteration order.
|
|
558
|
+
const seenTitles = new Set([
|
|
559
|
+
'AnyRequest',
|
|
560
|
+
'AnyResponse',
|
|
561
|
+
...defEntries.map((entry) => entry[3])
|
|
562
|
+
]);
|
|
563
|
+
for (const [defName, schema, io, title] of defEntries) {
|
|
564
|
+
const wireSchema = toWireJsonSchema(schema, io, defName);
|
|
565
|
+
titleNestedSchemas(wireSchema, title, seenTitles);
|
|
566
|
+
const varNames = constantVarNames.get(defName);
|
|
567
|
+
defs[defName] = {
|
|
568
|
+
title,
|
|
569
|
+
...wireSchema,
|
|
570
|
+
...(varNames && { 'x-enum-varnames': varNames })
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
const manifest = {
|
|
574
|
+
methods: methodNames.map(function (name) {
|
|
575
|
+
const progress = progressByMethod[name];
|
|
576
|
+
return {
|
|
577
|
+
name,
|
|
578
|
+
callShape: callShapeByHandlerType[methodShapes[name]],
|
|
579
|
+
requestSchema: `schema.json#/$defs/${name}.request`,
|
|
580
|
+
responseSchema: `schema.json#/$defs/${name}.response`,
|
|
581
|
+
...(progress && {
|
|
582
|
+
progress: {
|
|
583
|
+
condition: progress.condition,
|
|
584
|
+
responseSchema: `schema.json#/$defs/${progress.responseType}.response`
|
|
585
|
+
}
|
|
586
|
+
})
|
|
587
|
+
};
|
|
588
|
+
})
|
|
589
|
+
};
|
|
590
|
+
const schemaDocument = {
|
|
591
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
592
|
+
title: '@qvac/sdk wire contract',
|
|
593
|
+
description: 'Generated from the SDK Zod schemas by `bun run contract:export`. Do not edit by hand. ' +
|
|
594
|
+
'Requests use the schema input shape, responses the output shape; runtime-only ' +
|
|
595
|
+
'refinements and transforms stay server-side.',
|
|
596
|
+
$defs: defs
|
|
597
|
+
};
|
|
598
|
+
return { schemaDocument, manifest };
|
|
599
|
+
}
|
|
600
|
+
async function formatJson(value, fileName) {
|
|
601
|
+
const filePath = fileURLToPath(new URL(fileName, contractDir));
|
|
602
|
+
const config = await prettier.resolveConfig(filePath);
|
|
603
|
+
return prettier.format(JSON.stringify(value, null, 2), {
|
|
604
|
+
...config,
|
|
605
|
+
parser: 'json'
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
export async function renderContractFiles() {
|
|
609
|
+
const { schemaDocument, manifest } = buildContract();
|
|
610
|
+
const modelsRegistry = buildModelsRegistry();
|
|
611
|
+
const modelTypeMaps = buildModelTypeMaps();
|
|
612
|
+
const errorCodes = buildErrorCodes();
|
|
613
|
+
return {
|
|
614
|
+
'schema.json': await formatJson(schemaDocument, 'schema.json'),
|
|
615
|
+
'manifest.json': await formatJson(manifest, 'manifest.json'),
|
|
616
|
+
'models.json': await formatJson(modelsRegistry, 'models.json'),
|
|
617
|
+
'model-type-maps.json': await formatJson(modelTypeMaps, 'model-type-maps.json'),
|
|
618
|
+
'error-codes.json': await formatJson(errorCodes, 'error-codes.json')
|
|
619
|
+
};
|
|
620
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON export of the SDK error-code registries (name → numeric code) for the
|
|
3
|
+
* server, client, and registry error families. The Python client's typed
|
|
4
|
+
* error classes and its RPC-boundary reconstructor read these instead of
|
|
5
|
+
* hand-copying the numbers, so a code added or renamed on the SDK side surfaces
|
|
6
|
+
* as a `contract:check` / `generate.py --check` failure rather than a Python
|
|
7
|
+
* client that silently can't reconstruct a server error.
|
|
8
|
+
*
|
|
9
|
+
* A separate artifact from schema.json, like models.json / model-type-maps.json.
|
|
10
|
+
*/
|
|
11
|
+
export interface ErrorCodes {
|
|
12
|
+
server: Record<string, number>;
|
|
13
|
+
client: Record<string, number>;
|
|
14
|
+
registry: Record<string, number>;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildErrorCodes(): ErrorCodes;
|
|
17
|
+
//# sourceMappingURL=build-error-codes.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SDK_SERVER_ERROR_CODES } from '../../schemas/sdk-errors-server.js';
|
|
2
|
+
import { SDK_CLIENT_ERROR_CODES } from '../../schemas/sdk-errors-client.js';
|
|
3
|
+
import { REGISTRY_ERROR_CODES } from '../../schemas/sdk-errors-registry.js';
|
|
4
|
+
function sortedEntries(record) {
|
|
5
|
+
const entries = Object.entries(record);
|
|
6
|
+
entries.sort(function (a, b) {
|
|
7
|
+
return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
8
|
+
});
|
|
9
|
+
return Object.fromEntries(entries);
|
|
10
|
+
}
|
|
11
|
+
export function buildErrorCodes() {
|
|
12
|
+
return {
|
|
13
|
+
server: sortedEntries(SDK_SERVER_ERROR_CODES),
|
|
14
|
+
client: sortedEntries(SDK_CLIENT_ERROR_CODES),
|
|
15
|
+
registry: sortedEntries(REGISTRY_ERROR_CODES)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON export of the model-type resolution maps that `loadModel`'s
|
|
3
|
+
* client-side type-inference reads: alias → canonical model type, canonical
|
|
4
|
+
* engine → addon, and legacy engine string → canonical engine.
|
|
5
|
+
*
|
|
6
|
+
* Inference itself stays in each client (a plain string `modelSrc` carries no
|
|
7
|
+
* engine to infer from, so it can't move server-side), but the *data* it reads
|
|
8
|
+
* must not drift between languages — so the maps are exported here, alongside
|
|
9
|
+
* schema.json/models.json, and generated into each client rather than
|
|
10
|
+
* hand-copied. `contract:check` (JS) and `generate.py --check` (Python) then
|
|
11
|
+
* fail the build if a map is edited on one side only.
|
|
12
|
+
*
|
|
13
|
+
* A separate artifact from schema.json for the same reason models.json is: a
|
|
14
|
+
* language-neutral data catalog, not part of the RPC wire contract.
|
|
15
|
+
*/
|
|
16
|
+
export interface ModelTypeMaps {
|
|
17
|
+
aliasToCanonical: Record<string, string>;
|
|
18
|
+
engineToAddon: Record<string, string>;
|
|
19
|
+
legacyEngineToCanonical: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export declare function buildModelTypeMaps(): ModelTypeMaps;
|
|
22
|
+
//# sourceMappingURL=build-model-type-maps.d.ts.map
|