@qvac/sdk 0.22.0 → 0.24.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 (284) hide show
  1. package/NOTICE +194 -97
  2. package/README.md +29 -470
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  5. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
  6. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  7. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  8. package/dist/examples/assess-model-fit.d.ts +7 -9
  9. package/dist/examples/assess-model-fit.js +22 -43
  10. package/dist/examples/calc-tokens.d.ts +2 -0
  11. package/dist/examples/calc-tokens.js +21 -0
  12. package/dist/examples/classification/classify-image.js +11 -5
  13. package/dist/examples/completion-stop-reason.d.ts +3 -3
  14. package/dist/examples/completion-stop-reason.js +4 -4
  15. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  16. package/dist/examples/diffusion-flux3-klein.js +102 -0
  17. package/dist/examples/diffusion-img2vid-ltx.js +7 -14
  18. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  19. package/dist/examples/diffusion-moss-image.js +126 -0
  20. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  21. package/dist/examples/diffusion-qwen-image-21.js +115 -0
  22. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  23. package/dist/examples/embed-multimodal.d.ts +2 -0
  24. package/dist/examples/embed-multimodal.js +80 -0
  25. package/dist/examples/embed-p2p.js +2 -2
  26. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  27. package/dist/examples/image/megaloc.d.ts +2 -0
  28. package/dist/examples/image/megaloc.js +37 -0
  29. package/dist/examples/llamacpp-multimodal.js +21 -1
  30. package/dist/examples/mcp-websearch.js +1 -1
  31. package/dist/examples/plugins.js +1 -1
  32. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  33. package/dist/examples/rag/rag-turbovec.js +2 -2
  34. package/dist/examples/rerank.d.ts +2 -0
  35. package/dist/examples/rerank.js +33 -0
  36. package/dist/examples/sessions.d.ts +17 -0
  37. package/dist/examples/sessions.js +63 -0
  38. package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
  39. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
  40. package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
  41. package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
  42. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  43. package/dist/scripts/contract/build-contract.d.ts +2 -1
  44. package/dist/scripts/contract/build-contract.js +13 -1
  45. package/dist/scripts/contract/constants-registry.d.ts +19 -0
  46. package/dist/scripts/contract/constants-registry.js +9 -2
  47. package/dist/scripts/contract/method-shapes.d.ts +5 -0
  48. package/dist/scripts/contract/method-shapes.js +5 -0
  49. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  50. package/dist/scripts/enforce-inference-versions.js +28 -18
  51. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  52. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  53. package/dist/src/client/api/assess-model-fit.js +19 -32
  54. package/dist/src/client/api/audio-edit.d.ts +5 -3
  55. package/dist/src/client/api/audio-edit.js +7 -5
  56. package/dist/src/client/api/audio-gen-result.js +136 -47
  57. package/dist/src/client/api/audio-gen.d.ts +40 -3
  58. package/dist/src/client/api/audio-gen.js +42 -5
  59. package/dist/src/client/api/audio-understand.d.ts +2 -2
  60. package/dist/src/client/api/audio-understand.js +4 -4
  61. package/dist/src/client/api/batch-completion.js +4 -3
  62. package/dist/src/client/api/bci-transcribe.js +3 -3
  63. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  64. package/dist/src/client/api/calc-tokens.js +44 -0
  65. package/dist/src/client/api/cancel.d.ts +2 -2
  66. package/dist/src/client/api/cancel.js +3 -3
  67. package/dist/src/client/api/classify.d.ts +12 -5
  68. package/dist/src/client/api/classify.js +18 -6
  69. package/dist/src/client/api/client-request-id.d.ts +0 -15
  70. package/dist/src/client/api/client-request-id.js +15 -12
  71. package/dist/src/client/api/completion-stream.d.ts +9 -1
  72. package/dist/src/client/api/completion-stream.js +14 -3
  73. package/dist/src/client/api/decide.d.ts +1 -1
  74. package/dist/src/client/api/decide.js +3 -3
  75. package/dist/src/client/api/delete-cache.d.ts +9 -2
  76. package/dist/src/client/api/delete-cache.js +14 -4
  77. package/dist/src/client/api/diffusion.d.ts +38 -5
  78. package/dist/src/client/api/diffusion.js +42 -7
  79. package/dist/src/client/api/download-asset.js +3 -3
  80. package/dist/src/client/api/embed.d.ts +82 -29
  81. package/dist/src/client/api/embed.js +66 -21
  82. package/dist/src/client/api/finetune.js +3 -3
  83. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  84. package/dist/src/client/api/get-model-info.d.ts +2 -2
  85. package/dist/src/client/api/get-model-info.js +3 -3
  86. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  87. package/dist/src/client/api/get-system-resources.js +3 -3
  88. package/dist/src/client/api/heartbeat.d.ts +3 -2
  89. package/dist/src/client/api/heartbeat.js +4 -3
  90. package/dist/src/client/api/index.d.ts +8 -6
  91. package/dist/src/client/api/index.js +6 -4
  92. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  93. package/dist/src/client/api/invoke-plugin.js +18 -3
  94. package/dist/src/client/api/load-model.js +9 -6
  95. package/dist/src/client/api/logging-stream.d.ts +11 -2
  96. package/dist/src/client/api/logging-stream.js +12 -3
  97. package/dist/src/client/api/ocr.d.ts +5 -3
  98. package/dist/src/client/api/ocr.js +45 -22
  99. package/dist/src/client/api/rag.d.ts +1 -1
  100. package/dist/src/client/api/rag.js +3 -3
  101. package/dist/src/client/api/registry.d.ts +19 -8
  102. package/dist/src/client/api/registry.js +43 -17
  103. package/dist/src/client/api/rerank.d.ts +22 -0
  104. package/dist/src/client/api/rerank.js +39 -0
  105. package/dist/src/client/api/resume.d.ts +2 -1
  106. package/dist/src/client/api/resume.js +3 -3
  107. package/dist/src/client/api/rpc-server.d.ts +4 -4
  108. package/dist/src/client/api/rpc-server.js +12 -12
  109. package/dist/src/client/api/state.d.ts +2 -2
  110. package/dist/src/client/api/state.js +3 -3
  111. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  112. package/dist/src/client/api/subscribe-logs.js +4 -3
  113. package/dist/src/client/api/suspend.d.ts +4 -2
  114. package/dist/src/client/api/suspend.js +5 -4
  115. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  116. package/dist/src/client/api/text-to-speech.js +86 -32
  117. package/dist/src/client/api/transcribe.d.ts +7 -3
  118. package/dist/src/client/api/transcribe.js +9 -3
  119. package/dist/src/client/api/translate.js +2 -2
  120. package/dist/src/client/api/unload-model.d.ts +19 -7
  121. package/dist/src/client/api/unload-model.js +31 -13
  122. package/dist/src/client/api/upscale.d.ts +6 -3
  123. package/dist/src/client/api/upscale.js +10 -5
  124. package/dist/src/client/api/vector-index.d.ts +51 -17
  125. package/dist/src/client/api/vector-index.js +101 -49
  126. package/dist/src/client/api/video-request.d.ts +5 -5
  127. package/dist/src/client/api/video.d.ts +3 -2
  128. package/dist/src/client/api/video.js +6 -5
  129. package/dist/src/client/api/vla.d.ts +9 -5
  130. package/dist/src/client/api/vla.js +17 -8
  131. package/dist/src/client/api/world-result.js +2 -2
  132. package/dist/src/client/api/world.d.ts +6 -6
  133. package/dist/src/client/api/world.js +6 -6
  134. package/dist/src/client/init-hooks.d.ts +6 -4
  135. package/dist/src/client/init-hooks.js +12 -15
  136. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  137. package/dist/src/client/logging-stream-registry.js +36 -14
  138. package/dist/src/client/plugins-factory.d.ts +1 -1
  139. package/dist/src/client/plugins-factory.js +1 -1
  140. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  141. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  142. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  143. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  144. package/dist/src/client/rpc/expo-rpc-client.js +192 -138
  145. package/dist/src/client/rpc/node-rpc-client.js +324 -426
  146. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  147. package/dist/src/client/rpc/pear-runtime.js +12 -0
  148. package/dist/src/client/rpc/rpc-client.d.ts +6 -4
  149. package/dist/src/client/rpc/rpc-client.js +168 -31
  150. package/dist/src/client/rpc/rpc-error.js +24 -2
  151. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  152. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  153. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  154. package/dist/src/client/rpc/worker-failure.js +61 -0
  155. package/dist/src/client/session-registry.d.ts +75 -0
  156. package/dist/src/client/session-registry.js +149 -0
  157. package/dist/src/client/session.d.ts +125 -0
  158. package/dist/src/client/session.js +148 -0
  159. package/dist/src/commands/bundle/addons.d.ts +14 -0
  160. package/dist/src/commands/bundle/addons.js +65 -0
  161. package/dist/src/commands/bundle/constants.js +2 -0
  162. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  163. package/dist/src/commands/bundle/entry-gen.js +18 -51
  164. package/dist/src/commands/bundle/index.d.ts +60 -14
  165. package/dist/src/commands/bundle/index.js +350 -126
  166. package/dist/src/commands/bundle/link.d.ts +58 -0
  167. package/dist/src/commands/bundle/link.js +135 -0
  168. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  169. package/dist/src/commands/bundle/node-support.js +23 -0
  170. package/dist/src/commands/bundle/plugins.js +1 -1
  171. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  172. package/dist/src/commands/bundle/read-bundle.js +27 -0
  173. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  174. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  175. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  176. package/dist/src/commands/bundle/scratch.js +178 -0
  177. package/dist/src/commands/bundle/targets.d.ts +14 -0
  178. package/dist/src/commands/bundle/targets.js +37 -0
  179. package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
  180. package/dist/src/commands/host-prebuilds/index.js +13 -11
  181. package/dist/src/commands/index.d.ts +13 -12
  182. package/dist/src/commands/index.js +7 -7
  183. package/dist/src/commands/verify/abi.d.ts +21 -15
  184. package/dist/src/commands/verify/abi.js +12 -80
  185. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  186. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  187. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  188. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  189. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  190. package/dist/src/commands/verify/bundle-source.js +27 -23
  191. package/dist/src/commands/verify/engines-advice.d.ts +6 -12
  192. package/dist/src/commands/verify/engines-advice.js +9 -56
  193. package/dist/src/commands/verify/index.d.ts +34 -33
  194. package/dist/src/commands/verify/index.js +96 -204
  195. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  196. package/dist/src/commands/verify/node-modules-source.js +1 -1
  197. package/dist/src/commands/verify/prebuilds.d.ts +4 -6
  198. package/dist/src/commands/verify/prebuilds.js +3 -4
  199. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  200. package/dist/src/commands/verify/resource-collectors.js +3 -52
  201. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  202. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  203. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  204. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  205. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  206. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  207. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  208. package/dist/src/expo/plugins/withBareKit.js +204 -0
  209. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  210. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  211. package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
  212. package/dist/src/expo/plugins/withMobileBundle.js +38 -59
  213. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  214. package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
  215. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  216. package/dist/src/index.d.ts +6 -5
  217. package/dist/src/index.js +10 -14
  218. package/dist/src/logging/addon.d.ts +1 -1
  219. package/dist/src/logging/base-logger.js +1 -1
  220. package/dist/src/logging/utils.js +11 -3
  221. package/dist/src/plugin-ids.d.ts +3 -1
  222. package/dist/src/plugin-ids.js +4 -0
  223. package/dist/src/schemas/public.d.ts +1 -1
  224. package/dist/src/schemas/public.js +1 -1
  225. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  226. package/dist/src/schemas/sdk-errors-client.js +30 -36
  227. package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
  228. package/dist/src/schemas/sdk-errors-server.js +65 -2
  229. package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
  230. package/dist/src/server/rpc/rpc-utils.js +41 -0
  231. package/dist/src/utils/aggregate-events.d.ts +1 -1
  232. package/dist/src/utils/aggregate-events.js +2 -2
  233. package/dist/src/utils/errors-client.d.ts +37 -29
  234. package/dist/src/utils/errors-client.js +50 -41
  235. package/dist/src/utils/errors-server.d.ts +65 -1
  236. package/dist/src/utils/errors-server.js +122 -1
  237. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  238. package/dist/src/utils/mcp-adapter.js +1 -1
  239. package/dist/src/utils/tool-helpers.js +1 -1
  240. package/dist/src/utils/withTimeout.js +34 -17
  241. package/dist/src/worker/handle-request.js +26 -21
  242. package/dist/src/worker/handler-utils.d.ts +2 -6
  243. package/dist/src/worker/handler-utils.js +2 -20
  244. package/dist/src/worker/index.d.ts +2 -4
  245. package/dist/src/worker/index.js +24 -34
  246. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  247. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  248. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  249. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  250. package/dist/src/worker/shim.d.ts +4 -0
  251. package/dist/src/worker/shim.js +7 -0
  252. package/dist/src/worker/start.d.ts +9 -0
  253. package/dist/src/worker/start.js +16 -0
  254. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  255. package/dist/src/worker/unbundled-shim.js +4 -0
  256. package/docs/system-resources-support-matrix.md +27 -19
  257. package/package.json +91 -74
  258. package/src/electron-forge/index.cjs +65 -91
  259. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  260. package/dist/examples/model-fit-ui/server.js +0 -221
  261. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  262. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  263. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  264. package/dist/src/client/rpc/init-timeout.js +0 -25
  265. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  266. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  267. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  268. package/dist/src/commands/bundle/bare-pack.js +0 -77
  269. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  270. package/dist/src/commands/bundle/manifest.js +0 -192
  271. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  272. package/dist/src/expo/plugins/link-addons.js +0 -65
  273. package/dist/src/pear/pre.d.ts +0 -21
  274. package/dist/src/pear/pre.js +0 -448
  275. package/dist/src/server/env.d.ts +0 -22
  276. package/dist/src/server/env.js +0 -59
  277. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  278. package/dist/src/server/utils/qvac-paths.js +0 -5
  279. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  280. package/dist/src/server/utils/worker-lock.js +0 -67
  281. package/dist/src/worker/create-server.d.ts +0 -8
  282. package/dist/src/worker/create-server.js +0 -51
  283. package/dist/src/worker/lifecycle.d.ts +0 -23
  284. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,12 +1,13 @@
