@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
@@ -0,0 +1,75 @@
1
+ /**
2
+ * SmolVLA (vision-language-action) example using the QVAC SDK.
3
+ *
4
+ * Loads the SmolVLA-LIBERO GGUF model, runs a single inference pass with
5
+ * synthetic inputs (zero-filled gray images + BOS-only tokens + zero state +
6
+ * zero noise), and prints the produced action chunk + per-stage timings.
7
+ *
8
+ * Usage:
9
+ * bun examples/vla-smolvla.ts [path-to-smolvla.gguf]
10
+ *
11
+ * By default the example pulls the registry-baked SmolVLA-LIBERO GGUF
12
+ * (~1.9 GB) on first run and caches it locally. Pass an absolute path on
13
+ * the command line to override and load a local GGUF instead.
14
+ */
15
+ import { close, loadModel, SMOLVLA_LIBERO_VISION_Q8, unloadModel, vla, vlaHparams, vlaPadState, vlaPreprocessImage, } from "@qvac/sdk";
16
+ const modelSrcOverride = process.argv[2];
17
+ const modelSrc = modelSrcOverride ?? SMOLVLA_LIBERO_VISION_Q8;
18
+ try {
19
+ console.log("Loading SmolVLA model...");
20
+ const modelId = await loadModel({
21
+ modelSrc,
22
+ modelType: "vla",
23
+ modelConfig: { backend: "cpu" },
24
+ onProgress: (p) => typeof modelSrc === "string"
25
+ ? undefined
26
+ : process.stdout.write(`\rDownloading: ${p.percentage.toFixed(1)}%`),
27
+ });
28
+ if (typeof modelSrc !== "string")
29
+ process.stdout.write("\n");
30
+ console.log(`Model loaded: ${modelId}`);
31
+ const { hparams, backendName } = await vlaHparams({ modelId });
32
+ console.log(`Backend: ${backendName ?? "(unknown)"}`);
33
+ console.log("Hparams:", hparams);
34
+ // Build synthetic inputs sized to the model's expectations. A real
35
+ // consumer would: read camera frames, tokenize the instruction with the
36
+ // SmolVLM2 tokenizer, and read the robot's current end-effector pose.
37
+ const size = hparams.visionImageSize;
38
+ const dummyPixels = new Uint8Array(size * size * 3).fill(128);
39
+ const front = vlaPreprocessImage(dummyPixels, size, size, { size });
40
+ const wrist = vlaPreprocessImage(dummyPixels, size, size, { size });
41
+ const tokens = new Int32Array(hparams.tokenizerMaxLength);
42
+ const mask = new Uint8Array(hparams.tokenizerMaxLength);
43
+ // BOS-only "instruction" for the smoke test.
44
+ tokens[0] = 1;
45
+ mask[0] = 1;
46
+ const state = vlaPadState([0, 0, 0, 0, 0, 0], hparams.maxStateDim);
47
+ const noise = new Float32Array(hparams.chunkSize * hparams.maxActionDim);
48
+ console.log("Running VLA inference...");
49
+ const { actions, actionDim, chunkSize, stats } = await vla({
50
+ modelId,
51
+ images: [front, wrist],
52
+ imgWidth: size,
53
+ imgHeight: size,
54
+ state,
55
+ tokens,
56
+ mask,
57
+ noise,
58
+ });
59
+ console.log(`Got ${chunkSize} action steps of dim ${actionDim}.`);
60
+ console.log("First step:", Array.from(actions.subarray(0, actionDim)));
61
+ if (stats) {
62
+ console.log(`Timing: vision=${stats.vision_ms?.toFixed(0)}ms ` +
63
+ `smollm2=${stats.smollm2_total_ms?.toFixed(0)}ms ` +
64
+ `ode=${stats.ode_ms?.toFixed(0)}ms ` +
65
+ `total=${stats.total_ms?.toFixed(0)}ms`);
66
+ }
67
+ await unloadModel({ modelId, clearStorage: false });
68
+ console.log("Model unloaded.");
69
+ process.exit(0);
70
+ }
71
+ catch (error) {
72
+ console.error("VLA example failed:", error);
73
+ await close();
74
+ process.exit(1);
75
+ }
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Requirements: FFmpeg installed, microphone access, speakers.
12
12
  */
