@qvac/sdk 0.10.2 → 0.12.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.
Files changed (326) hide show
  1. package/NOTICE +1455 -29
  2. package/README.md +2 -0
  3. package/dist/client/api/cancel.d.ts +24 -32
  4. package/dist/client/api/cancel.js +58 -31
  5. package/dist/client/api/classify.d.ts +23 -0
  6. package/dist/client/api/classify.js +43 -0
  7. package/dist/client/api/client-request-id.d.ts +17 -0
  8. package/dist/client/api/client-request-id.js +27 -0
  9. package/dist/client/api/completion-stream.d.ts +1 -1
  10. package/dist/client/api/completion-stream.js +34 -3
  11. package/dist/client/api/diffusion.d.ts +46 -0
  12. package/dist/client/api/diffusion.js +50 -1
  13. package/dist/client/api/download-asset.d.ts +12 -2
  14. package/dist/client/api/download-asset.js +21 -3
  15. package/dist/client/api/embed.d.ts +8 -4
  16. package/dist/client/api/embed.js +14 -1
  17. package/dist/client/api/get-model-info.d.ts +1 -1
  18. package/dist/client/api/index.d.ts +5 -0
  19. package/dist/client/api/index.js +5 -0
  20. package/dist/client/api/load-model.d.ts +12 -4
  21. package/dist/client/api/load-model.js +49 -2
  22. package/dist/client/api/rag.d.ts +9 -3
  23. package/dist/client/api/rag.js +23 -3
  24. package/dist/client/api/transcribe.d.ts +23 -8
  25. package/dist/client/api/transcribe.js +69 -4
  26. package/dist/client/api/unload-model.d.ts +5 -2
  27. package/dist/client/api/unload-model.js +9 -4
  28. package/dist/client/api/upscale.d.ts +45 -0
  29. package/dist/client/api/upscale.js +99 -0
  30. package/dist/client/api/video.d.ts +64 -0
  31. package/dist/client/api/video.js +147 -0
  32. package/dist/client/api/vla-helpers.d.ts +45 -0
  33. package/dist/client/api/vla-helpers.js +130 -0
  34. package/dist/client/api/vla.d.ts +65 -0
  35. package/dist/client/api/vla.js +109 -0
  36. package/dist/client/config-loader/resolve-config.node.d.ts +16 -0
  37. package/dist/client/config-loader/resolve-config.node.js +77 -23
  38. package/dist/client/plugins-factory.d.ts +8 -0
  39. package/dist/client/plugins-factory.js +10 -0
  40. package/dist/client/rpc/bare-client.js +62 -66
  41. package/dist/client/rpc/ensure-worker-ready.d.ts +9 -0
  42. package/dist/client/rpc/ensure-worker-ready.js +17 -0
  43. package/dist/client/rpc/expo-rpc-client.js +2 -1
  44. package/dist/client/rpc/node-rpc-client.js +22 -8
  45. package/dist/client/rpc/rpc-client.d.ts +2 -2
  46. package/dist/client/rpc/rpc-client.js +10 -4
  47. package/dist/client/rpc/rpc-error.d.ts +9 -0
  48. package/dist/client/rpc/rpc-error.js +105 -0
  49. package/dist/commands/bundle/bare-pack.d.ts +13 -0
  50. package/dist/commands/bundle/bare-pack.js +54 -0
  51. package/dist/commands/bundle/constants.d.ts +7 -0
  52. package/dist/commands/bundle/constants.js +23 -0
  53. package/dist/commands/bundle/entry-gen.d.ts +2 -0
  54. package/dist/commands/bundle/entry-gen.js +48 -0
  55. package/dist/commands/bundle/index.d.ts +20 -0
  56. package/dist/commands/bundle/index.js +141 -0
  57. package/dist/commands/bundle/manifest.d.ts +21 -0
  58. package/dist/commands/bundle/manifest.js +193 -0
  59. package/dist/commands/bundle/plugins.d.ts +9 -0
  60. package/dist/commands/bundle/plugins.js +51 -0
  61. package/dist/commands/index.d.ts +5 -0
  62. package/dist/commands/index.js +2 -0
  63. package/dist/commands/verify/abi.d.ts +52 -0
  64. package/dist/commands/verify/abi.js +125 -0
  65. package/dist/commands/verify/addon-source.d.ts +43 -0
  66. package/dist/commands/verify/addon-source.js +75 -0
  67. package/dist/commands/verify/bundle-source.d.ts +12 -0
  68. package/dist/commands/verify/bundle-source.js +53 -0
  69. package/dist/commands/verify/index.d.ts +59 -0
  70. package/dist/commands/verify/index.js +371 -0
  71. package/dist/commands/verify/node-modules-source.d.ts +11 -0
  72. package/dist/commands/verify/node-modules-source.js +76 -0
  73. package/dist/commands/verify/prebuilds.d.ts +15 -0
  74. package/dist/commands/verify/prebuilds.js +39 -0
  75. package/dist/examples/cancel-by-request-id.d.ts +38 -0
  76. package/dist/examples/cancel-by-request-id.js +103 -0
  77. package/dist/examples/classification/classify-image.d.ts +2 -0
  78. package/dist/examples/classification/classify-image.js +23 -0
  79. package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
  80. package/dist/examples/diffusion-esrgan-upscale.js +78 -0
  81. package/dist/examples/diffusion-txt2vid.d.ts +2 -0
  82. package/dist/examples/diffusion-txt2vid.js +81 -0
  83. package/dist/examples/download-with-cancel.js +10 -10
  84. package/dist/examples/embed-multi-gpu.d.ts +2 -0
  85. package/dist/examples/embed-multi-gpu.js +46 -0
  86. package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
  87. package/dist/examples/llamacpp-multi-gpu.js +57 -0
  88. package/dist/examples/plugins.js +3 -7
  89. package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
  90. package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
  91. package/dist/examples/tools/llamacpp-tools-gemma4.js +73 -0
  92. package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
  93. package/dist/examples/tools/llamacpp-tools-qwen35.js +69 -0
  94. package/dist/examples/transcription/parakeet-ctc-filesystem.js +18 -12
  95. package/dist/examples/transcription/parakeet-microphone-record.js +7 -12
  96. package/dist/examples/transcription/parakeet-microphone-stream.d.ts +2 -0
  97. package/dist/examples/transcription/parakeet-microphone-stream.js +79 -0
  98. package/dist/examples/transcription/parakeet-sortformer-streaming.d.ts +2 -0
  99. package/dist/examples/transcription/parakeet-sortformer-streaming.js +121 -0
  100. package/dist/examples/transcription/parakeet-sortformer.js +58 -55
  101. package/dist/examples/transcription/parakeet-tdt-filesystem.js +18 -15
  102. package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
  103. package/dist/examples/transcription/whispercpp-microphone-conversation.js +107 -0
  104. package/dist/examples/tts/chatterbox.js +7 -16
  105. package/dist/examples/tts/llm-to-tts-streaming.js +3 -10
  106. package/dist/examples/tts/supertonic-multilingual.js +4 -12
  107. package/dist/examples/tts/supertonic.js +5 -12
  108. package/dist/examples/vla-smolvla.d.ts +2 -0
  109. package/dist/examples/vla-smolvla.js +75 -0
  110. package/dist/examples/voice-assistant/voice-assistant.js +3 -10
  111. package/dist/expo/plugins/find-in-ancestor-node-modules.d.ts +14 -0
  112. package/dist/expo/plugins/find-in-ancestor-node-modules.js +24 -0
  113. package/dist/expo/plugins/get-project-root.d.ts +22 -0
  114. package/dist/expo/plugins/get-project-root.js +23 -0
  115. package/dist/expo/plugins/index.d.ts +4 -0
  116. package/dist/expo/plugins/index.js +4 -0
  117. package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +9 -2
  118. package/dist/expo/plugins/resolve-sdk-package-dir.js +38 -11
  119. package/dist/expo/plugins/withDeviceInfo.js +2 -1
  120. package/dist/expo/plugins/withMobileBundle.d.ts +5 -4
  121. package/dist/expo/plugins/withMobileBundle.js +42 -58
  122. package/dist/index.d.ts +6 -2
  123. package/dist/index.js +23 -2
  124. package/dist/models/registry/models.d.ts +3725 -514
  125. package/dist/models/registry/models.js +7269 -3910
  126. package/dist/models/update-models/naming.js +22 -8
  127. package/dist/pear/pre.d.ts +3 -0
  128. package/dist/pear/pre.js +9 -2
  129. package/dist/schemas/cancel.d.ts +172 -28
  130. package/dist/schemas/cancel.js +120 -19
  131. package/dist/schemas/classification.d.ts +53 -0
  132. package/dist/schemas/classification.js +33 -0
  133. package/dist/schemas/common.d.ts +860 -1379
  134. package/dist/schemas/common.js +8 -1
  135. package/dist/schemas/completion-event.d.ts +17 -0
  136. package/dist/schemas/completion-event.js +12 -1
  137. package/dist/schemas/completion-stream.d.ts +16 -1
  138. package/dist/schemas/completion-stream.js +25 -7
  139. package/dist/schemas/download-asset.d.ts +25 -9
  140. package/dist/schemas/download-asset.js +17 -6
  141. package/dist/schemas/embed.d.ts +1 -0
  142. package/dist/schemas/embed.js +5 -0
  143. package/dist/schemas/engine-addon-map.d.ts +3 -0
  144. package/dist/schemas/engine-addon-map.js +18 -5
  145. package/dist/schemas/error.d.ts +31 -0
  146. package/dist/schemas/error.js +29 -1
  147. package/dist/schemas/finetune.d.ts +2 -0
  148. package/dist/schemas/finetune.js +5 -0
  149. package/dist/schemas/get-model-info.d.ts +10 -6
  150. package/dist/schemas/get-model-info.js +2 -0
  151. package/dist/schemas/index.d.ts +3 -0
  152. package/dist/schemas/index.js +3 -0
  153. package/dist/schemas/llamacpp-config.d.ts +64 -8
  154. package/dist/schemas/llamacpp-config.js +12 -0
  155. package/dist/schemas/load-model.d.ts +4644 -8605
  156. package/dist/schemas/load-model.js +90 -7
  157. package/dist/schemas/model-src-utils.d.ts +34 -14
  158. package/dist/schemas/model-types.d.ts +54 -14
  159. package/dist/schemas/model-types.js +28 -5
  160. package/dist/schemas/ocr.d.ts +8 -3
  161. package/dist/schemas/plugin.d.ts +60 -6
  162. package/dist/schemas/plugin.js +31 -5
  163. package/dist/schemas/rag.d.ts +9 -0
  164. package/dist/schemas/rag.js +17 -9
  165. package/dist/schemas/registry.d.ts +74 -30
  166. package/dist/schemas/registry.js +5 -0
  167. package/dist/schemas/reload-config.d.ts +34 -14
  168. package/dist/schemas/sdcpp-config.d.ts +445 -16
  169. package/dist/schemas/sdcpp-config.js +387 -26
  170. package/dist/schemas/sdk-config.d.ts +2431 -2723
  171. package/dist/schemas/sdk-config.js +16 -1
  172. package/dist/schemas/sdk-errors-client.d.ts +6 -0
  173. package/dist/schemas/sdk-errors-client.js +31 -1
  174. package/dist/schemas/sdk-errors-server.d.ts +8 -1
  175. package/dist/schemas/sdk-errors-server.js +45 -5
  176. package/dist/schemas/text-to-speech.d.ts +81 -698
  177. package/dist/schemas/text-to-speech.js +46 -19
  178. package/dist/schemas/transcription-config.d.ts +40 -229
  179. package/dist/schemas/transcription-config.js +76 -15
  180. package/dist/schemas/transcription.d.ts +108 -2
  181. package/dist/schemas/transcription.js +81 -0
  182. package/dist/schemas/translate.d.ts +2 -0
  183. package/dist/schemas/translate.js +13 -2
  184. package/dist/schemas/translation-config.d.ts +90 -40
  185. package/dist/schemas/unload-model.d.ts +2 -1
  186. package/dist/schemas/unload-model.js +4 -1
  187. package/dist/schemas/vla.d.ts +87 -0
  188. package/dist/schemas/vla.js +108 -0
  189. package/dist/scripts/run-unit-tests.js +22 -3
  190. package/dist/server/bare/ops/cancel.d.ts +27 -1
  191. package/dist/server/bare/ops/cancel.js +36 -10
  192. package/dist/server/bare/ops/embed.d.ts +3 -3
  193. package/dist/server/bare/ops/embed.js +144 -28
  194. package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
  195. package/dist/server/bare/ops/kv-cache-utils.js +8 -47
  196. package/dist/server/bare/ops/transcribe.d.ts +11 -5
  197. package/dist/server/bare/ops/transcribe.js +230 -50
  198. package/dist/server/bare/ops/translate.d.ts +1 -1
  199. package/dist/server/bare/ops/translate.js +197 -88
  200. package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +6 -0
  201. package/dist/server/bare/plugins/ggml-classification/ops/classify.js +30 -0
  202. package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +32 -0
  203. package/dist/server/bare/plugins/ggml-classification/plugin.js +55 -0
  204. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +3 -0
  205. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +12 -0
  206. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +3 -0
  207. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +75 -0
  208. package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +54 -0
  209. package/dist/server/bare/plugins/ggml-vla/plugin.js +57 -0
  210. package/dist/server/bare/plugins/index.d.ts +3 -1
  211. package/dist/server/bare/plugins/index.js +3 -1
  212. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
  213. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +173 -172
  214. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +29 -0
  215. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +65 -0
  216. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
  217. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
  218. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
  219. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
  220. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
  221. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +36 -3
  222. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +183 -85
  223. package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
  224. package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
  225. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
  226. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
  227. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +42 -15
  228. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
  229. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +8 -3
  230. package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
  231. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +73 -244
  232. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +68 -96
  233. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
  234. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
  235. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
  236. package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +3 -0
  237. package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +199 -0
  238. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +288 -15
  239. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +150 -7
  240. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.js +2 -15
  241. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.js +2 -1
  242. package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +75 -0
  243. package/dist/server/bare/plugins/tts-ggml/plugin.js +189 -0
  244. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +47 -3
  245. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +61 -14
  246. package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
  247. package/dist/server/bare/rag-hyperdb/index.js +1 -1
  248. package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
  249. package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
  250. package/dist/server/bare/registry/model-config-utils.js +7 -0
  251. package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
  252. package/dist/server/bare/runtime/disposable-scope.js +69 -0
  253. package/dist/server/bare/runtime/index.d.ts +8 -0
  254. package/dist/server/bare/runtime/index.js +3 -0
  255. package/dist/server/bare/runtime/request-context.d.ts +49 -0
  256. package/dist/server/bare/runtime/request-context.js +1 -0
  257. package/dist/server/bare/runtime/request-id.d.ts +12 -0
  258. package/dist/server/bare/runtime/request-id.js +14 -0
  259. package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
  260. package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
  261. package/dist/server/bare/runtime/request-registry.d.ts +136 -0
  262. package/dist/server/bare/runtime/request-registry.js +297 -0
  263. package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
  264. package/dist/server/bare/runtime/with-request-context.js +53 -0
  265. package/dist/server/bare/runtime-lifecycle.js +9 -9
  266. package/dist/server/bare/types/addon-responses.d.ts +12 -1
  267. package/dist/server/env.js +4 -1
  268. package/dist/server/plugins/index.d.ts +1 -1
  269. package/dist/server/plugins/index.js +1 -1
  270. package/dist/server/plugins/registry.d.ts +1 -0
  271. package/dist/server/plugins/registry.js +5 -0
  272. package/dist/server/rpc/handler-registry.js +30 -7
  273. package/dist/server/rpc/handler-selection.d.ts +9 -0
  274. package/dist/server/rpc/handler-selection.js +14 -0
  275. package/dist/server/rpc/handler-utils.js +5 -13
  276. package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
  277. package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
  278. package/dist/server/rpc/handlers/cancelHandler.js +54 -22
  279. package/dist/server/rpc/handlers/classify.d.ts +3 -0
  280. package/dist/server/rpc/handlers/classify.js +4 -0
  281. package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
  282. package/dist/server/rpc/handlers/delete-cache.js +13 -15
  283. package/dist/server/rpc/handlers/download-asset.js +133 -40
  284. package/dist/server/rpc/handlers/index.d.ts +4 -0
  285. package/dist/server/rpc/handlers/index.js +4 -0
  286. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
  287. package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
  288. package/dist/server/rpc/handlers/load-model/handler.js +216 -98
  289. package/dist/server/rpc/handlers/load-model/http.js +3 -3
  290. package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
  291. package/dist/server/rpc/handlers/load-model/registry.js +1 -1
  292. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
  293. package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
  294. package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
  295. package/dist/server/rpc/handlers/load-model/resolve.js +18 -6
  296. package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
  297. package/dist/server/rpc/handlers/rag.js +133 -15
  298. package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
  299. package/dist/server/rpc/handlers/upscale-stream.js +4 -0
  300. package/dist/server/rpc/handlers/video-stream.d.ts +3 -0
  301. package/dist/server/rpc/handlers/video-stream.js +4 -0
  302. package/dist/server/rpc/profiling/operation-metrics.js +23 -0
  303. package/dist/server/utils/completion-normalizer.js +8 -0
  304. package/dist/server/utils/config-transform.js +1 -1
  305. package/dist/server/utils/tools/dialect.js +4 -0
  306. package/dist/server/utils/tools/parser.js +16 -1
  307. package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
  308. package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
  309. package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
  310. package/dist/server/utils/tools/parsers/qwen35.js +120 -0
  311. package/dist/server/worker.js +14 -11
  312. package/dist/utils/aggregate-events.d.ts +9 -0
  313. package/dist/utils/aggregate-events.js +18 -3
  314. package/dist/utils/decorate-promise.d.ts +34 -0
  315. package/dist/utils/decorate-promise.js +35 -0
  316. package/dist/utils/errors-client.d.ts +18 -0
  317. package/dist/utils/errors-client.js +31 -0
  318. package/dist/utils/errors-server.d.ts +115 -2
  319. package/dist/utils/errors-server.js +148 -3
  320. package/package.json +68 -77
  321. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -490
  322. package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -266
  323. package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
  324. package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
  325. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.d.ts +0 -0
  326. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.d.ts +0 -0
