@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
@@ -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';
@@ -34,8 +35,9 @@ export { resume } from './resume.js';
34
35
  export { state } from './state.js';
35
36
  export { vla, vlaHparams, vlaSetEmbodiment } from './vla.js';
36
37
  export { vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE } from './vla-helpers.js';
37
- export { audioGen } from './audio-gen.js';
38
- export { audioEdit } from './audio-edit.js';
39
- export { audioUnderstand } from './audio-understand.js';
38
+ export { audioGen } from '../../client/api/audio-gen.js';
39
+ export { audioEdit } from '../../client/api/audio-edit.js';
40
+ export { audioUnderstand } from '../../client/api/audio-understand.js';
40
41
  export { startRpcServer, stopRpcServer, discoverRpcServers } from './rpc-server.js';
41
42
  export { decide } from './decide.js';
43
+ export { rerank } from './rerank.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
- import { send, stream } from '../rpc/rpc-client.js';
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
@@ -1,12 +1,13 @@
1
- import { send, stream } from '../rpc/rpc-client.js';
2
- import { startLoggingStreamForModel } from '../logging-stream-registry.js';
1
+ import { send, stream } from '../../client/rpc/rpc-client.js';
2
+ import { startLoggingStreamForModel } from '../../client/logging-stream-registry.js';
3
3
  import { loadBuiltinToRequestSchema, loadCustomPluginToRequestSchema, reloadConfigOptionsToRequestSchema, isBuiltInModelType, isModelTypeAlias, normalizeModelType, inferModelTypeFromModelSrc, ModelType } from '@qvac/inference/surface';
4
4
  import { ModelLoadFailedError, ModelTypeRequiredError, StreamEndedError, InvalidResponseError } from '../../utils/errors-client.js';
5
5
  import { assertModelSrcMatchesModelType } from '../../utils/load-model-validation.js';
