@qvac/sdk 0.10.2 → 0.11.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 (200) hide show
  1. package/NOTICE +92 -54
  2. package/dist/client/api/cancel.d.ts +24 -32
  3. package/dist/client/api/cancel.js +58 -31
  4. package/dist/client/api/client-request-id.d.ts +17 -0
  5. package/dist/client/api/client-request-id.js +27 -0
  6. package/dist/client/api/completion-stream.d.ts +1 -1
  7. package/dist/client/api/completion-stream.js +34 -3
  8. package/dist/client/api/diffusion.d.ts +46 -0
  9. package/dist/client/api/diffusion.js +50 -1
  10. package/dist/client/api/download-asset.d.ts +12 -2
  11. package/dist/client/api/download-asset.js +21 -3
  12. package/dist/client/api/embed.d.ts +8 -4
  13. package/dist/client/api/embed.js +14 -1
  14. package/dist/client/api/get-model-info.d.ts +1 -1
  15. package/dist/client/api/index.d.ts +1 -0
  16. package/dist/client/api/index.js +1 -0
  17. package/dist/client/api/load-model.d.ts +12 -4
  18. package/dist/client/api/load-model.js +25 -1
  19. package/dist/client/api/rag.d.ts +9 -3
  20. package/dist/client/api/rag.js +23 -3
  21. package/dist/client/api/transcribe.d.ts +20 -8
  22. package/dist/client/api/transcribe.js +58 -4
  23. package/dist/client/api/unload-model.d.ts +5 -2
  24. package/dist/client/api/unload-model.js +9 -4
  25. package/dist/client/api/upscale.d.ts +45 -0
  26. package/dist/client/api/upscale.js +99 -0
  27. package/dist/client/rpc/expo-rpc-client.js +2 -1
  28. package/dist/client/rpc/node-rpc-client.js +18 -7
  29. package/dist/client/rpc/rpc-client.d.ts +2 -2
  30. package/dist/client/rpc/rpc-client.js +10 -4
  31. package/dist/client/rpc/rpc-error.d.ts +9 -0
  32. package/dist/client/rpc/rpc-error.js +92 -0
  33. package/dist/examples/cancel-by-request-id.d.ts +38 -0
  34. package/dist/examples/cancel-by-request-id.js +103 -0
  35. package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
  36. package/dist/examples/diffusion-esrgan-upscale.js +78 -0
  37. package/dist/examples/download-with-cancel.js +10 -10
  38. package/dist/examples/embed-multi-gpu.d.ts +2 -0
  39. package/dist/examples/embed-multi-gpu.js +46 -0
  40. package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
  41. package/dist/examples/llamacpp-multi-gpu.js +57 -0
  42. package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
  43. package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
  44. package/dist/examples/tools/llamacpp-tools-gemma4.js +76 -0
  45. package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
  46. package/dist/examples/tools/llamacpp-tools-qwen35.js +70 -0
  47. package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
  48. package/dist/examples/transcription/whispercpp-microphone-conversation.js +102 -0
  49. package/dist/examples/tts/supertonic.js +1 -1
  50. package/dist/expo/plugins/withMobileBundle.d.ts +20 -4
  51. package/dist/expo/plugins/withMobileBundle.js +44 -6
  52. package/dist/index.d.ts +5 -2
  53. package/dist/index.js +21 -1
  54. package/dist/models/registry/models.d.ts +186 -318
  55. package/dist/models/registry/models.js +1522 -1667
  56. package/dist/pear/pre.d.ts +3 -0
  57. package/dist/pear/pre.js +3 -0
  58. package/dist/schemas/cancel.d.ts +167 -28
  59. package/dist/schemas/cancel.js +119 -19
  60. package/dist/schemas/common.d.ts +427 -208
  61. package/dist/schemas/common.js +3 -1
  62. package/dist/schemas/completion-event.d.ts +14 -0
  63. package/dist/schemas/completion-event.js +11 -1
  64. package/dist/schemas/completion-stream.d.ts +15 -1
  65. package/dist/schemas/completion-stream.js +25 -7
  66. package/dist/schemas/download-asset.d.ts +15 -9
  67. package/dist/schemas/download-asset.js +17 -6
  68. package/dist/schemas/embed.d.ts +1 -0
  69. package/dist/schemas/embed.js +5 -0
  70. package/dist/schemas/error.d.ts +31 -0
  71. package/dist/schemas/error.js +29 -1
  72. package/dist/schemas/finetune.d.ts +2 -0
  73. package/dist/schemas/finetune.js +5 -0
  74. package/dist/schemas/get-model-info.d.ts +6 -6
  75. package/dist/schemas/llamacpp-config.d.ts +54 -8
  76. package/dist/schemas/llamacpp-config.js +12 -0
  77. package/dist/schemas/load-model.d.ts +1911 -1260
  78. package/dist/schemas/load-model.js +15 -0
  79. package/dist/schemas/model-src-utils.d.ts +14 -14
  80. package/dist/schemas/model-types.d.ts +10 -10
  81. package/dist/schemas/ocr.d.ts +3 -3
  82. package/dist/schemas/plugin.d.ts +40 -1
  83. package/dist/schemas/plugin.js +10 -1
  84. package/dist/schemas/rag.d.ts +9 -0
  85. package/dist/schemas/rag.js +17 -9
  86. package/dist/schemas/registry.d.ts +30 -30
  87. package/dist/schemas/reload-config.d.ts +14 -14
  88. package/dist/schemas/sdcpp-config.d.ts +131 -17
  89. package/dist/schemas/sdcpp-config.js +163 -1
  90. package/dist/schemas/sdk-config.d.ts +649 -271
  91. package/dist/schemas/sdk-errors-client.d.ts +1 -0
  92. package/dist/schemas/sdk-errors-client.js +5 -0
  93. package/dist/schemas/sdk-errors-server.d.ts +5 -0
  94. package/dist/schemas/sdk-errors-server.js +25 -0
  95. package/dist/schemas/text-to-speech.d.ts +78 -78
  96. package/dist/schemas/transcription-config.d.ts +24 -24
  97. package/dist/schemas/transcription.d.ts +56 -2
  98. package/dist/schemas/transcription.js +27 -0
  99. package/dist/schemas/translate.d.ts +2 -0
  100. package/dist/schemas/translate.js +13 -2
  101. package/dist/schemas/translation-config.d.ts +40 -40
  102. package/dist/schemas/unload-model.d.ts +2 -1
  103. package/dist/schemas/unload-model.js +4 -1
  104. package/dist/scripts/run-unit-tests.js +15 -2
  105. package/dist/server/bare/ops/cancel.d.ts +27 -1
  106. package/dist/server/bare/ops/cancel.js +36 -10
  107. package/dist/server/bare/ops/embed.d.ts +3 -3
  108. package/dist/server/bare/ops/embed.js +144 -28
  109. package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
  110. package/dist/server/bare/ops/kv-cache-utils.js +8 -47
  111. package/dist/server/bare/ops/transcribe.d.ts +10 -5
  112. package/dist/server/bare/ops/transcribe.js +196 -41
  113. package/dist/server/bare/ops/translate.d.ts +1 -1
  114. package/dist/server/bare/ops/translate.js +197 -88
  115. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
  116. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +170 -172
  117. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
  118. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
  119. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
  120. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
  121. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
  122. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +30 -3
  123. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +157 -85
  124. package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
  125. package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
  126. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
  127. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
  128. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -15
  129. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
  130. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +3 -3
  131. package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
  132. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +39 -39
  133. package/dist/server/bare/plugins/onnx-tts/plugin.js +6 -0
  134. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +29 -21
  135. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +4 -1
  136. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
  137. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
  138. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
  139. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +91 -16
  140. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +97 -7
  141. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +22 -3
  142. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +50 -14
  143. package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
  144. package/dist/server/bare/rag-hyperdb/index.js +1 -1
  145. package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
  146. package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
  147. package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
  148. package/dist/server/bare/runtime/disposable-scope.js +69 -0
  149. package/dist/server/bare/runtime/index.d.ts +8 -0
  150. package/dist/server/bare/runtime/index.js +3 -0
  151. package/dist/server/bare/runtime/request-context.d.ts +49 -0
  152. package/dist/server/bare/runtime/request-context.js +1 -0
  153. package/dist/server/bare/runtime/request-id.d.ts +12 -0
  154. package/dist/server/bare/runtime/request-id.js +14 -0
  155. package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
  156. package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
  157. package/dist/server/bare/runtime/request-registry.d.ts +136 -0
  158. package/dist/server/bare/runtime/request-registry.js +297 -0
  159. package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
  160. package/dist/server/bare/runtime/with-request-context.js +53 -0
  161. package/dist/server/bare/types/addon-responses.d.ts +11 -1
  162. package/dist/server/rpc/handler-registry.js +26 -7
  163. package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
  164. package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
  165. package/dist/server/rpc/handlers/cancelHandler.js +54 -22
  166. package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
  167. package/dist/server/rpc/handlers/delete-cache.js +13 -15
  168. package/dist/server/rpc/handlers/download-asset.js +133 -40
  169. package/dist/server/rpc/handlers/index.d.ts +2 -0
  170. package/dist/server/rpc/handlers/index.js +2 -0
  171. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
  172. package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
  173. package/dist/server/rpc/handlers/load-model/handler.js +213 -98
  174. package/dist/server/rpc/handlers/load-model/http.js +3 -3
  175. package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
  176. package/dist/server/rpc/handlers/load-model/registry.js +1 -1
  177. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
  178. package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
  179. package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
  180. package/dist/server/rpc/handlers/load-model/resolve.js +9 -6
  181. package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
  182. package/dist/server/rpc/handlers/rag.js +133 -15
  183. package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
  184. package/dist/server/rpc/handlers/upscale-stream.js +4 -0
  185. package/dist/server/utils/completion-normalizer.js +8 -0
  186. package/dist/server/utils/tools/dialect.js +4 -0
  187. package/dist/server/utils/tools/parser.js +16 -1
  188. package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
  189. package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
  190. package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
  191. package/dist/server/utils/tools/parsers/qwen35.js +120 -0
  192. package/dist/utils/aggregate-events.d.ts +9 -0
  193. package/dist/utils/aggregate-events.js +18 -3
  194. package/dist/utils/decorate-promise.d.ts +34 -0
  195. package/dist/utils/decorate-promise.js +35 -0
  196. package/dist/utils/errors-client.d.ts +3 -0
  197. package/dist/utils/errors-client.js +5 -0
  198. package/dist/utils/errors-server.d.ts +85 -0
  199. package/dist/utils/errors-server.js +97 -0
  200. package/package.json +20 -15
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Attach metadata to a Promise so the metadata is reachable
3
+ * synchronously while the promise's normal async surface keeps working.
4
+ *
5
+ * The decorated-promise pattern lets a long-running client-API call
6
+ * (`loadModel(...)`, `downloadAsset(...)`) return a value that is both:
7
+ * - a `Promise<T>` you can `await` for the resolved result; and
8
+ * - a record carrying call metadata (`requestId`) you can read
9
+ * synchronously to target the in-flight call with
10
+ * `cancel({ requestId })` before it resolves.
11
+ *
12
+ * Implementation notes:
13
+ * - `Object.assign` attaches enumerable own properties without
14
+ * touching the prototype chain, so `await`, `.then`, `.catch`,
15
+ * `.finally`, and async-await unwrapping continue to work exactly
16
+ * as for a plain `Promise<T>`.
17
+ * - The intersection type `Promise<T> & M` is sound because the
18
+ * resolved-value type `T` does not intersect with `M`'s key set in
19
+ * practice (callers pick metadata keys that don't collide with
20
+ * `Promise` members like `then`/`catch`/`finally`). Picking such a
21
+ * key would shadow the Promise method and break the unwrap chain;
22
+ * don't.
23
+ * - We deliberately avoid extending `Promise.prototype` or calling
24
+ * `Object.setPrototypeOf`. Either would silently affect every
25
+ * promise in the worker; the plain-object approach is intentional
26
+ * and the helper exists to keep call sites consistent.
27
+ *
28
+ * @example
29
+ * const op = decoratePromise(innerPromise, { requestId: "abc" });
30
+ * op.requestId; // "abc" (synchronous)
31
+ * await op; // resolves to T (legacy contract preserved)
32
+ */
33
+ export declare function decoratePromise<T, M extends Record<string, unknown>>(promise: Promise<T>, metadata: M): Promise<T> & M;
34
+ //# sourceMappingURL=decorate-promise.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Attach metadata to a Promise so the metadata is reachable
3
+ * synchronously while the promise's normal async surface keeps working.
4
+ *
5
+ * The decorated-promise pattern lets a long-running client-API call
6
+ * (`loadModel(...)`, `downloadAsset(...)`) return a value that is both:
7
+ * - a `Promise<T>` you can `await` for the resolved result; and
8
+ * - a record carrying call metadata (`requestId`) you can read
9
+ * synchronously to target the in-flight call with
10
+ * `cancel({ requestId })` before it resolves.
11
+ *
12
+ * Implementation notes:
13
+ * - `Object.assign` attaches enumerable own properties without
14
+ * touching the prototype chain, so `await`, `.then`, `.catch`,
15
+ * `.finally`, and async-await unwrapping continue to work exactly
16
+ * as for a plain `Promise<T>`.
17
+ * - The intersection type `Promise<T> & M` is sound because the
18
+ * resolved-value type `T` does not intersect with `M`'s key set in
19
+ * practice (callers pick metadata keys that don't collide with
20
+ * `Promise` members like `then`/`catch`/`finally`). Picking such a
21
+ * key would shadow the Promise method and break the unwrap chain;
22
+ * don't.
23
+ * - We deliberately avoid extending `Promise.prototype` or calling
24
+ * `Object.setPrototypeOf`. Either would silently affect every
25
+ * promise in the worker; the plain-object approach is intentional
26
+ * and the helper exists to keep call sites consistent.
27
+ *
28
+ * @example
29
+ * const op = decoratePromise(innerPromise, { requestId: "abc" });
30
+ * op.requestId; // "abc" (synchronous)
31
+ * await op; // resolves to T (legacy contract preserved)
32
+ */
33
+ export function decoratePromise(promise, metadata) {
34
+ return Object.assign(promise, metadata);
35
+ }
@@ -68,6 +68,9 @@ export declare class WorkerFileNotFoundError extends QvacErrorBase {
68
68
  export declare class PearWorkerEntryRequiredError extends QvacErrorBase {
69
69
  constructor(workerEntry: string, cause?: unknown);
70
70
  }
71
+ export declare class BundleVerificationFailedError extends QvacErrorBase {
72
+ constructor(bundlePath: string, cause?: unknown);
73
+ }
71
74
  export declare class ConfigFileNotFoundError extends QvacErrorBase {
72
75
  constructor(searchPaths: string, cause?: unknown);
73
76
  }
@@ -121,6 +121,11 @@ export class PearWorkerEntryRequiredError extends QvacErrorBase {
121
121
  super(createErrorOptions(SDK_CLIENT_ERROR_CODES.PEAR_WORKER_ENTRY_REQUIRED, [workerEntry], cause));
122
122
  }
123
123
  }