@@ -1,12 +1,54 @@
1
1
  import { z } from "zod";
2
2
  import { modelSrcInputSchema } from "./model-src-utils.js";
3
3
  const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
4
+ const ABSOLUTE_PATH_PATTERN = /^(\/|[A-Za-z]:[\\/]|\\\\)/;
5
+ const base64StringSchema = z.string().min(1).regex(BASE64_PATTERN);
6
+ const samplingMethodSchema = z.enum([
7
+ "euler",
8
+ "euler_a",
9
+ "heun",
10
+ "dpm2",
11
+ "dpm++2m",
12
+ "dpm++2mv2",
13
+ "dpm++2s_a",
14
+ "lcm",
15
+ "ipndm",
16
+ "ipndm_v",
17
+ "ddim_trailing",
18
+ "tcd",
19
+ "res_multistep",
20
+ "res_2s",
21
+ ]);
22
+ const scheduleTypeSchema = z.enum([
23
+ "discrete", "karras", "exponential", "ays", "gits",
24
+ "sgm_uniform", "simple", "lcm", "smoothstep", "kl_optimal", "bong_tangent",
25
+ ]);
26
+ const cacheModeSchema = z.enum([
27
+ "disabled",
28
+ "easycache",
29
+ "ucache",
30
+ "dbcache",
31
+ "taylorseer",
32
+ "cache-dit",
33
+ ]);
4
34
  export const sdcppConfigSchema = z
