@qvac/sdk 0.23.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 (239) hide show
  1. package/NOTICE +115 -58
  2. package/README.md +10 -13
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
  5. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  6. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  7. package/dist/examples/assess-model-fit.d.ts +7 -9
  8. package/dist/examples/assess-model-fit.js +22 -43
  9. package/dist/examples/calc-tokens.d.ts +2 -0
  10. package/dist/examples/calc-tokens.js +21 -0
  11. package/dist/examples/classification/classify-image.js +11 -5
  12. package/dist/examples/completion-stop-reason.d.ts +3 -3
  13. package/dist/examples/completion-stop-reason.js +4 -4
  14. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  15. package/dist/examples/diffusion-flux3-klein.js +102 -0
  16. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  17. package/dist/examples/diffusion-moss-image.js +126 -0
  18. package/dist/examples/diffusion-qwen-image-21.js +15 -4
  19. package/dist/examples/embed-multimodal.d.ts +2 -0
  20. package/dist/examples/embed-multimodal.js +80 -0
  21. package/dist/examples/embed-p2p.js +2 -2
  22. package/dist/examples/image/megaloc.d.ts +2 -0
  23. package/dist/examples/image/megaloc.js +37 -0
  24. package/dist/examples/llamacpp-multimodal.js +18 -0
  25. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  26. package/dist/examples/rag/rag-turbovec.js +2 -2
  27. package/dist/examples/sessions.d.ts +17 -0
  28. package/dist/examples/sessions.js +63 -0
  29. package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
  30. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  31. package/dist/scripts/contract/build-contract.d.ts +2 -1
  32. package/dist/scripts/contract/build-contract.js +13 -1
  33. package/dist/scripts/contract/constants-registry.d.ts +17 -0
  34. package/dist/scripts/contract/constants-registry.js +8 -2
  35. package/dist/scripts/contract/method-shapes.d.ts +4 -0
  36. package/dist/scripts/contract/method-shapes.js +4 -0
  37. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  38. package/dist/scripts/enforce-inference-versions.js +28 -18
  39. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  40. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  41. package/dist/src/client/api/assess-model-fit.js +18 -31
  42. package/dist/src/client/api/audio-edit.d.ts +5 -3
  43. package/dist/src/client/api/audio-edit.js +5 -3
  44. package/dist/src/client/api/audio-gen-result.js +134 -45
  45. package/dist/src/client/api/audio-gen.d.ts +40 -3
  46. package/dist/src/client/api/audio-gen.js +40 -3
  47. package/dist/src/client/api/audio-understand.d.ts +2 -2
  48. package/dist/src/client/api/audio-understand.js +2 -2
  49. package/dist/src/client/api/batch-completion.js +2 -1
  50. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  51. package/dist/src/client/api/calc-tokens.js +44 -0
  52. package/dist/src/client/api/cancel.d.ts +2 -2
  53. package/dist/src/client/api/cancel.js +2 -2
  54. package/dist/src/client/api/classify.d.ts +12 -5
  55. package/dist/src/client/api/classify.js +17 -5
  56. package/dist/src/client/api/client-request-id.d.ts +0 -15
  57. package/dist/src/client/api/client-request-id.js +15 -12
  58. package/dist/src/client/api/completion-stream.d.ts +8 -1
  59. package/dist/src/client/api/completion-stream.js +10 -1
  60. package/dist/src/client/api/delete-cache.d.ts +9 -2
  61. package/dist/src/client/api/delete-cache.js +13 -3
  62. package/dist/src/client/api/diffusion.d.ts +20 -4
  63. package/dist/src/client/api/diffusion.js +23 -5
  64. package/dist/src/client/api/embed.d.ts +82 -29
  65. package/dist/src/client/api/embed.js +64 -19
  66. package/dist/src/client/api/get-model-info.d.ts +2 -2
  67. package/dist/src/client/api/get-model-info.js +2 -2
  68. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  69. package/dist/src/client/api/get-system-resources.js +2 -2
  70. package/dist/src/client/api/heartbeat.d.ts +3 -2
  71. package/dist/src/client/api/heartbeat.js +3 -2
  72. package/dist/src/client/api/index.d.ts +4 -3
  73. package/dist/src/client/api/index.js +2 -1
  74. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  75. package/dist/src/client/api/invoke-plugin.js +17 -2
  76. package/dist/src/client/api/load-model.js +5 -2
  77. package/dist/src/client/api/ocr.d.ts +5 -3
  78. package/dist/src/client/api/ocr.js +44 -21
  79. package/dist/src/client/api/rag.d.ts +1 -1
  80. package/dist/src/client/api/rag.js +1 -1
  81. package/dist/src/client/api/registry.d.ts +17 -7
  82. package/dist/src/client/api/registry.js +37 -12
  83. package/dist/src/client/api/resume.d.ts +2 -1
  84. package/dist/src/client/api/resume.js +2 -2
  85. package/dist/src/client/api/rpc-server.d.ts +4 -4
  86. package/dist/src/client/api/rpc-server.js +10 -10
  87. package/dist/src/client/api/state.d.ts +2 -2
  88. package/dist/src/client/api/state.js +2 -2
  89. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  90. package/dist/src/client/api/subscribe-logs.js +2 -2
  91. package/dist/src/client/api/suspend.d.ts +4 -2
  92. package/dist/src/client/api/suspend.js +4 -3
  93. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  94. package/dist/src/client/api/text-to-speech.js +83 -29
  95. package/dist/src/client/api/transcribe.d.ts +6 -2
  96. package/dist/src/client/api/transcribe.js +7 -1
  97. package/dist/src/client/api/unload-model.d.ts +19 -7
  98. package/dist/src/client/api/unload-model.js +29 -11
  99. package/dist/src/client/api/upscale.d.ts +6 -3
  100. package/dist/src/client/api/upscale.js +9 -4
  101. package/dist/src/client/api/vector-index.d.ts +50 -16
  102. package/dist/src/client/api/vector-index.js +100 -48
  103. package/dist/src/client/api/video-request.d.ts +5 -5
  104. package/dist/src/client/api/video.d.ts +3 -2
  105. package/dist/src/client/api/video.js +3 -2
  106. package/dist/src/client/api/vla.d.ts +9 -5
  107. package/dist/src/client/api/vla.js +17 -8
  108. package/dist/src/client/api/world.d.ts +5 -5
  109. package/dist/src/client/api/world.js +4 -4
  110. package/dist/src/client/init-hooks.d.ts +6 -4
  111. package/dist/src/client/init-hooks.js +12 -15
  112. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  113. package/dist/src/client/logging-stream-registry.js +31 -12
  114. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  115. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  116. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  117. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  118. package/dist/src/client/rpc/expo-rpc-client.js +189 -135
  119. package/dist/src/client/rpc/node-rpc-client.js +322 -413
  120. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  121. package/dist/src/client/rpc/pear-runtime.js +12 -0
  122. package/dist/src/client/rpc/rpc-client.d.ts +5 -4
  123. package/dist/src/client/rpc/rpc-client.js +126 -23
  124. package/dist/src/client/rpc/rpc-error.js +21 -2
  125. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  126. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  127. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  128. package/dist/src/client/rpc/worker-failure.js +61 -0
  129. package/dist/src/client/session-registry.d.ts +75 -0
  130. package/dist/src/client/session-registry.js +149 -0
  131. package/dist/src/client/session.d.ts +125 -0
  132. package/dist/src/client/session.js +148 -0
  133. package/dist/src/commands/bundle/addons.d.ts +14 -0
  134. package/dist/src/commands/bundle/addons.js +65 -0
  135. package/dist/src/commands/bundle/constants.js +1 -0
  136. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  137. package/dist/src/commands/bundle/entry-gen.js +17 -50
  138. package/dist/src/commands/bundle/index.d.ts +59 -13
  139. package/dist/src/commands/bundle/index.js +345 -121
  140. package/dist/src/commands/bundle/link.d.ts +58 -0
  141. package/dist/src/commands/bundle/link.js +135 -0
  142. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  143. package/dist/src/commands/bundle/node-support.js +23 -0
  144. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  145. package/dist/src/commands/bundle/read-bundle.js +27 -0
  146. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  147. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  148. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  149. package/dist/src/commands/bundle/scratch.js +178 -0
  150. package/dist/src/commands/bundle/targets.d.ts +14 -0
  151. package/dist/src/commands/bundle/targets.js +37 -0
  152. package/dist/src/commands/host-prebuilds/index.d.ts +5 -4
  153. package/dist/src/commands/host-prebuilds/index.js +9 -7
  154. package/dist/src/commands/index.d.ts +4 -3
  155. package/dist/src/commands/verify/abi.d.ts +20 -14
  156. package/dist/src/commands/verify/abi.js +11 -79
  157. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  158. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  159. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  160. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  161. package/dist/src/commands/verify/bundle-source.js +25 -21
  162. package/dist/src/commands/verify/engines-advice.d.ts +2 -8
  163. package/dist/src/commands/verify/engines-advice.js +7 -54
  164. package/dist/src/commands/verify/index.d.ts +30 -29
  165. package/dist/src/commands/verify/index.js +92 -200
  166. package/dist/src/commands/verify/prebuilds.d.ts +3 -5
  167. package/dist/src/commands/verify/prebuilds.js +1 -2
  168. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  169. package/dist/src/commands/verify/resource-collectors.js +1 -50
  170. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  171. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  172. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  173. package/dist/src/expo/plugins/withBareKit.js +204 -0
  174. package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
  175. package/dist/src/expo/plugins/withMobileBundle.js +36 -57
  176. package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
  177. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  178. package/dist/src/index.d.ts +6 -5
  179. package/dist/src/index.js +10 -14
  180. package/dist/src/logging/utils.js +10 -2
  181. package/dist/src/plugin-ids.d.ts +2 -1
  182. package/dist/src/plugin-ids.js +2 -0
  183. package/dist/src/schemas/public.d.ts +1 -1
  184. package/dist/src/schemas/public.js +1 -1
  185. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  186. package/dist/src/schemas/sdk-errors-client.js +30 -36
  187. package/dist/src/schemas/sdk-errors-server.d.ts +11 -1
  188. package/dist/src/schemas/sdk-errors-server.js +60 -2
  189. package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
  190. package/dist/src/server/rpc/rpc-utils.js +39 -5
  191. package/dist/src/utils/errors-client.d.ts +37 -29
  192. package/dist/src/utils/errors-client.js +50 -41
  193. package/dist/src/utils/errors-server.d.ts +59 -1
  194. package/dist/src/utils/errors-server.js +110 -1
  195. package/dist/src/utils/withTimeout.js +34 -17
  196. package/dist/src/worker/handle-request.js +25 -22
  197. package/dist/src/worker/handler-utils.d.ts +2 -6
  198. package/dist/src/worker/handler-utils.js +2 -20
  199. package/dist/src/worker/index.d.ts +2 -4
  200. package/dist/src/worker/index.js +23 -35
  201. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  202. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  203. package/dist/src/worker/shim.d.ts +4 -0
  204. package/dist/src/worker/shim.js +7 -0
  205. package/dist/src/worker/start.d.ts +9 -0
  206. package/dist/src/worker/start.js +16 -0
  207. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  208. package/dist/src/worker/unbundled-shim.js +4 -0
  209. package/docs/system-resources-support-matrix.md +27 -19
  210. package/package.json +62 -51
  211. package/src/electron-forge/index.cjs +65 -91
  212. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  213. package/dist/examples/model-fit-ui/server.js +0 -221
  214. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  215. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  216. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  217. package/dist/src/client/rpc/init-timeout.js +0 -25
  218. package/dist/src/client/rpc/ipc-socket-path.d.ts +0 -11
  219. package/dist/src/client/rpc/ipc-socket-path.js +0 -30
  220. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  221. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  222. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  223. package/dist/src/commands/bundle/bare-pack.js +0 -77
  224. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  225. package/dist/src/commands/bundle/manifest.js +0 -192
  226. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  227. package/dist/src/expo/plugins/link-addons.js +0 -65
  228. package/dist/src/pear/pre.d.ts +0 -21
  229. package/dist/src/pear/pre.js +0 -450
  230. package/dist/src/server/env.d.ts +0 -22
  231. package/dist/src/server/env.js +0 -59
  232. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  233. package/dist/src/server/utils/qvac-paths.js +0 -5
  234. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  235. package/dist/src/server/utils/worker-lock.js +0 -67
  236. package/dist/src/worker/create-server.d.ts +0 -8
  237. package/dist/src/worker/create-server.js +0 -51
  238. package/dist/src/worker/lifecycle.d.ts +0 -23
  239. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,10 +1,12 @@