124
+ export class BundleVerificationFailedError extends QvacErrorBase {
125
+ constructor(bundlePath, cause) {
126
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BUNDLE_VERIFICATION_FAILED, [bundlePath], cause));
127
+ }
128
+ }
124
129
  export class ConfigFileNotFoundError extends QvacErrorBase {
125
130
  constructor(searchPaths, cause) {
126
131
  super(createErrorOptions(SDK_CLIENT_ERROR_CODES.CONFIG_FILE_NOT_FOUND, [searchPaths], cause));
@@ -1,4 +1,21 @@
1
1
  import { QvacErrorBase } from "@qvac/error";
2
+ import type { CompletionStats, ToolCallWithCall } from "../schemas/index";
3
+ /**
4
+ * Partial completion payload attached to `InferenceCancelledError` when a
5
+ * cancel hits mid-stream. Mirrors the named fields on `CompletionFinal`
6
+ * so callers who want the partial output can read `.partial.text`,
7
+ * `.partial.toolCalls`, `.partial.stats` directly without reaching for
8
+ * a `Partial<CompletionFinal>` import.
9
+ *
10
+ * Fields are all optional: a same-tick cancel-before-begin races every
11
+ * event; a cancel after the first content chunk carries `text` but no
12
+ * `stats`; a cancel after a tool-call frame carries both.
13
+ */
14
+ export interface InferenceCancelledPartial {
15
+ text?: string;
16
+ toolCalls?: ToolCallWithCall[];
17
+ stats?: CompletionStats;
18
+ }
2
19
  export declare class ModelAlreadyRegisteredError extends QvacErrorBase {
3
20
  constructor(modelId: string, cause?: unknown);
4
21
  }
@@ -65,6 +82,74 @@ export declare class AttachmentNotFoundError extends QvacErrorBase {
65
82
  export declare class CancelFailedError extends QvacErrorBase {
66
83
  constructor(details?: string, cause?: unknown);
67
84
  }
85
+ export declare class RequestIdConflictError extends QvacErrorBase {
86
+ readonly requestId: string;
87
+ constructor(requestId: string, cause?: unknown);
88
+ /**
89
+ * Surface typed fields on the RPC error envelope so the client-side
90
+ * reconstructor in `client/rpc/rpc-error.ts` can rebuild this exact
91
+ * class on the consumer side. Without this, `err instanceof
92
+ * RequestIdConflictError` would always be `false` after the error
93
+ * crosses the worker boundary.
94
+ */
95
+ toErrorResponseFields(): Record<string, unknown>;
96
+ }
97
+ export declare class RequestNotFoundError extends QvacErrorBase {
98
+ readonly requestId: string;
99
+ constructor(requestId: string, cause?: unknown);
100
+ toErrorResponseFields(): Record<string, unknown>;
101
+ }
102
+ /**
103
+ * Thrown by `RequestRegistry.begin(...)` when a registered concurrency
104
+ * policy rejects the request (e.g. `oneAtATimePerModel` for the
105
+ * `completion` kind). Distinct from `RequestIdConflictError`, which
106
+ * only fires on UUID collisions.
107
+ */
108
+ export declare class RequestRejectedByPolicyError extends QvacErrorBase {
109
+ readonly requestId: string;
110
+ readonly kind: string;
111
+ readonly modelId: string;
112
+ readonly reason: string;
113
+ constructor(requestId: string, kind: string, modelId: string, reason: string, cause?: unknown);
114
+ toErrorResponseFields(): Record<string, unknown>;
115
+ }
116
+ /**
117
+ * Thrown when a long-running inference request was cancelled before
118
+ * completion. The `events` stream on `CompletionRun` ends normally with
119
+ * `stopReason: "cancelled"` on the last `completionDone`, but the
120
+ * promise-aggregates on the same run (`final` / `text` / `toolCalls` /
121
+ * `stats`) reject with this error so callers can't accidentally treat a
122
+ * cancelled run as a successful one.
123
+ *
124
+ * Carries:
125
+ * - `requestId` — correlates with `run.requestId` so callers know which
126
+ * in-flight request was cancelled when they fan out multiple cancels.
127
+ * - `partial` — whatever the aggregator accumulated up to the cancel
128
+ * point. Optional fields so consumers can opt into "show partial":
129
+ *
130
+ * try { await run.text } catch (err) {
131
+ * if (err instanceof InferenceCancelledError) {
132
+ * renderPartial(err.partial.text);
133
+ * }
134
+ * }
135
+ *
136
+ * The error is constructed client-side in
137
+ * `client/api/completion-stream.ts` when the wire stream ends with
138
+ * `stopReason: "cancelled"` — the partial payload comes from the
139
+ * client's own event aggregator. The class lives in `errors-server.ts`
140
+ * (and is re-exported from the package root) because the *semantic*
141
+ * origin of the cancel is server-side, and other handlers
142
+ * (embeddings, transcribe, …) will reuse the same class once their
143
+ * cancel surface lands.
144
+ */
145
+ export declare class InferenceCancelledError extends QvacErrorBase {
146
+ readonly requestId: string;
147
+ readonly partial: InferenceCancelledPartial;
148
+ constructor(requestId: string, partial?: InferenceCancelledPartial, cause?: unknown);
149
+ }
150
+ export declare class AsyncDisposeUnavailableError extends QvacErrorBase {
151
+ constructor(cause?: unknown);
152
+ }
68
153
  export declare class TextToSpeechFailedError extends QvacErrorBase {
69
154
  constructor(details?: string, cause?: unknown);
70
155
  }
@@ -115,6 +115,103 @@ export class CancelFailedError extends QvacErrorBase {
115
115
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.CANCEL_FAILED, details ? [details] : undefined, cause));
116
116
  }
117
117
  }