5
35
  .object({
36
+ mode: z.enum(["diffusion", "upscale", "video"]).default("diffusion")
37
+ .describe("Operation mode for the diffusion plugin. " +
38
+ "`'diffusion'` (default) builds a full SD / SDXL / SD3 / FLUX pipeline from " +
39
+ "the primary model plus optional auxiliary text encoders, VAE, and ESRGAN " +
40
+ "upscaler, and exposes diffusion({ ... }). " +
41
+ "`'upscale'` builds a standalone ESRGAN upscaler from the primary model " +
42
+ "file alone (auxiliary model sources are ignored) and exposes upscale({ ... }). " +
43
+ "`'video'` builds a Wan `VideoStableDiffusion` pipeline and exposes video({ ... }). " +
44
+ "On React Native, loading the video model on-device will likely fail " +
45
+ "because the video diffusion models currently " +
46
+ "shipped by the SDK are too large to load on typical mobile devices; " +
47
+ "pass a `delegate` to `loadModel(...)` to run generation on a desktop peer instead."),
6
48
  threads: z.number().optional(),
7
49
  device: z.enum(["gpu", "cpu"]).optional(),
8
50
  prediction: z
9
- .enum(["auto", "eps", "v", "edm_v", "flow", "flux_flow", "flux2_flow"])
51
+ .enum(["auto", "eps", "v", "edm_v", "flow", "flux2_flow"])
10
52
  .optional()
11
53
  .describe("Prediction type; auto-detected from model when omitted"),
12
54
  type: z
@@ -22,7 +64,18 @@ export const sdcppConfigSchema = z
22
64
  clip_on_cpu: z.boolean().optional().describe("Force CLIP text encoder to run on CPU"),
23
65
  vae_on_cpu: z.boolean().optional().describe("Force VAE decoder to run on CPU"),
24
66
  vae_tiling: z.boolean().optional().describe("Enable VAE tiling for large images on limited VRAM"),
67
+ offload_to_cpu: z.boolean().optional()
68
+ .describe("Keep model weights in CPU memory and offload them during GPU compute"),
25
69
  flash_attn: z.boolean().optional().describe("Enable flash attention to reduce memory usage"),
70
+ diffusion_fa: z.boolean().optional().describe("Enable flash attention for the diffusion transformer only"),
71
+ lora_apply_mode: z.enum(["auto", "immediately", "at_runtime"]).optional()
72
+ .describe("How LoRA adapters passed via diffusion({ lora }) are applied. " +
73
+ "'auto' (default): picked based on weight type — 'at_runtime' for " +
74
+ "quantized weights, 'immediately' for full-precision. " +
75
+ "'immediately': adapter is fused into the model on first use and " +
76
+ "persists across subsequent diffusion() calls until the model is " +
77
+ "unloaded. " +
78
+ "'at_runtime': adapter is applied per-call and not persisted."),
26
79
  verbosity: z.number().optional(),
27
80
  clipLModelSrc: modelSrcInputSchema.optional()
28
81
  .describe("CLIP-L text encoder model — required for SD3"),
@@ -34,6 +87,42 @@ export const sdcppConfigSchema = z
34
87
  .describe("LLM text encoder model (e.g. Qwen3) — required for FLUX.2 [klein]"),
35
88
  vaeModelSrc: modelSrcInputSchema.optional()
36
89
  .describe("VAE decoder model — required for FLUX.2 [klein], optional for SDXL"),
90
+ highNoiseDiffusionModelSrc: modelSrcInputSchema.optional()
91
+ .describe("High-noise diffusion expert — required for Wan 2.2 mixture-of-experts video models"),
92
+ upscaler: z.object({
93
+ type: z.literal("esrgan").optional()
94
+ .describe("Type of upscaler to use for post-generation upscaling when requested in diffusion({ upscale })."),
95
+ model_src: modelSrcInputSchema.optional()
96
+ .describe("ESRGAN upscaler model (e.g. RealESRGAN_x4plus_anime_6B.pth). " +
97
+ "Required in diffusion mode when this `upscaler` block is set — " +
98
+ "configures the post-generation upscaler invoked via diffusion({ upscale }). " +
99
+ "In `mode: 'upscale'` the primary modelSrc itself is the ESRGAN model, " +
100
+ "so this field is ignored."),
101
+ tile_size: z.number().int().positive().optional()
102
+ .describe("ESRGAN upscaler tile size in pixels. Smaller tiles use less VRAM " +
103
+ "at the cost of more passes."),
104
+ direct: z.boolean().optional()
105
+ .describe("Use direct convolution in the ESRGAN upscaler instead of im2col + " +
106
+ "GEMM. Faster on some backends, slower on others."),
107
+ offload_params_to_cpu: z.boolean().optional()
108
+ .describe("Keep ESRGAN upscaler weights on CPU and offload them during compute. " +
109
+ "Trades latency for VRAM headroom on memory-constrained GPUs."),
110
+ threads: z.union([
111
+ z.literal(-1),
112
+ z.number().int().positive(),
113
+ ])
114
+ .optional()
115
+ .describe("Number of CPU threads dedicated to the ESRGAN upscaler. -1 = auto."),
116
+ }).strict().optional()
117
+ .describe("ESRGAN upscaler configuration. In diffusion mode this enables the " +
118
+ "post-generation upscale path invoked via diffusion({ upscale }) and " +
119
+ "requires `model_src`. In `mode: 'upscale'` only the tuning fields " +
120
+ "(tile_size, direct, offload_params_to_cpu, threads) are honored — " +
121
+ "the primary modelSrc IS the ESRGAN model in that mode and " +
122
+ "`model_src` here is ignored. In `mode: 'video'` the entire `upscaler` " +
123
+ "object is ignored. Mode-dependent constraints (e.g. `model_src` " +
124
+ "required in diffusion mode) are enforced by the sdcpp-generation " +
125
+ "plugin at load time, not at the schema layer."),
37
126
  });
