@qvac/sdk 0.22.0 → 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 (150) hide show
  1. package/NOTICE +123 -83
  2. package/README.md +22 -460
  3. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +76 -0
  5. package/dist/examples/diffusion-img2vid-ltx.js +7 -14
  6. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  7. package/dist/examples/diffusion-qwen-image-21.js +104 -0
  8. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  9. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  10. package/dist/examples/llamacpp-multimodal.js +3 -1
  11. package/dist/examples/mcp-websearch.js +1 -1
  12. package/dist/examples/plugins.js +1 -1
  13. package/dist/examples/rerank.d.ts +2 -0
  14. package/dist/examples/rerank.js +33 -0
  15. package/dist/examples/tools/llamacpp-deferred-tools.js +5 -5
  16. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
  17. package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
  18. package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
  19. package/dist/scripts/contract/build-contract.d.ts +1 -1
  20. package/dist/scripts/contract/constants-registry.d.ts +2 -0
  21. package/dist/scripts/contract/constants-registry.js +2 -1
  22. package/dist/scripts/contract/method-shapes.d.ts +1 -0
  23. package/dist/scripts/contract/method-shapes.js +1 -0
  24. package/dist/src/client/api/assess-model-fit.js +1 -1
  25. package/dist/src/client/api/audio-edit.js +2 -2
  26. package/dist/src/client/api/audio-gen-result.js +2 -2
  27. package/dist/src/client/api/audio-gen.js +2 -2
  28. package/dist/src/client/api/audio-understand.js +2 -2
  29. package/dist/src/client/api/batch-completion.js +2 -2
  30. package/dist/src/client/api/bci-transcribe.js +3 -3
  31. package/dist/src/client/api/cancel.js +1 -1
  32. package/dist/src/client/api/classify.js +1 -1
  33. package/dist/src/client/api/completion-stream.d.ts +2 -1
  34. package/dist/src/client/api/completion-stream.js +5 -3
  35. package/dist/src/client/api/decide.d.ts +1 -1
  36. package/dist/src/client/api/decide.js +3 -3
  37. package/dist/src/client/api/delete-cache.js +1 -1
  38. package/dist/src/client/api/diffusion.d.ts +18 -1
  39. package/dist/src/client/api/diffusion.js +19 -2
  40. package/dist/src/client/api/download-asset.js +3 -3
  41. package/dist/src/client/api/embed.js +2 -2
  42. package/dist/src/client/api/finetune.js +3 -3
  43. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  44. package/dist/src/client/api/get-model-info.js +1 -1
  45. package/dist/src/client/api/get-system-resources.js +1 -1
  46. package/dist/src/client/api/heartbeat.js +1 -1
  47. package/dist/src/client/api/index.d.ts +4 -3
  48. package/dist/src/client/api/index.js +4 -3
  49. package/dist/src/client/api/invoke-plugin.js +1 -1
  50. package/dist/src/client/api/load-model.js +4 -4
  51. package/dist/src/client/api/logging-stream.d.ts +11 -2
  52. package/dist/src/client/api/logging-stream.js +12 -3
  53. package/dist/src/client/api/ocr.js +1 -1
  54. package/dist/src/client/api/rag.js +2 -2
  55. package/dist/src/client/api/registry.d.ts +2 -1
  56. package/dist/src/client/api/registry.js +6 -5
  57. package/dist/src/client/api/rerank.d.ts +22 -0
  58. package/dist/src/client/api/rerank.js +39 -0
  59. package/dist/src/client/api/resume.js +1 -1
  60. package/dist/src/client/api/rpc-server.js +2 -2
  61. package/dist/src/client/api/state.js +1 -1
  62. package/dist/src/client/api/subscribe-logs.js +3 -2
  63. package/dist/src/client/api/suspend.js +1 -1
  64. package/dist/src/client/api/text-to-speech.js +3 -3
  65. package/dist/src/client/api/transcribe.d.ts +1 -1
  66. package/dist/src/client/api/transcribe.js +2 -2
  67. package/dist/src/client/api/translate.js +2 -2
  68. package/dist/src/client/api/unload-model.js +2 -2
  69. package/dist/src/client/api/upscale.js +1 -1
  70. package/dist/src/client/api/vector-index.d.ts +1 -1
  71. package/dist/src/client/api/vector-index.js +1 -1
  72. package/dist/src/client/api/video.js +3 -3
  73. package/dist/src/client/api/world-result.js +2 -2
  74. package/dist/src/client/api/world.d.ts +1 -1
  75. package/dist/src/client/api/world.js +2 -2
  76. package/dist/src/client/logging-stream-registry.js +9 -6
  77. package/dist/src/client/plugins-factory.d.ts +1 -1
  78. package/dist/src/client/plugins-factory.js +1 -1
  79. package/dist/src/client/rpc/expo-rpc-client.js +3 -3
  80. package/dist/src/client/rpc/ipc-socket-path.d.ts +11 -0
  81. package/dist/src/client/rpc/ipc-socket-path.js +30 -0
  82. package/dist/src/client/rpc/node-rpc-client.js +14 -25
  83. package/dist/src/client/rpc/rpc-client.d.ts +3 -2
  84. package/dist/src/client/rpc/rpc-client.js +46 -12
  85. package/dist/src/client/rpc/rpc-error.js +4 -1
  86. package/dist/src/commands/bundle/constants.js +1 -0
  87. package/dist/src/commands/bundle/entry-gen.js +1 -1
  88. package/dist/src/commands/bundle/index.d.ts +1 -1
  89. package/dist/src/commands/bundle/index.js +11 -11
  90. package/dist/src/commands/bundle/plugins.js +1 -1
  91. package/dist/src/commands/host-prebuilds/index.d.ts +3 -3
  92. package/dist/src/commands/host-prebuilds/index.js +4 -4
  93. package/dist/src/commands/index.d.ts +12 -12
  94. package/dist/src/commands/index.js +7 -7
  95. package/dist/src/commands/verify/abi.d.ts +1 -1
  96. package/dist/src/commands/verify/abi.js +1 -1
  97. package/dist/src/commands/verify/bare-kit-runtime.d.ts +1 -1
  98. package/dist/src/commands/verify/bare-kit-runtime.js +1 -1
  99. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  100. package/dist/src/commands/verify/bundle-source.js +3 -3
  101. package/dist/src/commands/verify/engines-advice.d.ts +4 -4
  102. package/dist/src/commands/verify/engines-advice.js +4 -4
  103. package/dist/src/commands/verify/index.d.ts +5 -5
  104. package/dist/src/commands/verify/index.js +7 -7
  105. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  106. package/dist/src/commands/verify/node-modules-source.js +1 -1
  107. package/dist/src/commands/verify/prebuilds.d.ts +1 -1
  108. package/dist/src/commands/verify/prebuilds.js +2 -2
  109. package/dist/src/commands/verify/resource-collectors.js +2 -2
  110. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  111. package/dist/src/expo/plugins/link-addons.js +1 -1
  112. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  113. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  114. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  115. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  116. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  117. package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -4
  118. package/dist/src/expo/plugins/withMobileBundle.js +6 -6
  119. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  120. package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -1
  121. package/dist/src/index.d.ts +4 -4
  122. package/dist/src/index.js +3 -3
  123. package/dist/src/logging/addon.d.ts +1 -1
  124. package/dist/src/logging/base-logger.js +1 -1
  125. package/dist/src/logging/utils.js +1 -1
  126. package/dist/src/pear/pre.js +2 -0
  127. package/dist/src/plugin-ids.d.ts +2 -1
  128. package/dist/src/plugin-ids.js +2 -0
  129. package/dist/src/schemas/public.d.ts +1 -1
  130. package/dist/src/schemas/public.js +1 -1
  131. package/dist/src/schemas/sdk-errors-server.d.ts +1 -0
  132. package/dist/src/schemas/sdk-errors-server.js +6 -1
  133. package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
  134. package/dist/src/server/rpc/rpc-utils.js +7 -0
  135. package/dist/src/server/utils/qvac-paths.js +1 -1
  136. package/dist/src/server/utils/worker-lock.js +1 -1
  137. package/dist/src/utils/aggregate-events.d.ts +1 -1
  138. package/dist/src/utils/aggregate-events.js +2 -2
  139. package/dist/src/utils/errors-server.d.ts +6 -0
  140. package/dist/src/utils/errors-server.js +12 -0
  141. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  142. package/dist/src/utils/mcp-adapter.js +1 -1
  143. package/dist/src/utils/tool-helpers.js +1 -1
  144. package/dist/src/worker/handle-request.js +4 -2
  145. package/dist/src/worker/handler-utils.js +1 -1
  146. package/dist/src/worker/index.js +3 -1
  147. package/dist/src/worker/lifecycle.js +1 -1
  148. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  149. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  150. package/package.json +46 -40