1
- import { type DiffusionClientParams, type DiffusionStats } from '@qvac/inference/surface';
1
+ import { type DiffusionClientParams, type DiffusionStats, type RPCOptions } from '@qvac/inference/surface';
2
2
  export interface DiffusionProgressTick {
3
3
  step: number;
4
4
  totalSteps: number;
5
5
  elapsedMs: number;
6
6
  }
7
7
  interface DiffusionResult {
8
+ /** Stable id of this generation; pass to `cancel({ requestId })` to stop it. */
9
+ requestId: string;
8
10
  progressStream: AsyncGenerator<DiffusionProgressTick>;
9
11
  outputs: Promise<Uint8Array[]>;
10
12
  stats: Promise<DiffusionStats | undefined>;
@@ -13,7 +15,8 @@ interface DiffusionResult {
13
15
  * Generates images using a loaded diffusion model.
14
16
  *
15
17
  * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
16
- * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
18
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
19
+ * @returns A result object exposing `requestId` (stable identifier for this generation, for `cancel({ requestId })`), `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
17
20
  * @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
18
21
  * @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
19
22
  *
@@ -32,7 +35,7 @@ interface DiffusionResult {
32
35
  * const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
33
36
  *
34
37
  * // img2img (FLUX.2 — in-context conditioning)
35
- * // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
38
+ * // IMPORTANT: FLUX.2 img2img requires `prediction: "flux2_flow"` to be set on the
36
39
  * // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
37
40
  * // modelConfig: { prediction: "flux2_flow" } })`).
38
41
  * const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
@@ -52,6 +55,19 @@ interface DiffusionResult {
52
55
  * height: 768,
53
56
  * });
