@qvac/sdk 0.21.1 → 0.23.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 (249) hide show
  1. package/NOTICE +131 -62
  2. package/README.md +31 -326
  3. package/dist/examples/abot-world.js +1 -1
  4. package/dist/examples/advisory-model-fit.d.ts +0 -58
  5. package/dist/examples/advisory-model-fit.js +23 -150
  6. package/dist/examples/asr/moss-transcribe-filesystem.d.ts +2 -0
  7. package/dist/examples/asr/moss-transcribe-filesystem.js +84 -0
  8. package/dist/examples/asr/moss-transcribe-fit.d.ts +2 -0
  9. package/dist/examples/asr/moss-transcribe-fit.js +40 -0
  10. package/dist/examples/asr/nemotron-diarization-filesystem.d.ts +2 -0
  11. package/dist/examples/asr/nemotron-diarization-filesystem.js +64 -0
  12. package/dist/examples/asr/parakeet-ctc-filesystem.js +2 -2
  13. package/dist/examples/asr/parakeet-indic-conformer-filesystem.js +2 -2
  14. package/dist/examples/asr/parakeet-microphone-record.js +1 -1
  15. package/dist/examples/asr/parakeet-microphone-stream.js +1 -1
  16. package/dist/examples/asr/parakeet-nemotron-filesystem.js +3 -3
  17. package/dist/examples/asr/parakeet-sortformer-streaming.js +2 -2
  18. package/dist/examples/asr/parakeet-sortformer.js +1 -1
  19. package/dist/examples/asr/parakeet-tdt-filesystem-chunked.js +2 -2
  20. package/dist/examples/asr/parakeet-tdt-filesystem.js +2 -2
  21. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  22. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +76 -0
  23. package/dist/examples/asr/parakeet-unified-coreml.js +2 -2
  24. package/dist/examples/asr/parakeet-unified-filesystem.js +2 -2
  25. package/dist/examples/asr/whispercpp-filesystem-streaming.js +1 -1
  26. package/dist/examples/asr/whispercpp-filesystem.js +1 -1
  27. package/dist/examples/asr/whispercpp-microphone-record.js +1 -1
  28. package/dist/examples/asr/whispercpp-prompt.js +1 -1
  29. package/dist/examples/assess-model-fit.js +3 -6
  30. package/dist/examples/audiogen/edit-music.js +2 -2
  31. package/dist/examples/audiogen/generate-cover.js +2 -2
  32. package/dist/examples/audiogen/generate-music-minimax.js +1 -1
  33. package/dist/examples/audiogen/generate-music.js +1 -1
  34. package/dist/examples/audiogen/understand-music.js +2 -2
  35. package/dist/examples/batch-completion.d.ts +1 -1
  36. package/dist/examples/batch-completion.js +1 -1
  37. package/dist/examples/bci/bci-filesystem-streaming.js +2 -2
  38. package/dist/examples/bci/bci-filesystem.js +2 -2
  39. package/dist/examples/concurrent-completion-collision.js +1 -1
  40. package/dist/examples/config-reload.js +1 -1
  41. package/dist/examples/decisions.d.ts +2 -0
  42. package/dist/examples/decisions.js +38 -0
  43. package/dist/examples/diffusion-esrgan-upscale.js +1 -1
  44. package/dist/examples/diffusion-flux2-klein-img2img.js +1 -1
  45. package/dist/examples/diffusion-img2img.js +1 -1
  46. package/dist/examples/diffusion-img2vid-ltx.js +8 -15
  47. package/dist/examples/diffusion-img2vid-minimax-h3.d.ts +2 -0
  48. package/dist/examples/diffusion-img2vid-minimax-h3.js +72 -0
  49. package/dist/examples/diffusion-img2vid.js +1 -1
  50. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  51. package/dist/examples/diffusion-qwen-image-21.js +104 -0
  52. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  53. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  54. package/dist/examples/llamacpp-filesystem.js +1 -1
  55. package/dist/examples/llamacpp-multi-gpu.js +2 -2
  56. package/dist/examples/llamacpp-multimodal.js +3 -1
  57. package/dist/examples/llamacpp-structured-output.js +1 -1
  58. package/dist/examples/mcp-websearch.d.ts +2 -2
  59. package/dist/examples/mcp-websearch.js +4 -4
  60. package/dist/examples/model-fit-ui/server.d.ts +1 -1
  61. package/dist/examples/model-fit-ui/server.js +1 -1
  62. package/dist/examples/multi-job-completion.d.ts +1 -1
  63. package/dist/examples/multi-job-completion.js +1 -1
  64. package/dist/examples/ocr-fasttext.js +1 -1
  65. package/dist/examples/plugins.js +1 -1
  66. package/dist/examples/rerank.d.ts +2 -0
  67. package/dist/examples/rerank.js +33 -0
  68. package/dist/examples/tools/llamacpp-deferred-tools.js +5 -5
  69. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +5 -4
  70. package/dist/examples/tools/llamacpp-tools-gemma4.js +4 -4
  71. package/dist/examples/tools/llamacpp-tools-qwen35.js +5 -4
  72. package/dist/examples/tts/llm-to-tts-streaming.d.ts +2 -2
  73. package/dist/examples/tts/llm-to-tts-streaming.js +2 -2
  74. package/dist/examples/tts/moss-sound-effect-controls.d.ts +2 -0
  75. package/dist/examples/tts/moss-sound-effect-controls.js +88 -0
  76. package/dist/examples/tts/moss-sound-effect.d.ts +2 -0
  77. package/dist/examples/tts/moss-sound-effect.js +86 -0
  78. package/dist/examples/tts/moss-speech-audio.d.ts +2 -0
  79. package/dist/examples/tts/moss-speech-audio.js +159 -0
  80. package/dist/examples/tts/moss-speech.d.ts +2 -0
  81. package/dist/examples/tts/moss-speech.js +70 -0
  82. package/dist/examples/vla-groot.js +2 -2
  83. package/dist/examples/vla-pi05.js +2 -2
  84. package/dist/examples/vla-smolvla.js +2 -2
  85. package/dist/examples/voice-assistant/voice-assistant.js +1 -1
  86. package/dist/scripts/contract/build-contract.d.ts +3 -1
  87. package/dist/scripts/contract/build-contract.js +40 -2
  88. package/dist/scripts/contract/build-model-type-maps.d.ts +6 -1
  89. package/dist/scripts/contract/build-model-type-maps.js +3 -2
  90. package/dist/scripts/contract/constants-registry.d.ts +6 -0
  91. package/dist/scripts/contract/constants-registry.js +4 -1
  92. package/dist/scripts/contract/method-shapes.d.ts +2 -0
  93. package/dist/scripts/contract/method-shapes.js +2 -0
  94. package/dist/scripts/export-contract.js +20 -7
  95. package/dist/scripts/run-unit-tests.js +10 -5
  96. package/dist/src/client/api/assess-model-fit.d.ts +5 -5
  97. package/dist/src/client/api/assess-model-fit.js +6 -7
  98. package/dist/src/client/api/audio-edit.d.ts +14 -2
  99. package/dist/src/client/api/audio-edit.js +16 -4
  100. package/dist/src/client/api/audio-gen-result.js +2 -2
  101. package/dist/src/client/api/audio-gen.d.ts +10 -2
  102. package/dist/src/client/api/audio-gen.js +12 -4
  103. package/dist/src/client/api/audio-understand.d.ts +1 -1
  104. package/dist/src/client/api/audio-understand.js +3 -3
  105. package/dist/src/client/api/batch-completion.js +3 -3
  106. package/dist/src/client/api/bci-transcribe.js +3 -3
  107. package/dist/src/client/api/cancel.js +1 -1
  108. package/dist/src/client/api/classify.js +1 -1
  109. package/dist/src/client/api/completion-stream.d.ts +2 -1
  110. package/dist/src/client/api/completion-stream.js +6 -4
  111. package/dist/src/client/api/decide.d.ts +31 -0
  112. package/dist/src/client/api/decide.js +29 -0
  113. package/dist/src/client/api/delete-cache.js +1 -1
  114. package/dist/src/client/api/diffusion.d.ts +18 -1
  115. package/dist/src/client/api/diffusion.js +19 -2
  116. package/dist/src/client/api/download-asset.js +3 -3
  117. package/dist/src/client/api/embed.js +2 -2
  118. package/dist/src/client/api/finetune.js +3 -3
  119. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  120. package/dist/src/client/api/get-model-info.js +1 -1
  121. package/dist/src/client/api/get-system-resources.js +1 -1
  122. package/dist/src/client/api/heartbeat.js +1 -1
  123. package/dist/src/client/api/index.d.ts +5 -3
  124. package/dist/src/client/api/index.js +5 -3
  125. package/dist/src/client/api/invoke-plugin.js +1 -1
  126. package/dist/src/client/api/load-model.d.ts +1 -0
  127. package/dist/src/client/api/load-model.js +4 -4
  128. package/dist/src/client/api/logging-stream.d.ts +11 -2
  129. package/dist/src/client/api/logging-stream.js +12 -3
  130. package/dist/src/client/api/ocr.js +1 -1
  131. package/dist/src/client/api/rag.js +2 -2
  132. package/dist/src/client/api/registry.d.ts +2 -1
  133. package/dist/src/client/api/registry.js +6 -5
  134. package/dist/src/client/api/rerank.d.ts +22 -0
  135. package/dist/src/client/api/rerank.js +39 -0
  136. package/dist/src/client/api/resume.js +1 -1
  137. package/dist/src/client/api/rpc-server.js +2 -2
  138. package/dist/src/client/api/state.js +1 -1
  139. package/dist/src/client/api/subscribe-logs.js +3 -2
  140. package/dist/src/client/api/suspend.js +1 -1
  141. package/dist/src/client/api/text-to-speech.d.ts +1 -0
  142. package/dist/src/client/api/text-to-speech.js +18 -25
  143. package/dist/src/client/api/transcribe.d.ts +1 -1
  144. package/dist/src/client/api/transcribe.js +7 -4
  145. package/dist/src/client/api/translate.js +2 -2
  146. package/dist/src/client/api/unload-model.js +2 -2
  147. package/dist/src/client/api/upscale.js +1 -1
  148. package/dist/src/client/api/vector-index.d.ts +1 -1
  149. package/dist/src/client/api/vector-index.js +1 -1
  150. package/dist/src/client/api/video-request.d.ts +5 -5
  151. package/dist/src/client/api/video.d.ts +23 -3
  152. package/dist/src/client/api/video.js +26 -6
  153. package/dist/src/client/api/world-result.js +2 -2
  154. package/dist/src/client/api/world.d.ts +1 -1
  155. package/dist/src/client/api/world.js +2 -2
  156. package/dist/src/client/logging-stream-registry.js +9 -6
  157. package/dist/src/client/plugins-factory.d.ts +1 -1
  158. package/dist/src/client/plugins-factory.js +1 -1
  159. package/dist/src/client/rpc/expo-rpc-client.js +3 -3
  160. package/dist/src/client/rpc/ipc-socket-path.d.ts +11 -0
  161. package/dist/src/client/rpc/ipc-socket-path.js +30 -0
  162. package/dist/src/client/rpc/node-rpc-client.js +14 -25
  163. package/dist/src/client/rpc/rpc-client.d.ts +3 -2
  164. package/dist/src/client/rpc/rpc-client.js +46 -12
  165. package/dist/src/client/rpc/rpc-error.js +4 -1
  166. package/dist/src/commands/bundle/bare-pack.d.ts +8 -0
  167. package/dist/src/commands/bundle/bare-pack.js +28 -5
  168. package/dist/src/commands/bundle/constants.js +3 -0
  169. package/dist/src/commands/bundle/entry-gen.js +1 -1
  170. package/dist/src/commands/bundle/index.d.ts +8 -7
  171. package/dist/src/commands/bundle/index.js +135 -52
  172. package/dist/src/commands/bundle/manifest.d.ts +2 -0
  173. package/dist/src/commands/bundle/manifest.js +3 -2
  174. package/dist/src/commands/bundle/plugins.js +1 -1
  175. package/dist/src/commands/host-prebuilds/index.d.ts +18 -10
  176. package/dist/src/commands/host-prebuilds/index.js +39 -20
  177. package/dist/src/commands/index.d.ts +13 -13
  178. package/dist/src/commands/index.js +8 -8
  179. package/dist/src/commands/verify/abi.d.ts +1 -1
  180. package/dist/src/commands/verify/abi.js +1 -1
  181. package/dist/src/commands/verify/addon-source.d.ts +12 -0
  182. package/dist/src/commands/verify/addon-source.js +36 -3
  183. package/dist/src/commands/verify/bare-kit-runtime.d.ts +1 -1
  184. package/dist/src/commands/verify/bare-kit-runtime.js +1 -1
  185. package/dist/src/commands/verify/bare-kit-runtimes.js +2 -1
  186. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  187. package/dist/src/commands/verify/bundle-source.js +3 -3
  188. package/dist/src/commands/verify/engines-advice.d.ts +4 -4
  189. package/dist/src/commands/verify/engines-advice.js +4 -4
  190. package/dist/src/commands/verify/index.d.ts +5 -5
  191. package/dist/src/commands/verify/index.js +7 -7
  192. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  193. package/dist/src/commands/verify/node-modules-source.js +11 -2
  194. package/dist/src/{expo/plugins/patches/qvac-platform-addons.d.ts → commands/verify/platform-addons.d.ts} +6 -10
  195. package/dist/src/{expo/plugins/patches/qvac-platform-addons.js → commands/verify/platform-addons.js} +2 -45
  196. package/dist/src/commands/verify/prebuilds.d.ts +8 -11
  197. package/dist/src/commands/verify/prebuilds.js +44 -35
  198. package/dist/src/commands/verify/resource-collectors.js +2 -2
  199. package/dist/src/expo/plugins/link-addons.d.ts +18 -0
  200. package/dist/src/expo/plugins/link-addons.js +65 -0
  201. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  202. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  203. package/dist/src/expo/plugins/withMobileBundle.d.ts +13 -23
  204. package/dist/src/expo/plugins/withMobileBundle.js +27 -117
  205. package/dist/src/index.d.ts +4 -4
  206. package/dist/src/index.js +3 -3
  207. package/dist/src/logging/addon.d.ts +1 -1
  208. package/dist/src/pear/pre.js +4 -0
  209. package/dist/src/plugin-ids.d.ts +4 -1
  210. package/dist/src/plugin-ids.js +6 -0
  211. package/dist/src/schemas/public.d.ts +2 -1
  212. package/dist/src/schemas/public.js +2 -1
  213. package/dist/src/schemas/sdk-errors-client.d.ts +3 -0
  214. package/dist/src/schemas/sdk-errors-client.js +16 -0
  215. package/dist/src/schemas/sdk-errors-server.d.ts +2 -0
  216. package/dist/src/schemas/sdk-errors-server.js +11 -1
  217. package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
  218. package/dist/src/server/rpc/rpc-utils.js +7 -0
  219. package/dist/src/server/utils/qvac-paths.js +1 -1
  220. package/dist/src/server/utils/worker-lock.js +1 -1
  221. package/dist/src/utils/aggregate-events.d.ts +1 -1
  222. package/dist/src/utils/aggregate-events.js +2 -2
  223. package/dist/src/utils/errors-client.d.ts +10 -0
  224. package/dist/src/utils/errors-client.js +18 -0
  225. package/dist/src/utils/errors-server.d.ts +6 -0
  226. package/dist/src/utils/errors-server.js +12 -0
  227. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  228. package/dist/src/utils/mcp-adapter.js +13 -9
  229. package/dist/src/utils/tool-helpers.d.ts +1 -1
  230. package/dist/src/utils/tool-helpers.js +21 -53
  231. package/dist/src/worker/create-server.d.ts +1 -0
  232. package/dist/src/worker/create-server.js +5 -0
  233. package/dist/src/worker/handle-request.js +4 -2
  234. package/dist/src/worker/handler-utils.js +1 -1
  235. package/dist/src/worker/index.js +7 -1
  236. package/dist/src/worker/lifecycle.js +10 -2
  237. package/dist/src/worker/plugins/llamacpp-decision.d.ts +2 -0
  238. package/dist/src/worker/plugins/llamacpp-decision.js +1 -0
  239. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  240. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  241. package/dist/src/worker/plugins/moss-transcribe.d.ts +2 -0
  242. package/dist/src/worker/plugins/moss-transcribe.js +1 -0
  243. package/package.json +63 -53
  244. package/src/electron-forge/index.cjs +12 -71
  245. package/dist/scripts/link-workspace-inference.d.ts +0 -2
  246. package/dist/scripts/link-workspace-inference.js +0 -31
  247. package/src/expo/plugins/patches/android-link.mjs +0 -67
  248. package/src/expo/plugins/patches/ios-link.mjs +0 -67
  249. package/src/expo/plugins/patches/qvac-platform-addons.ts +0 -124