13
- import { loadModel, unloadModel, transcribeStream, completion, textToSpeech, WHISPER_TINY, VAD_SILERO_5_1_2, LLAMA_3_2_1B_INST_Q4_0, TTS_SUPERTONIC2_OFFICIAL_TEXT_ENCODER_SUPERTONE_FP32, TTS_SUPERTONIC2_OFFICIAL_DURATION_PREDICTOR_SUPERTONE_FP32, TTS_SUPERTONIC2_OFFICIAL_VECTOR_ESTIMATOR_SUPERTONE_FP32, TTS_SUPERTONIC2_OFFICIAL_VOCODER_SUPERTONE_FP32, TTS_SUPERTONIC2_OFFICIAL_UNICODE_INDEXER_SUPERTONE_FP32, TTS_SUPERTONIC2_OFFICIAL_TTS_CONFIG_SUPERTONE, TTS_SUPERTONIC2_OFFICIAL_VOICE_STYLE_SUPERTONE, } from "@qvac/sdk";
13
+ import { loadModel, unloadModel, transcribeStream, completion, textToSpeech, WHISPER_TINY, VAD_SILERO_5_1_2, LLAMA_3_2_1B_INST_Q4_0, TTS_EN_SUPERTONIC_Q8_0, } from "@qvac/sdk";
14
14
  import { spawnSync } from "child_process";
15
15
  import { startMicrophone } from "../audio/mic-input";
16
16
  import { createWavHeader, int16ArrayToBuffer, playAudio } from "../tts/utils";
@@ -100,21 +100,14 @@ const llmModelId = await loadModel({
100
100
  });
101
101
  console.log("Loading Supertonic TTS...");
102
102
  const ttsModelId = await loadModel({
103
- modelSrc: TTS_SUPERTONIC2_OFFICIAL_TEXT_ENCODER_SUPERTONE_FP32.src,
103
+ modelSrc: TTS_EN_SUPERTONIC_Q8_0.src,
104
104
  modelType: "tts",
105
105
  modelConfig: {
106
106
  ttsEngine: "supertonic",
107
107
  language: "en",
108
+ voice: "F1",
108
109
  ttsSpeed: 1.05,
109
110
  ttsNumInferenceSteps: 5,
110
- ttsSupertonicMultilingual: false,
111
- ttsTextEncoderSrc: TTS_SUPERTONIC2_OFFICIAL_TEXT_ENCODER_SUPERTONE_FP32.src,
112
- ttsDurationPredictorSrc: TTS_SUPERTONIC2_OFFICIAL_DURATION_PREDICTOR_SUPERTONE_FP32.src,
113
- ttsVectorEstimatorSrc: TTS_SUPERTONIC2_OFFICIAL_VECTOR_ESTIMATOR_SUPERTONE_FP32.src,
114
- ttsVocoderSrc: TTS_SUPERTONIC2_OFFICIAL_VOCODER_SUPERTONE_FP32.src,
115
- ttsUnicodeIndexerSrc: TTS_SUPERTONIC2_OFFICIAL_UNICODE_INDEXER_SUPERTONE_FP32.src,
116
- ttsTtsConfigSrc: TTS_SUPERTONIC2_OFFICIAL_TTS_CONFIG_SUPERTONE.src,
117
- ttsVoiceStyleSrc: TTS_SUPERTONIC2_OFFICIAL_VOICE_STYLE_SUPERTONE.src,
118
111
  },
119
112
  });
