@qvac/sdk 0.6.0 → 0.7.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/LICENSE +1 -24
- package/NOTICE +632 -0
- package/README.md +2 -1
- package/dist/client/api/embed.js +1 -4
- package/dist/client/api/get-model-info.d.ts +10 -3
- package/dist/client/api/index.d.ts +2 -0
- package/dist/client/api/index.js +2 -0
- package/dist/client/api/invoke-plugin.d.ts +14 -0
- package/dist/client/api/invoke-plugin.js +38 -0
- package/dist/client/api/registry.d.ts +14 -0
- package/dist/client/api/registry.js +37 -0
- package/dist/client/api/transcribe.js +0 -4
- package/dist/client/api/unload-model.js +1 -1
- package/dist/client/config-loader/resolve-config.node.d.ts +3 -2
- package/dist/client/config-loader/resolve-config.node.js +31 -4
- package/dist/client/init-hooks.js +2 -1
- package/dist/client/rpc/bare-client.d.ts +2 -0
- package/dist/client/rpc/bare-client.js +48 -7
- package/dist/client/rpc/expo-device-info.d.ts +6 -0
- package/dist/client/rpc/expo-device-info.js +32 -0
- package/dist/client/rpc/expo-rpc-client.js +9 -32
- package/dist/client/rpc/node-rpc-client.d.ts +1 -1
- package/dist/client/rpc/node-rpc-client.js +201 -28
- package/dist/client/rpc/rpc-client.d.ts +1 -1
- package/dist/client/rpc/rpc-client.js +2 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/registry.d.ts +2 -0
- package/dist/constants/registry.js +1 -0
- package/dist/examples/cache-management.js +2 -2
- package/dist/examples/config/plugins/plugins.config.d.ts +5 -0
- package/dist/examples/config/plugins/plugins.config.js +4 -0
- package/dist/examples/download-with-blind-relays.js +1 -1
- package/dist/examples/llamacpp-multimodal.js +3 -3
- package/dist/examples/llamacpp-native-tools.js +2 -2
- package/dist/examples/mcp-websearch.js +2 -2
- package/dist/examples/multi-model-demo.js +2 -2
- package/dist/examples/ocr-fasttext.js +4 -4
- package/dist/examples/parallel-download.js +2 -2
- package/dist/examples/plugins.d.ts +14 -0
- package/dist/examples/plugins.js +129 -0
- package/dist/examples/registry-query.d.ts +2 -0
- package/dist/examples/registry-query.js +87 -0
- package/dist/examples/translation/translation-bergamot-batch.js +2 -2
- package/dist/examples/translation/translation-bergamot.js +4 -4
- package/dist/examples/translation/translation-opus.js +2 -2
- package/dist/examples/translation/translation-stream.js +2 -2
- package/dist/examples/tts/chatterbox.d.ts +2 -0
- package/dist/examples/tts/chatterbox.js +59 -0
- package/dist/examples/tts/supertonic.d.ts +2 -0
- package/dist/examples/tts/supertonic.js +51 -0
- package/dist/examples/tts/utils.d.ts +17 -0
- package/dist/examples/tts/utils.js +93 -0
- package/dist/examples/whispercpp-filesystem.js +2 -3
- package/dist/examples/whispercpp-microphone-record.js +1 -2
- package/dist/examples/whispercpp-prompt.js +2 -3
- package/dist/expo/plugins/index.d.ts +3 -0
- package/dist/expo/plugins/index.js +3 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +15 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.js +31 -0
- package/dist/expo/plugins/withAndroidArchitecture.d.ts +8 -0
- package/dist/expo/plugins/withAndroidArchitecture.js +52 -0
- package/dist/expo/plugins/withAndroidNdkVersion.d.ts +8 -0
- package/dist/expo/plugins/withAndroidNdkVersion.js +31 -0
- package/dist/expo/plugins/withDeviceInfo.d.ts +10 -0
- package/dist/expo/plugins/withDeviceInfo.js +48 -0
- package/dist/expo/plugins/withMobileBundle.d.ts +5 -2
- package/dist/expo/plugins/withMobileBundle.js +121 -65
- package/dist/expo/plugins/withQvacSDK.d.ts +4 -0
- package/dist/expo/plugins/withQvacSDK.js +26 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/models/{hyperdrive → registry}/index.js +1 -1
- package/dist/models/registry/models.d.ts +9056 -0
- package/dist/models/registry/models.js +9351 -0
- package/dist/models/update-models/codegen.d.ts +3 -0
- package/dist/models/update-models/codegen.js +135 -0
- package/dist/models/update-models/history.d.ts +13 -0
- package/dist/models/update-models/history.js +88 -0
- package/dist/models/update-models/index.d.ts +2 -0
- package/dist/models/update-models/index.js +124 -0
- package/dist/models/update-models/naming.d.ts +4 -0
- package/dist/models/update-models/naming.js +314 -0
- package/dist/models/update-models/processing.d.ts +8 -0
- package/dist/models/update-models/processing.js +67 -0
- package/dist/models/update-models/registry.d.ts +4 -0
- package/dist/models/update-models/registry.js +67 -0
- package/dist/models/update-models/shards.d.ts +4 -0
- package/dist/models/update-models/shards.js +57 -0
- package/dist/models/update-models/types.d.ts +60 -0
- package/dist/models/update-models/types.js +1 -0
- package/dist/models/update-models/utils.d.ts +3 -0
- package/dist/models/update-models/utils.js +21 -0
- package/dist/pear/pre.d.ts +18 -0
- package/dist/pear/pre.js +433 -0
- package/dist/schemas/common.d.ts +286 -32
- package/dist/schemas/common.js +12 -0
- package/dist/schemas/download-asset.d.ts +35 -11
- package/dist/schemas/download-asset.js +5 -1
- package/dist/schemas/engine-addon-map.d.ts +5 -0
- package/dist/schemas/engine-addon-map.js +49 -0
- package/dist/schemas/get-model-info.d.ts +32 -16
- package/dist/schemas/get-model-info.js +17 -8
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +4 -4
- package/dist/schemas/load-model.d.ts +2224 -900
- package/dist/schemas/load-model.js +130 -25
- package/dist/schemas/model-src-utils.d.ts +30 -12
- package/dist/schemas/model-src-utils.js +5 -2
- package/dist/schemas/model-types.d.ts +15 -4
- package/dist/schemas/model-types.js +21 -4
- package/dist/schemas/path-validation.d.ts +10 -0
- package/dist/schemas/path-validation.js +22 -0
- package/dist/schemas/plugin.d.ts +180 -0
- package/dist/schemas/plugin.js +132 -0
- package/dist/schemas/rag.d.ts +2 -2
- package/dist/schemas/rag.js +7 -3
- package/dist/schemas/registry.d.ts +338 -0
- package/dist/schemas/registry.js +91 -0
- package/dist/schemas/sdk-errors-client.d.ts +6 -6
- package/dist/schemas/sdk-errors-client.js +15 -15
- package/dist/schemas/sdk-errors-registry.d.ts +6 -0
- package/dist/schemas/sdk-errors-registry.js +8 -0
- package/dist/schemas/sdk-errors-server.d.ts +16 -2
- package/dist/schemas/sdk-errors-server.js +90 -10
- package/dist/schemas/text-to-speech.d.ts +670 -1
- package/dist/schemas/text-to-speech.js +51 -2
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/scripts/run-security-tests-bare.d.ts +2 -0
- package/dist/scripts/run-security-tests-bare.js +78 -0
- package/dist/scripts/run-security-tests.d.ts +2 -0
- package/dist/scripts/run-security-tests.js +22 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +6 -0
- package/dist/server/bare/delegate-rpc-client.js +136 -56
- package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.d.ts +1 -1
- package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.js +3 -3
- package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.js +6 -6
- package/dist/server/bare/{addons → ops}/load-model.js +32 -42
- package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.d.ts +1 -1
- package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.js +5 -4
- package/dist/server/bare/plugins/index.d.ts +7 -0
- package/dist/server/bare/plugins/index.js +6 -0
- package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.js +1 -1
- package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.d.ts +1 -1
- package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.js +2 -3
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +115 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +142 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +24 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +73 -0
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +45 -0
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +97 -0
- package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.js +2 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +38 -0
- package/dist/server/bare/{addons/onnx-ocr/create-model.js → plugins/onnx-ocr/plugin.js} +39 -2
- package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.js +23 -1
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +26 -0
- package/dist/server/bare/plugins/onnx-tts/plugin.js +162 -0
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +14 -0
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +107 -0
- package/dist/server/bare/plugins/whispercpp-transcription/ops/transcribe-stream.d.ts +3 -0
- package/dist/server/bare/{addons/whispercpp-transcription/handlers → plugins/whispercpp-transcription/ops}/transcribe-stream.js +1 -2
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +31 -0
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +74 -0
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +2 -1
- package/dist/server/bare/registry/config-registry.js +1 -1
- package/dist/server/bare/registry/model-config-utils.js +0 -11
- package/dist/server/bare/registry/registry-client.d.ts +5 -0
- package/dist/server/bare/registry/registry-client.js +37 -0
- package/dist/server/env.d.ts +22 -0
- package/dist/server/env.js +57 -0
- package/dist/server/plugins/index.d.ts +2 -0
- package/dist/server/plugins/index.js +1 -0
- package/dist/server/plugins/registry.d.ts +9 -0
- package/dist/server/plugins/registry.js +75 -0
- package/dist/server/rpc/delegate-transport.d.ts +11 -0
- package/dist/server/rpc/delegate-transport.js +60 -0
- package/dist/server/rpc/handle-request.d.ts +0 -9
- package/dist/server/rpc/handle-request.js +13 -321
- package/dist/server/rpc/handler-registry.d.ts +3 -0
- package/dist/server/rpc/handler-registry.js +84 -0
- package/dist/server/rpc/handler-utils.d.ts +22 -0
- package/dist/server/rpc/handler-utils.js +87 -0
- package/dist/server/rpc/handlers/cancelHandler.js +1 -1
- package/dist/server/rpc/handlers/completion-stream-delegated.js +1 -1
- package/dist/server/rpc/handlers/completion-stream.js +2 -43
- package/dist/server/rpc/handlers/delete-cache.js +1 -1
- package/dist/server/rpc/handlers/embed.js +2 -21
- package/dist/server/rpc/handlers/get-model-info.js +19 -15
- package/dist/server/rpc/handlers/index.d.ts +9 -0
- package/dist/server/rpc/handlers/index.js +9 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +1 -0
- package/dist/server/rpc/handlers/load-model/download-manager.js +3 -0
- package/dist/server/rpc/handlers/load-model/handler.js +47 -24
- package/dist/server/rpc/handlers/load-model/http.js +3 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +14 -10
- package/dist/server/rpc/handlers/load-model/registry.d.ts +10 -0
- package/dist/server/rpc/handlers/load-model/registry.js +571 -0
- package/dist/server/rpc/handlers/load-model/resolve.js +18 -5
- package/dist/server/rpc/handlers/load-model-delegated.js +4 -2
- package/dist/server/rpc/handlers/ocr-stream.js +2 -37
- package/dist/server/rpc/handlers/ping.d.ts +3 -0
- package/dist/server/rpc/handlers/ping.js +3 -0
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +15 -0
- package/dist/server/rpc/handlers/plugin-dispatch.js +54 -0
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +4 -0
- package/dist/server/rpc/handlers/plugin-invoke.js +87 -0
- package/dist/server/rpc/handlers/registry.d.ts +5 -0
- package/dist/server/rpc/handlers/registry.js +157 -0
- package/dist/server/rpc/handlers/text-to-speech.js +2 -5
- package/dist/server/rpc/handlers/transcribe-stream.js +2 -30
- package/dist/server/rpc/handlers/translate.js +2 -42
- package/dist/server/rpc/handlers/unload-model.js +1 -1
- package/dist/server/rpc/index.d.ts +1 -1
- package/dist/server/utils/archive.d.ts +1 -0
- package/dist/server/utils/archive.js +10 -2
- package/dist/server/utils/cache.d.ts +5 -0
- package/dist/server/utils/cache.js +26 -2
- package/dist/server/utils/gguf-tensor-extractor.js +3 -3
- package/dist/server/utils/index.d.ts +1 -1
- package/dist/server/utils/index.js +1 -1
- package/dist/server/utils/path-security.d.ts +12 -0
- package/dist/server/utils/path-security.js +25 -0
- package/dist/server/utils/shard-utils.js +3 -3
- package/dist/server/worker-core.d.ts +6 -0
- package/dist/server/worker-core.js +88 -0
- package/dist/server/worker.d.ts +4 -5
- package/dist/server/worker.js +18 -116
- package/dist/utils/errors-client.d.ts +9 -6
- package/dist/utils/errors-client.js +19 -11
- package/dist/utils/errors-server.d.ts +44 -5
- package/dist/utils/errors-server.js +82 -9
- package/dist/utils/path-sanitize.d.ts +17 -0
- package/dist/utils/path-sanitize.js +54 -0
- package/expo/plugins/patches/android-link.mjs +63 -0
- package/expo/plugins/patches/ios-link.mjs +63 -0
- package/package.json +74 -12
- package/dist/examples/text-to-speech.d.ts +0 -3
- package/dist/examples/text-to-speech.js +0 -137
- package/dist/models/hyperdrive/models.d.ts +0 -4003
- package/dist/models/hyperdrive/models.js +0 -4282
- package/dist/server/bare/addons/index.d.ts +0 -4
- package/dist/server/bare/addons/index.js +0 -3
- package/dist/server/bare/addons/llamacpp-completion/create-model.d.ts +0 -8
- package/dist/server/bare/addons/llamacpp-completion/create-model.js +0 -43
- package/dist/server/bare/addons/llamacpp-completion/index.d.ts +0 -4
- package/dist/server/bare/addons/llamacpp-completion/index.js +0 -3
- package/dist/server/bare/addons/llamacpp-embedding/create-model.d.ts +0 -8
- package/dist/server/bare/addons/llamacpp-embedding/create-model.js +0 -38
- package/dist/server/bare/addons/llamacpp-embedding/index.d.ts +0 -3
- package/dist/server/bare/addons/llamacpp-embedding/index.js +0 -2
- package/dist/server/bare/addons/nmtcpp-translation/create-model.d.ts +0 -8
- package/dist/server/bare/addons/nmtcpp-translation/create-model.js +0 -52
- package/dist/server/bare/addons/nmtcpp-translation/index.d.ts +0 -3
- package/dist/server/bare/addons/nmtcpp-translation/index.js +0 -2
- package/dist/server/bare/addons/onnx-ocr/create-model.d.ts +0 -10
- package/dist/server/bare/addons/onnx-ocr/index.d.ts +0 -3
- package/dist/server/bare/addons/onnx-ocr/index.js +0 -2
- package/dist/server/bare/addons/onnx-tts/create-model.d.ts +0 -10
- package/dist/server/bare/addons/onnx-tts/create-model.js +0 -25
- package/dist/server/bare/addons/onnx-tts/index.d.ts +0 -3
- package/dist/server/bare/addons/onnx-tts/index.js +0 -2
- package/dist/server/bare/addons/whispercpp-transcription/create-model.d.ts +0 -10
- package/dist/server/bare/addons/whispercpp-transcription/create-model.js +0 -37
- package/dist/server/bare/addons/whispercpp-transcription/handlers/transcribe-stream.d.ts +0 -3
- package/dist/server/bare/addons/whispercpp-transcription/index.d.ts +0 -3
- package/dist/server/bare/addons/whispercpp-transcription/index.js +0 -2
- /package/dist/models/{hyperdrive → registry}/index.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/cancel.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/cancel.js +0 -0
- /package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/load-model.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/unload-model.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/unload-model.js +0 -0
- /package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.d.ts +0 -0
- /package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.d.ts +0 -0
- /package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.d.ts +0 -0
|
@@ -3,10 +3,15 @@ import { llmConfigBaseSchema, embedConfigBaseSchema, } from "./llamacpp-config.j
|
|
|
3
3
|
import { whisperConfigSchema } from "./whispercpp-config.js";
|
|
4
4
|
import { delegateSchema } from "./delegate.js";
|
|
5
5
|
import { nmtConfigSchema } from "./translation-config.js";
|
|
6
|
-
import { ttsConfigSchema } from "./text-to-speech.js";
|
|
6
|
+
import { ttsConfigSchema, ttsChatterboxRequestConfigSchema, ttsSupertonicRequestConfigSchema, ttsRequestConfigSchema, } from "./text-to-speech.js";
|
|
7
7
|
import { ocrConfigSchema } from "./ocr.js";
|
|
8
8
|
import { modelSrcInputSchema, modelInputToSrcSchema, modelInputToNameSchema, } from "./model-src-utils.js";
|
|
9
|
-
import { llmModelTypeSchema, whisperModelTypeSchema, embeddingsModelTypeSchema, nmtModelTypeSchema, ttsModelTypeSchema, ocrModelTypeSchema, ModelType, } from "./model-types.js";
|
|
9
|
+
import { llmModelTypeSchema, whisperModelTypeSchema, embeddingsModelTypeSchema, nmtModelTypeSchema, ttsModelTypeSchema, ocrModelTypeSchema, ModelType, ModelTypeAliases, } from "./model-types.js";
|
|
10
|
+
// Set of all built-in model types (canonical + aliases) for catch-all exclusion
|
|
11
|
+
const builtInModelTypes = new Set([
|
|
12
|
+
...Object.values(ModelType),
|
|
13
|
+
...Object.keys(ModelTypeAliases),
|
|
14
|
+
]);
|
|
10
15
|
import { reloadConfigRequestSchema } from "./reload-config.js";
|
|
11
16
|
const loadModelOptionsBaseSchema = z.union([
|
|
12
17
|
z.object({
|
|
@@ -42,12 +47,11 @@ const loadModelOptionsBaseSchema = z.union([
|
|
|
42
47
|
seed: z.boolean().optional(),
|
|
43
48
|
delegate: delegateSchema,
|
|
44
49
|
}),
|
|
50
|
+
// TTS (supports both Chatterbox and Supertonic via ttsEngine discriminator)
|
|
45
51
|
z.object({
|
|
46
52
|
modelSrc: modelSrcInputSchema,
|
|
47
53
|
modelType: ttsModelTypeSchema,
|
|
48
54
|
modelConfig: ttsConfigSchema,
|
|
49
|
-
configSrc: modelSrcInputSchema,
|
|
50
|
-
eSpeakDataPath: z.string(),
|
|
51
55
|
seed: z.boolean().optional(),
|
|
52
56
|
delegate: delegateSchema,
|
|
53
57
|
}),
|
|
@@ -59,6 +63,16 @@ const loadModelOptionsBaseSchema = z.union([
|
|
|
59
63
|
seed: z.boolean().optional(),
|
|
60
64
|
delegate: delegateSchema,
|
|
61
65
|
}),
|
|
66
|
+
// Custom plugin catch-all: accepts any modelType string EXCEPT built-ins
|
|
67
|
+
z.object({
|
|
68
|
+
modelSrc: modelSrcInputSchema,
|
|
69
|
+
modelType: z.string().refine((val) => !builtInModelTypes.has(val), {
|
|
70
|
+
message: "Built-in model types must use their specific schema",
|
|
71
|
+
}),
|
|
72
|
+
modelConfig: z.record(z.string(), z.unknown()).optional(),
|
|
73
|
+
seed: z.boolean().optional(),
|
|
74
|
+
delegate: delegateSchema,
|
|
75
|
+
}),
|
|
62
76
|
]);
|
|
63
77
|
export const loadModelOptionsSchema = loadModelOptionsBaseSchema.transform((data) => ({
|
|
64
78
|
...data,
|
|
@@ -167,25 +181,57 @@ export const loadModelOptionsToRequestSchema = z.union([
|
|
|
167
181
|
modelSrc: modelSrcInputSchema,
|
|
168
182
|
modelType: ttsModelTypeSchema,
|
|
169
183
|
modelConfig: ttsConfigSchema,
|
|
170
|
-
configSrc: modelSrcInputSchema,
|
|
171
|
-
eSpeakDataPath: z.string(),
|
|
172
184
|
seed: z.boolean().optional(),
|
|
173
185
|
delegate: delegateSchema,
|
|
174
186
|
onProgress: z.unknown().optional(),
|
|
175
187
|
withProgress: z.boolean().optional(),
|
|
176
188
|
})
|
|
177
|
-
.transform((data) =>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
.transform((data) => {
|
|
190
|
+
// Keep modelConfig intact, just convert ModelSrcInput values to strings
|
|
191
|
+
if (data.modelConfig.ttsEngine === "chatterbox") {
|
|
192
|
+
return {
|
|
193
|
+
type: "loadModel",
|
|
194
|
+
modelType: ModelType.onnxTts,
|
|
195
|
+
modelSrc: modelInputToSrcSchema.parse(data.modelSrc),
|
|
196
|
+
modelName: modelInputToNameSchema.parse(data.modelSrc),
|
|
197
|
+
modelConfig: {
|
|
198
|
+
ttsEngine: "chatterbox",
|
|
199
|
+
language: data.modelConfig.language,
|
|
200
|
+
ttsTokenizerSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsTokenizerSrc),
|
|
201
|
+
ttsSpeechEncoderSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsSpeechEncoderSrc),
|
|
202
|
+
ttsEmbedTokensSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsEmbedTokensSrc),
|
|
203
|
+
ttsConditionalDecoderSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsConditionalDecoderSrc),
|
|
204
|
+
ttsLanguageModelSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsLanguageModelSrc),
|
|
205
|
+
referenceAudioSrc: modelInputToSrcSchema.parse(data.modelConfig.referenceAudioSrc),
|
|
206
|
+
},
|
|
207
|
+
seed: data.seed ?? false,
|
|
208
|
+
withProgress: data.withProgress ?? !!data.onProgress,
|
|
209
|
+
delegate: data.delegate,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return {
|
|
214
|
+
type: "loadModel",
|
|
215
|
+
modelType: ModelType.onnxTts,
|
|
216
|
+
modelSrc: modelInputToSrcSchema.parse(data.modelSrc),
|
|
217
|
+
modelName: modelInputToNameSchema.parse(data.modelSrc),
|
|
218
|
+
modelConfig: {
|
|
219
|
+
ttsEngine: "supertonic",
|
|
220
|
+
language: data.modelConfig.language,
|
|
221
|
+
ttsTokenizerSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsTokenizerSrc),
|
|
222
|
+
ttsTextEncoderSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsTextEncoderSrc),
|
|
223
|
+
ttsLatentDenoiserSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsLatentDenoiserSrc),
|
|
224
|
+
ttsVoiceDecoderSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsVoiceDecoderSrc),
|
|
225
|
+
ttsVoiceSrc: modelInputToSrcSchema.parse(data.modelConfig.ttsVoiceSrc),
|
|
226
|
+
ttsSpeed: data.modelConfig.ttsSpeed,
|
|
227
|
+
ttsNumInferenceSteps: data.modelConfig.ttsNumInferenceSteps,
|
|
228
|
+
},
|
|
229
|
+
seed: data.seed ?? false,
|
|
230
|
+
withProgress: data.withProgress ?? !!data.onProgress,
|
|
231
|
+
delegate: data.delegate,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
189
235
|
z
|
|
190
236
|
.object({
|
|
191
237
|
modelSrc: modelSrcInputSchema,
|
|
@@ -210,6 +256,29 @@ export const loadModelOptionsToRequestSchema = z.union([
|
|
|
210
256
|
? modelInputToSrcSchema.parse(data.detectorModelSrc)
|
|
211
257
|
: undefined,
|
|
212
258
|
})),
|
|
259
|
+
// Custom plugin catch-all: accepts any modelType string EXCEPT built-ins
|
|
260
|
+
z
|
|
261
|
+
.object({
|
|
262
|
+
modelSrc: modelSrcInputSchema,
|
|
263
|
+
modelType: z.string().refine((val) => !builtInModelTypes.has(val), {
|
|
264
|
+
message: "Built-in model types must use their specific schema",
|
|
265
|
+
}),
|
|
266
|
+
modelConfig: z.record(z.string(), z.unknown()).optional(),
|
|
267
|
+
seed: z.boolean().optional(),
|
|
268
|
+
delegate: delegateSchema,
|
|
269
|
+
onProgress: z.unknown().optional(),
|
|
270
|
+
withProgress: z.boolean().optional(),
|
|
271
|
+
})
|
|
272
|
+
.transform((data) => ({
|
|
273
|
+
type: "loadModel",
|
|
274
|
+
modelType: data.modelType,
|
|
275
|
+
modelSrc: modelInputToSrcSchema.parse(data.modelSrc),
|
|
276
|
+
modelName: modelInputToNameSchema.parse(data.modelSrc),
|
|
277
|
+
modelConfig: data.modelConfig ?? {},
|
|
278
|
+
seed: data.seed ?? false,
|
|
279
|
+
withProgress: data.withProgress ?? !!data.onProgress,
|
|
280
|
+
delegate: data.delegate,
|
|
281
|
+
})),
|
|
213
282
|
]);
|
|
214
283
|
const commonModelConfigSchema = z.object({
|
|
215
284
|
type: z.literal("loadModel"),
|
|
@@ -217,7 +286,6 @@ const commonModelConfigSchema = z.object({
|
|
|
217
286
|
modelName: z.string().optional(),
|
|
218
287
|
projectionModelSrc: z.string().optional(),
|
|
219
288
|
vadModelSrc: z.string().optional(),
|
|
220
|
-
configSrc: z.string().optional(),
|
|
221
289
|
detectorModelSrc: z.string().optional(),
|
|
222
290
|
withProgress: z.boolean().optional(),
|
|
223
291
|
seed: z.boolean().optional(),
|
|
@@ -244,16 +312,29 @@ export const loadNmtModelRequestSchema = commonModelConfigSchema.extend({
|
|
|
244
312
|
srcVocabSrc: z.string().optional(),
|
|
245
313
|
dstVocabSrc: z.string().optional(),
|
|
246
314
|
});
|
|
315
|
+
export const loadTtsChatterboxModelRequestSchema = commonModelConfigSchema.extend({
|
|
316
|
+
modelType: z.literal(ModelType.onnxTts),
|
|
317
|
+
modelConfig: ttsChatterboxRequestConfigSchema,
|
|
318
|
+
});
|
|
319
|
+
export const loadTtsSupertonicModelRequestSchema = commonModelConfigSchema.extend({
|
|
320
|
+
modelType: z.literal(ModelType.onnxTts),
|
|
321
|
+
modelConfig: ttsSupertonicRequestConfigSchema,
|
|
322
|
+
});
|
|
247
323
|
export const loadTtsModelRequestSchema = commonModelConfigSchema.extend({
|
|
248
324
|
modelType: z.literal(ModelType.onnxTts),
|
|
249
|
-
modelConfig:
|
|
250
|
-
configSrc: z.string(),
|
|
251
|
-
eSpeakDataPath: z.string(),
|
|
325
|
+
modelConfig: ttsRequestConfigSchema,
|
|
252
326
|
});
|
|
253
327
|
export const loadOcrModelRequestSchema = commonModelConfigSchema.extend({
|
|
254
328
|
modelType: z.literal(ModelType.onnxOcr),
|
|
255
329
|
modelConfig: ocrConfigSchema, // ocr has no defaults
|
|
256
330
|
});
|
|
331
|
+
// Custom plugin catch-all: accepts any modelType string EXCEPT built-ins
|
|
332
|
+
export const loadCustomPluginModelRequestSchema = commonModelConfigSchema.extend({
|
|
333
|
+
modelType: z.string().refine((val) => !builtInModelTypes.has(val), {
|
|
334
|
+
message: "Built-in model types must use their specific schema",
|
|
335
|
+
}),
|
|
336
|
+
modelConfig: z.record(z.string(), z.unknown()).optional(),
|
|
337
|
+
});
|
|
257
338
|
// Union of all load model request types (using z.union since each modelType accepts multiple values)
|
|
258
339
|
export const loadModelSrcRequestSchema = z
|
|
259
340
|
.union([
|
|
@@ -263,6 +344,7 @@ export const loadModelSrcRequestSchema = z
|
|
|
263
344
|
loadNmtModelRequestSchema,
|
|
264
345
|
loadTtsModelRequestSchema,
|
|
265
346
|
loadOcrModelRequestSchema,
|
|
347
|
+
loadCustomPluginModelRequestSchema,
|
|
266
348
|
])
|
|
267
349
|
.transform((data) => ({
|
|
268
350
|
...data,
|
|
@@ -295,6 +377,16 @@ export const modelProgressUpdateSchema = z.object({
|
|
|
295
377
|
overallPercentage: z.number(),
|
|
296
378
|
})
|
|
297
379
|
.optional(),
|
|
380
|
+
onnxInfo: z
|
|
381
|
+
.object({
|
|
382
|
+
currentFile: z.string(),
|
|
383
|
+
fileIndex: z.number(),
|
|
384
|
+
totalFiles: z.number(),
|
|
385
|
+
overallDownloaded: z.number(),
|
|
386
|
+
overallTotal: z.number(),
|
|
387
|
+
overallPercentage: z.number(),
|
|
388
|
+
})
|
|
389
|
+
.optional(),
|
|
298
390
|
});
|
|
299
391
|
export const hyperdriveUrlSchema = z
|
|
300
392
|
.string()
|
|
@@ -303,14 +395,27 @@ export const hyperdriveUrlSchema = z
|
|
|
303
395
|
const match = url.match(/^pear:\/\/([0-9a-fA-F]{64})\/(.+)$/);
|
|
304
396
|
return { key: match[1], path: match[2] };
|
|
305
397
|
});
|
|
398
|
+
/**
|
|
399
|
+
* Schema for registry:// URLs (internal use only).
|
|
400
|
+
* Users should use model constants from @qvac/sdk instead of raw URLs.
|
|
401
|
+
* Format: registry://source/path/to/model.gguf
|
|
402
|
+
*/
|
|
403
|
+
export const registryUrlSchema = z
|
|
404
|
+
.string()
|
|
405
|
+
.regex(/^registry:\/\/([^/]+)\/(.+)$/, "Invalid registry URL. Expected format: registry://source/path/to/model.gguf")
|
|
406
|
+
.transform((url) => {
|
|
407
|
+
const match = url.match(/^registry:\/\/([^/]+)\/(.+)$/);
|
|
408
|
+
return {
|
|
409
|
+
registrySource: match[1],
|
|
410
|
+
registryPath: match[2], // Path without source prefix
|
|
411
|
+
};
|
|
412
|
+
});
|
|
306
413
|
export const loadModelServerParamsSchema = z.object({
|
|
307
414
|
modelId: z.string(),
|
|
308
415
|
modelPath: z.string(),
|
|
309
|
-
options:
|
|
416
|
+
options: loadModelSrcRequestSchema,
|
|
310
417
|
projectionModelPath: z.string().optional(),
|
|
311
418
|
vadModelPath: z.string().optional(),
|
|
312
|
-
ttsConfigModelPath: z.string().optional(),
|
|
313
|
-
eSpeakDataPath: z.string().optional(),
|
|
314
419
|
detectorModelPath: z.string().optional(),
|
|
315
420
|
modelName: z.string().optional(),
|
|
316
421
|
});
|
|
@@ -3,8 +3,11 @@ export declare const modelDescriptorSchema: z.ZodObject<{
|
|
|
3
3
|
src: z.ZodString;
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
5
|
modelId: z.ZodOptional<z.ZodString>;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
registryPath: z.ZodOptional<z.ZodString>;
|
|
7
|
+
registrySource: z.ZodOptional<z.ZodString>;
|
|
8
|
+
blobCoreKey: z.ZodOptional<z.ZodString>;
|
|
9
|
+
blobIndex: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
engine: z.ZodOptional<z.ZodString>;
|
|
8
11
|
expectedSize: z.ZodOptional<z.ZodNumber>;
|
|
9
12
|
sha256Checksum: z.ZodOptional<z.ZodString>;
|
|
10
13
|
addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -26,8 +29,11 @@ export declare const modelSrcInputSchema: z.ZodUnion<readonly [z.ZodString, z.Zo
|
|
|
26
29
|
src: z.ZodString;
|
|
27
30
|
name: z.ZodOptional<z.ZodString>;
|
|
28
31
|
modelId: z.ZodOptional<z.ZodString>;
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
registryPath: z.ZodOptional<z.ZodString>;
|
|
33
|
+
registrySource: z.ZodOptional<z.ZodString>;
|
|
34
|
+
blobCoreKey: z.ZodOptional<z.ZodString>;
|
|
35
|
+
blobIndex: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
engine: z.ZodOptional<z.ZodString>;
|
|
31
37
|
expectedSize: z.ZodOptional<z.ZodNumber>;
|
|
32
38
|
sha256Checksum: z.ZodOptional<z.ZodString>;
|
|
33
39
|
addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -55,8 +61,11 @@ export declare const modelInputToSrcSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zod
|
|
|
55
61
|
src: z.ZodString;
|
|
56
62
|
name: z.ZodOptional<z.ZodString>;
|
|
57
63
|
modelId: z.ZodOptional<z.ZodString>;
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
registryPath: z.ZodOptional<z.ZodString>;
|
|
65
|
+
registrySource: z.ZodOptional<z.ZodString>;
|
|
66
|
+
blobCoreKey: z.ZodOptional<z.ZodString>;
|
|
67
|
+
blobIndex: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
engine: z.ZodOptional<z.ZodString>;
|
|
60
69
|
expectedSize: z.ZodOptional<z.ZodNumber>;
|
|
61
70
|
sha256Checksum: z.ZodOptional<z.ZodString>;
|
|
62
71
|
addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -77,8 +86,11 @@ export declare const modelInputToSrcSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zod
|
|
|
77
86
|
src: string;
|
|
78
87
|
name?: string | undefined;
|
|
79
88
|
modelId?: string | undefined;
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
registryPath?: string | undefined;
|
|
90
|
+
registrySource?: string | undefined;
|
|
91
|
+
blobCoreKey?: string | undefined;
|
|
92
|
+
blobIndex?: number | undefined;
|
|
93
|
+
engine?: string | undefined;
|
|
82
94
|
expectedSize?: number | undefined;
|
|
83
95
|
sha256Checksum?: string | undefined;
|
|
84
96
|
addon?: "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr" | "llm" | "whisper" | "embeddings" | "nmt" | "tts" | "ocr" | "vad" | undefined;
|
|
@@ -91,8 +103,11 @@ export declare const modelInputToNameSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zo
|
|
|
91
103
|
src: z.ZodString;
|
|
92
104
|
name: z.ZodOptional<z.ZodString>;
|
|
93
105
|
modelId: z.ZodOptional<z.ZodString>;
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
registryPath: z.ZodOptional<z.ZodString>;
|
|
107
|
+
registrySource: z.ZodOptional<z.ZodString>;
|
|
108
|
+
blobCoreKey: z.ZodOptional<z.ZodString>;
|
|
109
|
+
blobIndex: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
engine: z.ZodOptional<z.ZodString>;
|
|
96
111
|
expectedSize: z.ZodOptional<z.ZodNumber>;
|
|
97
112
|
sha256Checksum: z.ZodOptional<z.ZodString>;
|
|
98
113
|
addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -113,8 +128,11 @@ export declare const modelInputToNameSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zo
|
|
|
113
128
|
src: string;
|
|
114
129
|
name?: string | undefined;
|
|
115
130
|
modelId?: string | undefined;
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
registryPath?: string | undefined;
|
|
132
|
+
registrySource?: string | undefined;
|
|
133
|
+
blobCoreKey?: string | undefined;
|
|
134
|
+
blobIndex?: number | undefined;
|
|
135
|
+
engine?: string | undefined;
|
|
118
136
|
expectedSize?: number | undefined;
|
|
119
137
|
sha256Checksum?: string | undefined;
|
|
120
138
|
addon?: "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr" | "llm" | "whisper" | "embeddings" | "nmt" | "tts" | "ocr" | "vad" | undefined;
|
|
@@ -6,8 +6,11 @@ export const modelDescriptorSchema = z.object({
|
|
|
6
6
|
src: z.string(),
|
|
7
7
|
name: z.string().optional(),
|
|
8
8
|
modelId: z.string().optional(),
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
registryPath: z.string().optional(),
|
|
10
|
+
registrySource: z.string().optional(),
|
|
11
|
+
blobCoreKey: z.string().optional(),
|
|
12
|
+
blobIndex: z.number().optional(),
|
|
13
|
+
engine: z.string().optional(),
|
|
11
14
|
expectedSize: z.number().optional(),
|
|
12
15
|
sha256Checksum: z.string().optional(),
|
|
13
16
|
addon: addonSchema.optional(),
|
|
@@ -87,10 +87,21 @@ export declare const modelTypeSchema: z.ZodPipe<z.ZodEnum<{
|
|
|
87
87
|
tts: "tts";
|
|
88
88
|
ocr: "ocr";
|
|
89
89
|
}>, z.ZodTransform<"llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr", "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr" | "llm" | "whisper" | "embeddings" | "nmt" | "tts" | "ocr">>;
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Normalize model type input to canonical form.
|
|
92
|
+
* Custom plugin types (not in built-ins) are returned as-is.
|
|
93
|
+
*/
|
|
94
|
+
export declare function normalizeModelType(input: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Type guard to check if a string is a canonical (built-in) model type.
|
|
97
|
+
* Returns false for custom plugin types.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isCanonicalModelType(input: string): input is CanonicalModelType;
|
|
100
|
+
/**
|
|
101
|
+
* Check if input is a built-in alias (not canonical or custom).
|
|
102
|
+
* Returns false for custom plugin types.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isModelTypeAlias(input: string): boolean;
|
|
94
105
|
/**
|
|
95
106
|
* LLM/Completion model type schema.
|
|
96
107
|
* - Alias: `"llm"` → resolves to `"llamacpp-completion"`
|
|
@@ -75,16 +75,33 @@ export const modelTypeSchema = modelTypeInputSchema.transform((val) => {
|
|
|
75
75
|
// Otherwise, look up in aliases
|
|
76
76
|
return ModelTypeAliases[val];
|
|
77
77
|
});
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Normalize model type input to canonical form.
|
|
80
|
+
* Custom plugin types (not in built-ins) are returned as-is.
|
|
81
|
+
*/
|
|
79
82
|
export function normalizeModelType(input) {
|
|
80
83
|
// If already canonical, return as-is
|
|
81
84
|
if (canonicalValuesSet.has(input)) {
|
|
82
85
|
return input;
|
|
83
86
|
}
|
|
84
|
-
//
|
|
85
|
-
|
|
87
|
+
// If it's an alias, normalize to canonical
|
|
88
|
+
if (input in ModelTypeAliases) {
|
|
89
|
+
return ModelTypeAliases[input];
|
|
90
|
+
}
|
|
91
|
+
// Custom plugin type - return as-is
|
|
92
|
+
return input;
|
|
86
93
|
}
|
|
87
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Type guard to check if a string is a canonical (built-in) model type.
|
|
96
|
+
* Returns false for custom plugin types.
|
|
97
|
+
*/
|
|
98
|
+
export function isCanonicalModelType(input) {
|
|
99
|
+
return canonicalValuesSet.has(input);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if input is a built-in alias (not canonical or custom).
|
|
103
|
+
* Returns false for custom plugin types.
|
|
104
|
+
*/
|
|
88
105
|
export function isModelTypeAlias(input) {
|
|
89
106
|
return input in ModelTypeAliases;
|
|
90
107
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod refinement for path components that get joined to a base directory.
|
|
4
|
+
* Rejects strings containing traversal sequences (.., null bytes).
|
|
5
|
+
*
|
|
6
|
+
* DO NOT apply to fields that accept absolute user paths (e.g. audio, image,
|
|
7
|
+
* model, or attachment paths).
|
|
8
|
+
*/
|
|
9
|
+
export declare const safePathComponent: z.ZodString;
|
|
10
|
+
//# sourceMappingURL=path-validation.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod refinement for path components that get joined to a base directory.
|
|
4
|
+
* Rejects strings containing traversal sequences (.., null bytes).
|
|
5
|
+
*
|
|
6
|
+
* DO NOT apply to fields that accept absolute user paths (e.g. audio, image,
|
|
7
|
+
* model, or attachment paths).
|
|
8
|
+
*/
|
|
9
|
+
export const safePathComponent = z.string().refine((s) => {
|
|
10
|
+
// Reject literal traversal
|
|
11
|
+
if (s.includes(".."))
|
|
12
|
+
return false;
|
|
13
|
+
// Reject null bytes (literal and URL-encoded)
|
|
14
|
+
if (s.includes("\0") || s.toLowerCase().includes("%00"))
|
|
15
|
+
return false;
|
|
16
|
+
// Reject URL-encoded traversal (%2e = ".", %2f = "/", %5c = "\")
|
|
17
|
+
if (/%2e/i.test(s))
|
|
18
|
+
return false;
|
|
19
|
+
return true;
|
|
20
|
+
}, {
|
|
21
|
+
message: "Path component must not contain traversal sequences ('..', '%2e'), null bytes, or '%00'",
|
|
22
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Definition for a plugin handler with explicit Zod schemas.
|
|
4
|
+
* Each handler must define its request/response schemas for validation.
|
|
5
|
+
*/
|
|
6
|
+
export interface PluginHandlerDefinition<TRequest extends z.ZodType = z.ZodType, TResponse extends z.ZodType = z.ZodType> {
|
|
7
|
+
requestSchema: TRequest;
|
|
8
|
+
responseSchema: TResponse;
|
|
9
|
+
streaming: boolean;
|
|
10
|
+
/** The handler function - receives validated request, returns validated response */
|
|
11
|
+
handler: TRequest extends z.ZodType<infer I> ? TResponse extends z.ZodType<infer O> ? (request: I) => Promise<O> | AsyncGenerator<O> : never : never;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parameters passed to createModel when loading a plugin model.
|
|
15
|
+
*
|
|
16
|
+
* Core fields are always present. The `artifacts` map contains
|
|
17
|
+
* additional file paths required by specific plugins (e.g., projection
|
|
18
|
+
* models, VAD models, config files).
|
|
19
|
+
*
|
|
20
|
+
* Built-in artifact keys:
|
|
21
|
+
* - `projectionModelPath` - LLM multimodal projection model
|
|
22
|
+
* - `vadModelPath` - Whisper voice activity detection model
|
|
23
|
+
* - `tokenizerPath`, `speechEncoderPath`, `embedTokensPath`, `conditionalDecoderPath`, `languageModelPath` - TTS (Chatterbox) model files
|
|
24
|
+
* - `referenceAudioPath` - TTS (Chatterbox) path to reference WAV file for voice cloning
|
|
25
|
+
* - `tokenizerPath`, `textEncoderPath`, `latentDenoiserPath`, `voiceDecoderPath` - TTS (Supertonic) model files
|
|
26
|
+
* - `voicePath` - TTS (Supertonic) path to voice .bin file (e.g. voices/M1.bin)
|
|
27
|
+
* - `speed`, `numInferenceSteps` - TTS (Supertonic) options
|
|
28
|
+
* - `detectorModelPath` - OCR detector model
|
|
29
|
+
*
|
|
30
|
+
* Custom plugins can define their own artifact keys.
|
|
31
|
+
*/
|
|
32
|
+
export interface CreateModelParams {
|
|
33
|
+
modelId: string;
|
|
34
|
+
modelPath: string;
|
|
35
|
+
modelConfig?: Record<string, unknown> | undefined;
|
|
36
|
+
modelName?: string | undefined;
|
|
37
|
+
artifacts?: Record<string, string> | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Minimal contract for plugin models.
|
|
41
|
+
* All models must implement `load()`. `unload()` is optional.
|
|
42
|
+
*/
|
|
43
|
+
export interface PluginModel {
|
|
44
|
+
load(force?: boolean): Promise<void>;
|
|
45
|
+
unload?(): void | Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface PluginModelResult {
|
|
48
|
+
model: PluginModel;
|
|
49
|
+
loader: unknown;
|
|
50
|
+
}
|
|
51
|
+
export interface PluginLogging {
|
|
52
|
+
module: unknown;
|
|
53
|
+
namespace: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Function to resolve a model source (URL or path) to a local file path.
|
|
57
|
+
* Passed to resolveConfig hook to allow plugins to resolve their artifacts.
|
|
58
|
+
*/
|
|
59
|
+
export type ResolveModelPath = (src: string) => Promise<string>;
|
|
60
|
+
export interface QvacPlugin {
|
|
61
|
+
modelType: string;
|
|
62
|
+
displayName: string;
|
|
63
|
+
addonPackage: string;
|
|
64
|
+
createModel: (params: CreateModelParams) => PluginModelResult;
|
|
65
|
+
handlers: Record<string, PluginHandlerDefinition>;
|
|
66
|
+
logging?: PluginLogging | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Optional hook to resolve model sources in modelConfig to local paths.
|
|
69
|
+
* Called before createModel if the plugin needs to download/resolve artifacts.
|
|
70
|
+
* Receives the raw modelConfig and a resolve function, returns transformed config.
|
|
71
|
+
*/
|
|
72
|
+
resolveConfig?: (modelConfig: Record<string, unknown>, resolve: ResolveModelPath) => Promise<Record<string, unknown>>;
|
|
73
|
+
}
|
|
74
|
+
export declare const pluginInvokeRequestSchema: z.ZodObject<{
|
|
75
|
+
type: z.ZodLiteral<"pluginInvoke">;
|
|
76
|
+
modelId: z.ZodString;
|
|
77
|
+
handler: z.ZodString;
|
|
78
|
+
params: z.ZodUnknown;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export declare const pluginInvokeResponseSchema: z.ZodObject<{
|
|
81
|
+
type: z.ZodLiteral<"pluginInvoke">;
|
|
82
|
+
result: z.ZodUnknown;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export declare const pluginInvokeStreamRequestSchema: z.ZodObject<{
|
|
85
|
+
type: z.ZodLiteral<"pluginInvokeStream">;
|
|
86
|
+
modelId: z.ZodString;
|
|
87
|
+
handler: z.ZodString;
|
|
88
|
+
params: z.ZodUnknown;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export declare const pluginInvokeStreamResponseSchema: z.ZodObject<{
|
|
91
|
+
type: z.ZodLiteral<"pluginInvokeStream">;
|
|
92
|
+
result: z.ZodUnknown;
|
|
93
|
+
done: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export type PluginInvokeRequest = z.infer<typeof pluginInvokeRequestSchema>;
|
|
96
|
+
export type PluginInvokeResponse = z.infer<typeof pluginInvokeResponseSchema>;
|
|
97
|
+
export type PluginInvokeStreamRequest = z.infer<typeof pluginInvokeStreamRequestSchema>;
|
|
98
|
+
export type PluginInvokeStreamResponse = z.infer<typeof pluginInvokeStreamResponseSchema>;
|
|
99
|
+
/**
|
|
100
|
+
* Helper function to define a plugin with full type inference.
|
|
101
|
+
* This is an identity function that provides type checking.
|
|
102
|
+
*/
|
|
103
|
+
export declare function definePlugin<T extends QvacPlugin>(plugin: T): T;
|
|
104
|
+
/**
|
|
105
|
+
* Helper function to define a handler with full type inference.
|
|
106
|
+
* This is an identity function that provides type checking.
|
|
107
|
+
*/
|
|
108
|
+
export declare function defineHandler<TRequest extends z.ZodType, TResponse extends z.ZodType>(definition: PluginHandlerDefinition<TRequest, TResponse>): PluginHandlerDefinition<TRequest, TResponse>;
|
|
109
|
+
export declare const pluginHandlerDefinitionRuntimeSchema: z.ZodObject<{
|
|
110
|
+
requestSchema: z.ZodObject<{
|
|
111
|
+
safeParse: z.ZodCustom<Function, Function>;
|
|
112
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
113
|
+
responseSchema: z.ZodObject<{
|
|
114
|
+
safeParse: z.ZodCustom<Function, Function>;
|
|
115
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
116
|
+
streaming: z.ZodBoolean;
|
|
117
|
+
handler: z.ZodCustom<Function, Function>;
|
|
118
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
119
|
+
export declare const pluginDefinitionRuntimeSchema: z.ZodObject<{
|
|
120
|
+
modelType: z.ZodString;
|
|
121
|
+
displayName: z.ZodString;
|
|
122
|
+
addonPackage: z.ZodString;
|
|
123
|
+
createModel: z.ZodCustom<Function, Function>;
|
|
124
|
+
handlers: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
125
|
+
requestSchema: z.ZodObject<{
|
|
126
|
+
safeParse: z.ZodCustom<Function, Function>;
|
|
127
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
128
|
+
responseSchema: z.ZodObject<{
|
|
129
|
+
safeParse: z.ZodCustom<Function, Function>;
|
|
130
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
131
|
+
streaming: z.ZodBoolean;
|
|
132
|
+
handler: z.ZodCustom<Function, Function>;
|
|
133
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
134
|
+
logging: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
module: z.ZodOptional<z.ZodUnknown>;
|
|
136
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
138
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
139
|
+
/**
|
|
140
|
+
* LLM text completion plugin (llama.cpp).
|
|
141
|
+
* Provides: completion, streaming chat, tool calling.
|
|
142
|
+
*/
|
|
143
|
+
export declare const PLUGIN_LLM: "@qvac/sdk/llamacpp-completion/plugin";
|
|
144
|
+
/**
|
|
145
|
+
* Text embedding plugin (llama.cpp).
|
|
146
|
+
* Provides: vector embeddings for RAG and semantic search.
|
|
147
|
+
*/
|
|
148
|
+
export declare const PLUGIN_EMBEDDING: "@qvac/sdk/llamacpp-embedding/plugin";
|
|
149
|
+
/**
|
|
150
|
+
* Speech-to-text transcription plugin (whisper.cpp).
|
|
151
|
+
* Provides: audio transcription, language detection.
|
|
152
|
+
*/
|
|
153
|
+
export declare const PLUGIN_WHISPER: "@qvac/sdk/whispercpp-transcription/plugin";
|
|
154
|
+
/**
|
|
155
|
+
* Neural machine translation plugin (nmt.cpp).
|
|
156
|
+
* Provides: text translation between languages.
|
|
157
|
+
*/
|
|
158
|
+
export declare const PLUGIN_NMT: "@qvac/sdk/nmtcpp-translation/plugin";
|
|
159
|
+
/**
|
|
160
|
+
* Text-to-speech synthesis plugin (ONNX).
|
|
161
|
+
* Provides: speech synthesis from text.
|
|
162
|
+
*/
|
|
163
|
+
export declare const PLUGIN_TTS: "@qvac/sdk/onnx-tts/plugin";
|
|
164
|
+
/**
|
|
165
|
+
* Optical character recognition plugin (ONNX).
|
|
166
|
+
* Provides: text extraction from images.
|
|
167
|
+
*/
|
|
168
|
+
export declare const PLUGIN_OCR: "@qvac/sdk/onnx-ocr/plugin";
|
|
169
|
+
/**
|
|
170
|
+
* All built-in SDK plugins.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // Use all defaults plus a custom plugin:
|
|
174
|
+
* const config = {
|
|
175
|
+
* plugins: [...SDK_DEFAULT_PLUGINS, myCustomPlugin],
|
|
176
|
+
* };
|
|
177
|
+
*/
|
|
178
|
+
export declare const SDK_DEFAULT_PLUGINS: readonly ["@qvac/sdk/llamacpp-completion/plugin", "@qvac/sdk/llamacpp-embedding/plugin", "@qvac/sdk/whispercpp-transcription/plugin", "@qvac/sdk/nmtcpp-translation/plugin", "@qvac/sdk/onnx-tts/plugin", "@qvac/sdk/onnx-ocr/plugin"];
|
|
179
|
+
export type BuiltinPlugin = (typeof SDK_DEFAULT_PLUGINS)[number];
|
|
180
|
+
//# sourceMappingURL=plugin.d.ts.map
|