1
1
  import { videoStreamResponseSchema } from '@qvac/inference/surface';
2
- import { stream as streamRpc } from '../rpc/rpc-client.js';
3
- import { generateClientRequestId } from './client-request-id.js';
4
- import { createVideoStreamRequest } from './video-request.js';
2
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
+ import { createVideoStreamRequest } from '../../client/api/video-request.js';
5
5
  import { decodeBase64 } from '../../utils/encoding.js';
6
6
  /**
7
7
  * Generates a video using a loaded video diffusion model.
8
8
  *
9
9
  * @param params - Video request parameters (model, prompt, dimensions, frame count, fps, sampler, seed, etc.).
10
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
10
11
  * @returns A result object exposing `requestId` (stable identifier for this in-flight generation), `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated video buffers, typically a single AVI file), and `stats` (promise of generation statistics).
11
12
  *
12
13
  * Supports `txt2vid` (text-to-video) and `img2vid` (image-to-video) for Wan,
@@ -116,7 +117,7 @@ import { decodeBase64 } from '../../utils/encoding.js';
116
117
  * await cancel(requestId);
117
118
  * ```
118
119
  */
119
- export function video(params) {
120
+ export function video(params, options) {
120
121
  const requestId = generateClientRequestId();
121
122
  const request = createVideoStreamRequest(params, requestId);
122
123
  let statsResolver = () => { };
@@ -140,7 +141,7 @@ export function video(params) {
140
141
  outputsPromise.catch(() => { });
141
142
  async function processResponses() {
142
143
  try {
143
- for await (const response of streamRpc(request)) {
144
+ for await (const response of streamRpc(request, options)) {
144
145
  if (response &&
145
146
  typeof response === 'object' &&
146
147
  'type' in response &&
@@ -1,4 +1,4 @@
1
- import { type VlaClientRunParams, type VlaClientRunResult, type VlaEmbodimentSelection, type VlaHparams } from '@qvac/inference/surface';
1
+ import { type VlaClientRunParams, type VlaClientRunResult, type VlaEmbodimentSelection, type VlaHparams, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Run VLA inference on a loaded model (SmolVLA, π₀.₅, or GR00T) and return the
4
4
  * produced action chunk plus per-stage timings.
@@ -31,9 +31,11 @@ import { type VlaClientRunParams, type VlaClientRunResult, type VlaEmbodimentSel
31
31
  * (`Float32Array` of length `hparams.chunkSize * hparams.maxActionDim`).
32
32
  * Optional for SmolVLA / π₀.₅ (addon samples its own prior when omitted).
33
33
  * Required for GR00T (`hparams.imageInputMode === 'patches'`).
34
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
34
35
  * @returns A `VlaClientRunResult` with the produced `actions` Float32Array
35
36
  * (length `chunkSize * actionDim`), the corresponding `chunkSize` /
36
- * `actionDim` returned by the addon, and optional per-stage `stats`.
37
+ * `actionDim` returned by the addon, and optional per-stage `stats`. The
38
+ * promise carries `requestId` synchronously for `cancel({ requestId })`.
37
39
  *
38
40
  * @example
39
41
  * ```typescript
@@ -54,7 +56,9 @@ import { type VlaClientRunParams, type VlaClientRunResult, type VlaEmbodimentSel
54
56
  * });
55
57
  * ```
56
58
  */
57
- export declare function vla(params: VlaClientRunParams): Promise<VlaClientRunResult>;
59
+ export declare function vla(params: VlaClientRunParams, options?: RPCOptions): Promise<VlaClientRunResult> & {
60
+ requestId: string;
61
+ };
58
62
  /**
59
63
  * Fetch the loaded VLA model's hyperparameters and the active ggml backend
60
64
  * name. Useful to size token / state / noise buffers before calling `vla()`.
@@ -66,7 +70,7 @@ export declare function vla(params: VlaClientRunParams): Promise<VlaClientRunRes
66
70
  */
67
71
  export declare function vlaHparams(params: {
68
72
  modelId: string;
69
- }): Promise<{
73
+ }, options?: RPCOptions): Promise<{
70
74
  hparams: VlaHparams;
71
75
  backendName: string | null;
72
76
  }>;
@@ -108,7 +112,7 @@ export declare function vlaHparams(params: {
108
112
  export declare function vlaSetEmbodiment(params: {
109
113
  modelId: string;
110
114
  embodiment: VlaEmbodimentSelection;
111
- }): Promise<{
115
+ }, options?: RPCOptions): Promise<{
112
116
  hparams: VlaHparams;
113
117
  }>;
114
118
  //# sourceMappingURL=vla.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import { vlaHparamsResponseSchema, vlaRunResponseSchema, vlaSetEmbodimentResponseSchema } from '@qvac/inference/surface';
2
2
  import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
3
+ import { decoratePromise } from '../../utils/decorate-promise.js';
4
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
3
5
  import { invokePlugin } from './invoke-plugin.js';
4
6
  const VLA_RUN_HANDLER = 'vlaRun';
5
7
  const VLA_HPARAMS_HANDLER = 'vlaHparams';
@@ -45,9 +47,11 @@ function f32FromBase64(b64) {
45
47
  * (`Float32Array` of length `hparams.chunkSize * hparams.maxActionDim`).
46
48
  * Optional for SmolVLA / π₀.₅ (addon samples its own prior when omitted).
47
49
  * Required for GR00T (`hparams.imageInputMode === 'patches'`).
50
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
48
51
  * @returns A `VlaClientRunResult` with the produced `actions` Float32Array
49
52
  * (length `chunkSize * actionDim`), the corresponding `chunkSize` /
50
- * `actionDim` returned by the addon, and optional per-stage `stats`.
53
+ * `actionDim` returned by the addon, and optional per-stage `stats`. The
54
+ * promise carries `requestId` synchronously for `cancel({ requestId })`.
51
55
  *
52
56
  * @example
53
57
  * ```typescript
@@ -68,7 +72,11 @@ function f32FromBase64(b64) {
68
72
  * });
69
73
  * ```
70
74
  */
71
- export async function vla(params) {
75
+ export function vla(params, options) {
76
+ const requestId = generateClientRequestId();
77
+ return decoratePromise(runVla(params, requestId, options), { requestId });
78
+ }
79
+ async function runVla(params, requestId, options) {
72
80
  const wireRequest = {
73
81
  type: 'vlaRun',
74
82
  modelId: params.modelId,
@@ -85,8 +93,9 @@ export async function vla(params) {
85
93
  const result = await invokePlugin({
86
94
  modelId: params.modelId,
87
95
  handler: VLA_RUN_HANDLER,
88
- params: wireRequest
89
- });
96
+ params: wireRequest,
97
+ requestId
98
+ }, options);
90
99
  const parsed = vlaRunResponseSchema.parse(result);
91
100
  return {
92
101
  actions: f32FromBase64(parsed.actions),
@@ -104,7 +113,7 @@ export async function vla(params) {
104
113
  * (`"CPU"` / `"Vulkan"` / `"Metal"` / `"OpenCL"` / `null` if the addon
105
114
  * has not surfaced one).
106
115
  */
107
- export async function vlaHparams(params) {
116
+ export async function vlaHparams(params, options) {
108
117
  const wireRequest = {
109
118
  type: 'vlaHparams',
110
119
  modelId: params.modelId
@@ -113,7 +122,7 @@ export async function vlaHparams(params) {
113
122
  modelId: params.modelId,
114
123
  handler: VLA_HPARAMS_HANDLER,
115
124
  params: wireRequest
116
- });
125
+ }, options);
117
126
  return vlaHparamsResponseSchema.parse(result);
118
127
  }
119
128
  /**
@@ -151,7 +160,7 @@ export async function vlaHparams(params) {
151
160
  * console.log(hparams.selectedEmbodimentTag, hparams.numCameras);
152
161
  * ```
153
162
  */
154
- export async function vlaSetEmbodiment(params) {
163
+ export async function vlaSetEmbodiment(params, options) {
155
164
  const wireRequest = {
156
165
  type: 'vlaSetEmbodiment',
157
166
  modelId: params.modelId,
@@ -161,6 +170,6 @@ export async function vlaSetEmbodiment(params) {
161
170
  modelId: params.modelId,
162
171
  handler: VLA_SET_EMBODIMENT_HANDLER,
163
172
  params: wireRequest
164
- });
173
+ }, options);
165
174
  return vlaSetEmbodimentResponseSchema.parse(result);
166
175
  }
@@ -1,6 +1,6 @@
1
1
  import { MAX_SCENE_IMAGE_BYTES, walkKeySchema, worldSceneStreamRequestSchema, worldSceneStreamResponseSchema, worldStepStreamRequestSchema, worldStepStreamResponseSchema } from '@qvac/inference/surface';
2
- import { parseClientInput } from '../parse-input.js';
3
- import { generateClientRequestId } from './client-request-id.js';
2
+ import { parseClientInput } from '../../client/parse-input.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
4
  import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
5
5
  import { InvalidResponseError, RequestValidationFailedError, StreamEndedError } from '../../utils/errors-client.js';
6
6
  import { InferenceCancelledError } from '../../utils/errors-server.js';
@@ -1,5 +1,5 @@
1
- import type { WorldSceneClientParams, WorldStepClientParams } from '@qvac/inference/surface';
2
- import { type WorldSceneResult, type WorldSceneResultWithPack, type WorldStepResult } from './world-result.js';
1
+ import type { RPCOptions, WorldSceneClientParams, WorldStepClientParams } from '@qvac/inference/surface';
2
+ import { type WorldSceneResult, type WorldSceneResultWithPack, type WorldStepResult } from '../../client/api/world-result.js';
3
3
  /**
4
4
  * Builds a world for an ABot-World session: the prompt and first frame are
5
5
  * encoded into a scene pack the walk then runs on.
@@ -72,11 +72,11 @@ import { type WorldSceneResult, type WorldSceneResultWithPack, type WorldStepRes
72
72
  */
73
73
  export declare function worldCreateScene(params: WorldSceneClientParams & {
74
74
  returnPack: true;
75
- }): WorldSceneResultWithPack;
75
+ }, options?: RPCOptions): WorldSceneResultWithPack;
76
76
  export declare function worldCreateScene(params: WorldSceneClientParams & {
77
77
  returnPack?: false | undefined;
78
- }): WorldSceneResult;
79
- export declare function worldCreateScene(params: WorldSceneClientParams): WorldSceneResult | WorldSceneResultWithPack;
78
+ }, options?: RPCOptions): WorldSceneResult;
79
+ export declare function worldCreateScene(params: WorldSceneClientParams, options?: RPCOptions): WorldSceneResult | WorldSceneResultWithPack;
80
80
  /**
81
81
  * Generates the next block of an ABot-World walk under the keys held for it.
82
82
  *
@@ -140,5 +140,5 @@ export declare function worldCreateScene(params: WorldSceneClientParams): WorldS
140
140
  * }
141
141
  * ```
142
142
  */
143
- export declare function worldStep(params: WorldStepClientParams): WorldStepResult;
143
+ export declare function worldStep(params: WorldStepClientParams, options?: RPCOptions): WorldStepResult;
144
144
  //# sourceMappingURL=world.d.ts.map
@@ -1,7 +1,7 @@
1
- import { stream as streamRpc } from '../rpc/rpc-client.js';
2
- import { createWorldSceneResult, createWorldStepResult } from './world-result.js';
3
- export function worldCreateScene(params) {
4
- return createWorldSceneResult(params, streamRpc);
1
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
2
+ import { createWorldSceneResult, createWorldStepResult } from '../../client/api/world-result.js';
3
+ export function worldCreateScene(params, options) {
4
+ return createWorldSceneResult(params, (request) => streamRpc(request, options));
5
5
  }
6
6
  /**
7
7
  * Generates the next block of an ABot-World walk under the keys held for it.
@@ -66,6 +66,6 @@ export function worldCreateScene(params) {
66
66
  * }
67
67
  * ```
68
68
  */
69
- export function worldStep(params) {
70
- return createWorldStepResult(params, streamRpc);
69
+ export function worldStep(params, options) {
70
+ return createWorldStepResult(params, (request) => streamRpc(request, options));
71
71
  }
@@ -4,14 +4,16 @@ interface RPCClient {
4
4
  request(command: number): any;
5
5
  }
6
6
  /**
7
- * Initializes SDK configuration and runtime context.
8
- * Config is loaded once and becomes immutable on the worker side.
7
+ * Sends the worker its first message: config, runtime context and the folder
8
+ * that holds `.qvac`. Config is loaded once and becomes immutable on the
9
+ * worker side.
9
10
  *
10
11
  * @param rpc - The RPC client instance
11
12
  * @param resolveConfig - Runtime-specific config resolver function
12
- * @param runtimeContext - Optional runtime context (platform, device info)
13
+ * @param runtimeContext - Runtime context (platform, device info)
14
+ * @param homeDir - Folder the worker keeps `.qvac` in
13
15
  */
14
- export declare function initializeConfig(rpc: RPCClient, resolveConfig: ResolveConfigFn, runtimeContext?: RuntimeContext): Promise<void>;
16
+ export declare function initializeConfig(rpc: RPCClient, resolveConfig: ResolveConfigFn, runtimeContext: RuntimeContext, homeDir: string): Promise<void>;
15
17
  /**
16
18
  * Legacy function for backward compatibility
17
19
  * @deprecated Use initializeConfig instead
@@ -9,11 +9,12 @@ function applyClientLoggerSettings(config) {
9
9
  setGlobalConsoleOutput(config.loggerConsoleOutput);
10
10
  }
11
11
  }
12
- async function sendInitMessage(rpc, config, runtimeContext) {
12
+ async function sendInitMessage(rpc, config, runtimeContext, homeDir) {
13
13
  const initMessage = {
14
14
  type: '__init_config',
15
15
  config,
16
- runtimeContext
16
+ runtimeContext,
17
+ homeDir
17
18
  };
18
19
  const req = rpc.request(1);
19
20
  req.send(JSON.stringify(initMessage), 'utf8');
@@ -24,33 +25,29 @@ async function sendInitMessage(rpc, config, runtimeContext) {
24
25
  }
25
26
  }
26
27
  /**
27
- * Initializes SDK configuration and runtime context.
28
- * Config is loaded once and becomes immutable on the worker side.
28
+ * Sends the worker its first message: config, runtime context and the folder
29
+ * that holds `.qvac`. Config is loaded once and becomes immutable on the
30
+ * worker side.
29
31
  *
30
32
  * @param rpc - The RPC client instance
31
33
  * @param resolveConfig - Runtime-specific config resolver function
32
- * @param runtimeContext - Optional runtime context (platform, device info)
34
+ * @param runtimeContext - Runtime context (platform, device info)
35
+ * @param homeDir - Folder the worker keeps `.qvac` in
33
36
  */
34
- export async function initializeConfig(rpc, resolveConfig, runtimeContext) {
37
+ export async function initializeConfig(rpc, resolveConfig, runtimeContext, homeDir) {
35
38
  const config = await resolveConfig();
36
- // Nothing to initialize
37
- if (!config && !runtimeContext) {
38
- return;
39
- }
40
- // Apply client-side logger settings
41
39
  if (config) {
42
40
  applyClientLoggerSettings(config);
43
41
  logger.info('📦 Initializing SDK config');
44
42
  }
45
- if (runtimeContext) {
46
- logger.info('📱 Runtime context:', runtimeContext);
47
- }
43
+ logger.info('📱 Runtime context:', runtimeContext);
48
44
  try {
49
- await sendInitMessage(rpc, config, runtimeContext);
45
+ await sendInitMessage(rpc, config, runtimeContext, homeDir);
50
46
  logger.info('✅ Initialization complete');
51
47
  }
52
48
  catch (error) {
53
49
  logger.error('❌ Initialization failed:', error);
50
+ throw error;
54
51
  }
55
52
  }
56
53
  /**
@@ -1,5 +1,8 @@
1
+ import type { RPCOptions } from '@qvac/inference/surface';
1
2
  import { type Logger } from '../logging/index.js';
2
- export declare function startLoggingStreamForModel(modelId: string, modelLogger: Logger): void;
3
- export declare function stopLoggingStreamForModel(modelId: string): void;
4
- export declare function hasActiveStreamForModel(modelId: string): boolean;
3
+ import { loggingStream } from './api/logging-stream.js';
4
+ export declare function startLoggingStreamForModel(modelId: string, modelLogger: Logger, options?: RPCOptions, openStream?: typeof loggingStream): void;
5
+ /** Stops the logging stream the caller behind `options` opened for the model. */
6
+ export declare function stopLoggingStreamForModel(modelId: string, options?: RPCOptions): void;
7
+ export declare function hasActiveStreamForModel(modelId: string, options?: RPCOptions): boolean;
5
8
  //# sourceMappingURL=logging-stream-registry.d.ts.map
@@ -1,14 +1,33 @@
1
1
  import { getClientLogger } from '../logging/index.js';
2
2
  import { loggingStream } from './api/logging-stream.js';
3
+ import { bindSession, sessionOf } from './session-registry.js';
3
4
  const logger = getClientLogger();
5
+ // One stream per caller and model: a session's logger opens its stream as
6
+ // that session, so the worker ends it when the session closes, and another
7
+ // caller sharing the model keeps its own logger.
4
8
  const activeStreams = new Map();
5
- export function startLoggingStreamForModel(modelId, modelLogger) {
6
- if (activeStreams.has(modelId)) {
9
+ function streamKey(modelId, options) {
10
+ return `${options?.sessionId ?? ''}\u0000${modelId}`;
11
+ }
12
+ export function startLoggingStreamForModel(modelId, modelLogger, options, openStream = loggingStream) {
13
+ const key = streamKey(modelId, options);
14
+ if (activeStreams.has(key)) {
7
15
  logger.warn(`Logging stream already active for model ${modelId}`);
8
16
  return;
9
17
  }
10
- const streamIterator = loggingStream({ id: modelId });
11
- activeStreams.set(modelId, { logger: modelLogger, streamIterator });
18
+ const controller = new AbortController();
19
+ // Only the caller's identity carries over from the load: its timeout and
20
+ // profiling options do not apply to a stream that lives as long as the model.
21
+ const streamOptions = { signal: controller.signal };
22
+ if (options?.sessionId !== undefined) {
23
+ streamOptions.sessionId = options.sessionId;
24
+ const record = sessionOf(options);
25
+ if (record)
26
+ bindSession(streamOptions, record);
27
+ }
28
+ const streamIterator = openStream({ id: modelId }, streamOptions);
29
+ const entry = { logger: modelLogger, controller };
30
+ activeStreams.set(key, entry);
12
31
  try {
13
32
  void (async () => {
14
33
  try {
@@ -36,26 +55,29 @@ export function startLoggingStreamForModel(modelId, modelLogger) {
36
55
  logger.error(`Logging stream error for model ${modelId}:`, error);
37
56
  }
38
57
  finally {
39
- activeStreams.delete(modelId);
58
+ // A reload may have replaced this entry.
59
+ if (activeStreams.get(key) === entry)
60
+ activeStreams.delete(key);
40
61
  }
41
62
  })();
42
63
  }
43
64
  catch (error) {
44
65
  logger.error(`Failed to start logging stream for model ${modelId}:`, error);
45
- activeStreams.delete(modelId);
66
+ activeStreams.delete(key);
46
67
  throw error;
47
68
  }
48
69
  }
49
- export function stopLoggingStreamForModel(modelId) {
50
- const stream = activeStreams.get(modelId);
70
+ /** Stops the logging stream the caller behind `options` opened for the model. */
71
+ export function stopLoggingStreamForModel(modelId, options) {
72
+ const key = streamKey(modelId, options);
73
+ const stream = activeStreams.get(key);
51
74
  if (stream) {
52
- activeStreams.delete(modelId);
53
- // Terminate the stream iterator - this will close the RPC connection
54
- // and the server-side async generator will automatically terminate
55
- void stream.streamIterator.return(undefined);
75
+ activeStreams.delete(key);
76
+ // `return()` would wait for a log an unloaded model never sends.
77
+ stream.controller.abort();
56
78
  logger.debug(`Stopped logging stream for model ${modelId}`);
57
79
  }
58
80
  }
59
- export function hasActiveStreamForModel(modelId) {
60
- return activeStreams.has(modelId);
81
+ export function hasActiveStreamForModel(modelId, options) {
82
+ return activeStreams.has(streamKey(modelId, options));
61
83
  }
@@ -1,4 +1,4 @@
1
- import * as hostApi from './api/index.js';
1
+ import * as hostApi from '../client/api/index.js';
2
2
  import type { QvacPlugin } from '@qvac/inference/surface';
3
3
  /**
4
4
  * Register plugins and return the client host API.
@@ -1,5 +1,5 @@
1
1
  import { registerPlugins } from '../server/plugins/index.js';
2
- import * as hostApi from './api/index.js';
2
+ import * as hostApi from '../client/api/index.js';
3
3
  /**
4
4
  * Register plugins and return the client host API.
5
5
  */
@@ -0,0 +1,29 @@
1
+ /** The field `bundleSdk` sets in a bundled worker's package.json to the `@qvac/sdk` version that bundled it. */
2
+ export declare const BUNDLED_SDK_VERSION_FIELD = "qvacSdkVersion";
3
+ /** The field `bundleSdk` sets in a bundled worker's package.json to the target it bundled for. */
4
+ export declare const BUNDLED_TARGET_FIELD = "qvacTarget";
5
+ /**
6
+ * The file `bundleSdk` writes at the root of a Kotlin or Python harness, which
7
+ * has no package.json, with the same fields as a JavaScript harness stamp.
8
+ */
9
+ export declare const BUNDLE_RECORD_FILE = "qvac-bundle.json";
10
+ /**
11
+ * The version of the `@qvac/sdk` package above `from`, which for this module
12
+ * is the SDK's own. Undefined when the SDK was bundled into the app.
13
+ */
14
+ export declare function installedSdkVersion(from?: string): string | undefined;
15
+ /**
16
+ * A warning when the bundled worker in `dir` was bundled by another
17
+ * `@qvac/sdk` than `installed`, or null when the versions match or the bundle
18
+ * cannot be read.
19
+ */
20
+ export declare function bundledSdkMismatch(dir: string, installed: string): string | null;
21
+ /** The target the worker in `dir` was bundled for, or undefined when it does not say. */
22
+ export declare function bundledTarget(dir: string): string | undefined;
23
+ /**
24
+ * The target the bundle at `bundlePath` was bundled for. A Kotlin or Python
25
+ * harness keeps its bundle in a subfolder, so the nearest folder above it with
26
+ * a record or a package.json says; undefined when that folder does not record it.
27
+ */
28
+ export declare function bundleTargetOf(bundlePath: string): string | undefined;
29
+ //# sourceMappingURL=bundle-stamp.d.ts.map
@@ -0,0 +1,75 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ /** The field `bundleSdk` sets in a bundled worker's package.json to the `@qvac/sdk` version that bundled it. */
5
+ export const BUNDLED_SDK_VERSION_FIELD = 'qvacSdkVersion';
6
+ /** The field `bundleSdk` sets in a bundled worker's package.json to the target it bundled for. */
7
+ export const BUNDLED_TARGET_FIELD = 'qvacTarget';
8
+ /**
9
+ * The file `bundleSdk` writes at the root of a Kotlin or Python harness, which
10
+ * has no package.json, with the same fields as a JavaScript harness stamp.
11
+ */
12
+ export const BUNDLE_RECORD_FILE = 'qvac-bundle.json';
13
+ const SDK_NAME = '@qvac/sdk';
14
+ function readJson(file) {
15
+ try {
16
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ function readManifest(dir) {
23
+ return readJson(path.join(dir, 'package.json'));
24
+ }
25
+ /**
26
+ * The version of the `@qvac/sdk` package above `from`, which for this module
27
+ * is the SDK's own. Undefined when the SDK was bundled into the app.
28
+ */
29
+ export function installedSdkVersion(from = path.dirname(fileURLToPath(import.meta.url))) {
30
+ for (let dir = from;; dir = path.dirname(dir)) {
31
+ const manifest = fs.existsSync(path.join(dir, 'package.json')) ? readManifest(dir) : null;
32
+ if (manifest?.['name'] === SDK_NAME) {
33
+ return typeof manifest['version'] === 'string' ? manifest['version'] : undefined;
34
+ }
35
+ if (path.dirname(dir) === dir)
36
+ return undefined;
37
+ }
38
+ }
39
+ /**
40
+ * A warning when the bundled worker in `dir` was bundled by another
41
+ * `@qvac/sdk` than `installed`, or null when the versions match or the bundle
42
+ * cannot be read.
43
+ */
44
+ export function bundledSdkMismatch(dir, installed) {
45
+ const manifest = readManifest(dir);
46
+ if (manifest === null)
47
+ return null;
48
+ const bundled = manifest[BUNDLED_SDK_VERSION_FIELD];
49
+ if (bundled === installed)
50
+ return null;
51
+ const bundledBy = typeof bundled === 'string' ? `@qvac/sdk ${bundled}` : 'an older @qvac/sdk';
52
+ return (`The worker in ${dir} was bundled by ${bundledBy}, but @qvac/sdk ${installed} is installed. ` +
53
+ 'Run `qvac bundle sdk` again so the worker matches the SDK.');
54
+ }
55
+ /** The target the worker in `dir` was bundled for, or undefined when it does not say. */
56
+ export function bundledTarget(dir) {
57
+ const target = readManifest(dir)?.[BUNDLED_TARGET_FIELD];
58
+ return typeof target === 'string' ? target : undefined;
59
+ }
60
+ /**
61
+ * The target the bundle at `bundlePath` was bundled for. A Kotlin or Python
62
+ * harness keeps its bundle in a subfolder, so the nearest folder above it with
63
+ * a record or a package.json says; undefined when that folder does not record it.
64
+ */
65
+ export function bundleTargetOf(bundlePath) {
66
+ for (let dir = path.dirname(bundlePath);; dir = path.dirname(dir)) {
67
+ const record = readJson(path.join(dir, BUNDLE_RECORD_FILE));
68
+ if (record !== null || fs.existsSync(path.join(dir, 'package.json'))) {
69
+ const target = (record ?? readManifest(dir))?.[BUNDLED_TARGET_FIELD];
70
+ return typeof target === 'string' ? target : undefined;
71
+ }
72
+ if (path.dirname(dir) === dir)
73
+ return undefined;
74
+ }
75
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getHomeDir(): Promise<string>;
2
+ //# sourceMappingURL=expo-home-dir.d.ts.map
@@ -0,0 +1,4 @@
1
+ export async function getHomeDir() {
2
+ const { Paths } = await import('expo-file-system');
3
+ return Paths.document.uri.replace('file://', '');
4
+ }