@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,10 +1,23 @@
1
1
  import { send } from "../rpc/rpc-client.js";
2
2
  import {} from "../../schemas/index.js";
3
3
  import { InvalidResponseError } from "../../utils/errors-client.js";
4
- export async function embed(params, options) {
4
+ import { decoratePromise } from "../../utils/decorate-promise.js";
5
+ import { generateClientRequestId } from "./client-request-id.js";
6
+ export function embed(params, options) {
7
+ // Client-generated `requestId` is surfaced synchronously on the
8
+ // returned promise so the caller can `cancel({ requestId })` before
9
+ // `await` resolves. The same id is threaded onto the wire envelope so
10
+ // the server's registry entry uses it as the canonical key —
11
+ // matching the `loadModel` / `downloadAsset` / `completion` shape.
12
+ const requestId = generateClientRequestId();
13
+ const inner = runEmbed(params, requestId, options);
14
+ return decoratePromise(inner, { requestId });
15
+ }
16
+ async function runEmbed(params, requestId, options) {
5
17
  const request = {
6
18
  type: "embed",
7
19
  ...params,
20
+ requestId,
8
21
  };
9
22
  const response = await send(request, options);
10
23
  if (response.type !== "embed") {
@@ -12,7 +12,7 @@ export declare function getModelInfo(params: GetModelInfoParams): Promise<{
12
12
  modelId: string;
13
13
  expectedSize: number;
14
14
  sha256Checksum: string;
15
- addon: "embeddings" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | "other";
15
+ addon: "embeddings" | "diffusion" | "tts" | "ocr" | "vla" | "llm" | "whisper" | "nmt" | "parakeet" | "classification" | "vad" | "other";
16
16
  isCached: boolean;
17
17
  isLoaded: boolean;
18
18
  cacheFiles: {
@@ -19,8 +19,13 @@ export { getLoadedModelInfo } from "./get-loaded-model-info";
19
19
  export { ocr } from "./ocr";
20
20
  export { invokePlugin, invokePluginStream } from "./invoke-plugin";
21
21
  export { diffusion, type DiffusionProgressTick } from "./diffusion";
22
+ export { classify } from "./classify";
23
+ export { video, type VideoProgressTick } from "./video";
24
+ export { upscale } from "./upscale";
22
25
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./registry";
23
26
  export { suspend } from "./suspend";
24
27
  export { resume } from "./resume";
25
28
  export { state } from "./state";
29
+ export { vla, vlaHparams } from "./vla";
30
+ export { vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, } from "./vla-helpers";
26
31
  //# sourceMappingURL=index.d.ts.map
@@ -19,7 +19,12 @@ export { getLoadedModelInfo } from "./get-loaded-model-info.js";
19
19
  export { ocr } from "./ocr.js";
20
20
  export { invokePlugin, invokePluginStream } from "./invoke-plugin.js";
21
21
  export { diffusion } from "./diffusion.js";
22
+ export { classify } from "./classify.js";
23
+ export { video } from "./video.js";
24
+ export { upscale } from "./upscale.js";
22
25
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./registry.js";
23
26
  export { suspend } from "./suspend.js";
24
27
  export { resume } from "./resume.js";
25
28
  export { state } from "./state.js";
29
+ export { vla, vlaHparams } from "./vla.js";
30
+ export { vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, } from "./vla-helpers.js";
@@ -17,7 +17,9 @@ import { type LoadModelOptions, type LoadCustomPluginModelOptions, type LoadMode
17
17
  * await loadModel({ modelSrc: WHISPER_TINY });
18
18
  * ```
19
19
  */
20
- export declare function loadModel<S extends ModelDescriptor>(options: LoadModelDescriptorParam<S>, rpcOptions?: RPCOptions): Promise<string>;
20
+ export declare function loadModel<S extends ModelDescriptor>(options: LoadModelDescriptorParam<S>, rpcOptions?: RPCOptions): Promise<string> & {
21
+ requestId: string;
22
+ };
21
23
  /**
22
24
  * Loads a machine learning model from a local path, remote URL, or Hyperdrive key.
23
25
  *
@@ -110,7 +112,9 @@ export declare function loadModel<S extends ModelDescriptor>(options: LoadModelD
110
112
  * });
111
113
  * ```
112
114
  */
113
- export declare function loadModel(options: LoadModelOptions, rpcOptions?: RPCOptions): Promise<string>;
115
+ export declare function loadModel(options: LoadModelOptions, rpcOptions?: RPCOptions): Promise<string> & {
116
+ requestId: string;
117
+ };
114
118
  /**
115
119
  * Loads a custom plugin model (any non-built-in `modelType` string).
116
120
  * `modelConfig` is plugin-defined; the SDK does not narrow it.
@@ -122,7 +126,9 @@ export declare function loadModel(options: LoadModelOptions, rpcOptions?: RPCOpt
122
126
  * @param rpcOptions - Optional RPC options including per-call profiling.
123
127
  * @returns Promise that resolves to the loaded model ID.
124
128
  */
125
- export declare function loadModel<T extends string>(options: LoadCustomPluginModelOptions<T>, rpcOptions?: RPCOptions): Promise<string>;
129
+ export declare function loadModel<T extends string>(options: LoadCustomPluginModelOptions<T>, rpcOptions?: RPCOptions): Promise<string> & {
130
+ requestId: string;
131
+ };
126
132
  /**
127
133
  * Hot-reloads configuration on an already loaded model.
128
134
  *
@@ -155,5 +161,7 @@ export declare function loadModel<T extends string>(options: LoadCustomPluginMod
155
161
  * });
156
162
  * ```
157
163
  */
158
- export declare function loadModel(options: ReloadConfigOptions, rpcOptions?: RPCOptions): Promise<string>;
164
+ export declare function loadModel(options: ReloadConfigOptions, rpcOptions?: RPCOptions): Promise<string> & {
165
+ requestId: string;
166
+ };
159
167
  //# sourceMappingURL=load-model.d.ts.map
@@ -1,11 +1,34 @@
1
1
  import { send, stream } from "../rpc/rpc-client.js";
2
2
  import { startLoggingStreamForModel } from "../logging-stream-registry.js";
3
- import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, isModelTypeAlias, normalizeModelType, inferModelTypeFromModelSrc, } from "../../schemas/index.js";
3
+ import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, isModelTypeAlias, normalizeModelType, inferModelTypeFromModelSrc, ModelType, } from "../../schemas/index.js";
4
4
  import { ModelLoadFailedError, ModelTypeRequiredError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
5
5
  import { assertModelSrcMatchesModelType } from "../../utils/load-model-validation.js";
6
6
  import { getClientLogger } from "../../logging/index.js";
7
+ import { decoratePromise } from "../../utils/decorate-promise.js";
8
+ import { generateClientRequestId } from "./client-request-id.js";
7
9
  const logger = getClientLogger();
8
- export async function loadModel(options, rpcOptions) {
10
+ function isReactNativeRuntime() {
11
+ const runtime = globalThis;
12
+ return runtime.navigator?.product === "ReactNative";
13
+ }
14
+ let warnedLocalVideoModelLoad = false;
15
+ export function loadModel(options, rpcOptions) {
16
+ // Generate a stable `requestId` once, synchronously, before kicking
17
+ // off any async work. The same id is:
18
+ // - threaded onto the request envelope (`request.requestId`) so the
19
+ // server's `registry.begin(...)` records it on the registry
20
+ // entry; and
21
+ // - attached to the returned promise via `decoratePromise` so the
22
+ // caller can target this exact call with `cancel({ requestId })`
23
+ // before `await` resolves. Generating client-side and surfacing
24
+ // it synchronously is what closes the "stop-button race" gap for
25
+ // `loadModel` / `downloadAsset` callers — same shape as the
26
+ // `CompletionRun.requestId` contract.
27
+ const requestId = generateClientRequestId();
28
+ const inner = runLoadModel(options, requestId, rpcOptions);
29
+ return decoratePromise(inner, { requestId });
30
+ }
31
+ async function runLoadModel(options, requestId, rpcOptions) {
9
32
  const isReloadConfig = "modelId" in options && !("modelSrc" in options);
10
33
  // Infer `modelType` from `modelSrc` when omitted; the schema still validates
11
34
  // the resolved options below.
@@ -27,7 +50,31 @@ export async function loadModel(options, rpcOptions) {
27
50
  const canonical = normalizeModelType(modelType);
28
51
  logger.warn(`Model type "${modelType}" is an alias and will be deprecated. Use "${canonical}" instead.`);
29
52
  }
53
+ const canonicalModelType = typeof modelType === "string" ? normalizeModelType(modelType) : modelType;
54
+ const modelConfig = resolvedOptions["modelConfig"];
55
+ if (isReactNativeRuntime() &&
56
+ canonicalModelType === ModelType.sdcppGeneration &&
57
+ modelConfig?.mode === "video" &&
58
+ resolvedOptions["delegate"] === undefined &&
59
+ !warnedLocalVideoModelLoad) {
60
+ warnedLocalVideoModelLoad = true;
61
+ const message = "QVAC video generation works on React Native, but loading the video " +
62
+ "model on-device will usually fail or take several minutes — the video " +
63
+ "diffusion models currently shipped by the SDK are too large to load " +
64
+ "on typical mobile devices. Pass a `delegate` to `loadModel(...)` to " +
65
+ "run generation on a desktop peer instead.";
66
+ logger.warn(message);
67
+ // Surface via console too - if an RN host app doesn't wire getClientLogger()
68
+ // to a visible transport, logger.warn alone won't reach the dev.
69
+ console.warn(message);
70
+ }
30
71
  }
72
+ // Splice the client-generated `requestId` onto the resolved options so
73
+ // the wire envelope carries it. The server uses the same value as the
74
+ // registry-entry key — that match is what makes
75
+ // `cancel({ requestId: op.requestId })` a no-op when no match exists
76
+ // and a precise abort when it does.
77
+ resolvedOptions = { ...resolvedOptions, requestId };
31
78
  const request = isReloadConfig
32
79
  ? reloadConfigOptionsToRequestSchema.parse(resolvedOptions)
33
80
  : loadModelOptionsToRequestSchema.parse(resolvedOptions);
@@ -65,7 +65,9 @@ export declare function ragChunk(params: RagChunkParams, options?: RPCOptions):
65
65
  export declare function ragIngest(params: RagIngestParams, options?: RPCOptions): Promise<{
66
66
  processed: RagSaveEmbeddingsResult[];
67
67
  droppedIndices: number[];
68
- }>;
68
+ }> & {
69
+ requestId: string;
70
+ };
69
71
  /**
70
72
  * Saves pre-embedded documents to the RAG vector database.
71
73
  * Part of the segregated flow: chunk() → embed() → saveEmbeddings()
@@ -99,7 +101,9 @@ export declare function ragIngest(params: RagIngestParams, options?: RPCOptions)
99
101
  * });
100
102
  * ```
101
103
  */
102
- export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, options?: RPCOptions): Promise<RagSaveEmbeddingsResult[]>;
104
+ export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, options?: RPCOptions): Promise<RagSaveEmbeddingsResult[]> & {
105
+ requestId: string;
106
+ };
103
107
  /**
104
108
  * Searches for similar documents in the RAG vector database.
105
109
  *
@@ -186,7 +190,9 @@ export declare function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams, o
186
190
  * });
187
191
  * ```
188
192
  */
189
- export declare function ragReindex(params: RagReindexParams, options?: RPCOptions): Promise<RagReindexResult>;
193
+ export declare function ragReindex(params: RagReindexParams, options?: RPCOptions): Promise<RagReindexResult> & {
194
+ requestId: string;
195
+ };
190
196
  /**
191
197
  * Lists all RAG workspaces with their open status.
192
198
  *
@@ -1,5 +1,7 @@
1
1
  import { send, stream } from "../rpc/rpc-client.js";
2
2
  import { InvalidResponseError, InvalidOperationError, StreamEndedError, RAGChunkFailedError, RAGSaveFailedError, RAGSearchFailedError, RAGDeleteFailedError, RAGCloseWorkspaceFailedError, RAGListWorkspacesFailedError, } from "../../utils/errors-client.js";
3
+ import { generateClientRequestId } from "./client-request-id.js";
4
+ import { decoratePromise } from "../../utils/decorate-promise.js";
3
5
  // ============== Chunk ==============
4
6
  /**
5
7
  * Chunks documents into smaller pieces for embedding.
@@ -82,7 +84,12 @@ export async function ragChunk(params, options) {
82
84
  * });
83
85
  * ```
84
86
  */
85
- export async function ragIngest(params, options) {
87
+ export function ragIngest(params, options) {
88
+ const requestId = generateClientRequestId();
89
+ const inner = runRagIngest(params, requestId, options);
90
+ return decoratePromise(inner, { requestId });
91
+ }
92
+ async function runRagIngest(params, requestId, options) {
86
93
  const { onProgress, ...requestParams } = params;
87
94
  const request = {
88
95
  type: "rag",
@@ -90,6 +97,7 @@ export async function ragIngest(params, options) {
90
97
  ...requestParams,
91
98
  chunk: requestParams.chunk ?? true,
92
99
  withProgress: onProgress ? true : undefined,
100
+ requestId,
93
101
  };
94
102
  if (onProgress) {
95
103
  // Use streaming for progress updates
@@ -160,13 +168,19 @@ export async function ragIngest(params, options) {
160
168
  * });
161
169
  * ```
162
170
  */
163
- export async function ragSaveEmbeddings(params, options) {
171
+ export function ragSaveEmbeddings(params, options) {
172
+ const requestId = generateClientRequestId();
173
+ const inner = runRagSaveEmbeddings(params, requestId, options);
174
+ return decoratePromise(inner, { requestId });
175
+ }
176
+ async function runRagSaveEmbeddings(params, requestId, options) {
164
177
  const { onProgress, ...requestParams } = params;
165
178
  const request = {
166
179
  type: "rag",
167
180
  operation: "saveEmbeddings",
168
181
  ...requestParams,
169
182
  withProgress: onProgress ? true : undefined,
183
+ requestId,
170
184
  };
171
185
  if (onProgress) {
172
186
  for await (const event of stream(request, options)) {
@@ -321,13 +335,19 @@ export async function ragDeleteEmbeddings(params, options) {
321
335
  * });
322
336
  * ```
323
337
  */
324
- export async function ragReindex(params, options) {
338
+ export function ragReindex(params, options) {
339
+ const requestId = generateClientRequestId();
340
+ const inner = runRagReindex(params, requestId, options);
341
+ return decoratePromise(inner, { requestId });
342
+ }
343
+ async function runRagReindex(params, requestId, options) {
325
344
  const { onProgress, ...requestParams } = params;
326
345
  const request = {
327
346
  type: "rag",
328
347
  operation: "reindex",
329
348
  ...requestParams,
330
349
  withProgress: onProgress ? true : undefined,
350
+ requestId,
331
351
  };
332
352
  if (onProgress) {
333
353
  for await (const event of stream(request, options)) {
@@ -1,4 +1,4 @@
1
- import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession } from "../../schemas/index";
1
+ import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession } from "../../schemas/index";
2
2
  /**
3
3
  * Transcribe audio and return the complete text. Accepts either a file
4
4
  * path or an audio buffer.
@@ -11,13 +11,21 @@ import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, t
11
11
  * segments (`{ text, startMs, endMs, append, id }`)
12
12
  * instead of joined text. Whisper engine only.
13
13
  * @param options - Optional RPC options including per-call profiling
14
- * @returns The complete transcribed text, or — when `metadata` is true —
15
- * the list of transcript segments in emission order.
14
+ * @returns A promise (decorated with `requestId`) resolving to the
15
+ * complete transcribed text, or — when `metadata` is true —
16
+ * the list of transcript segments in emission order. The
17
+ * `requestId` is reachable synchronously so callers can target
18
+ * this in-flight transcription with `cancel({ requestId })`
19
+ * before `await` resolves.
16
20
  */
17
21
  export declare function transcribe(params: TranscribeClientParams & {
18
22
  metadata: true;
19
- }, options?: RPCOptions): Promise<TranscribeSegment[]>;
20
- export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;
23
+ }, options?: RPCOptions): Promise<TranscribeSegment[]> & {
24
+ requestId: string;
25
+ };
26
+ export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string> & {
27
+ requestId: string;
28
+ };
21
29
  /**
22
30
  * @deprecated Pass audio via `transcribe()` instead. This overload will be
23
31
  * removed in the next major version.
@@ -50,10 +58,17 @@ export declare function transcribeStream(params: TranscribeClientParams, options
50
58
  * objects (`{ text, startMs, endMs, append, id }`)
51
59
  * instead of plain text. Whisper engine only.
52
60
  * @param options - Optional RPC options including per-call profiling.
53
- * @returns A session object: call `write(buffer)` to feed audio,
54
- * iterate with `for await (...)` to receive transcription,
55
- * and `end()` to signal end of audio.
61
+ * @returns A session object: call `write(audioChunk)` with a `Uint8Array`
62
+ * (Node `Buffer` is a `Uint8Array` subtype) to feed audio,
63
+ * iterate with `for await (...)` to receive transcription, and
64
+ * `end()` to signal end of audio.
56
65
  */
66
+ export declare function transcribeStream(params: TranscribeStreamClientParams & {
67
+ emitVadEvents: true;
68
+ }, options?: RPCOptions): Promise<TranscribeStreamConversationSession>;
69
+ export declare function transcribeStream(params: TranscribeStreamClientParams & {
70
+ parakeetStreamingConfig: NonNullable<TranscribeStreamClientParams["parakeetStreamingConfig"]>;
71
+ }, options?: RPCOptions): Promise<TranscribeStreamConversationSession>;
57
72
  export declare function transcribeStream(params: TranscribeStreamClientParams & {
58
73
  metadata: true;
59
74
  }, options?: RPCOptions): Promise<TranscribeStreamMetadataSession>;
@@ -2,8 +2,10 @@ import { transcribeResponseSchema, transcribeStreamResponseSchema, } from "../..
2
2
  import { stream, duplex } from "../rpc/rpc-client.js";
3
3
  import { getClientLogger } from "../../logging/index.js";
4
4
  import { TranscriptionFailedError } from "../../utils/errors-client.js";
5
+ import { decoratePromise } from "../../utils/decorate-promise.js";
6
+ import { generateClientRequestId } from "./client-request-id.js";
5
7
  const logger = getClientLogger();
6
- function buildTranscribeRequest(params) {
8
+ function buildTranscribeRequest(params, requestId) {
7
9
  return {
8
10
  type: "transcribe",
9
11
  modelId: params.modelId,
@@ -12,10 +14,21 @@ function buildTranscribeRequest(params) {
12
14
  : { type: "base64", value: params.audioChunk.toString("base64") },
13
15
  ...(params.prompt && { prompt: params.prompt }),
14
16
  ...(params.metadata === true && { metadata: true }),
17
+ requestId,
15
18
  };
16
19
  }
17
- export async function transcribe(params, options) {
18
- const request = buildTranscribeRequest(params);
20
+ export function transcribe(params, options) {
21
+ // Client-generated id surfaced synchronously on the returned promise
22
+ // — same shape as `loadModel` / `downloadAsset` / `completion`. The
23
+ // CLI cancel bridge in `qvac serve` binds `req.on('close')` to
24
+ // `cancel({ requestId })` immediately after the call returns so a
25
+ // client disconnect aborts the in-flight transcription.
26
+ const requestId = generateClientRequestId();
27
+ const inner = runTranscribe(params, requestId, options);
28
+ return decoratePromise(inner, { requestId });
29
+ }
30
+ async function runTranscribe(params, requestId, options) {
31
+ const request = buildTranscribeRequest(params, requestId);
19
32
  if (params.metadata === true) {
20
33
  const segments = [];
21
34
  for await (const response of stream(request, options)) {
@@ -54,6 +67,10 @@ export function transcribeStream(params, options) {
54
67
  return transcribeStreamWithAudio(params, options);
55
68
  }
56
69
  const streamParams = params;
70
+ if (streamParams.emitVadEvents === true ||
71
+ streamParams.parakeetStreamingConfig !== undefined) {
72
+ return transcribeStreamDuplexConversation(streamParams, options);
73
+ }
57
74
  if (streamParams.metadata === true) {
58
75
  return transcribeStreamDuplexMetadata(streamParams, options);
59
76
  }
@@ -64,7 +81,7 @@ export function transcribeStream(params, options) {
64
81
  * the value extracted from each response frame until `done` is seen.
65
82
  */
66
83
  async function* streamTranscribeValues(params, options, extract) {
67
- const request = buildTranscribeRequest(params);
84
+ const request = buildTranscribeRequest(params, generateClientRequestId());
68
85
  for await (const response of stream(request, options)) {
69
86
  if (response.type === "transcribe") {
70
87
  const parsed = transcribeResponseSchema.parse(response);
@@ -88,6 +105,16 @@ function buildTranscribeStreamRequest(params) {
88
105
  modelId: params.modelId,
89
106
  ...(params.prompt && { prompt: params.prompt }),
90
107
  ...(params.metadata === true && { metadata: true }),
108
+ ...(params.emitVadEvents === true && { emitVadEvents: true }),
109
+ ...(params.endOfTurnSilenceMs !== undefined && {
110
+ endOfTurnSilenceMs: params.endOfTurnSilenceMs,
111
+ }),
112
+ ...(params.vadRunIntervalMs !== undefined && {
113
+ vadRunIntervalMs: params.vadRunIntervalMs,
114
+ }),
115
+ ...(params.parakeetStreamingConfig && {
116
+ parakeetStreamingConfig: params.parakeetStreamingConfig,
117
+ }),
91
118
  };
92
119
  }
93
120
  /**
@@ -126,6 +153,10 @@ function transcribeStreamDuplex(params, options) {
126
153
  function transcribeStreamDuplexMetadata(params, options) {
127
154
  return createTranscribeStreamSession(params, options, processLineMetadata, "TranscribeStreamMetadataSession");
128
155
  }
156
+ function transcribeStreamDuplexConversation(params, options) {
157
+ const wantsMetadata = params.metadata === true;
158
+ return createTranscribeStreamSession(params, options, (line) => processLineConversation(line, wantsMetadata), "TranscribeStreamConversationSession");
159
+ }
129
160
  /**
130
161
  * Line-delimited parser: reads newline-separated frames from a duplex
131
162
  * response stream, passes each non-empty line through `process`, and yields
@@ -190,3 +221,37 @@ function processLine(line) {
190
221
  function processLineMetadata(line) {
191
222
  return processWith(line, (response) => response.segment);
192
223
  }
224
+ function processLineConversation(line, wantsMetadata) {
225
+ return processWith(line, (response) => {
226
+ if (response.vad) {
227
+ return {
228
+ type: "vad",
229
+ speaking: response.vad.speaking,
230
+ probability: response.vad.probability,
231
+ };
232
+ }
233
+ if (response.endOfTurn) {
234
+ if (response.endOfTurn.source === "whisper") {
235
+ return {
236
+ type: "endOfTurn",
237
+ source: "whisper",
238
+ silenceDurationMs: response.endOfTurn.silenceDurationMs,
239
+ };
240
+ }
241
+ return {
242
+ type: "endOfTurn",
243
+ source: "parakeet",
244
+ };
245
+ }
246
+ if (wantsMetadata) {
247
+ if (response.segment) {
248
+ return { type: "segment", segment: response.segment };
249
+ }
250
+ return undefined;
251
+ }
252
+ if (response.text && response.text.trim()) {
253
+ return { type: "text", text: response.text };
254
+ }
255
+ return undefined;
256
+ });
257
+ }
@@ -3,12 +3,15 @@ import { type UnloadModelParams } from "../../schemas/index";
3
3
  * Unloads a previously loaded model from the server.
4
4
  *
5
5
  * When the last model is unloaded (no more models remain), this function
6
- * automatically closes the RPC connection, allowing the process to exit
7
- * naturally without requiring manual cleanup.
6
+ * automatically closes the RPC connection on Node/Electron, allowing the
7
+ * process to exit naturally without requiring manual cleanup. On Bare the
8
+ * connection is left open by default so long-lived workers survive a routine
9
+ * unload; pass `autoClose: true` to opt in to closing.
8
10
  *
9
11
  * @param params - The parameters for unloading the model
10
12
  * @param params.modelId - The unique identifier of the model to unload
11
13
  * @param params.clearStorage - Whether to clear the storage for the model
14
+ * @param params.autoClose - Override the runtime-default auto-close behavior
12
15
  * @throws {QvacErrorBase} When the response type is invalid or when the unload operation fails
13
16
  */
14
17
  export declare function unloadModel(params: UnloadModelParams): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { isBare } from "which-runtime";
1
2
  import {} from "../../schemas/index.js";
2
3
  import { send, close } from "../rpc/rpc-client.js";
3
4
  import { stopLoggingStreamForModel } from "../logging-stream-registry.js";
@@ -8,12 +9,15 @@ const logger = getClientLogger();
8
9
  * Unloads a previously loaded model from the server.
9
10
  *
10
11
  * When the last model is unloaded (no more models remain), this function
11
- * automatically closes the RPC connection, allowing the process to exit
12
- * naturally without requiring manual cleanup.
12
+ * automatically closes the RPC connection on Node/Electron, allowing the
13
+ * process to exit naturally without requiring manual cleanup. On Bare the
14
+ * connection is left open by default so long-lived workers survive a routine
15
+ * unload; pass `autoClose: true` to opt in to closing.
13
16
  *
14
17
  * @param params - The parameters for unloading the model
15
18
  * @param params.modelId - The unique identifier of the model to unload
16
19
  * @param params.clearStorage - Whether to clear the storage for the model
20
+ * @param params.autoClose - Override the runtime-default auto-close behavior
17
21
  * @throws {QvacErrorBase} When the response type is invalid or when the unload operation fails
18
22
  */
19
23
  export async function unloadModel(params) {
@@ -30,8 +34,9 @@ export async function unloadModel(params) {
30
34
  throw new ModelUnloadFailedError(params.modelId);
31
35
  }
32
36
  stopLoggingStreamForModel(params.modelId);
33
- // Auto-close when no models remain AND no providers are active
34
- if (response.hasActiveModels === false &&
37
+ const shouldAutoClose = params.autoClose ?? !isBare;
38
+ if (shouldAutoClose &&
39
+ response.hasActiveModels === false &&
35
40
  response.hasActiveProviders === false) {
36
41
  logger.info("🧹 No models or providers active, automatically closing RPC connection...");
37
42
  await close();
@@ -0,0 +1,45 @@
1
+ import { type UpscaleClientParams, type UpscaleStats } from "../../schemas/sdcpp-config";
2
+ interface UpscaleResult {
3
+ outputs: Promise<Uint8Array[]>;
4
+ stats: Promise<UpscaleStats | undefined>;
5
+ }
6
+ /**
7
+ * Runs standalone ESRGAN upscaling on an arbitrary PNG/JPEG image.
8
+ *
9
+ * The model must have been loaded with `modelType: "diffusion"` and
10
+ * `modelConfig.mode: "upscale"` — calling `upscale()` against a model
11
+ * loaded in default (`mode: "diffusion"`) mode throws
12
+ * `ModelOperationNotSupportedError` upfront.
13
+ *
14
+ * `outputs` always resolves to length 1: `repeats` runs N passes
15
+ * internally and emits a single final image at `source * scale^repeats`
16
+ * dimensions. The `Uint8Array[]` shape reserves headroom for future
17
+ * multi-output variants.
18
+ *
19
+ * @param params - `{ modelId, image, repeats? }`. `image` is raw PNG/JPEG
20
+ * bytes; the client base64-encodes them on the wire.
21
+ * @returns `{ outputs, stats }` — `outputs` resolves to a single-element
22
+ * array containing the final upscaled PNG; `stats` resolves to
23
+ * addon-side stats (load/upscale ms, final width/height, repeats
24
+ * actually executed, etc.).
25
+ * @throws {ModelOperationNotSupportedError} If the model was not loaded
26
+ * with `mode: "upscale"`.
27
+ * @throws {StreamEndedError} If the RPC stream closes without emitting a
28
+ * terminal `done` chunk.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const modelId = await loadModel(REALESRGAN_X4PLUS_ANIME_6B, {
33
+ * modelType: "diffusion",
34
+ * modelConfig: { mode: "upscale", upscaler: { tile_size: 128 } },
35
+ * });
36
+ * const pngBytes = fs.readFileSync("input.png");
37
+ * const { outputs, stats } = upscale({ modelId, image: pngBytes, repeats: 2 });
38
+ * const [upscaledPng] = await outputs;
39
+ * fs.writeFileSync("upscaled.png", upscaledPng);
40
+ * console.log(await stats);
41
+ * ```
42
+ */
43
+ export declare function upscale(params: UpscaleClientParams): UpscaleResult;
44
+ export {};
45
+ //# sourceMappingURL=upscale.d.ts.map
@@ -0,0 +1,99 @@
1
+ import { upscaleStreamResponseSchema, } from "../../schemas/sdcpp-config.js";
2
+ import { stream as streamRpc } from "../rpc/rpc-client.js";
3
+ import { decodeBase64, encodeBase64 } from "../../utils/encoding.js";
4
+ import { StreamEndedError } from "../../utils/errors-client.js";
5
+ /**
6
+ * Runs standalone ESRGAN upscaling on an arbitrary PNG/JPEG image.
7
+ *
8
+ * The model must have been loaded with `modelType: "diffusion"` and
9
+ * `modelConfig.mode: "upscale"` — calling `upscale()` against a model
10
+ * loaded in default (`mode: "diffusion"`) mode throws
11
+ * `ModelOperationNotSupportedError` upfront.
12
+ *
13
+ * `outputs` always resolves to length 1: `repeats` runs N passes
14
+ * internally and emits a single final image at `source * scale^repeats`
15
+ * dimensions. The `Uint8Array[]` shape reserves headroom for future
16
+ * multi-output variants.
17
+ *
18
+ * @param params - `{ modelId, image, repeats? }`. `image` is raw PNG/JPEG
19
+ * bytes; the client base64-encodes them on the wire.
20
+ * @returns `{ outputs, stats }` — `outputs` resolves to a single-element
21
+ * array containing the final upscaled PNG; `stats` resolves to
22
+ * addon-side stats (load/upscale ms, final width/height, repeats
23
+ * actually executed, etc.).
24
+ * @throws {ModelOperationNotSupportedError} If the model was not loaded
25
+ * with `mode: "upscale"`.
26
+ * @throws {StreamEndedError} If the RPC stream closes without emitting a
27
+ * terminal `done` chunk.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const modelId = await loadModel(REALESRGAN_X4PLUS_ANIME_6B, {
32
+ * modelType: "diffusion",
33
+ * modelConfig: { mode: "upscale", upscaler: { tile_size: 128 } },
34
+ * });
35
+ * const pngBytes = fs.readFileSync("input.png");
36
+ * const { outputs, stats } = upscale({ modelId, image: pngBytes, repeats: 2 });
37
+ * const [upscaledPng] = await outputs;
38
+ * fs.writeFileSync("upscaled.png", upscaledPng);
39
+ * console.log(await stats);
40
+ * ```
41
+ */
42
+ export function upscale(params) {
43
+ const request = {
44
+ modelId: params.modelId,
45
+ image: encodeBase64(params.image),
46
+ ...(params.repeats !== undefined && { repeats: params.repeats }),
47
+ type: "upscaleStream",
48
+ };
49
+ let statsResolver = () => { };
50
+ let statsRejecter = () => { };
51
+ const statsPromise = new Promise((resolve, reject) => {
52
+ statsResolver = resolve;
53
+ statsRejecter = reject;
54
+ });
55
+ statsPromise.catch(() => { });
56
+ let outputsResolver = () => { };
57
+ let outputsRejecter = () => { };
58
+ const outputsPromise = new Promise((resolve, reject) => {
59
+ outputsResolver = resolve;
60
+ outputsRejecter = reject;
61
+ });
62
+ outputsPromise.catch(() => { });
63
+ const collectedBuffers = [];
64
+ async function processResponses() {
65
+ let sawDone = false;
66
+ try {
67
+ for await (const response of streamRpc(request)) {
68
+ if (response &&
69
+ typeof response === "object" &&
70
+ "type" in response &&
71
+ response.type === "upscaleStream") {
72
+ const parsed = upscaleStreamResponseSchema.parse(response);
73
+ if (parsed.data) {
74
+ collectedBuffers.push(decodeBase64(parsed.data));
75
+ }
76
+ if (parsed.done) {
77
+ sawDone = true;
78
+ statsResolver(parsed.stats);
79
+ outputsResolver(collectedBuffers);
80
+ }
81
+ }
82
+ }
83
+ if (!sawDone) {
84
+ const error = new StreamEndedError();
85
+ statsRejecter(error);
86
+ outputsRejecter(error);
87
+ }
88
+ }
89
+ catch (error) {
90
+ statsRejecter(error);
91
+ outputsRejecter(error);
92
+ }
93
+ }
94
+ void processResponses();
95
+ return {
96
+ outputs: outputsPromise,
97
+ stats: statsPromise,
98
+ };
99
+ }