120
113
  console.log("All models loaded.\n");
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Walks from `startDir` up to the filesystem root, returning the first
3
+ * `<dir>/node_modules/<name>` that exists, or `null`. Matches Node's own
4
+ * module resolution so packages hoisted to a monorepo root (e.g. by bun or
5
+ * yarn workspaces) are found from a nested project directory.
6
+ *
7
+ * Use this as the building block for any plugin lookup that historically
8
+ * checked only `<projectRoot>/node_modules`. For SDK resolution specifically
9
+ * use `resolveSDKPackageDir`, which layers multi-package disambiguation and
10
+ * shadowed-copy warnings on top of this.
11
+ */
12
+ declare function findInAncestorNodeModules(startDir: string, name: string): string | null;
13
+ export { findInAncestorNodeModules };
14
+ //# sourceMappingURL=find-in-ancestor-node-modules.d.ts.map
@@ -0,0 +1,24 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ /**
4
+ * Walks from `startDir` up to the filesystem root, returning the first
5
+ * `<dir>/node_modules/<name>` that exists, or `null`. Matches Node's own
6
+ * module resolution so packages hoisted to a monorepo root (e.g. by bun or
7
+ * yarn workspaces) are found from a nested project directory.
8
+ *
9
+ * Use this as the building block for any plugin lookup that historically
10
+ * checked only `<projectRoot>/node_modules`. For SDK resolution specifically
11
+ * use `resolveSDKPackageDir`, which layers multi-package disambiguation and
12
+ * shadowed-copy warnings on top of this.
13
+ */
14
+ function findInAncestorNodeModules(startDir, name) {
15
+ let dir = startDir;
16
+ let parent = path.dirname(dir);
17
+ for (; dir !== parent; dir = parent, parent = path.dirname(dir)) {
18
+ const candidate = path.join(dir, "node_modules", name);
19
+ if (fs.existsSync(candidate))
20
+ return candidate;
21
+ }
22
+ return null;
23
+ }
24
+ export { findInAncestorNodeModules };
@@ -0,0 +1,22 @@
1
+ import type { ExportedConfigWithProps } from "@expo/config-plugins";
2
+ import type { ExpoConfig } from "expo/config";
3
+ /**
4
+ * `projectRoot` resolution in Expo plugins depends on plugin type:
5
+ *
6
+ * - **Mod plugins** (callbacks passed to `withDangerousMod` etc.) receive an
7
+ * `ExportedConfigWithProps<...>` whose `modRequest.projectRoot` is the
8
+ * documented public API for the consumer's project directory.
9
+ * - **Base plugins** (called with the bare `ExpoConfig`) run before any mod
10
+ * cycle and have no `modRequest`. The only way to recover the project root
11
+ * is the (undocumented but stable) `_internal.projectRoot` escape hatch
12
+ * Expo's config-plugins runtime attaches to the config it hands plugins.
13
+ *
14
+ * Both helpers exist so the two access patterns are picked deliberately —
15
+ * call the one that matches the plugin shape you're in. Don't reach into the
16
+ * raw fields directly; that's how `withMobileBundle` and `withDeviceInfo`
17
+ * silently disagreed on which directory they were resolving against.
18
+ */
19
+ declare function getProjectRootFromMod(config: ExportedConfigWithProps<unknown>): string;
20
+ declare function getProjectRootFromBaseConfig(config: ExpoConfig): string | undefined;
21
+ export { getProjectRootFromMod, getProjectRootFromBaseConfig };
22
+ //# sourceMappingURL=get-project-root.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `projectRoot` resolution in Expo plugins depends on plugin type:
3
+ *
4
+ * - **Mod plugins** (callbacks passed to `withDangerousMod` etc.) receive an
5
+ * `ExportedConfigWithProps<...>` whose `modRequest.projectRoot` is the
6
+ * documented public API for the consumer's project directory.
7
+ * - **Base plugins** (called with the bare `ExpoConfig`) run before any mod
8
+ * cycle and have no `modRequest`. The only way to recover the project root
9
+ * is the (undocumented but stable) `_internal.projectRoot` escape hatch
10
+ * Expo's config-plugins runtime attaches to the config it hands plugins.
11
+ *
12
+ * Both helpers exist so the two access patterns are picked deliberately —
13
+ * call the one that matches the plugin shape you're in. Don't reach into the
14
+ * raw fields directly; that's how `withMobileBundle` and `withDeviceInfo`
15
+ * silently disagreed on which directory they were resolving against.
16
+ */
17
+ function getProjectRootFromMod(config) {
18
+ return config.modRequest.projectRoot;
19
+ }
20
+ function getProjectRootFromBaseConfig(config) {
21
+ return config._internal?.["projectRoot"];
22
+ }
23
+ export { getProjectRootFromMod, getProjectRootFromBaseConfig };
@@ -4,5 +4,9 @@ export { default as withDeviceInfo } from "./withDeviceInfo";
4
4
  export { default as withMobileBundle } from "./withMobileBundle";
5
5
  export { default as withOpenCL } from "./withOpenCL";
6
6
  export { default as withQvacSDK } from "./withQvacSDK";