118
+ export class RequestIdConflictError extends QvacErrorBase {
119
+ requestId;
120
+ constructor(requestId, cause) {
121
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_ID_CONFLICT, [requestId], cause));
122
+ this.requestId = requestId;
123
+ }
124
+ /**
125
+ * Surface typed fields on the RPC error envelope so the client-side
126
+ * reconstructor in `client/rpc/rpc-error.ts` can rebuild this exact
127
+ * class on the consumer side. Without this, `err instanceof
128
+ * RequestIdConflictError` would always be `false` after the error
129
+ * crosses the worker boundary.
130
+ */
131
+ toErrorResponseFields() {
132
+ return { requestId: this.requestId };
133
+ }
134
+ }
135
+ export class RequestNotFoundError extends QvacErrorBase {
136
+ requestId;
137
+ constructor(requestId, cause) {
138
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_NOT_FOUND, [requestId], cause));
139
+ this.requestId = requestId;
140
+ }
141
+ toErrorResponseFields() {
142
+ return { requestId: this.requestId };
143
+ }
144
+ }
145
+ /**
146
+ * Thrown by `RequestRegistry.begin(...)` when a registered concurrency
147
+ * policy rejects the request (e.g. `oneAtATimePerModel` for the
148
+ * `completion` kind). Distinct from `RequestIdConflictError`, which
149
+ * only fires on UUID collisions.
150
+ */
151
+ export class RequestRejectedByPolicyError extends QvacErrorBase {
152
+ requestId;
153
+ kind;
154
+ modelId;
155
+ reason;
156
+ constructor(requestId, kind, modelId, reason, cause) {
157
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_REJECTED_BY_POLICY, [requestId, kind, modelId, reason], cause));
158
+ this.requestId = requestId;
159
+ this.kind = kind;
160
+ this.modelId = modelId;
161
+ this.reason = reason;
162
+ }
163
+ toErrorResponseFields() {
164
+ return {
165
+ requestId: this.requestId,
166
+ kind: this.kind,
167
+ modelId: this.modelId,
168
+ reason: this.reason,
169
+ };
170
+ }
171
+ }
172
+ /**
173
+ * Thrown when a long-running inference request was cancelled before
174
+ * completion. The `events` stream on `CompletionRun` ends normally with
175
+ * `stopReason: "cancelled"` on the last `completionDone`, but the
176
+ * promise-aggregates on the same run (`final` / `text` / `toolCalls` /
177
+ * `stats`) reject with this error so callers can't accidentally treat a
178
+ * cancelled run as a successful one.
179
+ *
180
+ * Carries:
181
+ * - `requestId` — correlates with `run.requestId` so callers know which
182
+ * in-flight request was cancelled when they fan out multiple cancels.
183
+ * - `partial` — whatever the aggregator accumulated up to the cancel
184
+ * point. Optional fields so consumers can opt into "show partial":
185
+ *
186
+ * try { await run.text } catch (err) {
187
+ * if (err instanceof InferenceCancelledError) {
188
+ * renderPartial(err.partial.text);
189
+ * }
190
+ * }
191
+ *
192
+ * The error is constructed client-side in
193
+ * `client/api/completion-stream.ts` when the wire stream ends with
194
+ * `stopReason: "cancelled"` — the partial payload comes from the
195
+ * client's own event aggregator. The class lives in `errors-server.ts`
196
+ * (and is re-exported from the package root) because the *semantic*
197
+ * origin of the cancel is server-side, and other handlers
198
+ * (embeddings, transcribe, …) will reuse the same class once their
199
+ * cancel surface lands.
200
+ */
201
+ export class InferenceCancelledError extends QvacErrorBase {
202
+ requestId;
203
+ partial;
204
+ constructor(requestId, partial = {}, cause) {
205
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.INFERENCE_CANCELLED, [requestId], cause));
206
+ this.requestId = requestId;
207
+ this.partial = partial;
208
+ }
209
+ }
210
+ export class AsyncDisposeUnavailableError extends QvacErrorBase {
211
+ constructor(cause) {
212
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.ASYNC_DISPOSE_UNAVAILABLE, [], cause));
213
+ }
214
+ }
118
215
  export class TextToSpeechFailedError extends QvacErrorBase {
119
216
  constructor(details, cause) {
120
217
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.TEXT_TO_SPEECH_FAILED, details ? [details] : undefined, cause));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/sdk",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -173,19 +173,19 @@
173
173
  },