@@ -0,0 +1,31 @@
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
+ import { type DecideParams, type DecisionResult, type DecisionResponse, type RPCOptions } from '@qvac/inference/surface';
3
+ /**
4
+ * Answers typed decision questions about one state or a batch of states.
5
+ *
6
+ * @param params - Model ID, states, questions, and optional token budgets.
7
+ * @param options - RPC transport options.
8
+ * @returns A promise with a synchronous requestId for cancel(). One state
9
+ * resolves to one result; a batch resolves to results in input order.
10
+ * @throws {RequestValidationFailedError} If the request is invalid.
11
+ * @throws {InferenceCancelledError} If the request is cancelled.
12
+ * @throws {RequestRejectedByPolicyError} If this model's decision queue is full.
13
+ * @throws {InvalidResponseError} If the worker returns a malformed result.
14
+ */
15
+ export declare function decide(params: Extract<DecideParams, {
16
+ state: unknown;
17
+ }>, options?: RPCOptions): Promise<DecisionResult> & {
18
+ requestId: string;
19
+ };
20
+ export declare function decide(params: Extract<DecideParams, {
21
+ states: unknown;
22
+ }>, options?: RPCOptions): Promise<DecisionResult[]> & {
23
+ requestId: string;
24
+ };
25
+ export declare function decide(params: DecideParams, options?: RPCOptions): Promise<DecisionResponse> & {
26
+ requestId: string;
27
+ };
28
+ export declare function createDecisionCall(params: DecideParams, options?: RPCOptions, sendRequest?: typeof send): Promise<DecisionResponse> & {
29
+ requestId: string;
30
+ };
31
+ //# sourceMappingURL=decide.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { parseClientInput } from '../../client/parse-input.js';
2
+ import { send } from '../../client/rpc/rpc-client.js';
3
+ import { decideParamsSchema, decideResponseSchema } 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
+ export function decide(params, options) {
8
+ return createDecisionCall(params, options);
9
+ }
10
+ export function createDecisionCall(params, options, sendRequest = send) {
11
+ const requestId = generateClientRequestId();
12
+ return decoratePromise(runDecide(params, requestId, options, sendRequest), { requestId });
13
+ }
14
+ async function runDecide(params, requestId, options, sendRequest) {
15
+ const input = parseClientInput(decideParamsSchema, params);
16
+ const response = await sendRequest({ ...input, type: 'decide', requestId }, options);
17
+ if (response.type !== 'decide')
18
+ throw new InvalidResponseError('decide');
19
+ const parsed = decideResponseSchema.safeParse(response);
20
+ if (!parsed.success)
21
+ throw new InvalidResponseError('decide', parsed.error);
22
+ const { result } = parsed.data;
23
+ if ('states' in input
24
+ ? !Array.isArray(result) || result.length !== input.states.length
25
+ : Array.isArray(result)) {
26
+ throw new InvalidResponseError('decide');
27
+ }
28
+ return result;
29
+ }
@@ -1,4 +1,4 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import { InvalidDeleteCacheParamsError, DeleteCacheFailedError } from '../../utils/errors-client.js';
3
3
  /**
4
4
  * Deletes KV cache files.
@@ -14,8 +14,11 @@ interface DiffusionResult {
14
14
  *
15
15
  * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
16
16
  * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
17
+ * @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
18
+ * @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
17
19
  *
18
- * Supports both txt2img (no `init_image`) and img2img (with `init_image`).
20
+ * Supports txt2img without input images, img2img via `init_image`,
21
+ * and ordered multi-reference editing via `init_images` on supported models.
19
22
  *
20
23
  * @example
21
24
  * ```typescript
@@ -49,6 +52,20 @@ interface DiffusionResult {
49
52
  * height: 768,
50
53
  * });
51
54
  *
55
+ * // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
56
+ * // vision projector, and 2.1 VAE from your local files first.
57
+ * const { outputs: edited } = diffusion({
58
+ * modelId,
59
+ * prompt: "Place the two referenced people together in one office.",
60
+ * init_images: [refA, refB],
61
+ * width: 512,
62
+ * height: 512,
63
+ * steps: 30,
64
+ * cfg_scale: 6,
65
+ * sampling_method: "euler",
66
+ * seed: 42,
67
+ * });
68
+ *
52
69
  * // LoRA adapter for this generation (absolute path required).
53
70
  * // Persistence across subsequent diffusion() calls is controlled at
54
71
  * // loadModel time via `modelConfig.lora_apply_mode`.
@@ -1,13 +1,16 @@
1
1
  import { diffusionStreamResponseSchema } 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
3
  import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
4
4
  /**
5
5
  * Generates images using a loaded diffusion model.
6
6
  *
7
7
  * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
8
8
  * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
9
+ * @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
10
+ * @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
9
11
  *
10
- * Supports both txt2img (no `init_image`) and img2img (with `init_image`).
12
+ * Supports txt2img without input images, img2img via `init_image`,
13
+ * and ordered multi-reference editing via `init_images` on supported models.
11
14
  *
12
15
  * @example
13
16
  * ```typescript
@@ -41,6 +44,20 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
41
44
  * height: 768,
42
45
  * });
43
46
  *
47
+ * // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
48
+ * // vision projector, and 2.1 VAE from your local files first.
49
+ * const { outputs: edited } = diffusion({
50
+ * modelId,
51
+ * prompt: "Place the two referenced people together in one office.",
52
+ * init_images: [refA, refB],
53
+ * width: 512,
54
+ * height: 512,
55
+ * steps: 30,
56
+ * cfg_scale: 6,
57
+ * sampling_method: "euler",
58
+ * seed: 42,
59
+ * });
60
+ *
44
61
  * // LoRA adapter for this generation (absolute path required).
45
62
  * // Persistence across subsequent diffusion() calls is controlled at
46
63
  * // loadModel time via `modelConfig.lora_apply_mode`.
@@ -1,9 +1,9 @@
1
- import { send, stream } from '../rpc/rpc-client.js';
1
+ import { send, stream } from '../../client/rpc/rpc-client.js';
2
2
  import { downloadAssetOptionsToRequestSchema } from '@qvac/inference/surface';
3
3
  import { DownloadAssetFailedError, StreamEndedError, InvalidResponseError } from '../../utils/errors-client.js';
4
4
  import { decoratePromise } from '../../utils/decorate-promise.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
  /**
8
8
  * Downloads an asset (model file) without loading it into memory.
9
9
  *
@@ -1,8 +1,8 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import {} from '@qvac/inference/surface';
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
  export function embed(params, options) {
7
7
  // Client-generated `requestId` is surfaced synchronously on the
8
8
  // returned promise so the caller can `cancel({ requestId })` before
@@ -1,8 +1,8 @@
1
- import { send, stream as streamRpc } from '../rpc/rpc-client.js';
1
+ import { send, stream as streamRpc } from '../../client/rpc/rpc-client.js';
2
2
  import { finetuneRunParamsSchema, finetuneRunRequestSchema, finetuneStopRequestSchema, finetuneGetStateParamsSchema, finetuneGetStateRequestSchema, finetuneProgressResponseSchema, finetuneResponseSchema } from '@qvac/inference/surface';
3
3
  import { InvalidResponseError, StreamEndedError } from '../../utils/errors-client.js';
4
- import { parseClientInput } from '../parse-input.js';
5
- import { generateClientRequestId } from './client-request-id.js';
4
+ import { parseClientInput } from '../../client/parse-input.js';
5
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
6
6
  function isFinetuneReplyParams(params) {
7
7
  return (params.operation === 'pause' || params.operation === 'cancel' || params.operation === 'getState');
8
8
  }
@@ -1,5 +1,5 @@
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
  /**
5
5
  * Returns introspection info for a loaded `modelId`.
@@ -1,5 +1,5 @@
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
  /**
5
5
  * Returns status information for a catalog model, including cache state and loaded instances.
@@ -1,5 +1,5 @@
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
  /**
5
5
  * Read the worker's system capabilities and optional resource sample.
@@ -1,5 +1,5 @@
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
  /**
5
5
  * Checks whether the local SDK worker is responsive by sending a heartbeat
@@ -34,8 +34,10 @@ export { resume } from './resume.js';
34
34
  export { state } from './state.js';
35
35
  export { vla, vlaHparams, vlaSetEmbodiment } from './vla.js';
36
36
  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';
37
+ export { audioGen } from '../../client/api/audio-gen.js';
38
+ export { audioEdit } from '../../client/api/audio-edit.js';
39
+ export { audioUnderstand } from '../../client/api/audio-understand.js';
40
40
  export { startRpcServer, stopRpcServer, discoverRpcServers } from './rpc-server.js';
41
+ export { decide } from './decide.js';
42
+ export { rerank } from './rerank.js';
41
43
  //# sourceMappingURL=index.d.ts.map
@@ -34,7 +34,9 @@ export { resume } from './resume.js';
34
34
  export { state } from './state.js';
35
35
  export { vla, vlaHparams, vlaSetEmbodiment } from './vla.js';
36
36
  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';
37
+ export { audioGen } from '../../client/api/audio-gen.js';
38
+ export { audioEdit } from '../../client/api/audio-edit.js';
39
+ export { audioUnderstand } from '../../client/api/audio-understand.js';
40
40
  export { startRpcServer, stopRpcServer, discoverRpcServers } from './rpc-server.js';
41
+ export { decide } from './decide.js';
42
+ export { rerank } from './rerank.js';
@@ -1,4 +1,4 @@
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
3
  /**
4
4
  * Invoke a non-streaming plugin handler.
@@ -44,6 +44,7 @@ export declare function loadModel<S extends ModelDescriptor>(options: LoadModelD
44
44
  * - fallbackSrc: For a built-in catalog model, an HTTP URL or local file path to load from when the registry is unreachable (validated against the model checksum)
45
45
  * - requireHttpChecksum: Per-call override — reject a Hugging Face HTTP download that exposes no usable SHA-256 instead of downloading it unverified. Defaults to the engine config (false).
46
46
  * - requireSecureTransport: Per-call override — reject plaintext http:// and HTTPS→HTTP downgrades for every HTTP source (loopback exempt); when unset, only Hugging Face transport is hardened. Defaults to the engine config (false).
47
+ * - modelFitPolicy: Per-call override — "log" reports the engine fitter's verdict and loads anyway, "refuse" rejects a load it projects will not fit, "off" skips the check. Defaults to the engine config ("log").
47
48
  * - onProgress: Callback for download progress updates
48
49
  * - logger: Logger instance for model operation logs
49
50
  * @param rpcOptions - Optional RPC options including per-call profiling configuration
@@ -1,12 +1,12 @@
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
10
  const logger = getClientLogger();
11
11
  function isReactNativeRuntime() {
12
12
  const runtime = globalThis;
@@ -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,5 +1,5 @@
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
3
  /**
4
4
  * Performs Optical Character Recognition (OCR) on an image to extract text.
5
5
  *
@@ -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
  /**
@@ -33,7 +33,8 @@ declare function modelRegistrySearch(params?: ModelRegistrySearchParams): Promis
33
33
  * @param registryPath - Registry-relative path of the model to fetch.
34
34
  * @param registrySource - Registry source identifier (e.g., `"huggingface"`, `"local"`).
35
35
  * @returns A promise resolving to the matching `ModelRegistryEntry`.
36
- * @throws {ModelRegistryQueryFailedError} When the model cannot be located or the registry query fails.
36
+ * @throws {ModelRegistryModelNotFoundError} When the registry has no model at this source and path.
37
+ * @throws {ModelRegistryQueryFailedError} When the registry query fails.
37
38
  */
