@qvac/sdk 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/NOTICE +194 -97
  2. package/README.md +29 -470
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  5. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
  6. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  7. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  8. package/dist/examples/assess-model-fit.d.ts +7 -9
  9. package/dist/examples/assess-model-fit.js +22 -43
  10. package/dist/examples/calc-tokens.d.ts +2 -0
  11. package/dist/examples/calc-tokens.js +21 -0
  12. package/dist/examples/classification/classify-image.js +11 -5
  13. package/dist/examples/completion-stop-reason.d.ts +3 -3
  14. package/dist/examples/completion-stop-reason.js +4 -4
  15. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  16. package/dist/examples/diffusion-flux3-klein.js +102 -0
  17. package/dist/examples/diffusion-img2vid-ltx.js +7 -14
  18. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  19. package/dist/examples/diffusion-moss-image.js +126 -0
  20. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  21. package/dist/examples/diffusion-qwen-image-21.js +115 -0
  22. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  23. package/dist/examples/embed-multimodal.d.ts +2 -0
  24. package/dist/examples/embed-multimodal.js +80 -0
  25. package/dist/examples/embed-p2p.js +2 -2
  26. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  27. package/dist/examples/image/megaloc.d.ts +2 -0
  28. package/dist/examples/image/megaloc.js +37 -0
  29. package/dist/examples/llamacpp-multimodal.js +21 -1
  30. package/dist/examples/mcp-websearch.js +1 -1
  31. package/dist/examples/plugins.js +1 -1
  32. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  33. package/dist/examples/rag/rag-turbovec.js +2 -2
  34. package/dist/examples/rerank.d.ts +2 -0
  35. package/dist/examples/rerank.js +33 -0
  36. package/dist/examples/sessions.d.ts +17 -0
  37. package/dist/examples/sessions.js +63 -0
  38. package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
  39. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
  40. package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
  41. package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
  42. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  43. package/dist/scripts/contract/build-contract.d.ts +2 -1
  44. package/dist/scripts/contract/build-contract.js +13 -1
  45. package/dist/scripts/contract/constants-registry.d.ts +19 -0
  46. package/dist/scripts/contract/constants-registry.js +9 -2
  47. package/dist/scripts/contract/method-shapes.d.ts +5 -0
  48. package/dist/scripts/contract/method-shapes.js +5 -0
  49. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  50. package/dist/scripts/enforce-inference-versions.js +28 -18
  51. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  52. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  53. package/dist/src/client/api/assess-model-fit.js +19 -32
  54. package/dist/src/client/api/audio-edit.d.ts +5 -3
  55. package/dist/src/client/api/audio-edit.js +7 -5
  56. package/dist/src/client/api/audio-gen-result.js +136 -47
  57. package/dist/src/client/api/audio-gen.d.ts +40 -3
  58. package/dist/src/client/api/audio-gen.js +42 -5
  59. package/dist/src/client/api/audio-understand.d.ts +2 -2
  60. package/dist/src/client/api/audio-understand.js +4 -4
  61. package/dist/src/client/api/batch-completion.js +4 -3
  62. package/dist/src/client/api/bci-transcribe.js +3 -3
  63. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  64. package/dist/src/client/api/calc-tokens.js +44 -0
  65. package/dist/src/client/api/cancel.d.ts +2 -2
  66. package/dist/src/client/api/cancel.js +3 -3
  67. package/dist/src/client/api/classify.d.ts +12 -5
  68. package/dist/src/client/api/classify.js +18 -6
  69. package/dist/src/client/api/client-request-id.d.ts +0 -15
  70. package/dist/src/client/api/client-request-id.js +15 -12
  71. package/dist/src/client/api/completion-stream.d.ts +9 -1
  72. package/dist/src/client/api/completion-stream.js +14 -3
  73. package/dist/src/client/api/decide.d.ts +1 -1
  74. package/dist/src/client/api/decide.js +3 -3
  75. package/dist/src/client/api/delete-cache.d.ts +9 -2
  76. package/dist/src/client/api/delete-cache.js +14 -4
  77. package/dist/src/client/api/diffusion.d.ts +38 -5
  78. package/dist/src/client/api/diffusion.js +42 -7
  79. package/dist/src/client/api/download-asset.js +3 -3
  80. package/dist/src/client/api/embed.d.ts +82 -29
  81. package/dist/src/client/api/embed.js +66 -21
  82. package/dist/src/client/api/finetune.js +3 -3
  83. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  84. package/dist/src/client/api/get-model-info.d.ts +2 -2
  85. package/dist/src/client/api/get-model-info.js +3 -3
  86. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  87. package/dist/src/client/api/get-system-resources.js +3 -3
  88. package/dist/src/client/api/heartbeat.d.ts +3 -2
  89. package/dist/src/client/api/heartbeat.js +4 -3
  90. package/dist/src/client/api/index.d.ts +8 -6
  91. package/dist/src/client/api/index.js +6 -4
  92. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  93. package/dist/src/client/api/invoke-plugin.js +18 -3
  94. package/dist/src/client/api/load-model.js +9 -6
  95. package/dist/src/client/api/logging-stream.d.ts +11 -2
  96. package/dist/src/client/api/logging-stream.js +12 -3
  97. package/dist/src/client/api/ocr.d.ts +5 -3
  98. package/dist/src/client/api/ocr.js +45 -22
  99. package/dist/src/client/api/rag.d.ts +1 -1
  100. package/dist/src/client/api/rag.js +3 -3
  101. package/dist/src/client/api/registry.d.ts +19 -8
  102. package/dist/src/client/api/registry.js +43 -17
  103. package/dist/src/client/api/rerank.d.ts +22 -0
  104. package/dist/src/client/api/rerank.js +39 -0
  105. package/dist/src/client/api/resume.d.ts +2 -1
  106. package/dist/src/client/api/resume.js +3 -3
  107. package/dist/src/client/api/rpc-server.d.ts +4 -4
  108. package/dist/src/client/api/rpc-server.js +12 -12
  109. package/dist/src/client/api/state.d.ts +2 -2
  110. package/dist/src/client/api/state.js +3 -3
  111. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  112. package/dist/src/client/api/subscribe-logs.js +4 -3
  113. package/dist/src/client/api/suspend.d.ts +4 -2
  114. package/dist/src/client/api/suspend.js +5 -4
  115. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  116. package/dist/src/client/api/text-to-speech.js +86 -32
  117. package/dist/src/client/api/transcribe.d.ts +7 -3
  118. package/dist/src/client/api/transcribe.js +9 -3
  119. package/dist/src/client/api/translate.js +2 -2
  120. package/dist/src/client/api/unload-model.d.ts +19 -7
  121. package/dist/src/client/api/unload-model.js +31 -13
  122. package/dist/src/client/api/upscale.d.ts +6 -3
  123. package/dist/src/client/api/upscale.js +10 -5
  124. package/dist/src/client/api/vector-index.d.ts +51 -17
  125. package/dist/src/client/api/vector-index.js +101 -49
  126. package/dist/src/client/api/video-request.d.ts +5 -5
  127. package/dist/src/client/api/video.d.ts +3 -2
  128. package/dist/src/client/api/video.js +6 -5
  129. package/dist/src/client/api/vla.d.ts +9 -5
  130. package/dist/src/client/api/vla.js +17 -8
  131. package/dist/src/client/api/world-result.js +2 -2
  132. package/dist/src/client/api/world.d.ts +6 -6
  133. package/dist/src/client/api/world.js +6 -6
  134. package/dist/src/client/init-hooks.d.ts +6 -4
  135. package/dist/src/client/init-hooks.js +12 -15
  136. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  137. package/dist/src/client/logging-stream-registry.js +36 -14
  138. package/dist/src/client/plugins-factory.d.ts +1 -1
  139. package/dist/src/client/plugins-factory.js +1 -1
  140. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  141. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  142. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  143. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  144. package/dist/src/client/rpc/expo-rpc-client.js +192 -138
  145. package/dist/src/client/rpc/node-rpc-client.js +324 -426
  146. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  147. package/dist/src/client/rpc/pear-runtime.js +12 -0
  148. package/dist/src/client/rpc/rpc-client.d.ts +6 -4
  149. package/dist/src/client/rpc/rpc-client.js +168 -31
  150. package/dist/src/client/rpc/rpc-error.js +24 -2
  151. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  152. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  153. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  154. package/dist/src/client/rpc/worker-failure.js +61 -0
  155. package/dist/src/client/session-registry.d.ts +75 -0
  156. package/dist/src/client/session-registry.js +149 -0
  157. package/dist/src/client/session.d.ts +125 -0
  158. package/dist/src/client/session.js +148 -0
  159. package/dist/src/commands/bundle/addons.d.ts +14 -0
  160. package/dist/src/commands/bundle/addons.js +65 -0
  161. package/dist/src/commands/bundle/constants.js +2 -0
  162. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  163. package/dist/src/commands/bundle/entry-gen.js +18 -51
  164. package/dist/src/commands/bundle/index.d.ts +60 -14
  165. package/dist/src/commands/bundle/index.js +350 -126
  166. package/dist/src/commands/bundle/link.d.ts +58 -0
  167. package/dist/src/commands/bundle/link.js +135 -0
  168. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  169. package/dist/src/commands/bundle/node-support.js +23 -0
  170. package/dist/src/commands/bundle/plugins.js +1 -1
  171. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  172. package/dist/src/commands/bundle/read-bundle.js +27 -0
  173. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  174. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  175. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  176. package/dist/src/commands/bundle/scratch.js +178 -0
  177. package/dist/src/commands/bundle/targets.d.ts +14 -0
  178. package/dist/src/commands/bundle/targets.js +37 -0
  179. package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
  180. package/dist/src/commands/host-prebuilds/index.js +13 -11
  181. package/dist/src/commands/index.d.ts +13 -12
  182. package/dist/src/commands/index.js +7 -7
  183. package/dist/src/commands/verify/abi.d.ts +21 -15
  184. package/dist/src/commands/verify/abi.js +12 -80
  185. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  186. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  187. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  188. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  189. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  190. package/dist/src/commands/verify/bundle-source.js +27 -23
  191. package/dist/src/commands/verify/engines-advice.d.ts +6 -12
  192. package/dist/src/commands/verify/engines-advice.js +9 -56
  193. package/dist/src/commands/verify/index.d.ts +34 -33
  194. package/dist/src/commands/verify/index.js +96 -204
  195. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  196. package/dist/src/commands/verify/node-modules-source.js +1 -1
  197. package/dist/src/commands/verify/prebuilds.d.ts +4 -6
  198. package/dist/src/commands/verify/prebuilds.js +3 -4
  199. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  200. package/dist/src/commands/verify/resource-collectors.js +3 -52
  201. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  202. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  203. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  204. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  205. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  206. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  207. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  208. package/dist/src/expo/plugins/withBareKit.js +204 -0
  209. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  210. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  211. package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
  212. package/dist/src/expo/plugins/withMobileBundle.js +38 -59
  213. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  214. package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
  215. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  216. package/dist/src/index.d.ts +6 -5
  217. package/dist/src/index.js +10 -14
  218. package/dist/src/logging/addon.d.ts +1 -1
  219. package/dist/src/logging/base-logger.js +1 -1
  220. package/dist/src/logging/utils.js +11 -3
  221. package/dist/src/plugin-ids.d.ts +3 -1
  222. package/dist/src/plugin-ids.js +4 -0
  223. package/dist/src/schemas/public.d.ts +1 -1
  224. package/dist/src/schemas/public.js +1 -1
  225. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  226. package/dist/src/schemas/sdk-errors-client.js +30 -36
  227. package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
  228. package/dist/src/schemas/sdk-errors-server.js +65 -2
  229. package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
  230. package/dist/src/server/rpc/rpc-utils.js +41 -0
  231. package/dist/src/utils/aggregate-events.d.ts +1 -1
  232. package/dist/src/utils/aggregate-events.js +2 -2
  233. package/dist/src/utils/errors-client.d.ts +37 -29
  234. package/dist/src/utils/errors-client.js +50 -41
  235. package/dist/src/utils/errors-server.d.ts +65 -1
  236. package/dist/src/utils/errors-server.js +122 -1
  237. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  238. package/dist/src/utils/mcp-adapter.js +1 -1
  239. package/dist/src/utils/tool-helpers.js +1 -1
  240. package/dist/src/utils/withTimeout.js +34 -17
  241. package/dist/src/worker/handle-request.js +26 -21
  242. package/dist/src/worker/handler-utils.d.ts +2 -6
  243. package/dist/src/worker/handler-utils.js +2 -20
  244. package/dist/src/worker/index.d.ts +2 -4
  245. package/dist/src/worker/index.js +24 -34
  246. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  247. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  248. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  249. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  250. package/dist/src/worker/shim.d.ts +4 -0
  251. package/dist/src/worker/shim.js +7 -0
  252. package/dist/src/worker/start.d.ts +9 -0
  253. package/dist/src/worker/start.js +16 -0
  254. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  255. package/dist/src/worker/unbundled-shim.js +4 -0
  256. package/docs/system-resources-support-matrix.md +27 -19
  257. package/package.json +91 -74
  258. package/src/electron-forge/index.cjs +65 -91
  259. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  260. package/dist/examples/model-fit-ui/server.js +0 -221
  261. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  262. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  263. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  264. package/dist/src/client/rpc/init-timeout.js +0 -25
  265. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  266. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  267. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  268. package/dist/src/commands/bundle/bare-pack.js +0 -77
  269. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  270. package/dist/src/commands/bundle/manifest.js +0 -192
  271. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  272. package/dist/src/expo/plugins/link-addons.js +0 -65
  273. package/dist/src/pear/pre.d.ts +0 -21
  274. package/dist/src/pear/pre.js +0 -448
  275. package/dist/src/server/env.d.ts +0 -22
  276. package/dist/src/server/env.js +0 -59
  277. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  278. package/dist/src/server/utils/qvac-paths.js +0 -5
  279. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  280. package/dist/src/server/utils/worker-lock.js +0 -67
  281. package/dist/src/worker/create-server.d.ts +0 -8
  282. package/dist/src/worker/create-server.js +0 -51
  283. package/dist/src/worker/lifecycle.d.ts +0 -23
  284. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,20 +1,20 @@
