@qvac/sdk 0.10.1 → 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 (201) 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/delegate-rpc-client.js +10 -8
  106. package/dist/server/bare/ops/cancel.d.ts +27 -1
  107. package/dist/server/bare/ops/cancel.js +36 -10
  108. package/dist/server/bare/ops/embed.d.ts +3 -3
  109. package/dist/server/bare/ops/embed.js +144 -28
  110. package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
  111. package/dist/server/bare/ops/kv-cache-utils.js +8 -47
  112. package/dist/server/bare/ops/transcribe.d.ts +10 -5
  113. package/dist/server/bare/ops/transcribe.js +196 -41
  114. package/dist/server/bare/ops/translate.d.ts +1 -1
  115. package/dist/server/bare/ops/translate.js +197 -88
  116. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
  117. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +170 -172
  118. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
  119. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
  120. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
  121. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
  122. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
  123. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +30 -3
  124. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +157 -85
  125. package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
  126. package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
  127. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
  128. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
  129. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -15
  130. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
  131. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +3 -3
  132. package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
  133. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +39 -39
  134. package/dist/server/bare/plugins/onnx-tts/plugin.js +6 -0
  135. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +29 -21
  136. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +4 -1
  137. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
  138. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
  139. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
  140. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +91 -16
  141. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +97 -7
  142. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +22 -3
  143. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +50 -14
  144. package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
  145. package/dist/server/bare/rag-hyperdb/index.js +1 -1
  146. package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
  147. package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
  148. package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
  149. package/dist/server/bare/runtime/disposable-scope.js +69 -0
  150. package/dist/server/bare/runtime/index.d.ts +8 -0
  151. package/dist/server/bare/runtime/index.js +3 -0
  152. package/dist/server/bare/runtime/request-context.d.ts +49 -0
  153. package/dist/server/bare/runtime/request-context.js +1 -0
  154. package/dist/server/bare/runtime/request-id.d.ts +12 -0
  155. package/dist/server/bare/runtime/request-id.js +14 -0
  156. package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
  157. package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
  158. package/dist/server/bare/runtime/request-registry.d.ts +136 -0
  159. package/dist/server/bare/runtime/request-registry.js +297 -0
  160. package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
  161. package/dist/server/bare/runtime/with-request-context.js +53 -0
  162. package/dist/server/bare/types/addon-responses.d.ts +11 -1
  163. package/dist/server/rpc/handler-registry.js +26 -7
  164. package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
  165. package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
  166. package/dist/server/rpc/handlers/cancelHandler.js +54 -22
  167. package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
  168. package/dist/server/rpc/handlers/delete-cache.js +13 -15
  169. package/dist/server/rpc/handlers/download-asset.js +133 -40
  170. package/dist/server/rpc/handlers/index.d.ts +2 -0
  171. package/dist/server/rpc/handlers/index.js +2 -0
  172. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
  173. package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
  174. package/dist/server/rpc/handlers/load-model/handler.js +213 -98
  175. package/dist/server/rpc/handlers/load-model/http.js +3 -3
  176. package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
  177. package/dist/server/rpc/handlers/load-model/registry.js +1 -1
  178. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
  179. package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
  180. package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
  181. package/dist/server/rpc/handlers/load-model/resolve.js +9 -6
  182. package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
  183. package/dist/server/rpc/handlers/rag.js +133 -15
  184. package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
  185. package/dist/server/rpc/handlers/upscale-stream.js +4 -0
  186. package/dist/server/utils/completion-normalizer.js +8 -0
  187. package/dist/server/utils/tools/dialect.js +4 -0
  188. package/dist/server/utils/tools/parser.js +16 -1
  189. package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
  190. package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
  191. package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
  192. package/dist/server/utils/tools/parsers/qwen35.js +120 -0
  193. package/dist/utils/aggregate-events.d.ts +9 -0
  194. package/dist/utils/aggregate-events.js +18 -3
  195. package/dist/utils/decorate-promise.d.ts +34 -0
  196. package/dist/utils/decorate-promise.js +35 -0
  197. package/dist/utils/errors-client.d.ts +3 -0
  198. package/dist/utils/errors-client.js +5 -0
  199. package/dist/utils/errors-server.d.ts +85 -0
  200. package/dist/utils/errors-server.js +97 -0
  201. package/package.json +20 -15
@@ -19,7 +19,7 @@ import { deleteCacheRequestSchema, deleteCacheResponseSchema, } from "./delete-c
19
19
  import { getModelInfoRequestSchema, getModelInfoResponseSchema, } from "./get-model-info.js";