38
39
  declare function modelRegistryGetModel(registryPath: string, registrySource: string): Promise<ModelRegistryEntry>;
39
40
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel };
@@ -1,8 +1,8 @@
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
+ function validateRegistryResponse(response) {
4
4
  if (!response.success) {
5
- throw new ModelRegistryQueryFailedError(response.error ?? fallbackError ?? 'Unknown registry error');
5
+ throw new ModelRegistryQueryFailedError(response.error ?? 'Unknown registry error');
6
6
  }
7
7
  }
8
8
  /**
@@ -48,7 +48,8 @@ async function modelRegistrySearch(params = {}) {
48
48
  * @param registryPath - Registry-relative path of the model to fetch.
49
49
  * @param registrySource - Registry source identifier (e.g., `"huggingface"`, `"local"`).
50
50
  * @returns A promise resolving to the matching `ModelRegistryEntry`.
51
- * @throws {ModelRegistryQueryFailedError} When the model cannot be located or the registry query fails.
51
+ * @throws {ModelRegistryModelNotFoundError} When the registry has no model at this source and path.
52
+ * @throws {ModelRegistryQueryFailedError} When the registry query fails.
52
53
  */
53
54
  async function modelRegistryGetModel(registryPath, registrySource) {
54
55
  const request = {
@@ -57,7 +58,7 @@ async function modelRegistryGetModel(registryPath, registrySource) {
57
58
  registrySource
58
59
  };
59
60
  const response = (await send(request));
60
- validateRegistryResponse(response, `Model not found: ${registrySource}/${registryPath}`);
61
+ validateRegistryResponse(response);
61
62
  return response.model;
62
63
  }
63
64
  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,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
@@ -1,8 +1,8 @@
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.
@@ -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.
@@ -26,7 +26,8 @@ const logger = getClientLogger();
26
26
  * ```
27
27
  */
28
28
  export function subscribeServerLogs(handler) {
29
- const streamIterator = loggingStream({ id: SDK_ALL_LOG_ID });
29
+ const controller = new AbortController();
30
+ const streamIterator = loggingStream({ id: SDK_ALL_LOG_ID }, { 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,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
@@ -83,6 +83,7 @@ export declare function textToSpeech(params: TtsClientParamsInput, options?: RPC
83
83
  * so `await result.sampleRate` can never hang or reject on its own.
84
84
  */
85
85
  export type TtsSideChannel = {
86
+ text: Promise<string | undefined>;
86
87
  sampleRate: Promise<number | undefined>;
87
88
  stats: Promise<TtsStats | undefined>;
88
89
  stopReason: Promise<'completed' | 'cancelled' | undefined>;