1
- import { type StartRpcServerOptions, type StopRpcServerOptions, type DiscoverRpcServersOptions, type RpcServerInfo, type RpcServerCandidate } from '@qvac/inference/surface';
1
+ import { type StartRpcServerOptions, type StopRpcServerOptions, type DiscoverRpcServersOptions, type RpcServerInfo, type RpcServerCandidate, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Start a worker-owned native RPC server. Non-loopback binding and advertising require explicit opt-in.
4
4
  * Cancel a pending start with its promise.requestId.
5
5
  */
6
- export declare function startRpcServer(options?: StartRpcServerOptions): Promise<RpcServerInfo> & {
6
+ export declare function startRpcServer(options?: StartRpcServerOptions, rpcOptions?: RPCOptions): Promise<RpcServerInfo> & {
7
7
  requestId: string;
8
8
  };
9
9
  /** Withdraw the announcement and await native stop. Bare stop has no deadline. */
10
- export declare function stopRpcServer(options: StopRpcServerOptions): Promise<void>;
10
+ export declare function stopRpcServer(options: StopRpcServerOptions, rpcOptions?: RPCOptions): Promise<void>;
11
11
  /**
12
12
  * Find private-network candidates with device inventories and server RDMA availability.
13
13
  * RDMA availability is a server-side offer, not a guarantee of the negotiated transport.
14
14
  * Use getRpcDeviceMap with the chosen endpoint registration order before loadModel.
15
15
  * Cancel a pending search with its promise.requestId.
16
16
  */
17
- export declare function discoverRpcServers(options: DiscoverRpcServersOptions): Promise<RpcServerCandidate[]> & {
17
+ export declare function discoverRpcServers(options: DiscoverRpcServersOptions, rpcOptions?: RPCOptions): Promise<RpcServerCandidate[]> & {
18
18
  requestId: string;
19
19
  };
20
20
  //# sourceMappingURL=rpc-server.d.ts.map
@@ -1,18 +1,18 @@
1
1
  import {} from '@qvac/inference/surface';
2
- import { send } from '../rpc/rpc-client.js';
2
+ import { send } from '../../client/rpc/rpc-client.js';
3
3
  import { InvalidResponseError } from '../../utils/errors-client.js';
4
4
  import { decoratePromise } from '../../utils/decorate-promise.js';
5
- import { generateClientRequestId } from './client-request-id.js';
5
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
6
6
  /**
7
7
  * Start a worker-owned native RPC server. Non-loopback binding and advertising require explicit opt-in.
8
8
  * Cancel a pending start with its promise.requestId.
9
9
  */
10
- export function startRpcServer(options = {}) {
10
+ export function startRpcServer(options = {}, rpcOptions) {
11
11
  const requestId = generateClientRequestId();
12
- return decoratePromise(runStartRpcServer(options, requestId), { requestId });
12
+ return decoratePromise(runStartRpcServer(options, requestId, rpcOptions), { requestId });
13
13
  }
14
- async function runStartRpcServer(options, requestId) {
15
- const response = await send({ ...options, type: 'startRpcServer', requestId });
14
+ async function runStartRpcServer(options, requestId, rpcOptions) {
15
+ const response = await send({ ...options, type: 'startRpcServer', requestId }, rpcOptions);
16
16
  if (response.type !== 'startRpcServer')
17
17
  throw new InvalidResponseError('startRpcServer');
18
18
  return {
@@ -22,8 +22,8 @@ async function runStartRpcServer(options, requestId) {
22
22
  };
23
23
  }
24
24
  /** Withdraw the announcement and await native stop. Bare stop has no deadline. */
25
- export async function stopRpcServer(options) {
26
- const response = await send({ ...options, type: 'stopRpcServer' });
25
+ export async function stopRpcServer(options, rpcOptions) {
26
+ const response = await send({ ...options, type: 'stopRpcServer' }, rpcOptions);
27
27
  if (response.type !== 'stopRpcServer')
28
28
  throw new InvalidResponseError('stopRpcServer');
29
29
  }
@@ -33,12 +33,12 @@ export async function stopRpcServer(options) {
33
33
  * Use getRpcDeviceMap with the chosen endpoint registration order before loadModel.
34
34
  * Cancel a pending search with its promise.requestId.
35
35
  */
36
- export function discoverRpcServers(options) {
36
+ export function discoverRpcServers(options, rpcOptions) {
37
37
  const requestId = generateClientRequestId();
38
- return decoratePromise(runDiscoverRpcServers(options, requestId), { requestId });
38
+ return decoratePromise(runDiscoverRpcServers(options, requestId, rpcOptions), { requestId });
39
39
  }
40
- async function runDiscoverRpcServers(options, requestId) {
41
- const response = await send({ ...options, type: 'discoverRpcServers', requestId });
40
+ async function runDiscoverRpcServers(options, requestId, rpcOptions) {
41
+ const response = await send({ ...options, type: 'discoverRpcServers', requestId }, rpcOptions);
42
42
  if (response.type !== 'discoverRpcServers')
43
43
  throw new InvalidResponseError('discoverRpcServers');
44
44
  return response.servers;
@@ -1,4 +1,4 @@
1
- import type { LifecycleState } from '@qvac/inference/surface';
1
+ import type { LifecycleState, RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Returns the current runtime lifecycle state.
4
4
  *
@@ -19,5 +19,5 @@ import type { LifecycleState } from '@qvac/inference/surface';
19
19
  * await resume();
20
20
  * }
21
21
  */
22
- export declare function state(): Promise<LifecycleState>;
22
+ export declare function state(options?: RPCOptions): Promise<LifecycleState>;
23
23
  //# sourceMappingURL=state.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
  * Returns the current runtime lifecycle state.
@@ -20,8 +20,8 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
20
20
  * await resume();
21
21
  * }
22
22
  */
23
- export async function state() {
24
- const response = await send({ type: 'state' });
23
+ export async function state(options) {
24
+ const response = await send({ type: 'state' }, options);
25
25
  if (response.type !== 'state') {
26
26
  throw new InvalidResponseError('state');
27
27
  }
@@ -1,4 +1,4 @@
1
- import type { LoggingStreamResponse } from '@qvac/inference/surface';
1
+ import type { LoggingStreamResponse, RPCOptions } from '@qvac/inference/surface';
2
2
  export type ServerLogHandler = (log: LoggingStreamResponse) => void;
3
3
  /**
4
4
  * Subscribes to every server-side log through a single stream: SDK server logs,
@@ -24,5 +24,5 @@ export type ServerLogHandler = (log: LoggingStreamResponse) => void;
24
24
  * unsubscribe();
25
25
  * ```
26
26
  */
27
- export declare function subscribeServerLogs(handler: ServerLogHandler): () => void;
27
+ export declare function subscribeServerLogs(handler: ServerLogHandler, options?: RPCOptions): () => void;
28
28
  //# sourceMappingURL=subscribe-logs.d.ts.map
@@ -25,8 +25,9 @@ const logger = getClientLogger();
25
25
  * unsubscribe();
26
26
  * ```
27
27
  */
28
- export function subscribeServerLogs(handler) {
29
- const streamIterator = loggingStream({ id: SDK_ALL_LOG_ID });
28
+ export function subscribeServerLogs(handler, options) {
29
+ const controller = new AbortController();
30
+ const streamIterator = loggingStream({ id: SDK_ALL_LOG_ID }, { ...options, signal: controller.signal });
30
31
  void (async () => {
31
32
  try {
32
33
  for await (const log of streamIterator) {
@@ -38,6 +39,6 @@ export function subscribeServerLogs(handler) {
38
39
  }
39
40
  })();
40
41
  return () => {
41
- void streamIterator.return(undefined);
42
+ controller.abort();
42
43
  };
43
44
  }
@@ -1,3 +1,4 @@
1
+ import type { RPCOptions } from '@qvac/inference/surface';
1
2
  /**
2
3
  * Suspends the SDK runtime: pauses all registered Hyperswarm and Corestore
3
4
  * resources and engages the lifecycle gate so non-lifecycle operations are
@@ -8,7 +9,8 @@
8
9
  *
9
10
  * After `suspend()` resolves, runtime state is `"suspended"` and any non-
10
11
  * lifecycle SDK operation throws `LifecycleOperationBlockedError` until
11
- * `resume()` is called.
12
+ * `resume()` is called. `session.close()` is the exception: a session can
13
+ * still end and release its leases while the runtime is suspended.
12
14
  *
13
15
  * In-flight operations started before suspend:
14
16
  * - P2P / Hyperdrive downloads: stall cleanly, continue after `resume()`
@@ -23,5 +25,5 @@
23
25
  * await suspend();
24
26
  * console.log(await state()); // "suspended"
25
27
  */
26
- export declare function suspend(): Promise<void>;
28
+ export declare function suspend(options?: RPCOptions): Promise<void>;
27
29
  //# sourceMappingURL=suspend.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
  * Suspends the SDK runtime: pauses all registered Hyperswarm and Corestore
@@ -10,7 +10,8 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
10
10
  *
11
11
  * After `suspend()` resolves, runtime state is `"suspended"` and any non-
12
12
  * lifecycle SDK operation throws `LifecycleOperationBlockedError` until
13
- * `resume()` is called.
13
+ * `resume()` is called. `session.close()` is the exception: a session can
14
+ * still end and release its leases while the runtime is suspended.
14
15
  *
15
16
  * In-flight operations started before suspend:
16
17
  * - P2P / Hyperdrive downloads: stall cleanly, continue after `resume()`
@@ -25,8 +26,8 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
25
26
  * await suspend();
26
27
  * console.log(await state()); // "suspended"
27
28
  */
28
- export async function suspend() {
29
- const response = await send({ type: 'suspend' });
29
+ export async function suspend(options) {
30
+ const response = await send({ type: 'suspend' }, options);
30
31
  if (response.type !== 'suspend') {
31
32
  throw new InvalidResponseError('suspend');
32
33
  }
@@ -35,9 +35,10 @@ export declare class TtsMulticast {
35
35
  *
36
36
  * - `stream: false` — collect all PCM samples and resolve once via
37
37
  * `result.buffer` (`Promise<number[]>`). `bufferStream` is empty.
38
- * - `stream: true` (default) — yield PCM samples through `result.bufferStream`
39
- * (`AsyncGenerator<number>`) as they arrive. `buffer` resolves to an empty
40
- * array.
38
+ * - `stream: true` (default) — yield PCM through `result.chunkStream`
39
+ * (`AsyncGenerator<Int16Array>`, one chunk per frame) or
40
+ * `result.bufferStream` (`AsyncGenerator<number>`, one sample at a time).
41
+ * `buffer` resolves to an empty array.
41
42
  * - `stream: true, sentenceStream: true` — also exposes `result.chunkUpdates`
42
43
  * (`AsyncGenerator<TtsSentenceChunkUpdate>`) so callers can mux per-sentence
43
44
  * metadata with the audio. Multiple consumers can iterate the response
@@ -60,7 +61,8 @@ export declare class TtsMulticast {
60
61
  * before draining the audio); `result.stats` and `result.stopReason` resolve
61
62
  * from the terminal frame. All three resolve — with `undefined` when the run
62
63
  * produced none — rather than reject. In `stream: true` mode (the default) the
63
- * run starts lazily: nothing is sent until `bufferStream` is first iterated, so
64
+ * run starts lazily: nothing is sent until `chunkStream` or `bufferStream` is
65
+ * first iterated, so
64
66
  * `done`, `sampleRate`, `stats` and `stopReason` stay pending until then. In
65
67
  * `stream: false` and `sentenceStream: true` modes the run starts immediately.
66
68
  * Read `sampleRate` rather than assuming the engine default: `outputSampleRate`
@@ -68,7 +70,7 @@ export declare class TtsMulticast {
68
70
  *
69
71
  * @param params - TTS request parameters (see `TtsClientParamsInput`).
70
72
  * @param options - Optional RPC options (timeout, profiling, force new connection).
71
- * @returns A `TextToSpeechStreamResult` with `bufferStream`, `buffer`, `done`,
73
+ * @returns A `TextToSpeechStreamResult` with `chunkStream`, `bufferStream`, `buffer`, `done`,
72
74
  * `sampleRate`, `stats`, and (when `sentenceStream: true`)
73
75
  * `chunkUpdates`.
74
76
  * @throws {TextToSpeechStreamFailedError} When `sentenceStream: true` is paired
@@ -87,11 +89,18 @@ export type TtsSideChannel = {
87
89
  sampleRate: Promise<number | undefined>;
88
90
  stats: Promise<TtsStats | undefined>;
89
91
  stopReason: Promise<'completed' | 'cancelled' | undefined>;
92
+ speechTokenIds: Promise<number[] | undefined>;
90
93
  observe(response: TtsResponse): void;
91
94
  settle(): void;
92
95
  };
93
96
  /** Exported for test use; not part of the public SDK surface. */
94
97
  export declare function createTtsSideChannel(): TtsSideChannel;
98
+ export declare function sentenceAudioViews(subscription: AsyncGenerator<TtsResponse>): {
99
+ bufferStream: AsyncGenerator<number>;
100
+ chunkStream: AsyncGenerator<Int16Array>;
101
+ };
102
+ export declare function pcmChunksOf(source: AsyncIterable<TtsResponse>): AsyncGenerator<Int16Array>;
103
+ export declare function samplesOf(chunks: AsyncIterable<Int16Array>): AsyncGenerator<number>;
95
104
  export declare function encodeTextToSpeechFragment(textFragment: string | Uint8Array): Uint8Array<ArrayBufferLike>;
96
105
  /**
97
106
  * Duplex session: write UTF-8 text fragments (e.g. LLM token deltas) via `write`. Each string or
@@ -1,9 +1,9 @@
1
- import { textToSpeechStreamResponseSchema, textToSpeechStreamRequestSchema, ttsClientParamsSchema } from '@qvac/inference/surface';
2
- import { stream as streamRpc, duplex } from '../rpc/rpc-client.js';
1
+ import { textToSpeechStreamResponseSchema, textToSpeechStreamRequestSchema, ttsClientParamsSchema, withDecodedTtsPcm, decodeTtsPcm } from '@qvac/inference/surface';
2
+ import { stream as streamRpc, duplex } from '../../client/rpc/rpc-client.js';
3
3
  import { getClientLogger } from '../../logging/index.js';
4
4
  import { TextToSpeechStreamFailedError } from '../../utils/errors-client.js';
5
- import { parseClientInput } from '../parse-input.js';
6
- import { generateClientRequestId } from './client-request-id.js';
5
+ import { parseClientInput } from '../../client/parse-input.js';
6
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
7
7
  const logger = getClientLogger();
8
8
  /**
9
9
  * Fan-out queue that lets multiple consumers iterate the same TTS response
@@ -164,7 +164,13 @@ function buildTextToSpeechStreamRequest(params, requestId) {
164
164
  ...(params.expressivity !== undefined && { expressivity: params.expressivity }),
165
165
  ...(params.noise !== undefined && { noise: params.noise }),
166
166
  ...(params.reverb !== undefined && { reverb: params.reverb }),
167
- ...(params.quality !== undefined && { quality: params.quality })
167
+ ...(params.quality !== undefined && { quality: params.quality }),
168
+ // Per-request voice controls: CosyVoice3's instruct, Audio8's reference pair.
169
+ ...(params.instruct !== undefined && { instruct: params.instruct }),
170
+ ...(params.referenceAudioSrc !== undefined && {
171
+ referenceAudioSrc: params.referenceAudioSrc
172
+ }),
173
+ ...(params.referenceText !== undefined && { referenceText: params.referenceText })
168
174
  };
169
175
  }
170
176
  /**
@@ -174,9 +180,10 @@ function buildTextToSpeechStreamRequest(params, requestId) {
174
180
  *
175
181
  * - `stream: false` — collect all PCM samples and resolve once via
176
182
  * `result.buffer` (`Promise<number[]>`). `bufferStream` is empty.
177
- * - `stream: true` (default) — yield PCM samples through `result.bufferStream`
178
- * (`AsyncGenerator<number>`) as they arrive. `buffer` resolves to an empty
179
- * array.
183
+ * - `stream: true` (default) — yield PCM through `result.chunkStream`
184
+ * (`AsyncGenerator<Int16Array>`, one chunk per frame) or
185
+ * `result.bufferStream` (`AsyncGenerator<number>`, one sample at a time).
186
+ * `buffer` resolves to an empty array.
180
187
  * - `stream: true, sentenceStream: true` — also exposes `result.chunkUpdates`
181
188
  * (`AsyncGenerator<TtsSentenceChunkUpdate>`) so callers can mux per-sentence
182
189
  * metadata with the audio. Multiple consumers can iterate the response
@@ -199,7 +206,8 @@ function buildTextToSpeechStreamRequest(params, requestId) {
199
206
  * before draining the audio); `result.stats` and `result.stopReason` resolve
200
207
  * from the terminal frame. All three resolve — with `undefined` when the run
201
208
  * produced none — rather than reject. In `stream: true` mode (the default) the
202
- * run starts lazily: nothing is sent until `bufferStream` is first iterated, so
209
+ * run starts lazily: nothing is sent until `chunkStream` or `bufferStream` is
210
+ * first iterated, so
203
211
  * `done`, `sampleRate`, `stats` and `stopReason` stay pending until then. In
204
212
  * `stream: false` and `sentenceStream: true` modes the run starts immediately.
205
213
  * Read `sampleRate` rather than assuming the engine default: `outputSampleRate`
@@ -207,7 +215,7 @@ function buildTextToSpeechStreamRequest(params, requestId) {
207
215
  *
208
216
  * @param params - TTS request parameters (see `TtsClientParamsInput`).
209
217
  * @param options - Optional RPC options (timeout, profiling, force new connection).
210
- * @returns A `TextToSpeechStreamResult` with `bufferStream`, `buffer`, `done`,
218
+ * @returns A `TextToSpeechStreamResult` with `chunkStream`, `bufferStream`, `buffer`, `done`,
211
219
  * `sampleRate`, `stats`, and (when `sentenceStream: true`)
212
220
  * `chunkUpdates`.
213
221
  * @throws {TextToSpeechStreamFailedError} When `sentenceStream: true` is paired
@@ -236,9 +244,10 @@ export function textToSpeech(params, options) {
236
244
  // constructed in tests with a hand-rolled source instead.
237
245
  async function* ttsResponseSource(request, options, side) {
238
246
  try {
239
- for await (const response of streamRpc(request, options)) {
240
- if (response.type !== 'textToSpeech')
247
+ for await (const raw of streamRpc(request, options)) {
248
+ if (raw.type !== 'textToSpeech')
241
249
  continue;
250
+ const response = withDecodedTtsPcm(raw);
242
251
  side.observe(response);
243
252
  yield response;
244
253
  }
@@ -259,6 +268,7 @@ export function createTtsSideChannel() {
259
268
  let resolveSampleRate;
260
269
  let resolveStats;
261
270
  let resolveStopReason;
271
+ let resolveSpeechTokenIds;
262
272
  const sampleRate = new Promise((resolve) => {
263
273
  resolveSampleRate = resolve;
264
274
  });
@@ -268,15 +278,22 @@ export function createTtsSideChannel() {
268
278
  const stopReason = new Promise((resolve) => {
269
279
  resolveStopReason = resolve;
270
280
  });
281
+ const speechTokenIds = new Promise((resolve) => {
282
+ resolveSpeechTokenIds = resolve;
283
+ });
271
284
  let seenSampleRate;
272
285
  let latestStats;
273
286
  let seenStopReason;
287
+ // CosyVoice3 hands back one array per native synthesis; the chunked paths
288
+ // run one per sentence, so the run's trajectory is their concatenation.
289
+ let seenSpeechTokenIds;
274
290
  let settled = false;
275
291
  return {
276
292
  text,
277
293
  sampleRate,
278
294
  stats,
279
295
  stopReason,
296
+ speechTokenIds,
280
297
  observe(response) {
281
298
  if (response.text !== undefined)
282
299
  seenText = response.text;
@@ -292,6 +309,13 @@ export function createTtsSideChannel() {
292
309
  latestStats = response.stats;
293
310
  if (response.stopReason !== undefined)
294
311
  seenStopReason = response.stopReason;
312
+ if (response.speechTokenIds !== undefined) {
313
+ // Append into one owned array: a spread per frame would copy every
314
+ // token collected so far on each sentence of a long stream.
315
+ seenSpeechTokenIds ??= [];
316
+ for (const id of response.speechTokenIds)
317
+ seenSpeechTokenIds.push(id);
318
+ }
295
319
  },
296
320
  settle() {
297
321
  if (settled)
@@ -301,6 +325,7 @@ export function createTtsSideChannel() {
301
325
  resolveSampleRate(seenSampleRate);
302
326
  resolveStats(latestStats);
303
327
  resolveStopReason(seenStopReason);
328
+ resolveSpeechTokenIds(seenSpeechTokenIds);
304
329
  }
305
330
  };
306
331
  }
@@ -312,10 +337,11 @@ function sentenceStreamTts(request, options) {
312
337
  // deferred subscribing until the generators were iterated, the first
313
338
  // consumer could trim the queue before the second ever registered,
314
339
  // silently dropping earlier frames.
315
- const bufferSubscription = multicast.subscribe();
340
+ const audio = sentenceAudioViews(multicast.subscribe());
316
341
  const chunkSubscription = multicast.subscribe();
317
342
  return {
318
- bufferStream: sentenceBufferStream(bufferSubscription),
343
+ bufferStream: audio.bufferStream,
344
+ chunkStream: audio.chunkStream,
319
345
  chunkUpdates: sentenceChunkUpdates(chunkSubscription),
320
346
  buffer: Promise.resolve([]),
321
347
  done: multicast.done,
@@ -323,23 +349,38 @@ function sentenceStreamTts(request, options) {
323
349
  text: side.text,
324
350
  sampleRate: side.sampleRate,
325
351
  stats: side.stats,
326
- stopReason: side.stopReason
352
+ stopReason: side.stopReason,
353
+ speechTokenIds: side.speechTokenIds
327
354
  };
328
355
  }
329
- async function* sentenceBufferStream(source) {
356
+ // Both audio views share ONE multicast subscription, so an un-iterated
357
+ // `chunkStream` cannot pin the queue for a caller that drains `bufferStream`
358
+ // and `chunkUpdates` only. Exported for test use; not part of the public
359
+ // surface.
360
+ export function sentenceAudioViews(subscription) {
361
+ const chunkStream = pcmChunksOf(subscription);
362
+ return { bufferStream: samplesOf(chunkStream), chunkStream };
363
+ }
364
+ export async function* pcmChunksOf(source) {
330
365
  for await (const m of source) {
331
366
  if (m.buffer.length > 0) {
332
- yield* m.buffer;
367
+ yield Int16Array.from(m.buffer);
333
368
  }
334
369
  if (m.done)
335
370
  break;
336
371
  }
337
372
  }
373
+ export async function* samplesOf(chunks) {
374
+ for await (const chunk of chunks) {
375
+ yield* chunk;
376
+ }
377
+ }
338
378
  async function* sentenceChunkUpdates(source) {
339
379
  for await (const m of source) {
340
380
  const hasAudio = m.buffer.length > 0;
341
381
  const hasMeta = m.chunkIndex !== undefined ||
342
- (typeof m.sentenceChunk === 'string' && m.sentenceChunk.length > 0);
382
+ (typeof m.sentenceChunk === 'string' && m.sentenceChunk.length > 0) ||
383
+ m.speechTokenIds !== undefined;
343
384
  if (hasAudio || hasMeta) {
344
385
  yield {
345
386
  buffer: hasAudio ? [...m.buffer] : [],
@@ -348,7 +389,8 @@ async function* sentenceChunkUpdates(source) {
348
389
  ...(typeof m.sentenceChunk === 'string' && m.sentenceChunk.length > 0
349
390
  ? { sentenceChunk: m.sentenceChunk }
350
391
  : {}),
351
- ...(m.isLast !== undefined ? { isLast: m.isLast } : {})
392
+ ...(m.isLast !== undefined ? { isLast: m.isLast } : {}),
393
+ ...(m.speechTokenIds !== undefined ? { speechTokenIds: m.speechTokenIds } : {})
352
394
  };
353
395
  }
354
396
  if (m.done)
@@ -364,30 +406,38 @@ function plainStreamTts(request, options) {
364
406
  });
365
407
  done.catch(() => { });
366
408
  const side = createTtsSideChannel();
409
+ // Both views share one lazy run; iterating either starts it.
410
+ const chunkStream = plainTtsChunkStream(request, options, resolveDone, rejectDone, side);
367
411
  return {
368
- bufferStream: plainTtsBufferStream(request, options, resolveDone, rejectDone, side),
412
+ bufferStream: samplesOf(chunkStream),
413
+ chunkStream,
369
414
  buffer: Promise.resolve([]),
370
415
  done,
371
416
  requestId: request.requestId,
372
417
  text: side.text,
373
418
  sampleRate: side.sampleRate,
374
419
  stats: side.stats,
375
- stopReason: side.stopReason
420
+ stopReason: side.stopReason,
421
+ speechTokenIds: side.speechTokenIds
376
422
  };
377
423
  }
378
- async function* plainTtsBufferStream(request, options, resolveDone, rejectDone, side) {
424
+ async function* plainTtsChunkStream(request, options, resolveDone, rejectDone, side) {
379
425
  let settled = false;
380
426
  try {
381
- for await (const response of streamRpc(request, options)) {
382
- if (response.type !== 'textToSpeech')
427
+ for await (const raw of streamRpc(request, options)) {
428
+ if (raw.type !== 'textToSpeech')
383
429
  continue;
384
430
  // See TtsMulticast.pump — skip per-frame Zod validation; the server is
385
431
  // the source of truth for this wire shape.
386
- side.observe(response);
387
- if (response.buffer.length > 0) {
388
- yield* response.buffer;
432
+ // The side channel reads text, rate, stats and stopReason, never the
433
+ // audio, so a `pcm` frame is decoded straight to the typed array callers
434
+ // get instead of through an intermediate `number[]`.
435
+ side.observe(raw);
436
+ const chunk = raw.pcm !== undefined ? decodeTtsPcm(raw.pcm) : Int16Array.from(raw.buffer);
437
+ if (chunk.length > 0) {
438
+ yield chunk;
389
439
  }
390
- if (response.done) {
440
+ if (raw.done) {
391
441
  settled = true;
392
442
  resolveDone(true);
393
443
  }
@@ -419,24 +469,28 @@ function collectTts(request, options) {
419
469
  const side = createTtsSideChannel();
420
470
  return {
421
471
  bufferStream: emptyBufferStream(),
472
+ chunkStream: emptyChunkStream(),
422
473
  buffer: collectTtsBuffer(request, options, resolveDone, rejectDone, side),
423
474
  done,
424
475
  requestId: request.requestId,
425
476
  text: side.text,
426
477
  sampleRate: side.sampleRate,
427
478
  stats: side.stats,
428
- stopReason: side.stopReason
479
+ stopReason: side.stopReason,
480
+ speechTokenIds: side.speechTokenIds
429
481
  };
430
482
  }
431
483
  async function* emptyBufferStream() {
432
484
  // Non-streaming mode exposes no incremental buffer stream.
433
485
  }
486
+ async function* emptyChunkStream() { }
434
487
  async function collectTtsBuffer(request, options, resolveDone, rejectDone, side) {
435
488
  let buffer = [];
436
489
  try {
437
- for await (const response of streamRpc(request, options)) {
438
- if (response.type !== 'textToSpeech')
490
+ for await (const raw of streamRpc(request, options)) {
491
+ if (raw.type !== 'textToSpeech')
439
492
  continue;
493
+ const response = withDecodedTtsPcm(raw);
440
494
  side.observe(response);
441
495
  buffer = buffer.concat(response.buffer);
442
496
  if (response.done) {
@@ -558,5 +612,5 @@ function processTextToSpeechStreamLine(line) {
558
612
  if (obj['type'] === 'error') {
559
613
  throw new TextToSpeechStreamFailedError(obj['message'] ?? 'Unknown server error');
560
614
  }
561
- return textToSpeechStreamResponseSchema.parse(parsed);
615
+ return withDecodedTtsPcm(textToSpeechStreamResponseSchema.parse(parsed));
562
616
  }
@@ -1,5 +1,5 @@
1
1
  import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamRequest, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStreamEvent, type TranscribeStats, type InferenceBackendDiagnostics } from '@qvac/inference/surface';
2
- import { stream, duplex } from '../rpc/rpc-client.js';
2
+ import { stream, duplex } from '../../client/rpc/rpc-client.js';
3
3
  type TranscribeDuplexFactory = (request: TranscribeStreamRequest, options?: RPCOptions) => ReturnType<typeof duplex>;
4
4
  /**
5
5
  * Transcribe audio and return the complete text. Accepts either a file
@@ -11,7 +11,9 @@ type TranscribeDuplexFactory = (request: TranscribeStreamRequest, options?: RPCO
11
11
  * @param params.prompt - Optional initial prompt to guide the transcription
12
12
  * @param params.metadata - When true, resolves to an array of transcript
13
13
  * segments (`{ text, startMs, endMs, append, id }`,
14
- * plus `isEndOfTurn` and `startsWord` on parakeet)
14
+ * plus `isEndOfTurn` and `startsWord` on parakeet, and
15
+ * `language`, `noSpeechProb`, `speakerTurnNext` and
16
+ * `tokens` on whisper when the engine reports them)
15
17
  * instead of joined text.
16
18
  * @param options - Optional RPC options including per-call profiling
17
19
  * @returns A promise (decorated with `requestId`) resolving to the
@@ -61,7 +63,9 @@ export declare function transcribeStream(params: TranscribeClientParams, options
61
63
  * @param params.prompt - Optional initial prompt to guide transcription
62
64
  * @param params.metadata - When true, the session yields transcript segment
63
65
  * objects (`{ text, startMs, endMs, append, id }`,
64
- * plus `isEndOfTurn` and `startsWord` on parakeet)
66
+ * plus `isEndOfTurn` and `startsWord` on parakeet, and
67
+ * `language`, `noSpeechProb`, `speakerTurnNext` and
68
+ * `tokens` on whisper when the engine reports them)
65
69
  * instead of plain text.
66
70
  * @param options - Optional RPC options including per-call profiling.
67
71
  * @returns A session object: call `write(audioChunk)` with a `Uint8Array`
@@ -1,9 +1,9 @@
1
1
  import { transcribeResponseSchema, transcribeStreamResponseSchema } from '@qvac/inference/surface';
2
- import { stream, duplex } from '../rpc/rpc-client.js';
2
+ import { stream, duplex } from '../../client/rpc/rpc-client.js';
3
3
  import { getClientLogger } from '../../logging/index.js';
4
4
  import { TranscriptionFailedError } from '../../utils/errors-client.js';
5
5
  import { decoratePromise } from '../../utils/decorate-promise.js';
6
- import { generateClientRequestId } from './client-request-id.js';
6
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
7
7
  const logger = getClientLogger();
8
8
  function buildTranscribeRequest(params, requestId) {
9
9
  return {
@@ -313,6 +313,8 @@ export function processLineConversation(line, wantsMetadata, onTerminal) {
313
313
  speaking: response.vad.speaking,
314
314
  probability: response.vad.probability,
315
315
  ...(response.vad.source && { source: response.vad.source }),
316
+ ...(response.vad.timestamp !== undefined && { timestamp: response.vad.timestamp }),
317
+ ...(response.vad.chunkIndex !== undefined && { chunkIndex: response.vad.chunkIndex }),
316
318
  ...(response.vad.speakerId !== undefined && { speakerId: response.vad.speakerId })
317
319
  };
318
320
  }
@@ -324,9 +326,13 @@ export function processLineConversation(line, wantsMetadata, onTerminal) {
324
326
  silenceDurationMs: response.endOfTurn.silenceDurationMs
325
327
  };
326
328
  }
329
+ const { timestamp, chunkIndex, confidence } = response.endOfTurn;
327
330
  return {
328
331
  type: 'endOfTurn',
329
- source: 'parakeet'
332
+ source: 'parakeet',
333
+ ...(timestamp !== undefined && { timestamp }),
334
+ ...(chunkIndex !== undefined && { chunkIndex }),
335
+ ...(confidence !== undefined && { confidence })
330
336
  };
331
337
  }
332
338
  if (wantsMetadata) {
@@ -1,5 +1,5 @@
1
- import { stream as streamRpc } from '../rpc/rpc-client.js';
2
- import { generateClientRequestId } from './client-request-id.js';
1
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
2
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
3
3
  import { translateResponseSchema } from '@qvac/inference/surface';
4
4
  /**
5
5
  * Translates text from one language to another using a specified translation model.
@@ -1,18 +1,30 @@
1
- import { type UnloadModelParams } from '@qvac/inference/surface';
1
+ import { type UnloadModelParams, type RPCOptions } from '@qvac/inference/surface';
2
+ import { send, close } from '../../client/rpc/rpc-client.js';
3
+ export interface UnloadModelResult {
4
+ /** The caller's lease on the model was released. */
5
+ released: boolean;
6
+ /** The model left memory. False while another session still holds it. */
7
+ unloaded: boolean;
8
+ }
2
9
  /**
3
- * Unloads a previously loaded model from the server.
10
+ * Releases the caller's hold on a loaded model. The model leaves memory once
11
+ * no caller session holds it; a session that shares the model with another
12
+ * only drops its own lease.
4
13
  *
5
- * When the last model is unloaded (no more models remain), this function
6
- * automatically closes the RPC connection on Node/Electron, allowing the
7
- * process to exit naturally without requiring manual cleanup. On Bare the
14
+ * When the owner unloads the last model and no caller session is open, this
15
+ * function automatically closes the RPC connection on Node/Electron, allowing
16
+ * the process to exit naturally without requiring manual cleanup. On Bare the
8
17
  * connection is left open by default so long-lived workers survive a routine
9
- * unload; pass `autoClose: true` to opt in to closing.
18
+ * unload; pass `autoClose: true` to opt in to closing. A session never closes
19
+ * the runtime.
10
20
  *
11
21
  * @param params - The parameters for unloading the model
12
22
  * @param params.modelId - The unique identifier of the model to unload
13
23
  * @param params.clearStorage - Whether to clear the storage for the model
14
24
  * @param params.autoClose - Override the runtime-default auto-close behavior
25
+ * @param options - Optional RPC options (timeout, profiling, force new connection).
15
26
  * @throws {QvacErrorBase} When the response type is invalid or when the unload operation fails
16
27
  */
17
- export declare function unloadModel(params: UnloadModelParams): Promise<void>;
28
+ export declare function unloadModel(params: UnloadModelParams, options?: RPCOptions): Promise<UnloadModelResult>;
29
+ export declare function createUnloadModelCall(params: UnloadModelParams, options?: RPCOptions, sendRequest?: typeof send, closeRuntime?: typeof close): Promise<UnloadModelResult>;
18
30
  //# sourceMappingURL=unload-model.d.ts.map