38
127
  export const diffusionStatsSchema = z.object({
39
128
  modelLoadMs: z
@@ -81,6 +170,36 @@ export const diffusionStatsSchema = z.object({
81
170
  .optional()
82
171
  .describe("Seed that produced these outputs (randomized when not supplied by the caller)."),
83
172
  });
173
+ export const videoStatsSchema = diffusionStatsSchema.pick({
174
+ modelLoadMs: true,
175
+ generationMs: true,
176
+ totalGenerationMs: true,
177
+ totalWallMs: true,
178
+ totalSteps: true,
179
+ totalGenerations: true,
180
+ totalImages: true,
181
+ totalPixels: true,
182
+ width: true,
183
+ height: true,
184
+ seed: true,
185
+ }).extend({
186
+ totalVideos: z
187
+ .number()
188
+ .optional()
189
+ .describe("Total number of videos produced."),
190
+ totalVideoFrames: z
191
+ .number()
192
+ .optional()
193
+ .describe("Total number of video frames produced."),
194
+ videoFrames: z
195
+ .number()
196
+ .optional()
197
+ .describe("Frame count of the most recent generated video."),
198
+ fps: z
199
+ .number()
200
+ .optional()
201
+ .describe("Frames-per-second metadata for the most recent generated video."),
202
+ });
84
203
  export const diffusionStreamResponseSchema = z.object({
85
204
  type: z.literal("diffusionStream"),
86
205
  step: z.number().optional(),
@@ -91,6 +210,16 @@ export const diffusionStreamResponseSchema = z.object({
91
210
  done: z.boolean().optional(),
92
211
  stats: diffusionStatsSchema.optional(),
93
212
  });
213
+ export const videoStreamResponseSchema = z.object({
214
+ type: z.literal("videoStream"),
215
+ step: z.number().optional(),
216
+ totalSteps: z.number().optional(),
217
+ elapsedMs: z.number().optional(),
218
+ data: z.string().optional(),
219
+ outputIndex: z.number().optional(),
220
+ done: z.boolean().optional(),
221
+ stats: videoStatsSchema.optional(),
222
+ });
94
223
  export const diffusionRequestSchema = z.object({
95
224
  modelId: z
96
225
  .string()
@@ -132,30 +261,10 @@ export const diffusionRequestSchema = z.object({
132
261
  .number()
133
262
  .optional()
134
263
  .describe("Distilled guidance for FLUX models; typical range 1–10, default 3.5"),
135
- sampling_method: z
136
- .enum([
137
- "euler",
138
- "euler_a",
139
- "heun",
140
- "dpm2",
141
- "dpm++2m",
142
- "dpm++2mv2",
143
- "dpm++2s_a",
144
- "lcm",
145
- "ipndm",
146
- "ipndm_v",
147
- "ddim_trailing",
148
- "tcd",
149
- "res_multistep",
150
- "res_2s",
151
- ])
264
+ sampling_method: samplingMethodSchema
152
265
  .optional()
153
266
  .describe("Sampling algorithm used by the diffusion scheduler."),
154
- scheduler: z
155
- .enum([
156
- "discrete", "karras", "exponential", "ays", "gits",
157
- "sgm_uniform", "simple", "lcm", "smoothstep", "kl_optimal", "bong_tangent",
158
- ])
267
+ scheduler: scheduleTypeSchema
159
268
  .optional()
160
269
  .describe("Noise schedule to apply when sampling."),
161
270
  seed: z
@@ -177,19 +286,271 @@ export const diffusionRequestSchema = z.object({
177
286
  .string()
178
287
  .optional()
179
288
  .describe("Optional name of a cached sampler preset to reuse."),
180
- init_image: z
289
+ init_image: base64StringSchema
290
+ .optional()
291
+ .describe("Base64-encoded image for img2img generation. Mutually exclusive with init_images."),
292
+ init_images: z.array(base64StringSchema)
293
+ .min(1)
294
+ .optional()
295
+ .describe("FLUX.2-only multi-reference fusion: array of base64-encoded PNG/JPEG buffers. " +
296
+ "Each buffer becomes a separate reference image that the FLUX.2 transformer attends to. " +
297
+ "Mutually exclusive with init_image; requires the model to be loaded with " +
298
+ "config.prediction='flux2_flow' and a Qwen3 text encoder via llmModelSrc."),
299
+ increase_ref_index: z.boolean().optional()
300
+ .describe("FLUX.2 fusion only. When omitted, the addon default (false) is used. When false, all " +
301
+ "reference latents share one RoPE index slot and blend via attention (recommended for " +
302
+ "FLUX.2-klein). When true, each reference gets its own RoPE index slot — use only with " +
303
+ "text encoders that receive per-image vision tokens."),
304
+ auto_resize_ref_image: z.boolean().optional()
305
+ .describe("FLUX.2 only. When omitted, the addon default (true) is used. When true, every reference " +
306
+ "image (single or fusion) is auto-resized to the target width/height before VAE-encoding. " +
307
+ "Disable only if the buffers are already at the exact target dimensions."),
308
+ lora: z
181
309
  .string()
182
310
  .min(1)
183
- .regex(BASE64_PATTERN)
311
+ .regex(ABSOLUTE_PATH_PATTERN, {
312
+ message: "lora must be an absolute path",
313
+ })
184
314
  .optional()
185
- .describe("Base64-encoded image for img2img generation"),
315
+ .describe("Optional local LoRA adapter path to apply for this generation. " +
316
+ "Must be an absolute filesystem path. " +
317
+ "Whether the adapter persists across subsequent diffusion() calls is controlled " +
318
+ "by sdcppConfigSchema.lora_apply_mode (set at loadModel time)."),
186
319
  strength: z
187
320
  .number()
188
321
  .min(0)
189
322
  .max(1)
190
323
  .optional()
191
324
  .describe("img2img denoising strength (0.0 = keep source, 1.0 = ignore source); used by the SD/SDXL SDEdit path. No-op for FLUX.2, which uses in-context conditioning and ignores this field."),
325
+ upscale: z
326
+ .union([
327
+ z.boolean(),
328
+ z.object({
329
+ repeats: z.number().int().positive().optional(),
330
+ }).strict(),
331
+ ])
332
+ .optional()
333
+ .describe("Post-generation ESRGAN upscale. " +
334
+ "`true` (or `{}` / `{ repeats: 1 }`) runs a single upscale pass at the " +
335
+ "model's native scale factor (e.g. x4 for RealESRGAN_x4plus). " +
336
+ "`false` is a no-op (same as omitting the field). " +
337
+ "`{ repeats: N }` runs the upscaler N times sequentially — each pass " +
338
+ "multiplies the output dimensions by the model's scale factor. When " +
339
+ "`batch_count > 1`, every output image is upscaled independently. " +
340
+ "Requires the model to be loaded with `upscaler.model_src` set in modelConfig."),
341
+ }).refine((d) => d.init_image === undefined || d.init_images === undefined, {
342
+ message: "init_image and init_images are mutually exclusive — pass one or the other, not both.",
192
343
  });
193
344
  export const diffusionStreamRequestSchema = diffusionRequestSchema.extend({
194
345
  type: z.literal("diffusionStream"),
195
346
  });
347
+ export const videoRequestSchema = z.object({
348
+ modelId: z
349
+ .string()
350
+ .describe("The identifier of the loaded video model to use for generation. " +
351
+ "On React Native, prefer a `modelId` loaded with a `delegate` because " +
352
+ "the video diffusion models currently shipped by the SDK are too " +
353
+ "large to load on typical mobile devices."),
354
+ requestId: z
355
+ .string()
356
+ .min(1)
357
+ .optional()
358
+ .describe("Stable identifier for this in-flight video generation. Optional on the wire — the server falls back to a server-generated id when the field is missing."),
359
+ mode: z
360
+ .enum(["txt2vid"])
361
+ .describe("Video generation mode. Only `txt2vid` is supported today."),
362
+ prompt: z.string().describe("Positive prompt describing the video to generate."),
363
+ negative_prompt: z
364
+ .string()
365
+ .optional()
366
+ .describe("Optional negative prompt describing what to avoid."),
367
+ width: z
368
+ .number()
369
+ .int()
370
+ .positive()
371
+ .multipleOf(8)
372
+ .optional()
373
+ .describe("Video width in pixels (must be a multiple of 8)."),
374
+ height: z
375
+ .number()
376
+ .int()
377
+ .positive()
378
+ .multipleOf(8)
379
+ .optional()
380
+ .describe("Video height in pixels (must be a multiple of 8)."),
381
+ video_frames: z
382
+ .number()
383
+ .int()
384
+ .refine((value) => value >= 5 && (value - 1) % 4 === 0, {
385
+ message: "video_frames must be an integer >= 5 of the form (4*k + 1)",
386
+ })
387
+ .optional()
388
+ .describe("Frame count for the generated video; must satisfy (4*k + 1), where k>=1."),
389
+ fps: z
390
+ .number()
391
+ .positive()
392
+ .max(120)
393
+ .optional()
394
+ .describe("AVI framerate metadata in frames per second; must be in (0, 120]."),
395
+ seed: z
396
+ .number()
397
+ .int()
398
+ .optional()
399
+ .describe("Random seed; when omitted the SDK picks one and returns it in stats."),
400
+ steps: z
401
+ .number()
402
+ .int()
403
+ .positive()
404
+ .optional()
405
+ .describe("Low-noise or single-expert denoising step count."),
406
+ sampling_method: samplingMethodSchema
407
+ .optional()
408
+ .describe("Sampling algorithm used by the low-noise diffusion scheduler."),
409
+ scheduler: scheduleTypeSchema
410
+ .optional()
411
+ .describe("Noise schedule to apply for the low-noise diffusion path."),
412
+ cfg_scale: z
413
+ .number()
414
+ .optional()
415
+ .describe("Classifier-free guidance scale."),
416
+ flow_shift: z
417
+ .number()
418
+ .optional()
419
+ .describe("Per-request flow-matching guidance shift override."),
420
+ high_noise_steps: z
421
+ .number()
422
+ .int()
423
+ .positive()
424
+ .optional()
425
+ .describe("Wan 2.2 high-noise expert step count."),
426
+ high_noise_sampler: samplingMethodSchema
427
+ .optional()
428
+ .describe("Wan 2.2 high-noise expert sampler."),
429
+ high_noise_scheduler: scheduleTypeSchema
430
+ .optional()
431
+ .describe("Wan 2.2 high-noise expert scheduler."),
432
+ high_noise_cfg_scale: z
433
+ .number()
434
+ .optional()
435
+ .describe("Wan 2.2 high-noise expert CFG scale."),
436
+ high_noise_flow_shift: z
437
+ .number()
438
+ .optional()
439
+ .describe("Wan 2.2 high-noise expert flow shift override."),
440
+ moe_boundary: z
441
+ .number()
442
+ .min(0)
443
+ .max(1)
444
+ .optional()
445
+ .describe("Wan 2.2 mixture-of-experts boundary in [0, 1]."),
446
+ vace_strength: z
447
+ .number()
448
+ .min(0)
449
+ .max(1)
450
+ .optional()
451
+ .describe("Control-frame guidance strength."),
452
+ control_frames: z.array(base64StringSchema)
453
+ .min(1)
454
+ .optional()
455
+ .describe("Optional array of base64-encoded control-frame images."),
456
+ vae_tiling: z
457
+ .boolean()
458
+ .optional()
459
+ .describe("Enable VAE tiling for large videos on constrained VRAM."),
460
+ vae_tile_size: z
461
+ .union([z.number().positive(), z.string().min(1)])
462
+ .optional()
463
+ .describe("VAE tile size override."),
464
+ vae_tile_overlap: z
465
+ .number()
466
+ .optional()
467
+ .describe("VAE tile overlap override."),
468
+ cache_mode: cacheModeSchema
469
+ .optional()
470
+ .describe("Step-caching algorithm."),
471
+ cache_preset: z
472
+ .string()
473
+ .optional()
474
+ .describe("Optional name of a cached sampler preset to reuse."),
475
+ cache_threshold: z
476
+ .number()
477
+ .optional()
478
+ .describe("Direct cache reuse threshold override."),
479
+ });
480
+ export const videoStreamRequestSchema = videoRequestSchema.extend({
481
+ type: z.literal("videoStream"),
482
+ });
483
+ // ============================================
484
+ // Standalone ESRGAN upscale (mode: "upscale")
485
+ // ============================================
486
+ export const upscaleStatsSchema = z.object({
487
+ modelLoadMs: z
488
+ .number()
489
+ .optional()
490
+ .describe("Wall-clock time in milliseconds spent loading the upscaler model."),
491
+ upscaleMs: z
492
+ .number()
493
+ .optional()
494
+ .describe("Wall-clock time in milliseconds for the most recent upscale job."),
495
+ totalUpscaleMs: z
496
+ .number()
497
+ .optional()
498
+ .describe("Cumulative upscale time in milliseconds across all jobs."),
499
+ totalWallMs: z
500
+ .number()
501
+ .optional()
502
+ .describe("Total wall-clock time in milliseconds including model load and upscaling."),
503
+ totalUpscales: z
504
+ .number()
505
+ .optional()
506
+ .describe("Cumulative number of upscale calls."),
507
+ totalImages: z
508
+ .number()
509
+ .optional()
510
+ .describe("Cumulative number of images produced."),
511
+ totalPixels: z
512
+ .number()
513
+ .optional()
514
+ .describe("Cumulative number of pixels produced across all images."),
515
+ width: z.number().optional().describe("Width of the most recent emitted PNG."),
516
+ height: z.number().optional().describe("Height of the most recent emitted PNG."),
517
+ repeats: z
518
+ .number()
519
+ .optional()
520
+ .describe("Number of ESRGAN passes used by the most recent upscale job."),
521
+ backendDevice: z
522
+ .enum(["cpu", "gpu"])
523
+ .optional()
524
+ .describe("Actual compute device used by the ESRGAN upscaler. " +
525
+ "Reflects the backend stable-diffusion.cpp selected (e.g. Android `gpu` " +
526
+ "falls back to `cpu` because the mobile GPU/OpenCL path is unstable)."),
527
+ });
528
+ export const upscaleRequestSchema = z.object({
529
+ modelId: z
530
+ .string()
531
+ .describe("Identifier of the loaded upscaler model. The model must have been loaded " +
532
+ "with `modelType: 'diffusion'` and `modelConfig.mode: 'upscale'`."),
533
+ image: z
534
+ .string()
535
+ .min(1)
536
+ .regex(BASE64_PATTERN)
537
+ .describe("Base64-encoded PNG/JPEG bytes of the source image."),
538
+ repeats: z
539
+ .number()
540
+ .int()
541
+ .positive()
542
+ .optional()
543
+ .describe("Number of ESRGAN passes to run sequentially. Each pass multiplies " +
544
+ "dimensions by the model's native scale factor; only the final image " +
545
+ "is emitted (`outputs.length === 1`). Defaults to 1."),
546
+ });
547
+ export const upscaleStreamRequestSchema = upscaleRequestSchema.extend({
548
+ type: z.literal("upscaleStream"),
549
+ });
550
+ export const upscaleStreamResponseSchema = z.object({
551
+ type: z.literal("upscaleStream"),
552
+ data: z.string().optional(),
553
+ outputIndex: z.number().optional(),
554
+ done: z.boolean().optional(),
555
+ stats: upscaleStatsSchema.optional(),
556
+ });