7
+ export { getProjectRootFromMod, getProjectRootFromBaseConfig, } from "./get-project-root";
8
+ export { resolveSDKPackageDir, SDK_PACKAGE_NAMES, } from "./resolve-sdk-package-dir";
9
+ export type { SDKPackageInfo } from "./resolve-sdk-package-dir";
10
+ export { findInAncestorNodeModules } from "./find-in-ancestor-node-modules";
7
11
  export { default } from "./withQvacSDK";
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -4,5 +4,9 @@ export { default as withDeviceInfo } from "./withDeviceInfo.js";
4
4
  export { default as withMobileBundle } from "./withMobileBundle.js";
5
5
  export { default as withOpenCL } from "./withOpenCL.js";
6
6
  export { default as withQvacSDK } from "./withQvacSDK.js";
7
+ // Helpers for downstream plugin authors composing on top of these plugins.
8
+ export { getProjectRootFromMod, getProjectRootFromBaseConfig, } from "./get-project-root.js";
9
+ export { resolveSDKPackageDir, SDK_PACKAGE_NAMES, } from "./resolve-sdk-package-dir.js";
10
+ export { findInAncestorNodeModules } from "./find-in-ancestor-node-modules.js";
7
11
  // Export the main plugin as default for easy usage
8
12
  export { default } from "./withQvacSDK.js";