20
20
  import { getLoadedModelInfoRequestSchema, getLoadedModelInfoResponseSchema, } from "./get-loaded-model-info.js";
21
21
  import { ocrStreamRequestSchema, ocrStreamResponseSchema } from "./ocr.js";
22
- import { diffusionStreamRequestSchema, diffusionStreamResponseSchema, } from "./sdcpp-config.js";
22
+ import { diffusionStreamRequestSchema, diffusionStreamResponseSchema, upscaleStreamRequestSchema, upscaleStreamResponseSchema, } from "./sdcpp-config.js";
23
23
  import { finetuneRequestSchema, finetuneResponseSchema, finetuneProgressResponseSchema, } from "./finetune.js";
24
24
  import { pluginInvokeRequestSchema, pluginInvokeResponseSchema, pluginInvokeStreamRequestSchema, pluginInvokeStreamResponseSchema, } from "./plugin.js";
25
25
  import { modelRegistryListRequestSchema, modelRegistryListResponseSchema, modelRegistrySearchRequestSchema, modelRegistrySearchResponseSchema, modelRegistryGetModelRequestSchema, modelRegistryGetModelResponseSchema, } from "./registry.js";
@@ -48,6 +48,7 @@ export const requestSchema = z.union([
48
48
  getLoadedModelInfoRequestSchema,
49
49
  ocrStreamRequestSchema,
50
50
  diffusionStreamRequestSchema,
51
+ upscaleStreamRequestSchema,
51
52
  finetuneRequestSchema,
52
53
  pluginInvokeRequestSchema,
53
54
  pluginInvokeStreamRequestSchema,
@@ -83,6 +84,7 @@ export const responseSchema = z.discriminatedUnion("type", [
83
84
  getLoadedModelInfoResponseSchema,
84
85
  ocrStreamResponseSchema,
85
86
  diffusionStreamResponseSchema,
87
+ upscaleStreamResponseSchema,
86
88
  finetuneResponseSchema,
87
89
  finetuneProgressResponseSchema,
88
90
  pluginInvokeResponseSchema,
@@ -69,6 +69,7 @@ export declare const completionErrorSchema: z.ZodObject<{
69
69
  message: z.ZodString;
70
70
  }, z.core.$strip>;
71
71
  declare const stopReasonEnum: z.ZodEnum<{
72
+ cancelled: "cancelled";
72
73
  eos: "eos";
73
74
  length: "length";
74
75
  stopSequence: "stopSequence";
@@ -87,6 +88,7 @@ export declare const doneEventSchema: z.ZodUnion<readonly [z.ZodObject<{
87
88
  type: z.ZodLiteral<"completionDone">;
88
89
  seq: z.ZodNumber;
89
90
  stopReason: z.ZodOptional<z.ZodEnum<{
91
+ cancelled: "cancelled";
90
92
  eos: "eos";
91
93
  length: "length";
92
94
  stopSequence: "stopSequence";
@@ -155,6 +157,7 @@ export declare const completionEventSchema: z.ZodUnion<readonly [z.ZodObject<{
155
157
  type: z.ZodLiteral<"completionDone">;
156
158
  seq: z.ZodNumber;
157
159
  stopReason: z.ZodOptional<z.ZodEnum<{
160
+ cancelled: "cancelled";
158
161
  eos: "eos";
159
162
  length: "length";
160
163
  stopSequence: "stopSequence";
@@ -197,6 +200,17 @@ export type CompletionFinal = {
197
200
  cacheableAssistantContent?: string;
198
201
  };
199
202
  export type CompletionRun = {
203
+ /**
204
+ * Stable identifier for this run, generated client-side at call time
205
+ * (UUIDv4 when `crypto.randomUUID` is available, otherwise an opaque
206
+ * random hex token) and available synchronously the moment
207
+ * `completion(...)` returns. Pass it to `cancel({ requestId })` to
208
+ * target this specific request without affecting any other inference
209
+ * running on the same model. The cancel only takes effect once the
210
+ * server has begun the request, so a cancel issued in the same tick
211
+ * as `completion(...)` may race the begin and is logged as a no-match.
212
+ */
213
+ requestId: string;
200
214
  /** Ordered stream of typed completion events — the canonical consumption API. */
201
215
  events: AsyncIterable<CompletionEvent>;
202
216
  /** Resolves when the stream ends with aggregated content, thinking, tool calls, stats, and raw output. */
@@ -44,7 +44,17 @@ export const completionErrorSchema = z.object({
44
44
  const rawOutputSchema = z.object({
45
45
  fullText: z.string(),
46
46
  });
47
- const stopReasonEnum = z.enum(["eos", "length", "stopSequence"]);
47
+ // `"cancelled"` is a clean termination, not a mid-stream failure: the
48
+ // stream ended on purpose because the request was aborted, just not at
49
+ // EOS. It rides the success-done path (alongside "eos" / "length" /
50
+ // "stopSequence") so consumers iterating `events` see the stream end
51
+ // naturally. The companion error path (`errorDoneSchema` below) keeps
52
+ // `stopReason: "error"` for actual mid-stream failures where the
53
+ // partial state is unsafe to use. The promise-aggregates on the
54
+ // client-side `CompletionRun` (`final` / `text` / `toolCalls` / `stats`)
55
+ // reject with `InferenceCancelledError` carrying the partial state — see
56
+ // `client/api/completion-stream.ts` for the rejection plumbing.
57
+ const stopReasonEnum = z.enum(["eos", "length", "stopSequence", "cancelled"]);
48
58
  const successDoneSchema = z
49
59
  .object({
50
60
  type: z.literal("completionDone"),
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export { completionStatsSchema, type CompletionStats } from "./completion-event";
2
+ export { completionStatsSchema, type CompletionStats, } from "./completion-event";
3
3
  /**
4
4
  * Tool-call output dialect. Auto-detected from the model name; pass via
5
5
  * `completion({ toolDialect })` to override.
@@ -9,12 +9,16 @@ export { completionStatsSchema, type CompletionStats } from "./completion-event"
9
9
  * - `"pythonic"`: `[get_weather(city="Tokyo")]` (optionally `<|tool_call_start|>...<|tool_call_end|>`-wrapped)
10
10
  * - `"json"`: `{"name":"get_weather","arguments":{"city":"Tokyo"}}` or `{"tool_calls":[{"name":"...","arguments":{...}}]}`
11
11
  * - `"harmony"`: `<|channel|>commentary to=functions.get_weather <|constrain|>json<|message|>{"city":"Tokyo"}<|call|>`
12
+ * - `"qwen35"`: `<tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>`
13
+ * - `"gemma4"`: `<|tool_call>call:NAME{key:<|"|>val<|"|>,...}<tool_call|>`
12
14
  */
13
15
  export declare const toolDialectSchema: z.ZodEnum<{
14
16
  hermes: "hermes";
15
17
  pythonic: "pythonic";
16
18
  json: "json";
17
19
  harmony: "harmony";
20
+ qwen35: "qwen35";
21
+ gemma4: "gemma4";
18
22
  }>;
19
23
  export declare const attachmentSchema: z.ZodObject<{
20
24
  path: z.ZodString;
@@ -28,6 +32,7 @@ export declare const generationParamsSchema: z.ZodObject<{
28
32
  frequency_penalty: z.ZodOptional<z.ZodNumber>;
29
33
  presence_penalty: z.ZodOptional<z.ZodNumber>;
30
34
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
35
+ reasoning_budget: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodLiteral<0>]>>;
31
36
  }, z.core.$strict>;
32
37
  export declare const responseFormatSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
33
38
  type: z.ZodLiteral<"text">;
@@ -94,6 +99,7 @@ export declare const completionClientParamsSchema: z.ZodObject<{
94
99
  frequency_penalty: z.ZodOptional<z.ZodNumber>;
95
100
  presence_penalty: z.ZodOptional<z.ZodNumber>;
96
101
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
102
+ reasoning_budget: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodLiteral<0>]>>;
97
103
  }, z.core.$strict>>;
98
104
  captureThinking: z.ZodOptional<z.ZodBoolean>;
99
105
  emitRawDeltas: z.ZodOptional<z.ZodBoolean>;
@@ -102,6 +108,8 @@ export declare const completionClientParamsSchema: z.ZodObject<{
102
108
  pythonic: "pythonic";
103
109
  json: "json";
104
110
  harmony: "harmony";
111
+ qwen35: "qwen35";
112
+ gemma4: "gemma4";
105
113
  }>>;
106
114
  responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
107
115
  type: z.ZodLiteral<"text">;
@@ -116,6 +124,7 @@ export declare const completionClientParamsSchema: z.ZodObject<{
116
124
  strict: z.ZodOptional<z.ZodBoolean>;
117
125
  }, z.core.$strict>;
118
126
  }, z.core.$strict>], "type">>;
127
+ requestId: z.ZodOptional<z.ZodString>;
119
128
  }, z.core.$strip>;
120
129
  export declare const completionStreamRequestSchema: z.ZodObject<{
121
130
  history: z.ZodArray<z.ZodObject<{
@@ -158,6 +167,7 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
158
167
  frequency_penalty: z.ZodOptional<z.ZodNumber>;
159
168
  presence_penalty: z.ZodOptional<z.ZodNumber>;
160
169
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
170
+ reasoning_budget: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodLiteral<0>]>>;
161
171
  }, z.core.$strict>>;
162
172
  captureThinking: z.ZodOptional<z.ZodBoolean>;
163
173
  emitRawDeltas: z.ZodOptional<z.ZodBoolean>;
@@ -166,6 +176,8 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
166
176
  pythonic: "pythonic";
167
177
  json: "json";
168
178
  harmony: "harmony";
179
+ qwen35: "qwen35";
180
+ gemma4: "gemma4";
169
181
  }>>;
170
182
  responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
171
183
  type: z.ZodLiteral<"text">;
@@ -180,6 +192,7 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
180
192
  strict: z.ZodOptional<z.ZodBoolean>;
181
193
  }, z.core.$strict>;
182
194
  }, z.core.$strict>], "type">>;
195
+ requestId: z.ZodOptional<z.ZodString>;
183
196
  type: z.ZodLiteral<"completionStream">;
184
197
  }, z.core.$strip>;
185
198
  export declare const completionStreamResponseSchema: z.ZodObject<{
@@ -245,6 +258,7 @@ export declare const completionStreamResponseSchema: z.ZodObject<{
245
258
  type: z.ZodLiteral<"completionDone">;
246
259
  seq: z.ZodNumber;
247
260
  stopReason: z.ZodOptional<z.ZodEnum<{
261
+ cancelled: "cancelled";
248
262
  eos: "eos";
249
263
  length: "length";
250
264
  stopSequence: "stopSequence";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { toolSchema } from "./tools.js";
3
3
  import { completionEventSchema } from "./completion-event.js";
4
- export { completionStatsSchema } from "./completion-event.js";
4
+ export { completionStatsSchema, } from "./completion-event.js";
5
5
  /**
6
6
  * Tool-call output dialect. Auto-detected from the model name; pass via
7
7
  * `completion({ toolDialect })` to override.
@@ -11,8 +11,17 @@ export { completionStatsSchema } from "./completion-event.js";
11
11
  * - `"pythonic"`: `[get_weather(city="Tokyo")]` (optionally `<|tool_call_start|>...<|tool_call_end|>`-wrapped)
12
12
  * - `"json"`: `{"name":"get_weather","arguments":{"city":"Tokyo"}}` or `{"tool_calls":[{"name":"...","arguments":{...}}]}`
13
13
  * - `"harmony"`: `<|channel|>commentary to=functions.get_weather <|constrain|>json<|message|>{"city":"Tokyo"}<|call|>`
14
+ * - `"qwen35"`: `<tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>`
15
+ * - `"gemma4"`: `<|tool_call>call:NAME{key:<|"|>val<|"|>,...}<tool_call|>`
14
16
  */
15
- export const toolDialectSchema = z.enum(["hermes", "pythonic", "json", "harmony"]);
17
+ export const toolDialectSchema = z.enum([
18
+ "hermes",
19
+ "pythonic",
20
+ "json",
21
+ "harmony",
22
+ "qwen35",
23
+ "gemma4"
24
+ ]);
16
25
  export const attachmentSchema = z.object({
17
26
  path: z
18
27
  .string()
@@ -40,10 +49,7 @@ export const generationParamsSchema = z
40
49
  .number()
41
50
  .optional()
42
51
  .describe("Max tokens to predict. `-1` = until stop token, `-2` = until context filled."),
43
- seed: z
44
- .number()
45
- .optional()
46
- .describe("Random seed for reproducibility."),
52
+ seed: z.number().optional().describe("Random seed for reproducibility."),
47
53
  frequency_penalty: z
48
54
  .number()
49
55
  .optional()
@@ -56,6 +62,10 @@ export const generationParamsSchema = z
56
62
  .number()
57
63
  .optional()
58
64
  .describe("Penalty applied to repeated tokens."),
65
+ reasoning_budget: z
66
+ .union([z.literal(-1), z.literal(0)])
67
+ .optional()
68
+ .describe("Per-request reasoning channel budget. `-1` keeps the model's reasoning channel on; `0` disables it for this request. Equivalent to the load-time `reasoning_budget` config but scoped to a single `run()` call; the prior value is restored afterwards."),
59
69
  })
60
70
  .strict();
61
71
  const jsonSchemaObjectSchema = z.record(z.string(), z.unknown());
@@ -67,7 +77,10 @@ export const responseFormatSchema = z.discriminatedUnion("type", [
67
77
  type: z.literal("json_schema"),
68
78
  json_schema: z
69
79
  .object({
70
- name: z.string().min(1).describe("Schema identifier; OpenAI-compatibility only — not used by the addon."),
80
+ name: z
81
+ .string()
82
+ .min(1)
83
+ .describe("Schema identifier; OpenAI-compatibility only — not used by the addon."),
71
84
  description: z
72
85
  .string()
73
86
  .optional()
@@ -128,6 +141,11 @@ const completionClientParamsBaseSchema = completionParamsSchema.extend({
128
141
  responseFormat: responseFormatSchema
129
142
  .optional()
130
143
  .describe("Optional structured-output constraint: `text` (default, free-form), `json_object` (any valid JSON), or `json_schema` (output conforms to the provided JSON Schema). Mutually exclusive with `tools`."),
144
+ requestId: z
145
+ .string()
146
+ .min(1)
147
+ .optional()
148
+ .describe("Stable identifier for this in-flight request, generated by the client at call time (opaque token, UUIDv4 when available). Surfaced on the `CompletionRun` result so callers can target it with `cancel({ requestId })`. Optional on the wire so legacy clients keep working — the server falls back to a server-generated id when the field is missing. Note: cancel-by-requestId only takes effect once the server has begun the request, so a cancel issued in the same tick as `completion()` may arrive before the request is registered."),
131
149
  });
132
150
  function refineNoToolsWithStructuredOutput(data, ctx) {
133
151
  if (data.responseFormat &&
@@ -14,6 +14,9 @@ export declare const downloadAssetOptionsSchema: z.ZodPipe<z.ZodObject<{
14
14
  sha256Checksum: z.ZodOptional<z.ZodString>;
15
15
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
16
16
  embeddings: "embeddings";
17
+ diffusion: "diffusion";
18
+ tts: "tts";
19
+ ocr: "ocr";
17
20
  "llamacpp-completion": "llamacpp-completion";
18
21
  "whispercpp-transcription": "whispercpp-transcription";
19
22
  "llamacpp-embedding": "llamacpp-embedding";
@@ -26,9 +29,6 @@ export declare const downloadAssetOptionsSchema: z.ZodPipe<z.ZodObject<{
26
29
  whisper: "whisper";
27
30
  nmt: "nmt";
28
31
  parakeet: "parakeet";
29
- tts: "tts";
30
- ocr: "ocr";
31
- diffusion: "diffusion";
32
32
  }>, z.ZodLiteral<"vad">]>>;
33
33
  }, z.core.$strip>]>;
34
34
  seed: z.ZodOptional<z.ZodBoolean>;
@@ -45,7 +45,7 @@ export declare const downloadAssetOptionsSchema: z.ZodPipe<z.ZodObject<{
45
45
  engine?: string | undefined;
46
46
  expectedSize?: number | undefined;
47
47
  sha256Checksum?: string | undefined;
48
- addon?: "embeddings" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | undefined;
48
+ addon?: "embeddings" | "diffusion" | "tts" | "ocr" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "vad" | undefined;
49
49
  };
50
50
  }, {
51
51
  assetSrc: string | {
@@ -59,7 +59,7 @@ export declare const downloadAssetOptionsSchema: z.ZodPipe<z.ZodObject<{
59
59
  engine?: string | undefined;
60
60
  expectedSize?: number | undefined;
61
61
  sha256Checksum?: string | undefined;
62
- addon?: "embeddings" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | undefined;
62
+ addon?: "embeddings" | "diffusion" | "tts" | "ocr" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "vad" | undefined;
63
63
  };
64
64
  seed?: boolean | undefined;
65
65
  }>>;
@@ -77,6 +77,9 @@ export declare const downloadAssetOptionsToRequestSchema: z.ZodPipe<z.ZodObject<
77
77
  sha256Checksum: z.ZodOptional<z.ZodString>;
78
78
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
79
79
  embeddings: "embeddings";
80
+ diffusion: "diffusion";
81
+ tts: "tts";
82
+ ocr: "ocr";
80
83
  "llamacpp-completion": "llamacpp-completion";
81
84
  "whispercpp-transcription": "whispercpp-transcription";
82
85
  "llamacpp-embedding": "llamacpp-embedding";
@@ -89,19 +92,18 @@ export declare const downloadAssetOptionsToRequestSchema: z.ZodPipe<z.ZodObject<
89
92
  whisper: "whisper";
90
93
  nmt: "nmt";
91
94
  parakeet: "parakeet";
92
- tts: "tts";
93
- ocr: "ocr";
94
- diffusion: "diffusion";
95
95
  }>, z.ZodLiteral<"vad">]>>;
96
96
  }, z.core.$strip>]>;
97
97
  seed: z.ZodOptional<z.ZodBoolean>;
98
98
  onProgress: z.ZodOptional<z.ZodUnknown>;
99
99
  withProgress: z.ZodOptional<z.ZodBoolean>;
100
+ requestId: z.ZodOptional<z.ZodString>;
100
101
  }, z.core.$strip>, z.ZodTransform<{
101
102
  type: "downloadAsset";
102
103
  assetSrc: string;
103
104
  withProgress: boolean;
104
105
  seed: boolean;
106
+ requestId?: string;
105
107
  }, {
106
108
  assetSrc: string | {
107
109
  src: string;
@@ -114,27 +116,31 @@ export declare const downloadAssetOptionsToRequestSchema: z.ZodPipe<z.ZodObject<
114
116
  engine?: string | undefined;
115
117
  expectedSize?: number | undefined;
116
118
  sha256Checksum?: string | undefined;
117
- addon?: "embeddings" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | undefined;
119
+ addon?: "embeddings" | "diffusion" | "tts" | "ocr" | "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "parakeet-transcription" | "onnx-ocr" | "sdcpp-generation" | "llm" | "whisper" | "nmt" | "parakeet" | "vad" | undefined;
118
120
  };
119
121
  seed?: boolean | undefined;
120
122
  onProgress?: unknown;
121
123
  withProgress?: boolean | undefined;
124
+ requestId?: string | undefined;
122
125
  }>>;
123
126
  export declare const downloadAssetRequestSchema: z.ZodPipe<z.ZodObject<{
124
127
  type: z.ZodLiteral<"downloadAsset">;
125
128
  assetSrc: z.ZodString;
126
129
  withProgress: z.ZodOptional<z.ZodBoolean>;
127
130
  seed: z.ZodOptional<z.ZodBoolean>;
131
+ requestId: z.ZodOptional<z.ZodString>;
128
132
  }, z.core.$strip>, z.ZodTransform<{
129
133
  seed: boolean;
130
134
  type: "downloadAsset";
131
135
  assetSrc: string;
132
136
  withProgress?: boolean | undefined;
137
+ requestId?: string | undefined;
133
138
  }, {
134
139
  type: "downloadAsset";
135
140
  assetSrc: string;
136
141
  withProgress?: boolean | undefined;
137
142
  seed?: boolean | undefined;
143
+ requestId?: string | undefined;
138
144
  }>>;
139
145
  export declare const downloadAssetResponseSchema: z.ZodObject<{
140
146
  type: z.ZodLiteral<"downloadAsset">;
@@ -12,19 +12,30 @@ export const downloadAssetOptionsToRequestSchema = downloadAssetOptionsBaseSchem
12
12
  .extend({
13
13
  onProgress: z.unknown().optional(),
14
14
  withProgress: z.boolean().optional(),
15
+ requestId: z.string().min(1).optional(),
15
16
  })
16
- .transform((data) => ({
17
- type: "downloadAsset",
18
- assetSrc: modelInputToSrcSchema.parse(data.assetSrc),
19
- withProgress: data.withProgress ?? !!data.onProgress,
20
- seed: data.seed ?? false,
21
- }));
17
+ .transform((data) => {
18
+ const out = {
19
+ type: "downloadAsset",
20
+ assetSrc: modelInputToSrcSchema.parse(data.assetSrc),
21
+ withProgress: data.withProgress ?? !!data.onProgress,
22
+ seed: data.seed ?? false,
23
+ };
24
+ if (data.requestId !== undefined)
25
+ out.requestId = data.requestId;
26
+ return out;
27
+ });
22
28
  export const downloadAssetRequestSchema = z
23
29
  .object({
24
30
  type: z.literal("downloadAsset"),
25
31
  assetSrc: z.string(),
26
32
  withProgress: z.boolean().optional(),
27
33
  seed: z.boolean().optional(),
34
+ requestId: z
35
+ .string()
36
+ .min(1)
37
+ .optional()
38
+ .describe("Stable identifier for this in-flight download, generated by the client at call time. Optional on the wire so legacy clients keep working — the server falls back to a server-generated id when the field is missing. Exposed on the client-side decorated promise so callers can target this download with `cancel({ requestId })`."),
28
39
  })
29
40
  .transform((data) => ({
30
41
  ...data,
@@ -7,6 +7,7 @@ export declare const embedRequestSchema: z.ZodObject<{
7
7
  modelId: z.ZodString;
8
8
  text: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
9
9
  type: z.ZodLiteral<"embed">;
10
+ requestId: z.ZodOptional<z.ZodString>;
10
11
  }, z.core.$strip>;
11
12
  export declare const embedStatsSchema: z.ZodObject<{
12
13
  totalTime: z.ZodOptional<z.ZodNumber>;
@@ -12,6 +12,11 @@ export const embedParamsSchema = z.object({
12
12
  });
13
13
  export const embedRequestSchema = embedParamsSchema.extend({
14
14
  type: z.literal("embed"),
15
+ requestId: z
16
+ .string()
17
+ .min(1)
18
+ .optional()
19
+ .describe("Stable identifier for this in-flight embed, generated by the client at call time. Surfaces on the registry so callers can target it with `cancel({ requestId })`. Optional on the wire — the server falls back to a server-generated id when the field is missing."),
15
20
  });
16
21
  export const embedStatsSchema = z.object({
17
22
  totalTime: z
@@ -1,4 +1,20 @@
1
1
  import { z } from "zod";
2
+ /**
3
+ * Wire shape for errors thrown across the RPC boundary. The fields are
4
+ * the union of (a) the legacy `QvacErrorBase` serialisation (`name`,
5
+ * `code`, `message`, `stack`, `cause`, `timestamp`) and (b) the new
6
+ * `typedFields` map (0.11.0+) carrying per-class structured data the
7
+ * client-side reconstructor uses to rebuild the original typed error.
8
+ *
9
+ * `typedFields` is opaque on the wire — `z.unknown()` — and the
10
+ * per-class reconstructor in `client/rpc/rpc-error.ts` casts each
11
+ * member at the boundary. The single-map shape keeps the schema
12
+ * compact regardless of how many typed-error classes the SDK
13
+ * eventually surfaces across RPC. New typed-error classes that need
14
+ * cross-RPC reconstruction add a `toErrorResponseFields()` method on
15
+ * the server side and a row to the reconstructor map on the client
16
+ * side; the schema itself doesn't change.
17
+ */
2
18
  export declare const errorResponseSchema: z.ZodObject<{
3
19
  type: z.ZodLiteral<"error">;
4
20
  message: z.ZodString;
@@ -7,7 +23,22 @@ export declare const errorResponseSchema: z.ZodObject<{
7
23
  name: z.ZodOptional<z.ZodString>;
8
24
  code: z.ZodOptional<z.ZodNumber>;
9
25
  cause: z.ZodOptional<z.ZodUnknown>;
26
+ typedFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
10
27
  }, z.core.$strip>;
11
28
  export type ErrorResponse = z.infer<typeof errorResponseSchema>;
29
+ /**
30
+ * A `QvacErrorBase` subclass that opts into typed-field serialisation
31
+ * across the RPC boundary. The method returns the subset of own
32
+ * properties the client-side reconstructor needs to rebuild the
33
+ * original class with its named constructor arguments populated.
34
+ *
35
+ * Co-located with each class (see `utils/errors-server.ts`) so adding
36
+ * a new cross-RPC typed error is a three-step change in one PR: define
37
+ * the class, implement the method, add a reconstructor entry in
38
+ * `client/rpc/rpc-error.ts`.
39
+ */
40
+ export interface TypedErrorSerializer {
41
+ toErrorResponseFields(): Record<string, unknown>;
42
+ }
12
43
  export declare function createErrorResponse(error: unknown): ErrorResponse;
13
44
  //# sourceMappingURL=error.d.ts.map
@@ -1,5 +1,21 @@
1
1
  import { z } from "zod";
2
2
  import { QvacErrorBase } from "@qvac/error";
3
+ /**
4
+ * Wire shape for errors thrown across the RPC boundary. The fields are
5
+ * the union of (a) the legacy `QvacErrorBase` serialisation (`name`,
6
+ * `code`, `message`, `stack`, `cause`, `timestamp`) and (b) the new
7
+ * `typedFields` map (0.11.0+) carrying per-class structured data the
8
+ * client-side reconstructor uses to rebuild the original typed error.
9
+ *
10
+ * `typedFields` is opaque on the wire — `z.unknown()` — and the
11
+ * per-class reconstructor in `client/rpc/rpc-error.ts` casts each
12
+ * member at the boundary. The single-map shape keeps the schema
13
+ * compact regardless of how many typed-error classes the SDK
14
+ * eventually surfaces across RPC. New typed-error classes that need
15
+ * cross-RPC reconstruction add a `toErrorResponseFields()` method on
16
+ * the server side and a row to the reconstructor map on the client
17
+ * side; the schema itself doesn't change.
18
+ */
3
19
  export const errorResponseSchema = z.object({
4
20
  type: z.literal("error"),
5
21
  message: z.string(),
@@ -8,14 +24,22 @@ export const errorResponseSchema = z.object({
8
24
  name: z.string().optional(),
9
25
  code: z.number().optional(),
10
26
  cause: z.unknown().optional(),
27
+ typedFields: z.record(z.string(), z.unknown()).optional(),
11
28
  });
29
+ function hasTypedFields(error) {
30
+ return (error !== null &&
31
+ typeof error === "object" &&
32
+ "toErrorResponseFields" in error &&
33
+ typeof error
34
+ .toErrorResponseFields === "function");
35
+ }
12
36
  function isQvacError(error) {
13
37
  return error instanceof QvacErrorBase;
14
38
  }
15
39
  export function createErrorResponse(error) {
16
40
  if (isQvacError(error)) {
17
41
  const qvacData = error.toJSON();
18
- return {
42
+ const response = {
19
43
  type: "error",
20
44
  name: qvacData.name,
21
45
  code: qvacData.code,
@@ -23,6 +47,10 @@ export function createErrorResponse(error) {
23
47
  stack: qvacData.stack,
24
48
  timestamp: new Date().toISOString(),
25
49
  };
50
+ if (hasTypedFields(error)) {
51
+ response.typedFields = error.toErrorResponseFields();
52
+ }
53
+ return response;
26
54
  }
27
55
  const message = error instanceof Error ? error.message : String(error);
28
56
  const stack = error instanceof Error ? error.stack : undefined;
@@ -336,6 +336,7 @@ export declare const finetuneRunRequestSchema: z.ZodObject<{
336
336
  resume: "resume";
337
337
  }>>;
338
338
  withProgress: z.ZodOptional<z.ZodBoolean>;
339
+ requestId: z.ZodOptional<z.ZodString>;
339
340
  }, z.core.$strict>;
340
341
  export declare const finetuneGetStateRequestSchema: z.ZodObject<{
341
342
  modelId: z.ZodString;
@@ -466,6 +467,7 @@ export declare const finetuneRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
466
467
  resume: "resume";
467
468
  }>>;
468
469
  withProgress: z.ZodOptional<z.ZodBoolean>;
470
+ requestId: z.ZodOptional<z.ZodString>;
469
471
  }, z.core.$strict>, z.ZodObject<{
470
472
  modelId: z.ZodString;
471
473
  options: z.ZodObject<{
@@ -96,6 +96,11 @@ export const finetuneRunRequestSchema = finetuneRunParamsSchemaBase
96
96
  type: z.literal("finetune"),
97
97
  operation: z.enum(["start", "resume"]).optional(),
98
98
  withProgress: z.boolean().optional(),
99
+ requestId: z
100
+ .string()
101
+ .min(1)
102
+ .optional()
103
+ .describe("Stable identifier for this in-flight finetune, generated by the client at call time. Surfaces on the registry so callers can target it with `cancel({ requestId })`. Optional on the wire — the server falls back to a server-generated id when the field is missing."),
99
104
  })
100
105
  .strict();
101
106
  export const finetuneGetStateRequestSchema = finetuneRunParamsSchemaBase
@@ -36,13 +36,13 @@ export declare const modelInfoSchema: z.ZodObject<{
36
36
  sha256Checksum: z.ZodString;
37
37
  addon: z.ZodEnum<{
38
38
  embeddings: "embeddings";
39
+ diffusion: "diffusion";
40
+ tts: "tts";
41
+ ocr: "ocr";
39
42
  llm: "llm";
40
43
  whisper: "whisper";
41
44
  nmt: "nmt";
42
45
  parakeet: "parakeet";
43
- tts: "tts";
44
- ocr: "ocr";
45
- diffusion: "diffusion";
46
46
  vad: "vad";
47
47
  other: "other";
48
48
  }>;
@@ -83,13 +83,13 @@ export declare const getModelInfoResponseSchema: z.ZodObject<{
83
83
  sha256Checksum: z.ZodString;
84
84
  addon: z.ZodEnum<{
85
85
  embeddings: "embeddings";
86
+ diffusion: "diffusion";
87
+ tts: "tts";
88
+ ocr: "ocr";
86
89
  llm: "llm";
87
90
  whisper: "whisper";
88
91
  nmt: "nmt";
89
92
  parakeet: "parakeet";
90
- tts: "tts";
91
- ocr: "ocr";
92
- diffusion: "diffusion";
93
93
  vad: "vad";
94
94
  other: "other";
95
95
  }>;