@@ -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,9 +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
41
  export { decide } from './decide.js';
42
+ export { rerank } from './rerank.js';
42
43
  //# sourceMappingURL=index.d.ts.map
@@ -34,8 +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
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.
@@ -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
@@ -1,9 +1,9 @@
1
1
  import { textToSpeechStreamResponseSchema, textToSpeechStreamRequestSchema, ttsClientParamsSchema } from '@qvac/inference/surface';
2
- import { stream as streamRpc, duplex } from '../rpc/rpc-client.js';
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
@@ -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
@@ -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 {
@@ -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,7 +1,7 @@
1
1
  import { isBare } from 'which-runtime';
2
2
  import {} from '@qvac/inference/surface';
3
- import { send, close } from '../rpc/rpc-client.js';
4
- import { stopLoggingStreamForModel } from '../logging-stream-registry.js';
3
+ import { send, close } from '../../client/rpc/rpc-client.js';
4
+ import { stopLoggingStreamForModel } from '../../client/logging-stream-registry.js';
5
5
  import { InvalidResponseError, ModelUnloadFailedError } from '../../utils/errors-client.js';
6
6
  import { getClientLogger } from '../../logging/index.js';
7
7
  const logger = getClientLogger();
@@ -1,5 +1,5 @@
1
1
  import { upscaleStreamResponseSchema } 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
  import { StreamEndedError } from '../../utils/errors-client.js';
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import { type CreateVectorIndexParams, type LoadVectorIndexParams, type RPCOptions, type VectorIndexAddParams, type VectorIndexHit, type VectorIndexIdsParams, type VectorIndexStorage, type VectorIndexWriteParams } from '@qvac/inference/surface';
3
3
  /**
4
4
  * A handle to a vector index that lives in worker memory.
@@ -1,4 +1,4 @@
1
- import { send } from '../rpc/rpc-client.js';
1
+ import { send } from '../../client/rpc/rpc-client.js';
2
2
  import { DEFAULT_VECTOR_INDEX_STORAGE, findVectorRowLengthMismatch, toWireVectorIds } from '@qvac/inference/surface';
3
3
  import { InvalidOperationError, InvalidResponseError, RequestValidationFailedError } from '../../utils/errors-client.js';
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { videoStreamResponseSchema } from '@qvac/inference/surface';
2
- import { stream as streamRpc } from '../rpc/rpc-client.js';
3
- import { generateClientRequestId } from './client-request-id.js';
4
- import { createVideoStreamRequest } from './video-request.js';
2
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
+ import { createVideoStreamRequest } from '../../client/api/video-request.js';
5
5
  import { decodeBase64 } from '../../utils/encoding.js';
6
6
  /**
7
7
  * Generates a video using a loaded video diffusion model.
@@ -1,6 +1,6 @@
1
1
  import { MAX_SCENE_IMAGE_BYTES, walkKeySchema, worldSceneStreamRequestSchema, worldSceneStreamResponseSchema, worldStepStreamRequestSchema, worldStepStreamResponseSchema } from '@qvac/inference/surface';
2
- import { parseClientInput } from '../parse-input.js';
3
- import { generateClientRequestId } from './client-request-id.js';
2
+ import { parseClientInput } from '../../client/parse-input.js';
3
+ import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
4
  import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
5
5
  import { InvalidResponseError, RequestValidationFailedError, StreamEndedError } from '../../utils/errors-client.js';
6
6
  import { InferenceCancelledError } from '../../utils/errors-server.js';
@@ -1,5 +1,5 @@
1
1
  import type { WorldSceneClientParams, WorldStepClientParams } from '@qvac/inference/surface';
2
- import { type WorldSceneResult, type WorldSceneResultWithPack, type WorldStepResult } from './world-result.js';
2
+ import { type WorldSceneResult, type WorldSceneResultWithPack, type WorldStepResult } from '../../client/api/world-result.js';
3
3
  /**
4
4
  * Builds a world for an ABot-World session: the prompt and first frame are
5
5
  * encoded into a scene pack the walk then runs on.
@@ -1,5 +1,5 @@
1
- import { stream as streamRpc } from '../rpc/rpc-client.js';
2
- import { createWorldSceneResult, createWorldStepResult } from './world-result.js';
1
+ import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
2
+ import { createWorldSceneResult, createWorldStepResult } from '../../client/api/world-result.js';
3
3
  export function worldCreateScene(params) {
4
4
  return createWorldSceneResult(params, streamRpc);
5
5
  }
@@ -7,8 +7,10 @@ export function startLoggingStreamForModel(modelId, modelLogger) {
7
7
  logger.warn(`Logging stream already active for model ${modelId}`);
8
8
  return;
9
9
  }
10
- const streamIterator = loggingStream({ id: modelId });
11
- activeStreams.set(modelId, { logger: modelLogger, streamIterator });
10
+ const controller = new AbortController();
11
+ const streamIterator = loggingStream({ id: modelId }, { signal: controller.signal });
12
+ const entry = { logger: modelLogger, controller };
13
+ activeStreams.set(modelId, entry);
12
14
  try {
13
15
  void (async () => {
14
16
  try {
@@ -36,7 +38,9 @@ export function startLoggingStreamForModel(modelId, modelLogger) {
36
38
  logger.error(`Logging stream error for model ${modelId}:`, error);
37
39
  }
38
40
  finally {
39
- activeStreams.delete(modelId);
41
+ // A reload may have replaced this entry.
42
+ if (activeStreams.get(modelId) === entry)
43
+ activeStreams.delete(modelId);
40
44
  }
41
45
  })();
42
46
  }
@@ -50,9 +54,8 @@ export function stopLoggingStreamForModel(modelId) {
50
54
  const stream = activeStreams.get(modelId);
51
55
  if (stream) {
52
56
  activeStreams.delete(modelId);
53
- // Terminate the stream iterator - this will close the RPC connection
54
- // and the server-side async generator will automatically terminate
55
- void stream.streamIterator.return(undefined);
57
+ // `return()` would wait for a log an unloaded model never sends.
58
+ stream.controller.abort();
56
59
  logger.debug(`Stopped logging stream for model ${modelId}`);
57
60
  }
58
61
  }
@@ -1,4 +1,4 @@
1
- import * as hostApi from './api/index.js';
1
+ import * as hostApi from '../client/api/index.js';
2
2
  import type { QvacPlugin } from '@qvac/inference/surface';
3
3
  /**
4
4
  * Register plugins and return the client host API.
@@ -1,5 +1,5 @@
1
1
  import { registerPlugins } from '../server/plugins/index.js';
2
- import * as hostApi from './api/index.js';
2
+ import * as hostApi from '../client/api/index.js';
3
3
  /**
4
4
  * Register plugins and return the client host API.
5
5
  */
@@ -1,9 +1,9 @@
1
1
  import RPC from 'bare-rpc';
2
2
  import { RPCConnectionFailedError } from '../../utils/errors-client.js';
3
- import { initializeConfig } from '../init-hooks.js';
4
- import { resolveConfig } from '../config-loader/resolve-config.expo.js';
3
+ import { initializeConfig } from '../../client/init-hooks.js';
4
+ import { resolveConfig } from '../../client/config-loader/resolve-config.expo.js';
5
5
  import { getClientLogger } from '../../logging/index.js';
6
- import { getDeviceInfo } from './expo-device-info.js';
6
+ import { getDeviceInfo } from '../../client/rpc/expo-device-info.js';
7
7
  const logger = getClientLogger();
8
8
  let rpcInstance = null;
9
9
  let rpcPromise = null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Create the endpoint the worker dials.
3
+ *
4
+ * On Unix the socket sits in a fresh directory that only the current user can
5
+ * enter, so other local users cannot reach it whatever the process umask. On
6
+ * Windows it is a named pipe, whose default access already denies other users.
7
+ */
8
+ export declare function createIPCSocketPath(): string;
9
+ /** Remove the socket file and its directory. Named pipes have nothing to remove. */
10
+ export declare function removeIPCSocketPath(socketPath: string): void;
11
+ //# sourceMappingURL=ipc-socket-path.d.ts.map