174
174
  "dependencies": {
175
175
  "@qvac/decoder-audio": "^0.3.7",
176
- "@qvac/diffusion-cpp": "^0.3.0",
177
- "@qvac/embed-llamacpp": "^0.14.0",
176
+ "@qvac/diffusion-cpp": "^0.7.0",
177
+ "@qvac/embed-llamacpp": "^0.16.0",
178
178
  "@qvac/error": "^0.1.1",
179
179
  "@qvac/langdetect-text": "^0.1.2",
180
- "@qvac/llm-llamacpp": "^0.17.1",
180
+ "@qvac/llm-llamacpp": "^0.20.0",
181
181
  "@qvac/logging": "^0.1.0",
182
- "@qvac/ocr-onnx": "^0.4.2",
183
- "@qvac/rag": "^0.4.4",
184
- "@qvac/registry-client": "^0.4.1",
185
- "@qvac/transcription-parakeet": "^0.3.1",
186
- "@qvac/transcription-whispercpp": "^0.6.1",
187
- "@qvac/translation-nmtcpp": "^2.0.1",
188
- "@qvac/tts-onnx": "^0.8.4",
182
+ "@qvac/ocr-onnx": "^0.5.0",
183
+ "@qvac/rag": "^0.5.0",
184
+ "@qvac/registry-client": "^0.5.0",
185
+ "@qvac/transcription-parakeet": "^0.5.0",
186
+ "@qvac/transcription-whispercpp": "^0.7.0",
187
+ "@qvac/translation-nmtcpp": "^3.0.0",
188
+ "@qvac/tts-onnx": "^0.9.0",
189
189
  "fast-safe-stringify": "2.1.1",
190
190
  "which-runtime": "^1.3.2",
191
191
  "zod": "^4.3.0"
@@ -195,7 +195,7 @@
195
195
  "@expo/config-plugins": "^54.0.4",
196
196
  "@lancedb/lancedb": "^0.21.3",
197
197
  "@modelcontextprotocol/sdk": "^1.12.1",
198
- "@qvac/cli": "^0.2.4",
198
+ "@qvac/cli": "^0.4.0",
199
199
  "@sqliteai/sqlite-wasm": "3.50.4-sync.0.8.30-vector.0.9.23",
200
200
  "@types/node": "^24.2.1",
201
201
  "@types/tar-stream": "^3.1.4",
@@ -226,7 +226,7 @@
226
226
  },