@@ -6,8 +6,15 @@ type SDKPackageInfo = {
6
6
  /**
7
7
  * Resolves the installed SDK package directory from node_modules.
8
8
  *
9
- * Checks all known published package names and returns the one that exists.
10
- * Throws if none found or if multiple are found (ambiguous installation).
9
+ * Walks from `projectRoot` up to the filesystem root, checking each
10
+ * `node_modules` directory along the way. This matches Node's own module
11
+ * resolution so packages hoisted to a monorepo root (e.g. by bun or yarn
12
+ * workspaces) are found correctly.
13
+ *
14
+ * When multiple SDK installs are found across the tree, the one closest to
15
+ * `projectRoot` wins and a warning lists the others. Only throws
16
+ * `MultipleSDKInstallationsError` when two *different* SDK package names
17
+ * coexist at the same nesting level (a real ambiguity in package selection).
11
18
  */
12
19
  declare function resolveSDKPackageDir(projectRoot: string): SDKPackageInfo;
13
20
  export { resolveSDKPackageDir, SDK_PACKAGE_NAMES };
@@ -6,26 +6,53 @@ const SDK_PACKAGE_NAMES = [
6
6
  "@tetherto/sdk-mono",
7
7
  "@tetherto/sdk-dev",
8
8
  ];
9
+ function findAllInAncestorNodeModules(startDir, name) {
10
+ const matches = [];
11
+ let dir = startDir;
12
+ let parent = path.dirname(dir);
13
+ let depth = 0;
14
+ for (; dir !== parent; dir = parent, parent = path.dirname(dir), depth++) {
15
+ const candidate = path.join(dir, "node_modules", name);
16
+ if (fs.existsSync(candidate)) {
17
+ matches.push({ name, dir: candidate, depth });
18
+ }
19
+ }
20
+ return matches;
21
+ }
9
22
  /**
10
23
  * Resolves the installed SDK package directory from node_modules.
11
24
  *
12
- * Checks all known published package names and returns the one that exists.
13
- * Throws if none found or if multiple are found (ambiguous installation).
25
+ * Walks from `projectRoot` up to the filesystem root, checking each
26
+ * `node_modules` directory along the way. This matches Node's own module
27
+ * resolution so packages hoisted to a monorepo root (e.g. by bun or yarn
28
+ * workspaces) are found correctly.
29
+ *
30
+ * When multiple SDK installs are found across the tree, the one closest to
31
+ * `projectRoot` wins and a warning lists the others. Only throws
32
+ * `MultipleSDKInstallationsError` when two *different* SDK package names
33
+ * coexist at the same nesting level (a real ambiguity in package selection).
14
34
  */
15
35
  function resolveSDKPackageDir(projectRoot) {
16
- const found = [];
36
+ const allMatches = [];
17
37
  for (const name of SDK_PACKAGE_NAMES) {
18
- const dir = path.join(projectRoot, "node_modules", name);
19
- if (fs.existsSync(dir)) {
20
- found.push({ name, dir });
21
- }
38
+ allMatches.push(...findAllInAncestorNodeModules(projectRoot, name));
22
39
  }
23
- if (found.length === 0) {
40
+ if (allMatches.length === 0) {
24
41
  throw new SDKNotFoundInNodeModulesError();
25
42
  }
26
- if (found.length > 1) {
27
- throw new MultipleSDKInstallationsError(found.map((f) => f.name).join(", "));
43
+ const minDepth = Math.min(...allMatches.map((m) => m.depth));
44
+ const closest = allMatches.filter((m) => m.depth === minDepth);
45
+ if (closest.length > 1) {
46
+ throw new MultipleSDKInstallationsError(closest.map((m) => m.name).join(", "));
47
+ }
48
+ const winner = closest[0];
49
+ const shadowed = allMatches.filter((m) => m !== winner);
50
+ if (shadowed.length > 0) {
51
+ const others = shadowed.map((m) => `"${m.name}" at "${m.dir}"`).join(", ");
52
+ console.warn(`[resolveSDKPackageDir] Multiple SDK installations found; using ` +
53
+ `"${winner.name}" at "${winner.dir}" (closest to projectRoot). ` +
54
+ `Ignoring: ${others}.`);
28
55
  }
29
- return found[0];
56
+ return { name: winner.name, dir: winner.dir };
30
57
  }
31
58
  export { resolveSDKPackageDir, SDK_PACKAGE_NAMES };
@@ -1,6 +1,7 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
4
+ import { getProjectRootFromBaseConfig } from "./get-project-root.js";
4
5
  let didRun = false;
5
6
  /**
6
7
  * Expo plugin that stubs expo-device-info when expo-device is not a declared
@@ -13,7 +14,7 @@ function withDeviceInfo(config) {
13
14
  return config;
14
15
  }
15
16
  didRun = true;
16
- const projectRoot = config._internal?.["projectRoot"];
17
+ const projectRoot = getProjectRootFromBaseConfig(config);
17
18
  if (!projectRoot) {
18
19
  return config;
19
20
  }
@@ -1,11 +1,12 @@
1
1
  import type { ExpoConfig } from "expo/config";
2
+ declare const MOBILE_HOSTS: string[];
2
3
  /**
3
- * Expo plugin that automatically generates the mobile worker bundle during build.
4
+ * Expo plugin: bundle, verify, then copy the mobile worker bundle.
4
5
  *
5
- * Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
6
- * Uses qvac.config.* if exists, else includes all built-in plugins.
7
- * Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
6
+ * Flow: bundleSdk -> verifyBundle -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
7
+ * Uses `qvac.config.*` if present.
8
8
  */
9
9
  declare function withMobileBundle(config: ExpoConfig): ExpoConfig;
10
+ export { MOBILE_HOSTS };
10
11
  export default withMobileBundle;
11
12
  //# sourceMappingURL=withMobileBundle.d.ts.map
@@ -1,14 +1,13 @@
1
1
  import configPlugins from "@expo/config-plugins";
2
- import { execSync } from "child_process";
3
2
  import * as fs from "fs";
4
3
  import * as path from "path";
4
+ import { bundleSdk, verifyBundle, hasErrors, formatVerifyBundleResult } from "../../commands/index.js";
5
+ import { CONFIG_CANDIDATES } from "../../client/config-loader/resolve-config.node.js";
5
6
  import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
7
+ import { getProjectRootFromMod } from "./get-project-root.js";
8
+ import { findInAncestorNodeModules } from "./find-in-ancestor-node-modules.js";
9
+ import { BundleVerificationFailedError } from "../../utils/errors-client.js";
6
10
  const { withDangerousMod } = configPlugins;
7
- const CONFIG_CANDIDATES = [
8
- "qvac.config.json",
9
- "qvac.config.js",
10
- "qvac.config.mjs",
11
- ];
12
11
  /** Modules to defer from mobile bundles (not available at bundle time) */
13
12
  const DEFERRED_MODULES = ["expo-file-system", "react-native-bare-kit"];
14
13
  const MOBILE_HOSTS = [
@@ -18,19 +17,16 @@ const MOBILE_HOSTS = [
18
17
  "ios-x64-simulator",
19
18
  ];
20
19
  /**
21
- * Expo plugin that automatically generates the mobile worker bundle during build.
20
+ * Expo plugin: bundle, verify, then copy the mobile worker bundle.
22
21
  *
23
- * Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
24
- * Uses qvac.config.* if exists, else includes all built-in plugins.
25
- * Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
22
+ * Flow: bundleSdk -> verifyBundle -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
23
+ * Uses `qvac.config.*` if present.
26
24
  */
27
25
  function withMobileBundle(config) {
28
- function buildMobileBundle(config) {
29
- const projectRoot = config.modRequest.projectRoot;
26
+ async function buildMobileBundle(config) {
27
+ const projectRoot = getProjectRootFromMod(config);
30
28
  const sdkPackage = resolveSDKPackageDir(projectRoot);
31
29
  const outputPath = path.join(sdkPackage.dir, "dist", "worker.mobile.bundle.js");
32
- // Generate bundle via qvac CLI
33
- // (uses qvac.config.* if exists, else includes all built-in plugins)
34
30
  const configPath = findConfigFile(projectRoot);
35
31
  if (configPath) {
36
32
  console.log(`🕚 QVAC: Found ${path.basename(configPath)}, generating tree-shaken bundle...`);
@@ -42,15 +38,11 @@ function withMobileBundle(config) {
42
38
  ...DEFERRED_MODULES,
43
39
  `${sdkPackage.name}/worker.mobile.bundle`,
44
40
  ];
45
- runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
46
- // Copy the generated bundle to SDK location
41
+ await runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
47
42
  const generatedBundle = path.join(projectRoot, "qvac", "worker.bundle.js");
48
- if (!fs.existsSync(generatedBundle)) {
49
- throw new Error(`QVAC: Bundle generation failed — ${generatedBundle} not found. ` +
50
- `Check qvac CLI output above for errors.`);
51
- }
43
+ await runVerifier(projectRoot, generatedBundle, configPath);
52
44
  fs.copyFileSync(generatedBundle, outputPath);
53
- console.log("🫡 QVAC: Mobile bundle generated");
45
+ console.log("🫡 QVAC: Mobile bundle generated and verified");
54
46
  return config;
55
47
  }
56
48
  config = withDangerousMod(config, ["android", buildMobileBundle]);
@@ -67,49 +59,42 @@ function findConfigFile(projectRoot) {
67
59
  }
68
60
  return null;
69
61
  }
70
- /**
71
- * Resolves the qvac CLI command.
72
- *
73
- * Prefers local @qvac/cli installation for version consistency,
74
- * falls back to npx for convenience when CLI is not installed.
75
- */
76
- function resolveCliCommand(projectRoot) {
77
- const cliPath = path.join(projectRoot, "node_modules", "@qvac", "cli", "dist", "index.js");
78
- if (fs.existsSync(cliPath)) {
79
- return `node "${cliPath}"`;
62
+ async function runVerifier(projectRoot, generatedBundle, configPath) {
63
+ if (!configPath) {
64
+ console.log("⚠️ QVAC: no qvac.config.* found — Bare runtime will be auto-detected " +
65
+ "from node_modules (bare-runtime, then bare). Add qvac.config.json " +
66
+ "with `bareRuntimeVersion` to pin ABI checks deterministically.");
67
+ }
68
+ const result = await verifyBundle({
69
+ projectRoot,
70
+ addonsSource: generatedBundle,
71
+ hosts: MOBILE_HOSTS,
72
+ ...(configPath ? { configPath } : {}),
73
+ });
74
+ if (hasErrors(result)) {
75
+ throw new BundleVerificationFailedError(generatedBundle, new Error(formatVerifyBundleResult(result)));
80
76
  }
81
- console.log("⚠️ QVAC: @qvac/cli not found in node_modules, falling back to npx");
82
- console.log(" Tip: Add @qvac/cli as a dependency for consistent versioning");
83
- return "npx --package=@qvac/cli qvac";
84
77
  }
85
- /** Runs qvac CLI with mobile-specific options */
86
- function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
87
- // Patch bare-kit linkers to use addons manifest
78
+ async function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
88
79
  patchBareKitLinkers(projectRoot, qvacSdkPath);
89
- const hostFlags = MOBILE_HOSTS.map((h) => `--host ${h}`).join(" ");
90
- const deferFlags = deferredModules.map((m) => `--defer "${m}"`).join(" ");
91
- const configFlag = configPath ? `--config "${configPath}"` : "";
92
- const sdkPathFlag = `--sdk-path "${qvacSdkPath}"`;
93
- const cliCommand = resolveCliCommand(projectRoot);
94
- try {
95
- execSync(`${cliCommand} bundle sdk ${sdkPathFlag} ${configFlag} ${hostFlags} ${deferFlags} --quiet`, { stdio: "inherit", cwd: projectRoot });
96
- }
97
- catch (error) {
98
- console.error("❌ QVAC: Failed to generate bundle:", error);
99
- throw error;
100
- }
80
+ await bundleSdk({
81
+ projectRoot,
82
+ sdkPath: qvacSdkPath,
83
+ ...(configPath ? { configPath } : {}),
84
+ hosts: MOBILE_HOSTS,
85
+ defer: deferredModules,
86
+ quiet: true,
87
+ });
101
88
  }
102
89
  /**
103
90
  * Patches react-native-bare-kit linkers to use the addons manifest.
104
- *
105
- * Copies the manifest-aware link.mjs files over the originals so that
106
- * bare-link only links the native addons actually required by the bundle.
107
- * This reduces app size by excluding unused native addon binaries.
108
91
  */
109
92
  function patchBareKitLinkers(projectRoot, qvacSdkPath) {
110
- const bareKitPath = path.join(projectRoot, "node_modules", "react-native-bare-kit");
111
- if (!fs.existsSync(bareKitPath)) {
112
- console.log("⚠️ QVAC: react-native-bare-kit not found, skipping linker patch");
93
+ const bareKitPath = findInAncestorNodeModules(projectRoot, "react-native-bare-kit");
94
+ if (bareKitPath === null) {
95
+ console.warn("⚠️ QVAC: react-native-bare-kit not found in any ancestor node_modules, " +
96
+ "skipping linker patch. The bundle will link all native addons " +
97
+ "rather than only those required by your bundle.");
113
98
  return;
114
99
  }
115
100
  const patchesDir = path.join(qvacSdkPath, "expo", "plugins", "patches");
@@ -117,7 +102,6 @@ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
117
102
  console.log(`⚠️ QVAC: patches directory not found (${patchesDir}), skipping linker patch`);
118
103
  return;
119
104
  }
120
- // Patch Android linker
121
105
  const androidPatch = path.join(patchesDir, "android-link.mjs");
122
106
  const androidTarget = path.join(bareKitPath, "android", "link.mjs");
123
107
  if (fs.existsSync(androidPatch)) {
@@ -127,7 +111,6 @@ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
127
111
  else {
128
112
  console.log(`⚠️ QVAC: Android linker patch not found (${androidPatch})`);
129
113
  }
130
- // Patch iOS linker
131
114
  const iosPatch = path.join(patchesDir, "ios-link.mjs");
132
115
  const iosTarget = path.join(bareKitPath, "ios", "link.mjs");
133
116
  if (fs.existsSync(iosPatch)) {
@@ -138,4 +121,5 @@ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
138
121
  console.log(`⚠️ QVAC: iOS linker patch not found (${iosPatch})`);
139
122
  }
140
123
  }
124
+ export { MOBILE_HOSTS };
141
125
  export default withMobileBundle;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  import "#polyfill-bare-globals";
2
- export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, type DiffusionProgressTick, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, suspend, resume, state, type FinetuneHandle, } from "./client/api/index";
2
+ export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, type DiffusionProgressTick, classify, video, type VideoProgressTick, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, suspend, resume, state, vla, vlaHparams, vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, type FinetuneHandle, } from "./client/api/index";
3
3
  export { close } from "./client/index";
4
- export { type LifecycleState, type ModelProgressUpdate, type LoadModelOptions, type LoadCustomPluginModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionEvent, type CompletionFinal, type CompletionRun, type CompletionStats, type EmbedStats, VERBOSITY, type Attachment, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeSegment, type TextToSpeechStreamSession, type TextToSpeechStreamResponse, type TextToSpeechStreamClientParams, type CompletionParams, type ToolDialect, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type GetLoadedModelInfoParams, type LoadedModelInfo, type LoadedInstance, type CacheFileInfo, toolSchema, TOOLS_MODE, type ToolsMode, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, type DiffusionClientParams, type DiffusionStreamResponse, type DiffusionStats, definePlugin, defineHandler, defineDuplexHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, type ProfilerMode, type FinetuneValidation, type FinetuneRunParams, type FinetuneGetStateParams, type FinetuneStopParams, type FinetuneParams, type FinetuneStatus, type FinetuneProgress, type FinetuneStats, type FinetuneResult, } from "./schemas/index";
4
+ export { plugins } from "./client/plugins-factory";
5
+ export { type LifecycleState, type ModelProgressUpdate, type LoadModelOptions, type LoadCustomPluginModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionEvent, type CompletionFinal, type CompletionRun, type CompletionStats, type EmbedStats, VERBOSITY, type Attachment, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStreamEvent, type VadStateEvent, type EndOfTurnEvent, type TranscribeSegment, type TextToSpeechStreamSession, type TextToSpeechStreamResponse, type TextToSpeechStreamClientParams, type CompletionParams, type ToolDialect, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, RAG_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type GetLoadedModelInfoParams, type LoadedModelInfo, type LoadedInstance, type CacheFileInfo, toolSchema, TOOLS_MODE, type ToolsMode, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, type ClassifyClientParams, type ClassificationResult, type DiffusionClientParams, type DiffusionStreamResponse, type DiffusionStats, type VideoClientParams, type VideoStreamResponse, type VideoStats, type UpscaleClientParams, type UpscaleStreamResponse, type UpscaleStats, type VlaConfig, type VlaClientRunParams, type VlaClientRunResult, type VlaHparams, type VlaStats, definePlugin, defineHandler, defineDuplexHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, type ProfilerMode, type FinetuneValidation, type FinetuneRunParams, type FinetuneGetStateParams, type FinetuneStopParams, type FinetuneParams, type FinetuneStatus, type FinetuneProgress, type FinetuneStats, type FinetuneResult, } from "./schemas/index";
5
6
  export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
6
7
  export { MODEL_TYPES, ModelType } from "./schemas/index";
7
8
  export * from "./models/registry/index";
8
9
  export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio";
10
+ export { InferenceCancelledError } from "./utils/errors-server";
11
+ export type { InferenceCancelledPartial } from "./utils/errors-server";
12
+ export { ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server";
9
13
  export { getLogger, SDK_LOG_ID } from "./logging/index";
10
14
  export type { Logger, LogTransport, LoggerOptions } from "./logging/index";
11
15
  export { profiler } from "./profiling/index";
package/dist/index.js CHANGED
@@ -1,14 +1,35 @@
1
1
  import "#polyfill-bare-globals";
2
2
  // Public API exports only
3
- export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, suspend, resume, state, } from "./client/api/index.js";
3
+ export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, classify, video, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, suspend, resume, state, vla, vlaHparams, vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, } from "./client/api/index.js";
4
4
  export { close } from "./client/index.js";
5
- export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, TOOLS_MODE, definePlugin, defineHandler, defineDuplexHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
5
+ export { plugins } from "./client/plugins-factory.js";
6
+ export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, RAG_ERROR_CODES, toolSchema, TOOLS_MODE, definePlugin, defineHandler, defineDuplexHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
6
7
  export {} from "./utils/tool-helpers.js";
7
8
  // Model types - canonical naming with backward-compatible aliases
8
9
  export { MODEL_TYPES, ModelType } from "./schemas/index.js";
9
10
  // Model registry constants
10
11
  export * from "./models/registry/index.js";
11
12
  export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio.js";
13
+ // Error classes that clients need for `instanceof` checks on rejected
14
+ // promises. `InferenceCancelledError` rides the standard `QvacError`
15
+ // envelope, but consumers reach for it through `instanceof` on
16
+ // `await run.final` / `run.text` / `run.toolCalls` / `run.stats`
17
+ // rejections. `RequestRejectedByPolicyError` is thrown by
18
+ // `RequestRegistry.begin(...)` when a registered concurrency policy
19
+ // (e.g. `oneAtATimePerModel` on `completion`) rejects a new request;
20
+ // it propagates out through the worker so the client can distinguish
21
+ // "the request collided with another one" from "the request failed".
22
+ //
23
+ // `RequestIdConflictError` and `RequestNotFoundError` are thrown by
24
+ // `RequestRegistry.begin(...)` / `.end(...)` on UUID collisions and
25
+ // missing-target cancels. They're surfaced here so consumers using
26
+ // the decorated-promise `requestId` can pattern-match on rejected
27
+ // cancel paths. All three classes round-trip the RPC boundary via
28
+ // the typed-error reconstructor in `client/rpc/rpc-error.ts` so
29
+ // `err instanceof <Class>` works on the consumer side, not just on
30
+ // the worker side.
31
+ export { InferenceCancelledError } from "./utils/errors-server.js";
32
+ export { ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server.js";
12
33
  // Logging exports
13
34
  export { getLogger, SDK_LOG_ID } from "./logging/index.js";
14
35
  // Profiler exports