6
- import { parseClientInput } from '../parse-input.js';
6
+ 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
- import { generateClientRequestId } from './client-request-id.js';
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,9 +1,12 @@
1
- import type { LoggingStreamResponse, LoggingParams } from '@qvac/inference/surface';
1
+ import type { LoggingStreamResponse, LoggingParams, AbortableRPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Opens a logging stream to receive real-time logs.
4
4
  *
5
5
  * @param params - The arguments for the logging stream
6
6
  * @param params.id - The unique identifier to stream logs for
7
+ * @param options - Call options
8
+ * @param options.signal - Abort to end the stream and release the subscription
9
+ * on the worker at once, from outside the loop.
7
10
  * @returns AsyncGenerator yielding logging stream responses
8
11
  * @throws {QvacErrorBase} When the response type is invalid or when the stream fails
9
12
  *
@@ -18,7 +21,13 @@ import type { LoggingStreamResponse, LoggingParams } from '@qvac/inference/surfa
18
21
  * for await (const logMessage of logStream) {
19
22
  * console.log(`[${logMessage.level}] ${logMessage.namespace}: ${logMessage.message}`);
20
23
  * }
24
+ *
25
+ * // Stop from outside the loop
26
+ * const controller = new AbortController();
27
+ * const modelLogs = loggingStream({ id: 'my-model-id' }, { signal: controller.signal });
28
+ * // later
29
+ * controller.abort();
21
30
  * ```
22
31
  */
23
- export declare function loggingStream(params: LoggingParams): AsyncGenerator<LoggingStreamResponse>;
32
+ export declare function loggingStream(params: LoggingParams, options?: AbortableRPCOptions): AsyncGenerator<LoggingStreamResponse>;
24
33
  //# sourceMappingURL=logging-stream.d.ts.map
@@ -1,10 +1,13 @@
1
- import { stream } from '../rpc/rpc-client.js';
1
+ import { stream } from '../../client/rpc/rpc-client.js';
2
2
  import { InvalidResponseError } from '../../utils/errors-client.js';
3
3
  /**
4
4
  * Opens a logging stream to receive real-time logs.
5
5
  *
6
6
  * @param params - The arguments for the logging stream
7
7
  * @param params.id - The unique identifier to stream logs for
8
+ * @param options - Call options
9
+ * @param options.signal - Abort to end the stream and release the subscription
10
+ * on the worker at once, from outside the loop.
8
11
  * @returns AsyncGenerator yielding logging stream responses
9
12
  * @throws {QvacErrorBase} When the response type is invalid or when the stream fails
10
13
  *
@@ -19,14 +22,20 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
19
22
  * for await (const logMessage of logStream) {
20
23
  * console.log(`[${logMessage.level}] ${logMessage.namespace}: ${logMessage.message}`);
21
24
  * }
25
+ *
26
+ * // Stop from outside the loop
27
+ * const controller = new AbortController();
28
+ * const modelLogs = loggingStream({ id: 'my-model-id' }, { signal: controller.signal });
29
+ * // later
30
+ * controller.abort();
22
31
  * ```
23
32
  */
24
- export async function* loggingStream(params) {
33
+ export async function* loggingStream(params, options) {
25
34
  const request = {
26
35
  type: 'loggingStream',
27
36
  ...params
28
37
  };
29
- const responseStream = stream(request);
38
+ const responseStream = stream(request, options);
30
39
  for await (const response of responseStream) {
31
40
  if (response.type !== 'loggingStream') {
32
41
  throw new InvalidResponseError('loggingStream');
@@ -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>;
@@ -1,5 +1,6 @@
1
1
  import { ocrStreamResponseSchema } from '@qvac/inference/surface';
2
- import { stream as streamRpc } from '../rpc/rpc-client.js';
2
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
3
4
  /**
4
5
  * Performs Optical Character Recognition (OCR) on an image to extract text.
5
6
  *
@@ -8,7 +9,8 @@ import { stream as streamRpc } from '../rpc/rpc-client.js';
8
9
  * @param params.image - Image input as either a file path (string) or image buffer
9
10
  * @param params.options - Optional OCR options (e.g., paragraph mode)
10
11
  * @param params.stream - Whether to stream blocks as they're detected (true) or return all at once (false). Defaults to false
11
- * @returns Object with blockStream generator, blocks promise, and stats promise
12
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
13
+ * @returns Object with `requestId` (pass to `cancel({ requestId })`), blockStream generator, blocks promise, and stats promise
12
14
  * @example
13
15
  * ```typescript
14
16
  * // Load an OCR model first. Registry GGUF models resolve their pipeline
@@ -33,9 +35,11 @@ import { stream as streamRpc } from '../rpc/rpc-client.js';
33
35
  * }
34
36
  * ```
35
37
  */
36
- export function ocr(params) {
38
+ export function ocr(params, options) {
39
+ const requestId = generateClientRequestId();
37
40
  const request = {
38
41
  type: 'ocrStream',
42
+ requestId,
39
43
  modelId: params.modelId,
40
44
  image: typeof params.image === 'string'
41
45
  ? { type: 'filePath', value: params.image }
@@ -44,25 +48,37 @@ export function ocr(params) {
44
48
  };
45
49
  let ocrStats;
46
50
  let statsResolver = () => { };
47
- const statsPromise = new Promise((resolve) => {
51
+ let statsRejecter = () => { };
52
+ const statsPromise = new Promise((resolve, reject) => {
48
53
  statsResolver = resolve;
54
+ statsRejecter = reject;
49
55
  });
56
+ // A failed stream (a cancel, a timeout, a worker error) sends no `done`
57
+ // frame, so it rejects `stats` too instead of leaving it pending.
58
+ statsPromise.catch(() => { });
50
59
  if (params.stream) {
51
60
  const blockStream = (async function* () {
52
- for await (const response of streamRpc(request)) {
53
- if (response.type === 'ocrStream') {
54
- const streamResponse = ocrStreamResponseSchema.parse(response);
55
- if (streamResponse.blocks && streamResponse.blocks.length > 0) {
56
- yield streamResponse.blocks;
57
- }
58
- if (streamResponse.done) {
59
- ocrStats = streamResponse.stats;
60
- statsResolver(ocrStats);
61
+ try {
62
+ for await (const response of streamRpc(request, options)) {
63
+ if (response.type === 'ocrStream') {
64
+ const streamResponse = ocrStreamResponseSchema.parse(response);
65
+ if (streamResponse.blocks && streamResponse.blocks.length > 0) {
66
+ yield streamResponse.blocks;
67
+ }
68
+ if (streamResponse.done) {
69
+ ocrStats = streamResponse.stats;
70
+ statsResolver(ocrStats);
71
+ }
61
72
  }
62
73
  }
63
74
  }
75
+ catch (error) {
76
+ statsRejecter(error);
77
+ throw error;
78
+ }
64
79
  })();
65
80
  return {
81
+ requestId,
66
82
  blockStream,
67
83
  blocks: Promise.resolve([]),
68
84
  stats: statsPromise
@@ -74,21 +90,28 @@ export function ocr(params) {
74
90
  })();
75
91
  const blocksPromise = (async () => {
76
92
  let allBlocks = [];
77
- for await (const response of streamRpc(request)) {
78
- if (response.type === 'ocrStream') {
79
- const streamResponse = ocrStreamResponseSchema.parse(response);
80
- if (streamResponse.blocks) {
81
- allBlocks = allBlocks.concat(streamResponse.blocks);
82
- }
83
- if (streamResponse.done) {
84
- ocrStats = streamResponse.stats;
85
- statsResolver(ocrStats);
93
+ try {
94
+ for await (const response of streamRpc(request, options)) {
95
+ if (response.type === 'ocrStream') {
96
+ const streamResponse = ocrStreamResponseSchema.parse(response);
97
+ if (streamResponse.blocks) {
98
+ allBlocks = allBlocks.concat(streamResponse.blocks);
99
+ }
100
+ if (streamResponse.done) {
101
+ ocrStats = streamResponse.stats;
102
+ statsResolver(ocrStats);
103
+ }
86
104
  }
87
105
  }
88
106
  }
107
+ catch (error) {
108
+ statsRejecter(error);
109
+ throw error;
110
+ }
89
111
  return allBlocks;
90
112
  })();
91
113
  return {
114
+ requestId,
92
115
  blockStream,
93
116
  blocks: blocksPromise,
94
117
  stats: statsPromise
@@ -84,7 +84,7 @@ export declare function ragIngest(params: RagIngestParams, options?: RPCOptions)
84
84
  * ```typescript
85
85
  * // Segregated flow
86
86
  * const chunks = await ragChunk({ documents: ["text1", "text2"] });
87
- * const { embedding: embeddings } = await embed({ modelId, text: chunks.map(c => c.content) });
87
+ * const { embedding: embeddings } = await embedBatch({ modelId, inputs: chunks.map(c => c.content) });
88
88
  * const embeddedDocs = chunks.map((chunk, i) => ({
89
89
  * ...chunk,
90
90
  * embedding: embeddings[i],
@@ -1,6 +1,6 @@
1
- import { send, stream } from '../rpc/rpc-client.js';
1
+ import { send, stream } from '../../client/rpc/rpc-client.js';
2
2
  import { InvalidResponseError, InvalidOperationError, StreamEndedError, RAGChunkFailedError, RAGSaveFailedError, RAGSearchFailedError, RAGDeleteFailedError, RAGCloseWorkspaceFailedError, RAGListWorkspacesFailedError } from '../../utils/errors-client.js';
3
- import { generateClientRequestId } from './client-request-id.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
4
  import { decoratePromise } from '../../utils/decorate-promise.js';
5
5
  // ============== Chunk ==============
6
6
  /**
@@ -151,7 +151,7 @@ async function runRagIngest(params, requestId, options) {
151
151
  * ```typescript
152
152
  * // Segregated flow
153
153
  * const chunks = await ragChunk({ documents: ["text1", "text2"] });
154
- * const { embedding: embeddings } = await embed({ modelId, text: chunks.map(c => c.content) });
154
+ * const { embedding: embeddings } = await embedBatch({ modelId, inputs: chunks.map(c => c.content) });
155
155
  * const embeddedDocs = chunks.map((chunk, i) => ({
156
156
  * ...chunk,
157
157
  * embedding: embeddings[i],
@@ -1,4 +1,4 @@
1
- import type { ModelRegistryEntry, ModelRegistryEntryAddon } from '@qvac/inference/surface';
1
+ import type { ModelRegistryEntry, ModelRegistryEntryAddon, RPCOptions } from '@qvac/inference/surface';
2
2
  export type { ModelRegistryEntry, ModelRegistryEntryAddon };
3
3
  export interface ModelRegistrySearchParams {
4
4
  filter?: string;
@@ -7,13 +7,19 @@ export interface ModelRegistrySearchParams {
7
7
  modelType?: ModelRegistryEntryAddon;
8
8
  addon?: ModelRegistryEntryAddon;
9
9
  }
10
+ /** A registry query's result, with the id that `cancel({ requestId })` takes. */
11
+ export type RegistryQuery<T> = Promise<T> & {
12
+ requestId: string;
13
+ };
10
14
  /**
11
15
  * Returns all available models from the QVAC distributed model registry.
12
16
  *
13
- * @returns A promise resolving to an array of `ModelRegistryEntry` describing every model the SDK's connected registry knows about.
17
+ * @returns A promise resolving to an array of `ModelRegistryEntry` describing every model the SDK's connected registry knows about,
18
+ * decorated with a synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
19
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
14
20
  * @throws {ModelRegistryQueryFailedError} When the registry query fails.
15
21
  */
16
- declare function modelRegistryList(): Promise<ModelRegistryEntry[]>;
22
+ declare function modelRegistryList(options?: RPCOptions): RegistryQuery<ModelRegistryEntry[]>;
17
23
  /**
18
24
  * Searches the model registry with optional filters for model type, engine, and quantization.
19
25
  *
@@ -23,18 +29,23 @@ declare function modelRegistryList(): Promise<ModelRegistryEntry[]>;
23
29
  * @param params.quantization - Quantization identifier (e.g., `"Q4_K_M"`).
24
30
  * @param params.modelType - Alias for `addon`; kept for backward compatibility.
25
31
  * @param params.addon - Model addon / category to restrict results to.
26
- * @returns A promise resolving to the matching `ModelRegistryEntry` entries.
32
+ * @returns A promise resolving to the matching `ModelRegistryEntry` entries, decorated with a
33
+ * synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
34
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
27
35
  * @throws {ModelRegistryQueryFailedError} When the registry query fails.
28
36
  */
29
- declare function modelRegistrySearch(params?: ModelRegistrySearchParams): Promise<ModelRegistryEntry[]>;
37
+ declare function modelRegistrySearch(params?: ModelRegistrySearchParams, options?: RPCOptions): RegistryQuery<ModelRegistryEntry[]>;
30
38
  /**
31
39
  * Fetches a single model entry from the registry by its path and source.
32
40
  *
33
41
  * @param registryPath - Registry-relative path of the model to fetch.
34
42
  * @param registrySource - Registry source identifier (e.g., `"huggingface"`, `"local"`).
35
- * @returns A promise resolving to the matching `ModelRegistryEntry`.
36
- * @throws {ModelRegistryQueryFailedError} When the model cannot be located or the registry query fails.
43
+ * @returns A promise resolving to the matching `ModelRegistryEntry`, decorated with a
44
+ * synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
45
+ * @throws {ModelRegistryModelNotFoundError} When the registry has no model at this source and path.
46
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
47
+ * @throws {ModelRegistryQueryFailedError} When the registry query fails.
37
48
  */
38
- declare function modelRegistryGetModel(registryPath: string, registrySource: string): Promise<ModelRegistryEntry>;
49
+ declare function modelRegistryGetModel(registryPath: string, registrySource: string, options?: RPCOptions): RegistryQuery<ModelRegistryEntry>;
39
50
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel };
40
51
  //# sourceMappingURL=registry.d.ts.map
@@ -1,21 +1,30 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import { ModelRegistryQueryFailedError } from '../../utils/errors-client.js';
3
- function validateRegistryResponse(response, fallbackError) {
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
+ import { decoratePromise } from '../../utils/decorate-promise.js';
5
+ function validateRegistryResponse(response) {
4
6
  if (!response.success) {
5
- throw new ModelRegistryQueryFailedError(response.error ?? fallbackError ?? 'Unknown registry error');
7
+ throw new ModelRegistryQueryFailedError(response.error ?? 'Unknown registry error');
6
8
  }
7
9
  }
8
10
  /**
9
11
  * Returns all available models from the QVAC distributed model registry.
10
12
  *
11
- * @returns A promise resolving to an array of `ModelRegistryEntry` describing every model the SDK's connected registry knows about.
13
+ * @returns A promise resolving to an array of `ModelRegistryEntry` describing every model the SDK's connected registry knows about,
14
+ * decorated with a synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
15
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
12
16
  * @throws {ModelRegistryQueryFailedError} When the registry query fails.
13
17
  */
14
- async function modelRegistryList() {
18
+ function modelRegistryList(options) {
19
+ const requestId = generateClientRequestId();
20
+ return decoratePromise(runList(requestId, options), { requestId });
21
+ }
22
+ async function runList(requestId, options) {
15
23
  const request = {
16
- type: 'modelRegistryList'
24
+ type: 'modelRegistryList',
25
+ requestId
17
26
  };
18
- const response = (await send(request));
27
+ const response = (await send(request, options));
19
28
  validateRegistryResponse(response);
20
29
  return response.models;
21
30
  }
@@ -28,17 +37,24 @@ async function modelRegistryList() {
28
37
  * @param params.quantization - Quantization identifier (e.g., `"Q4_K_M"`).
29
38
  * @param params.modelType - Alias for `addon`; kept for backward compatibility.
30
39
  * @param params.addon - Model addon / category to restrict results to.
31
- * @returns A promise resolving to the matching `ModelRegistryEntry` entries.
40
+ * @returns A promise resolving to the matching `ModelRegistryEntry` entries, decorated with a
41
+ * synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
42
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
32
43
  * @throws {ModelRegistryQueryFailedError} When the registry query fails.
33
44
  */
34
- async function modelRegistrySearch(params = {}) {
45
+ function modelRegistrySearch(params = {}, options) {
46
+ const requestId = generateClientRequestId();
47
+ return decoratePromise(runSearch(params, requestId, options), { requestId });
48
+ }
49
+ async function runSearch(params, requestId, options) {
35
50
  const { modelType, ...rest } = params;
36
51
  const request = {
37
52
  type: 'modelRegistrySearch',
38
53
  ...rest,
39
- addon: modelType ?? rest.addon
54
+ addon: modelType ?? rest.addon,
55
+ requestId
40
56
  };
41
- const response = (await send(request));
57
+ const response = (await send(request, options));
42
58
  validateRegistryResponse(response);
43
59
  return response.models;
44
60
  }
@@ -47,17 +63,27 @@ async function modelRegistrySearch(params = {}) {
47
63
  *
48
64
  * @param registryPath - Registry-relative path of the model to fetch.
49
65
  * @param registrySource - Registry source identifier (e.g., `"huggingface"`, `"local"`).
50
- * @returns A promise resolving to the matching `ModelRegistryEntry`.
51
- * @throws {ModelRegistryQueryFailedError} When the model cannot be located or the registry query fails.
66
+ * @returns A promise resolving to the matching `ModelRegistryEntry`, decorated with a
67
+ * synchronous `requestId` for `cancel({ requestId })` while the query waits for the registry.
68
+ * @throws {ModelRegistryModelNotFoundError} When the registry has no model at this source and path.
69
+ * @throws {ModelRegistryBusyError} When another QVAC process kept the registry for longer than the query waits.
70
+ * @throws {ModelRegistryQueryFailedError} When the registry query fails.
52
71
  */
53
- async function modelRegistryGetModel(registryPath, registrySource) {
72
+ function modelRegistryGetModel(registryPath, registrySource, options) {
73
+ const requestId = generateClientRequestId();
74
+ return decoratePromise(runGetModel(registryPath, registrySource, requestId, options), {
75
+ requestId
76
+ });
77
+ }
78
+ async function runGetModel(registryPath, registrySource, requestId, options) {
54
79
  const request = {
55
80
  type: 'modelRegistryGetModel',
56
81
  registryPath,
57
- registrySource
82
+ registrySource,
83
+ requestId
58
84
  };
59
- const response = (await send(request));
60
- validateRegistryResponse(response, `Model not found: ${registrySource}/${registryPath}`);
85
+ const response = (await send(request, options));
86
+ validateRegistryResponse(response);
61
87
  return response.model;
62
88
  }
63
89
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel };
@@ -0,0 +1,22 @@
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
+ import { type RerankParams, type RerankScores, type RPCOptions } from '@qvac/inference/surface';
3
+ /**
4
+ * Scores documents by relevance to a query with a reranker model.
5
+ *
6
+ * @param params - Model ID, query, and the documents to score.
7
+ * @param options - RPC transport options.
8
+ * @returns A promise with a synchronous requestId for cancel(). Resolves to
9
+ * one score per document, in input order; higher is more relevant. Scores are
10
+ * the model's raw output, so compare them within one model only.
11
+ * @throws {RequestValidationFailedError} If the request is invalid.
12
+ * @throws {InferenceCancelledError} If the request is cancelled.
13
+ * @throws {RequestRejectedByPolicyError} If this model's rerank queue is full.
14
+ * @throws {InvalidResponseError} If the worker returns a malformed result.
15
+ */
16
+ export declare function rerank(params: RerankParams, options?: RPCOptions): Promise<RerankScores> & {
17
+ requestId: string;
18
+ };
19
+ export declare function createRerankCall(params: RerankParams, options?: RPCOptions, sendRequest?: typeof send): Promise<RerankScores> & {
20
+ requestId: string;
21
+ };
22
+ //# sourceMappingURL=rerank.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { parseClientInput } from '../../client/parse-input.js';
2
+ import { send } from '../../client/rpc/rpc-client.js';
3
+ import { rerankParamsSchema, rerankResponseSchema } from '@qvac/inference/surface';
4
+ import { InvalidResponseError } from '../../utils/errors-client.js';
5
+ import { decoratePromise } from '../../utils/decorate-promise.js';
6
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
7
+ /**
8
+ * Scores documents by relevance to a query with a reranker model.
9
+ *
10
+ * @param params - Model ID, query, and the documents to score.
11
+ * @param options - RPC transport options.
12
+ * @returns A promise with a synchronous requestId for cancel(). Resolves to
13
+ * one score per document, in input order; higher is more relevant. Scores are
14
+ * the model's raw output, so compare them within one model only.
15
+ * @throws {RequestValidationFailedError} If the request is invalid.
16
+ * @throws {InferenceCancelledError} If the request is cancelled.
17
+ * @throws {RequestRejectedByPolicyError} If this model's rerank queue is full.
18
+ * @throws {InvalidResponseError} If the worker returns a malformed result.
19
+ */
20
+ export function rerank(params, options) {
21
+ return createRerankCall(params, options);
22
+ }
23
+ export function createRerankCall(params, options, sendRequest = send) {
24
+ const requestId = generateClientRequestId();
25
+ return decoratePromise(runRerank(params, requestId, options, sendRequest), { requestId });
26
+ }
27
+ async function runRerank(params, requestId, options, sendRequest) {
28
+ const input = parseClientInput(rerankParamsSchema, params);
29
+ const response = await sendRequest({ ...input, type: 'rerank', requestId }, options);
30
+ if (response.type !== 'rerank')
31
+ throw new InvalidResponseError('rerank');
32
+ const parsed = rerankResponseSchema.safeParse(response);
33
+ if (!parsed.success)
34
+ throw new InvalidResponseError('rerank', parsed.error);
35
+ const { scores } = parsed.data;
36
+ if (scores.length !== input.documents.length)
37
+ throw new InvalidResponseError('rerank');
38
+ return scores;
39
+ }
@@ -1,3 +1,4 @@
1
+ import type { RPCOptions } from '@qvac/inference/surface';
1
2
  /**
2
3
  * Resumes the SDK runtime: restores all suspended Hyperswarm and Corestore
3
4
  * resources and releases the lifecycle gate so all SDK operations are allowed
@@ -23,5 +24,5 @@
23
24
  * await resume();
24
25
  * console.log(await state()); // "active"
25
26
  */
26
- export declare function resume(): Promise<void>;
27
+ export declare function resume(options?: RPCOptions): Promise<void>;
27
28
  //# sourceMappingURL=resume.d.ts.map
@@ -1,4 +1,4 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import { InvalidResponseError } from '../../utils/errors-client.js';
3
3
  /**
4
4
  * Resumes the SDK runtime: restores all suspended Hyperswarm and Corestore
@@ -25,8 +25,8 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
25
25
  * await resume();
26
26
  * console.log(await state()); // "active"
27
27
  */
28
- export async function resume() {
29
- const response = await send({ type: 'resume' });
28
+ export async function resume(options) {
29
+ const response = await send({ type: 'resume' }, options);
30
30
  if (response.type !== 'resume') {
31
31
  throw new InvalidResponseError('resume');
32
32
  }