227
227
  "peerDependencies": {
228
228
  "@modelcontextprotocol/sdk": "^1.0.0",
229
- "@qvac/cli": "^0.2.4",
229
+ "@qvac/cli": "^0.4.0",
230
230
  "bare-abort-controller": "^1.0.0",
231
231
  "bare-buffer": "^3.4.2",
232
232
  "bare-crypto": "^1.13.4",
@@ -240,7 +240,7 @@
240
240
  "bare-os": "^3.6.2",
241
241
  "bare-path": "^3.0.0",
242
242
  "bare-process": "^4.2.2",
243
- "bare-rpc": "^1.0.0",
243
+ "bare-rpc": "^1.3.2",
244
244
  "bare-runtime": "^1.24.2",
245
245
  "bare-stream": "^2.7.0",
246
246
  "bare-subprocess": "^5.2.3",
@@ -251,9 +251,11 @@
251
251
  "expo-build-properties": ">=0.12.0",
252
252
  "expo-device": "^8.0.0",
253
253
  "expo-file-system": "^19.0.15",
254
+ "hyperblobs": "^2.8.0",
254
255
  "hyperdb": "^4.19.0",
256
+ "hyperdht": "^6.23.0",
255
257
  "hyperdrive": "^13.0.1",
256
- "hyperswarm": "^4.12.1",
258
+ "hyperswarm": "^4.14.0",
257
259
  "llm-splitter": "~0.2.0",
258
260
  "pear-pipe": "^1.0.6",
259
261
  "react-native-bare-kit": "0.12.3",
@@ -281,6 +283,9 @@
281
283
  "compact-encoding": {
282
284
  "optional": true
283
285
  },
286
+ "hyperdht": {
287
+ "optional": true
288
+ },
284
289
  "pear-pipe": {
285
290
  "optional": true
286
291
  }