54
57
  *
58
+ * // FLUX.3 Image Klein reference editing. Load the Qwen3-VL 4B encoder and the
59
+ * // FLUX.2 VAE; the engine detects FLUX.3 from the weights, so leave `prediction` unset.
60
+ * const { outputs: flux3Edit } = diffusion({
61
+ * modelId,
62
+ * prompt: "Place the subject in a lush garden, preserving its appearance.",
63
+ * init_images: [refA],
64
+ * width: 512,
65
+ * height: 512,
66
+ * steps: 16,
67
+ * cfg_scale: 1,
68
+ * sampling_method: "euler",
69
+ * });
70
+ *
55
71
  * // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
56
72
  * // vision projector, and 2.1 VAE from your local files first.
57
73
  * const { outputs: edited } = diffusion({
@@ -105,6 +121,6 @@ interface DiffusionResult {
105
121
  * const buffers = await outputs;
106
122
  * ```
107
123
  */
108
- export declare function diffusion(params: DiffusionClientParams): DiffusionResult;
124
+ export declare function diffusion(params: DiffusionClientParams, options?: RPCOptions): DiffusionResult;
109
125
  export {};
110
126
  //# sourceMappingURL=diffusion.d.ts.map
@@ -1,11 +1,13 @@
1
1
  import { diffusionStreamResponseSchema } from '@qvac/inference/surface';
2
2
  import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
3
4
  import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
4
5
  /**
5
6
  * Generates images using a loaded diffusion model.
6
7
  *
7
8
  * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
8
- * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
9
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
10
+ * @returns A result object exposing `requestId` (stable identifier for this generation, for `cancel({ requestId })`), `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
9
11
  * @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
10
12
  * @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
11
13
  *
@@ -24,7 +26,7 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
24
26
  * const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
25
27
  *
26
28
  * // img2img (FLUX.2 — in-context conditioning)
27
- * // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
29
+ * // IMPORTANT: FLUX.2 img2img requires `prediction: "flux2_flow"` to be set on the
28
30
  * // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
29
31
  * // modelConfig: { prediction: "flux2_flow" } })`).
30
32
  * const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
@@ -44,6 +46,19 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
44
46
  * height: 768,
45
47
  * });
46
48
  *
49
+ * // FLUX.3 Image Klein reference editing. Load the Qwen3-VL 4B encoder and the
50
+ * // FLUX.2 VAE; the engine detects FLUX.3 from the weights, so leave `prediction` unset.
51
+ * const { outputs: flux3Edit } = diffusion({
52
+ * modelId,
53
+ * prompt: "Place the subject in a lush garden, preserving its appearance.",
54
+ * init_images: [refA],
55
+ * width: 512,
56
+ * height: 512,
57
+ * steps: 16,
58
+ * cfg_scale: 1,
59
+ * sampling_method: "euler",
60
+ * });
61
+ *
47
62
  * // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
48
63
  * // vision projector, and 2.1 VAE from your local files first.
49
64
  * const { outputs: edited } = diffusion({
@@ -97,15 +112,17 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
97
112
  * const buffers = await outputs;
98
113
  * ```
99
114
  */
100
- export function diffusion(params) {
115
+ export function diffusion(params, options) {
101
116
  const { init_image, init_images, ...rest } = params;
117
+ const requestId = generateClientRequestId();
102
118
  const request = {
103
119
  ...rest,
104
120
  ...(init_image !== undefined && { init_image: encodeBase64(init_image) }),
105
121
  ...(init_images !== undefined && {
106
122
  init_images: init_images.map(encodeBase64)
107
123
  }),
108
- type: 'diffusionStream'
124
+ type: 'diffusionStream',
125
+ requestId
109
126
  };
110
127
  let statsResolver = () => { };
111
128
  let statsRejecter = () => { };
@@ -128,7 +145,7 @@ export function diffusion(params) {
128
145
  outputsPromise.catch(() => { });
129
146
  const processResponses = async () => {
130
147
  try {
131
- for await (const response of streamRpc(request)) {
148
+ for await (const response of streamRpc(request, options)) {
132
149
  if (response &&
133
150
  typeof response === 'object' &&
134
151
  'type' in response &&
@@ -187,6 +204,7 @@ export function diffusion(params) {
187
204
  }
188
205
  })();
189
206
  return {
207
+ requestId,
190
208
  progressStream,
191
209
  outputs: outputsPromise,
192
210
  stats: statsPromise
@@ -1,42 +1,95 @@
1
- import { type EmbedStats, type RPCOptions } from '@qvac/inference/surface';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
+ import { type EmbedClientParams, type EmbedBatchClientParams, type EmbedClientInput, type EmbedInput, type EmbedStats, type RPCOptions } from '@qvac/inference/surface';
3
+ type EmbedResult<T> = Promise<{
4
+ embedding: T;
5
+ stats?: EmbedStats;
6
+ }> & {
7
+ requestId: string;
8
+ };
9
+ /**
10
+ * Embeds one input supported by the loaded model.
11
+ *
12
+ * @overloadLabel "Single input"
13
+ * @param params - Model identifier and text, ordered text/media parts, or image bytes.
14
+ * @param options - Optional RPC options.
15
+ * @returns One vector, optional statistics, and a synchronous requestId for cancellation.
16
+ * @throws {QvacErrorBase} When validation or inference fails.
17
+ */
18
+ export declare function embed(params: {
19
+ modelId: string;
20
+ input: EmbedClientInput;
21
+ text?: never;
22
+ inputs?: never;
23
+ }, options?: RPCOptions): EmbedResult<number[]>;
2
24
  /**
3
- * Generates embeddings for a single text using a specified model.
25
+ * Embeds one text string.
4
26
  *
5
27
  * @overloadLabel "Single text"
6
- * @param params - The parameters for the embedding
7
- * @param params.modelId - The identifier of the embedding model to use
8
- * @param params.text - The input text to embed
9
- * @param options - Optional RPC options including per-call profiling
10
- * @returns A promise (decorated with `requestId`) resolving to an object with `embedding` (a single `number[]` vector) and optional `stats` performance data.
11
- * @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
28
+ * @param params - Model identifier and text.
29
+ * @param options - Optional RPC options.
30
+ * @returns One vector with optional statistics and a requestId for cancellation.
31
+ * @throws {QvacErrorBase} When validation or inference fails.
12
32
  */
13
33
  export declare function embed(params: {
14
34
  modelId: string;
15
35
  text: string;
16
- }, options?: RPCOptions): Promise<{
17
- embedding: number[];
18
- stats?: EmbedStats;
19
- }> & {
20
- requestId: string;
21
- };
36
+ inputs?: never;
37
+ input?: never;
38
+ }, options?: RPCOptions): EmbedResult<number[]>;
22
39
  /**
23
- * Generates embeddings for multiple texts using a specified model.
24
- *
25
- * @overloadLabel "Multiple texts"
26
- * @param params - The parameters for the embedding
27
- * @param params.modelId - The identifier of the embedding model to use
28
- * @param params.text - The input texts to embed
29
- * @param options - Optional RPC options including per-call profiling
30
- * @returns A promise (decorated with `requestId`) resolving to an object with `embedding` (one `number[]` vector per input text, i.e. `number[][]`) and optional `stats` performance data.
31
- * @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
40
+ * @deprecated Use `embedBatch({ modelId, inputs })` instead. This overload will be
41
+ * removed in the next major version.
42
+ *
43
+ * Embeds each string in a text array.
44
+ *
45
+ * @overloadLabel "Legacy text batch (deprecated)"
46
+ * @param params - Model identifier and text strings.
47
+ * @param options - Optional RPC options.
48
+ * @returns One vector per string, optional statistics, and a requestId.
49
+ * @throws {QvacErrorBase} When validation or inference fails.
32
50
  */
33
51
  export declare function embed(params: {
34
52
  modelId: string;
35
53
  text: string[];
36
- }, options?: RPCOptions): Promise<{
37
- embedding: number[][];
38
- stats?: EmbedStats;
39
- }> & {
40
- requestId: string;
41
- };
54
+ inputs?: never;
55
+ input?: never;
56
+ }, options?: RPCOptions): EmbedResult<number[][]>;
57
+ /**
58
+ * @deprecated Use `embedBatch({ modelId, inputs })` instead. This overload will be
59
+ * removed in the next major version.
60
+ *
61
+ * Embeds each text or ordered text/media input.
62
+ *
63
+ * @overloadLabel "Legacy inputs batch (deprecated)"
64
+ * @param params - Model identifier and text or ordered text/media inputs. Images go through embedBatch.
65
+ * @param options - Optional RPC options.
66
+ * @returns One vector per input, optional statistics, and a requestId.
67
+ * @throws {QvacErrorBase} When validation or inference fails.
68
+ */
69
+ export declare function embed(params: {
70
+ modelId: string;
71
+ inputs: EmbedInput[];
72
+ text?: never;
73
+ input?: never;
74
+ }, options?: RPCOptions): EmbedResult<number[][]>;
75
+ /**
76
+ * Embeds a single input or a legacy batch supported by the loaded model.
77
+ *
78
+ * @param params - Model identifier and input.
79
+ * @param options - Optional RPC options.
80
+ * @returns Embeddings, optional statistics, and a requestId for cancellation.
81
+ * @throws {QvacErrorBase} When validation or inference fails.
82
+ */
83
+ export declare function embed(params: EmbedClientParams, options?: RPCOptions): EmbedResult<number[] | number[][]>;
84
+ /**
85
+ * Embeds a batch of inputs supported by the loaded model, in input order.
86
+ *
87
+ * @param params - Model identifier and a non-empty list of inputs.
88
+ * @param options - Optional RPC options.
89
+ * @returns One vector per input, including one-item batches, optional statistics, and a requestId.
90
+ * @throws {QvacErrorBase} When validation or inference fails.
91
+ */
92
+ export declare function embedBatch(params: EmbedBatchClientParams, options?: RPCOptions): EmbedResult<number[][]>;
93
+ export declare function createEmbedCall(params: EmbedClientParams, options?: RPCOptions, sendRequest?: typeof send): EmbedResult<number[] | number[][]>;
94
+ export {};
42
95
  //# sourceMappingURL=embed.d.ts.map
@@ -1,30 +1,75 @@
1
1
  import { send } from '../../client/rpc/rpc-client.js';
2
- import {} from '@qvac/inference/surface';
2
+ import { embedClientParamsSchema, embedBatchClientParamsSchema, embedResponseSchema, embedBatchResponseSchema } from '@qvac/inference/surface';
3
3
  import { InvalidResponseError } from '../../utils/errors-client.js';
4
+ import { parseClientInput } from '../../client/parse-input.js';
5
+ import { encodeBase64 } from '../../utils/encoding.js';
4
6
  import { decoratePromise } from '../../utils/decorate-promise.js';
5
7
  import { generateClientRequestId } from '../../client/api/client-request-id.js';
8
+ import { getClientLogger } from '../../logging/index.js';
9
+ const logger = getClientLogger();
6
10
  export function embed(params, options) {
7
- // Client-generated `requestId` is surfaced synchronously on the
8
- // returned promise so the caller can `cancel({ requestId })` before
9
- // `await` resolves. The same id is threaded onto the wire envelope so
10
- // the server's registry entry uses it as the canonical key —
11
- // matching the `loadModel` / `downloadAsset` / `completion` shape.
11
+ return createEmbedCall(params, options);
12
+ }
13
+ /**
14
+ * Embeds a batch of inputs supported by the loaded model, in input order.
15
+ *
16
+ * @param params - Model identifier and a non-empty list of inputs.
17
+ * @param options - Optional RPC options.
18
+ * @returns One vector per input, including one-item batches, optional statistics, and a requestId.
19
+ * @throws {QvacErrorBase} When validation or inference fails.
20
+ */
21
+ export function embedBatch(params, options) {
12
22
  const requestId = generateClientRequestId();
13
- const inner = runEmbed(params, requestId, options);
14
- return decoratePromise(inner, { requestId });
23
+ return decoratePromise(runEmbedBatch(params, requestId, options), { requestId });
15
24
  }
16
- async function runEmbed(params, requestId, options) {
17
- const request = {
18
- type: 'embed',
19
- ...params,
20
- requestId
21
- };
22
- const response = await send(request, options);
23
- if (response.type !== 'embed') {
24
- throw new InvalidResponseError('embed');
25
+ export function createEmbedCall(params, options, sendRequest = send) {
26
+ const requestId = generateClientRequestId();
27
+ return decoratePromise(runEmbed(params, requestId, options, sendRequest), { requestId });
28
+ }
29
+ function encodeInput(input) {
30
+ return typeof input === 'object' && !Array.isArray(input)
31
+ ? { ...input, image: encodeBase64(input.image) }
32
+ : input;
33
+ }
34
+ async function runEmbed(params, requestId, options, sendRequest) {
35
+ const parsed = parseClientInput(embedClientParamsSchema, params);
36
+ if (parsed.inputs !== undefined) {
37
+ logger.warn('embed() with inputs is deprecated. Use embedBatch() instead.');
25
38
  }
39
+ else if (Array.isArray(parsed.text)) {
40
+ logger.warn('embed() with a text array is deprecated. Use embedBatch() instead.');
41
+ }
42
+ const request = parsed.input !== undefined
43
+ ? { modelId: parsed.modelId, input: encodeInput(parsed.input) }
44
+ : parsed.inputs !== undefined
45
+ ? { modelId: parsed.modelId, inputs: parsed.inputs }
46
+ : { modelId: parsed.modelId, text: parsed.text };
47
+ const response = await sendRequest({ ...request, type: 'embed', requestId }, options);
48
+ if (response.type !== 'embed')
49
+ throw new InvalidResponseError('embed');
50
+ const result = embedResponseSchema.safeParse(response);
51
+ if (!result.success)
52
+ throw new InvalidResponseError('embed', result.error);
53
+ return {
54
+ embedding: result.data.embedding,
55
+ ...(result.data.stats !== undefined && { stats: result.data.stats })
56
+ };
57
+ }
58
+ async function runEmbedBatch(params, requestId, options) {
59
+ const parsed = parseClientInput(embedBatchClientParamsSchema, params);
60
+ const response = await send({
61
+ modelId: parsed.modelId,
62
+ inputs: parsed.inputs.map(encodeInput),
63
+ type: 'embedBatch',
64
+ requestId
65
+ }, options);
66
+ if (response.type !== 'embedBatch')
67
+ throw new InvalidResponseError('embedBatch');
68
+ const result = embedBatchResponseSchema.safeParse(response);
69
+ if (!result.success)
70
+ throw new InvalidResponseError('embedBatch', result.error);
26
71
  return {
27
- embedding: response.embedding,
28
- ...(response.stats !== undefined && { stats: response.stats })
72
+ embedding: result.data.embedding,
73
+ ...(result.data.stats !== undefined && { stats: result.data.stats })
29
74
  };
30
75
  }
@@ -1,4 +1,4 @@
1
- import { type GetModelInfoParams, type ModelInfo } from '@qvac/inference/surface';
1
+ import { type GetModelInfoParams, type ModelInfo, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Returns status information for a catalog model, including cache state and loaded instances.
4
4
  *
@@ -7,5 +7,5 @@ import { type GetModelInfoParams, type ModelInfo } from '@qvac/inference/surface
7
7
  * @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
8
8
  * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
9
9
  */
10
- export declare function getModelInfo(params: GetModelInfoParams): Promise<ModelInfo>;
10
+ export declare function getModelInfo(params: GetModelInfoParams, options?: RPCOptions): Promise<ModelInfo>;
11
11
  //# sourceMappingURL=get-model-info.d.ts.map
@@ -9,12 +9,12 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
9
9
  * @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
10
10
  * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
11
11
  */
12
- export async function getModelInfo(params) {
12
+ export async function getModelInfo(params, options) {
13
13
  const request = {
14
14
  type: 'getModelInfo',
15
15
  name: params.name
16
16
  };
17
- const response = await send(request);
17
+ const response = await send(request, options);
18
18
  if (response.type !== 'getModelInfo') {
19
19
  throw new InvalidResponseError('getModelInfo');
20
20
  }
@@ -1,4 +1,4 @@
1
- import { type GetSystemResourcesInput, type SystemResources } from '@qvac/inference/surface';
1
+ import { type GetSystemResourcesInput, type SystemResources, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Read the worker's system capabilities and optional resource sample.
4
4
  *
@@ -7,5 +7,5 @@ import { type GetSystemResourcesInput, type SystemResources } from '@qvac/infere
7
7
  * @throws {InvalidResponseError} If the worker returns a different response type.
8
8
  * @throws {Error} If the RPC request fails.
9
9
  */
10
- export declare function getSystemResources(input?: GetSystemResourcesInput): Promise<SystemResources>;
10
+ export declare function getSystemResources(input?: GetSystemResourcesInput, options?: RPCOptions): Promise<SystemResources>;
11
11
  //# sourceMappingURL=get-system-resources.d.ts.map
@@ -9,12 +9,12 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
9
9
  * @throws {InvalidResponseError} If the worker returns a different response type.
10
10
  * @throws {Error} If the RPC request fails.
11
11
  */
12
- export async function getSystemResources(input) {
12
+ export async function getSystemResources(input, options) {
13
13
  const request = {
14
14
  type: 'getSystemResources',
15
15
  ...(input?.sample !== undefined && { sample: input.sample })
16
16
  };
17
- const response = await send(request);
17
+ const response = await send(request, options);
18
18
  if (response.type !== 'getSystemResources') {
19
19
  throw new InvalidResponseError('getSystemResources');
20
20
  }
@@ -1,13 +1,14 @@
1
- import { type HeartbeatResponse } from '@qvac/inference/surface';
1
+ import { type HeartbeatResponse, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Checks whether the local SDK worker is responsive by sending a heartbeat
4
4
  * round-trip.
5
5
  *
6
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
6
7
  * @returns A promise that resolves to a heartbeat response.
7
8
  * @throws {QvacErrorBase} When the response is invalid.
8
9
  *
9
10
  * @example
10
11
  * await heartbeat();
11
12
  */
12
- export declare function heartbeat(): Promise<HeartbeatResponse>;
13
+ export declare function heartbeat(options?: RPCOptions): Promise<HeartbeatResponse>;
13
14
  //# sourceMappingURL=heartbeat.d.ts.map
@@ -5,15 +5,16 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
5
5
  * Checks whether the local SDK worker is responsive by sending a heartbeat
6
6
  * round-trip.
7
7
  *
8
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
8
9
  * @returns A promise that resolves to a heartbeat response.
9
10
  * @throws {QvacErrorBase} When the response is invalid.
10
11
  *
11
12
  * @example
12
13
  * await heartbeat();
13
14
  */
14
- export async function heartbeat() {
15
+ export async function heartbeat(options) {
15
16
  const request = { type: 'heartbeat' };
16
- const response = await send(request);
17
+ const response = await send(request, options);
17
18
  if (response.type !== 'heartbeat') {
18
19
  throw new InvalidResponseError('heartbeat');
19
20
  }
@@ -3,18 +3,19 @@ export { downloadAsset } from './download-asset.js';
3
3
  export { batchCompletion } from './batch-completion.js';
4
4
  export { completion } from './completion-stream.js';
5
5
  export { deleteCache } from './delete-cache.js';
6
- export { unloadModel } from './unload-model.js';
6
+ export { calcTokens, type CalcTokensClientParams } from './calc-tokens.js';
7
+ export { unloadModel, type UnloadModelResult } from './unload-model.js';
7
8
  export { loggingStream } from './logging-stream.js';
8
9
  export { subscribeServerLogs, type ServerLogHandler } from './subscribe-logs.js';
9
10
  export { heartbeat } from './heartbeat.js';
10
11
  export { transcribe, transcribeStream } from './transcribe.js';
11
12
  export { bciTranscribe, bciTranscribeStream } from './bci-transcribe.js';
12
- export { embed } from './embed.js';
13
+ export { embed, embedBatch } from './embed.js';
13
14
  export { finetune, type FinetuneHandle } from './finetune.js';
14
15
  export { translate } from './translate.js';
15
16
  export { cancel } from './cancel.js';
16
17
  export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace } from './rag.js';
17
- export { createVectorIndex, loadVectorIndex, type VectorIndex } from './vector-index.js';
18
+ export { createVectorIndex, loadVectorIndex, type VectorIndex, type VectorIndexOperation } from './vector-index.js';
18
19
  export { textToSpeech, textToSpeechStream } from './text-to-speech.js';
19
20
  export { getModelInfo } from './get-model-info.js';
20
21
  export { getLoadedModelInfo } from './get-loaded-model-info.js';
@@ -3,13 +3,14 @@ export { downloadAsset } from './download-asset.js';
3
3
  export { batchCompletion } from './batch-completion.js';
4
4
  export { completion } from './completion-stream.js';
5
5
  export { deleteCache } from './delete-cache.js';
6
+ export { calcTokens } from './calc-tokens.js';
6
7
  export { unloadModel } from './unload-model.js';
7
8
  export { loggingStream } from './logging-stream.js';
8
9
  export { subscribeServerLogs } from './subscribe-logs.js';
9
10
  export { heartbeat } from './heartbeat.js';
10
11
  export { transcribe, transcribeStream } from './transcribe.js';
11
12
  export { bciTranscribe, bciTranscribeStream } from './bci-transcribe.js';
12
- export { embed } from './embed.js';
13
+ export { embed, embedBatch } from './embed.js';
13
14
  export { finetune } from './finetune.js';
14
15
  export { translate } from './translate.js';
15
16
  export { cancel } from './cancel.js';
@@ -3,6 +3,8 @@ export interface InvokePluginOptions<TParams = unknown> {
3
3
  modelId: string;
4
4
  handler: string;
5
5
  params: TParams;
6
+ /** Caller-minted id for `cancel({ requestId })`; generated when omitted. */
7
+ requestId?: string;
6
8
  }
7
9
  /**
8
10
  * Invoke a non-streaming plugin handler.
@@ -15,7 +17,9 @@ export interface InvokePluginOptions<TParams = unknown> {
15
17
  * @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
16
18
  * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
17
19
  */
18
- export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse>;
20
+ export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse> & {
21
+ requestId: string;
22
+ };
19
23
  /**
20
24
  * Invoke a streaming plugin handler.
21
25
  *
@@ -27,5 +31,7 @@ export declare function invokePlugin<TResponse = unknown, TParams = unknown>(opt
27
31
  * @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
28
32
  * @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
29
33
  */
30
- export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse>;
34
+ export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse> & {
35
+ requestId: string;
36
+ };
31
37
  //# sourceMappingURL=invoke-plugin.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import { send, stream } from '../../client/rpc/rpc-client.js';
2
2
  import { InvalidResponseError } from '../../utils/errors-client.js';
3
+ import { decoratePromise } from '../../utils/decorate-promise.js';
4
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
3
5
  /**
4
6
  * Invoke a non-streaming plugin handler.
5
7
  *
@@ -11,9 +13,16 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
11
13
  * @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
12
14
  * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
13
15
  */
14
- export async function invokePlugin(options, rpcOptions) {
16
+ export function invokePlugin(options, rpcOptions) {
17
+ const requestId = options.requestId ?? generateClientRequestId();
18
+ return decoratePromise(runInvokePlugin(options, requestId, rpcOptions), {
19
+ requestId
20
+ });
21
+ }
22
+ async function runInvokePlugin(options, requestId, rpcOptions) {
15
23
  const request = {
16
24
  type: 'pluginInvoke',
25
+ requestId,
17
26
  modelId: options.modelId,
18
27
  handler: options.handler,
19
28
  params: options.params
@@ -35,9 +44,15 @@ export async function invokePlugin(options, rpcOptions) {
35
44
  * @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
36
45
  * @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
37
46
  */
38
- export async function* invokePluginStream(options, rpcOptions) {
47
+ export function invokePluginStream(options, rpcOptions) {
48
+ const requestId = options.requestId ?? generateClientRequestId();
49
+ const generator = runInvokePluginStream(options, requestId, rpcOptions);
50
+ return Object.assign(generator, { requestId });
51
+ }
52
+ async function* runInvokePluginStream(options, requestId, rpcOptions) {
39
53
  const request = {
40
54
  type: 'pluginInvokeStream',
55
+ requestId,
41
56
  modelId: options.modelId,
42
57
  handler: options.handler,
43
58
  params: options.params
@@ -7,6 +7,7 @@ import { parseClientInput } from '../../client/parse-input.js';
7
7
  import { getClientLogger } from '../../logging/index.js';
8
8
  import { decoratePromise } from '../../utils/decorate-promise.js';
9
9
  import { generateClientRequestId } from '../../client/api/client-request-id.js';
10
+ import { recordHeldModel } from '../../client/session-registry.js';
10
11
  const logger = getClientLogger();
11
12
  function isReactNativeRuntime() {
12
13
  const runtime = globalThis;
@@ -93,10 +94,11 @@ async function runLoadModel(options, requestId, rpcOptions) {
93
94
  throw new ModelLoadFailedError(response.error);
94
95
  }
95
96
  const modelId = response.modelId;
97
+ recordHeldModel(rpcOptions, modelId);
96
98
  // Start logging stream in the background if logger is provided, catch to avoid failing the entire loadModel operation
97
99
  if (modelLogger) {
98
100
  try {
99
- startLoggingStreamForModel(modelId, modelLogger);
101
+ startLoggingStreamForModel(modelId, modelLogger, rpcOptions);
100
102
  }
101
103
  catch (error) {
102
104
  logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
@@ -116,9 +118,10 @@ async function runLoadModel(options, requestId, rpcOptions) {
116
118
  throw new ModelLoadFailedError(response.error);
117
119
  }
118
120
  const modelId = response.modelId;
121
+ recordHeldModel(rpcOptions, modelId);
119
122
  if (modelLogger) {
120
123
  try {
121
- startLoggingStreamForModel(modelId, modelLogger);
124
+ startLoggingStreamForModel(modelId, modelLogger, rpcOptions);
122
125
  }
123
126
  catch (error) {
124
127
  logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
@@ -1,4 +1,4 @@
1
- import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/inference/surface';
1
+ import { type OCRClientParams, type OCRTextBlock, type OCRStats, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Performs Optical Character Recognition (OCR) on an image to extract text.
4
4
  *
@@ -7,7 +7,8 @@ import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/in
7
7
  * @param params.image - Image input as either a file path (string) or image buffer
8
8
  * @param params.options - Optional OCR options (e.g., paragraph mode)
9
9
  * @param params.stream - Whether to stream blocks as they're detected (true) or return all at once (false). Defaults to false
10
- * @returns Object with blockStream generator, blocks promise, and stats promise
10
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
11
+ * @returns Object with `requestId` (pass to `cancel({ requestId })`), blockStream generator, blocks promise, and stats promise
11
12
  * @example
12
13
  * ```typescript
13
14
  * // Load an OCR model first. Registry GGUF models resolve their pipeline
@@ -32,7 +33,8 @@ import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/in
32
33
  * }
33
34
  * ```
34
35
  */
35
- export declare function ocr(params: OCRClientParams): {
36
+ export declare function ocr(params: OCRClientParams, options?: RPCOptions): {
37
+ requestId: string;
36
38
  blockStream: AsyncGenerator<OCRTextBlock[]>;
37
39
  blocks: Promise<OCRTextBlock[]>;
38
40
  stats: Promise<OCRStats | undefined>;