@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
@@ -79,6 +79,9 @@ export declare const reloadConfigOptionsSchema: z.ZodUnion<readonly [z.ZodObject
79
79
  sha256Checksum: z.ZodOptional<z.ZodString>;
80
80
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
81
81
  embeddings: "embeddings";
82
+ diffusion: "diffusion";
83
+ tts: "tts";
84
+ ocr: "ocr";
82
85
  "llamacpp-completion": "llamacpp-completion";
83
86
  "whispercpp-transcription": "whispercpp-transcription";
84
87
  "llamacpp-embedding": "llamacpp-embedding";
@@ -91,9 +94,6 @@ export declare const reloadConfigOptionsSchema: z.ZodUnion<readonly [z.ZodObject
91
94
  whisper: "whisper";
92
95
  nmt: "nmt";
93
96
  parakeet: "parakeet";
94
- tts: "tts";
95
- ocr: "ocr";
96
- diffusion: "diffusion";
97
97
  }>, z.ZodLiteral<"vad">]>>;
98
98
  }, z.core.$strip>]>>>;
99
99
  }, z.core.$strict>;
@@ -177,6 +177,9 @@ export declare const reloadConfigOptionsToRequestSchema: z.ZodUnion<readonly [z.
177
177
  sha256Checksum: z.ZodOptional<z.ZodString>;
178
178
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
179
179
  embeddings: "embeddings";
180
+ diffusion: "diffusion";
181
+ tts: "tts";
182
+ ocr: "ocr";
180
183
  "llamacpp-completion": "llamacpp-completion";
181
184
  "whispercpp-transcription": "whispercpp-transcription";
182
185
  "llamacpp-embedding": "llamacpp-embedding";
@@ -189,9 +192,6 @@ export declare const reloadConfigOptionsToRequestSchema: z.ZodUnion<readonly [z.
189
192
  whisper: "whisper";
190
193
  nmt: "nmt";
191
194
  parakeet: "parakeet";
192
- tts: "tts";
193
- ocr: "ocr";
194
- diffusion: "diffusion";
195
195
  }>, z.ZodLiteral<"vad">]>>;
196
196
  }, z.core.$strip>]>>>;
197
197
  }, z.core.$strict>;
@@ -264,7 +264,7 @@ export declare const reloadConfigOptionsToRequestSchema: z.ZodUnion<readonly [z.
264
264
  engine?: string | undefined;
265
265
  expectedSize?: number | undefined;
266
266
  sha256Checksum?: string | undefined;
267
- 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;
267
+ 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;
268
268
  } | undefined;
269
269
  };
270
270
  }, {
@@ -335,7 +335,7 @@ export declare const reloadConfigOptionsToRequestSchema: z.ZodUnion<readonly [z.
335
335
  engine?: string | undefined;
336
336
  expectedSize?: number | undefined;
337
337
  sha256Checksum?: string | undefined;
338
- 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;
338
+ 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;
339
339
  } | undefined;
340
340
  };
341
341
  }>>]>;
@@ -423,6 +423,9 @@ export declare const reloadConfigWhisperRequestSchema: z.ZodObject<{
423
423
  sha256Checksum: z.ZodOptional<z.ZodString>;
424
424
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
425
425
  embeddings: "embeddings";
426
+ diffusion: "diffusion";
427
+ tts: "tts";
428
+ ocr: "ocr";
426
429
  "llamacpp-completion": "llamacpp-completion";
427
430
  "whispercpp-transcription": "whispercpp-transcription";
428
431
  "llamacpp-embedding": "llamacpp-embedding";
@@ -435,9 +438,6 @@ export declare const reloadConfigWhisperRequestSchema: z.ZodObject<{
435
438
  whisper: "whisper";
436
439
  nmt: "nmt";
437
440
  parakeet: "parakeet";
438
- tts: "tts";
439
- ocr: "ocr";
440
- diffusion: "diffusion";
441
441
  }>, z.ZodLiteral<"vad">]>>;
442
442
  }, z.core.$strip>]>>>;
443
443
  }, z.core.$strip>;
@@ -526,6 +526,9 @@ export declare const reloadConfigRequestSchema: z.ZodUnion<readonly [z.ZodObject
526
526
  sha256Checksum: z.ZodOptional<z.ZodString>;
527
527
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
528
528
  embeddings: "embeddings";
529
+ diffusion: "diffusion";
530
+ tts: "tts";
531
+ ocr: "ocr";
529
532
  "llamacpp-completion": "llamacpp-completion";
530
533
  "whispercpp-transcription": "whispercpp-transcription";
531
534
  "llamacpp-embedding": "llamacpp-embedding";
@@ -538,9 +541,6 @@ export declare const reloadConfigRequestSchema: z.ZodUnion<readonly [z.ZodObject
538
541
  whisper: "whisper";
539
542
  nmt: "nmt";
540
543
  parakeet: "parakeet";
541
- tts: "tts";
542
- ocr: "ocr";
543
- diffusion: "diffusion";
544
544
  }>, z.ZodLiteral<"vad">]>>;
545
545
  }, z.core.$strip>]>>>;
546
546
  }, z.core.$strip>;
@@ -1,5 +1,9 @@
1
1
  import { z } from "zod";
2
2
  export declare const sdcppConfigSchema: z.ZodObject<{
3
+ mode: z.ZodDefault<z.ZodEnum<{
4
+ diffusion: "diffusion";
5
+ upscale: "upscale";
6
+ }>>;
3
7
  threads: z.ZodOptional<z.ZodNumber>;
4
8
  device: z.ZodOptional<z.ZodEnum<{
5
9
  cpu: "cpu";
@@ -44,6 +48,11 @@ export declare const sdcppConfigSchema: z.ZodObject<{
44
48
  vae_on_cpu: z.ZodOptional<z.ZodBoolean>;
45
49
  vae_tiling: z.ZodOptional<z.ZodBoolean>;
46
50
  flash_attn: z.ZodOptional<z.ZodBoolean>;
51
+ lora_apply_mode: z.ZodOptional<z.ZodEnum<{
52
+ auto: "auto";
53
+ immediately: "immediately";
54
+ at_runtime: "at_runtime";
55
+ }>>;
47
56
  verbosity: z.ZodOptional<z.ZodNumber>;
48
57
  clipLModelSrc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
49
58
  src: z.ZodString;
@@ -58,6 +67,9 @@ export declare const sdcppConfigSchema: z.ZodObject<{
58
67
  sha256Checksum: z.ZodOptional<z.ZodString>;
59
68
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
60
69
  embeddings: "embeddings";
70
+ diffusion: "diffusion";
71
+ tts: "tts";
72
+ ocr: "ocr";
61
73
  "llamacpp-completion": "llamacpp-completion";
62
74
  "whispercpp-transcription": "whispercpp-transcription";
63
75
  "llamacpp-embedding": "llamacpp-embedding";
@@ -70,9 +82,6 @@ export declare const sdcppConfigSchema: z.ZodObject<{
70
82
  whisper: "whisper";
71
83
  nmt: "nmt";
72
84
  parakeet: "parakeet";
73
- tts: "tts";
74
- ocr: "ocr";
75
- diffusion: "diffusion";
76
85
  }>, z.ZodLiteral<"vad">]>>;
77
86
  }, z.core.$strip>]>>;
78
87
  clipGModelSrc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -88,6 +97,9 @@ export declare const sdcppConfigSchema: z.ZodObject<{
88
97
  sha256Checksum: z.ZodOptional<z.ZodString>;
89
98
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
90
99
  embeddings: "embeddings";
100
+ diffusion: "diffusion";
101
+ tts: "tts";
102
+ ocr: "ocr";
91
103
  "llamacpp-completion": "llamacpp-completion";
92
104
  "whispercpp-transcription": "whispercpp-transcription";
93
105
  "llamacpp-embedding": "llamacpp-embedding";
@@ -100,9 +112,6 @@ export declare const sdcppConfigSchema: z.ZodObject<{
100
112
  whisper: "whisper";
101
113
  nmt: "nmt";
102
114
  parakeet: "parakeet";
103
- tts: "tts";
104
- ocr: "ocr";
105
- diffusion: "diffusion";
106
115
  }>, z.ZodLiteral<"vad">]>>;
107
116
  }, z.core.$strip>]>>;
108
117
  t5XxlModelSrc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -118,6 +127,9 @@ export declare const sdcppConfigSchema: z.ZodObject<{
118
127
  sha256Checksum: z.ZodOptional<z.ZodString>;
119
128
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
120
129
  embeddings: "embeddings";
130
+ diffusion: "diffusion";
131
+ tts: "tts";
132
+ ocr: "ocr";
121
133
  "llamacpp-completion": "llamacpp-completion";
122
134
  "whispercpp-transcription": "whispercpp-transcription";
123
135
  "llamacpp-embedding": "llamacpp-embedding";
@@ -130,9 +142,6 @@ export declare const sdcppConfigSchema: z.ZodObject<{
130
142
  whisper: "whisper";
131
143
  nmt: "nmt";
132
144
  parakeet: "parakeet";
133
- tts: "tts";
134
- ocr: "ocr";
135
- diffusion: "diffusion";
136
145
  }>, z.ZodLiteral<"vad">]>>;
137
146
  }, z.core.$strip>]>>;
138
147
  llmModelSrc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -148,6 +157,9 @@ export declare const sdcppConfigSchema: z.ZodObject<{
148
157
  sha256Checksum: z.ZodOptional<z.ZodString>;
149
158
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
150
159
  embeddings: "embeddings";
160
+ diffusion: "diffusion";
161
+ tts: "tts";
162
+ ocr: "ocr";
151
163
  "llamacpp-completion": "llamacpp-completion";
152
164
  "whispercpp-transcription": "whispercpp-transcription";
153
165
  "llamacpp-embedding": "llamacpp-embedding";
@@ -160,9 +172,6 @@ export declare const sdcppConfigSchema: z.ZodObject<{
160
172
  whisper: "whisper";
161
173
  nmt: "nmt";
162
174
  parakeet: "parakeet";
163
- tts: "tts";
164
- ocr: "ocr";
165
- diffusion: "diffusion";
166
175
  }>, z.ZodLiteral<"vad">]>>;
167
176
  }, z.core.$strip>]>>;
168
177
  vaeModelSrc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
@@ -178,6 +187,9 @@ export declare const sdcppConfigSchema: z.ZodObject<{
178
187
  sha256Checksum: z.ZodOptional<z.ZodString>;
179
188
  addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
180
189
  embeddings: "embeddings";
190
+ diffusion: "diffusion";
191
+ tts: "tts";
192
+ ocr: "ocr";
181
193
  "llamacpp-completion": "llamacpp-completion";
182
194
  "whispercpp-transcription": "whispercpp-transcription";
183
195
  "llamacpp-embedding": "llamacpp-embedding";
@@ -190,13 +202,47 @@ export declare const sdcppConfigSchema: z.ZodObject<{
190
202
  whisper: "whisper";
191
203
  nmt: "nmt";
192
204
  parakeet: "parakeet";
193
- tts: "tts";
194
- ocr: "ocr";
195
- diffusion: "diffusion";
196
205
  }>, z.ZodLiteral<"vad">]>>;
197
206
  }, z.core.$strip>]>>;
207
+ upscaler: z.ZodOptional<z.ZodObject<{
208
+ type: z.ZodOptional<z.ZodLiteral<"esrgan">>;
209
+ model_src: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
210
+ src: z.ZodString;
211
+ name: z.ZodOptional<z.ZodString>;
212
+ modelId: z.ZodOptional<z.ZodString>;
213
+ registryPath: z.ZodOptional<z.ZodString>;
214
+ registrySource: z.ZodOptional<z.ZodString>;
215
+ blobCoreKey: z.ZodOptional<z.ZodString>;
216
+ blobIndex: z.ZodOptional<z.ZodNumber>;
217
+ engine: z.ZodOptional<z.ZodString>;
218
+ expectedSize: z.ZodOptional<z.ZodNumber>;
219
+ sha256Checksum: z.ZodOptional<z.ZodString>;
220
+ addon: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
221
+ embeddings: "embeddings";
222
+ diffusion: "diffusion";
223
+ tts: "tts";
224
+ ocr: "ocr";
225
+ "llamacpp-completion": "llamacpp-completion";
226
+ "whispercpp-transcription": "whispercpp-transcription";
227
+ "llamacpp-embedding": "llamacpp-embedding";
228
+ "nmtcpp-translation": "nmtcpp-translation";
229
+ "onnx-tts": "onnx-tts";
230
+ "parakeet-transcription": "parakeet-transcription";
231
+ "onnx-ocr": "onnx-ocr";
232
+ "sdcpp-generation": "sdcpp-generation";
233
+ llm: "llm";
234
+ whisper: "whisper";
235
+ nmt: "nmt";
236
+ parakeet: "parakeet";
237
+ }>, z.ZodLiteral<"vad">]>>;
238
+ }, z.core.$strip>]>>;
239
+ tile_size: z.ZodOptional<z.ZodNumber>;
240
+ direct: z.ZodOptional<z.ZodBoolean>;
241
+ offload_params_to_cpu: z.ZodOptional<z.ZodBoolean>;
242
+ threads: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodNumber]>>;
243
+ }, z.core.$strict>>;
198
244
  }, z.core.$strip>;
199
- export type SdcppConfig = z.infer<typeof sdcppConfigSchema>;
245
+ export type SdcppConfig = z.input<typeof sdcppConfigSchema>;
200
246
  export declare const diffusionStatsSchema: z.ZodObject<{
201
247
  modelLoadMs: z.ZodOptional<z.ZodNumber>;
202
248
  generationMs: z.ZodOptional<z.ZodNumber>;
@@ -278,7 +324,14 @@ export declare const diffusionRequestSchema: z.ZodObject<{
278
324
  vae_tiling: z.ZodOptional<z.ZodBoolean>;
279
325
  cache_preset: z.ZodOptional<z.ZodString>;
280
326
  init_image: z.ZodOptional<z.ZodString>;
327
+ init_images: z.ZodOptional<z.ZodArray<z.ZodString>>;
328
+ increase_ref_index: z.ZodOptional<z.ZodBoolean>;
329
+ auto_resize_ref_image: z.ZodOptional<z.ZodBoolean>;
330
+ lora: z.ZodOptional<z.ZodString>;
281
331
  strength: z.ZodOptional<z.ZodNumber>;
332
+ upscale: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
333
+ repeats: z.ZodOptional<z.ZodNumber>;
334
+ }, z.core.$strict>]>>;
282
335
  }, z.core.$strip>;
283
336
  export type DiffusionRequest = z.input<typeof diffusionRequestSchema>;
284
337
  export declare const diffusionStreamRequestSchema: z.ZodObject<{
@@ -325,11 +378,72 @@ export declare const diffusionStreamRequestSchema: z.ZodObject<{
325
378
  vae_tiling: z.ZodOptional<z.ZodBoolean>;
326
379
  cache_preset: z.ZodOptional<z.ZodString>;
327
380
  init_image: z.ZodOptional<z.ZodString>;
381
+ init_images: z.ZodOptional<z.ZodArray<z.ZodString>>;
382
+ increase_ref_index: z.ZodOptional<z.ZodBoolean>;
383
+ auto_resize_ref_image: z.ZodOptional<z.ZodBoolean>;
384
+ lora: z.ZodOptional<z.ZodString>;
328
385
  strength: z.ZodOptional<z.ZodNumber>;
386
+ upscale: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
387
+ repeats: z.ZodOptional<z.ZodNumber>;
388
+ }, z.core.$strict>]>>;
329
389
  type: z.ZodLiteral<"diffusionStream">;
330
390
  }, z.core.$strip>;
331
391
  export type DiffusionStreamRequest = z.input<typeof diffusionStreamRequestSchema>;
332
- export type DiffusionClientParams = Omit<DiffusionRequest, "init_image"> & {
392
+ type DiffusionClientParamsBase = Omit<DiffusionRequest, "init_image" | "init_images">;
393
+ export type DiffusionClientParams = DiffusionClientParamsBase & ({
333
394
  init_image?: Uint8Array;
395
+ init_images?: never;
396
+ } | {
397
+ init_image?: never;
398
+ init_images?: Uint8Array[];
399
+ });
400
+ export declare const upscaleStatsSchema: z.ZodObject<{
401
+ modelLoadMs: z.ZodOptional<z.ZodNumber>;
402
+ upscaleMs: z.ZodOptional<z.ZodNumber>;
403
+ totalUpscaleMs: z.ZodOptional<z.ZodNumber>;
404
+ totalWallMs: z.ZodOptional<z.ZodNumber>;
405
+ totalUpscales: z.ZodOptional<z.ZodNumber>;
406
+ totalImages: z.ZodOptional<z.ZodNumber>;
407
+ totalPixels: z.ZodOptional<z.ZodNumber>;
408
+ width: z.ZodOptional<z.ZodNumber>;
409
+ height: z.ZodOptional<z.ZodNumber>;
410
+ repeats: z.ZodOptional<z.ZodNumber>;
411
+ }, z.core.$strip>;
412
+ export type UpscaleStats = z.infer<typeof upscaleStatsSchema>;
413
+ export declare const upscaleRequestSchema: z.ZodObject<{
414
+ modelId: z.ZodString;
415
+ image: z.ZodString;
416
+ repeats: z.ZodOptional<z.ZodNumber>;
417
+ }, z.core.$strip>;
418
+ export type UpscaleRequest = z.input<typeof upscaleRequestSchema>;
419
+ export declare const upscaleStreamRequestSchema: z.ZodObject<{
420
+ modelId: z.ZodString;
421
+ image: z.ZodString;
422
+ repeats: z.ZodOptional<z.ZodNumber>;
423
+ type: z.ZodLiteral<"upscaleStream">;
424
+ }, z.core.$strip>;
425
+ export type UpscaleStreamRequest = z.input<typeof upscaleStreamRequestSchema>;
426
+ export declare const upscaleStreamResponseSchema: z.ZodObject<{
427
+ type: z.ZodLiteral<"upscaleStream">;
428
+ data: z.ZodOptional<z.ZodString>;
429
+ outputIndex: z.ZodOptional<z.ZodNumber>;
430
+ done: z.ZodOptional<z.ZodBoolean>;
431
+ stats: z.ZodOptional<z.ZodObject<{
432
+ modelLoadMs: z.ZodOptional<z.ZodNumber>;
433
+ upscaleMs: z.ZodOptional<z.ZodNumber>;
434
+ totalUpscaleMs: z.ZodOptional<z.ZodNumber>;
435
+ totalWallMs: z.ZodOptional<z.ZodNumber>;
436
+ totalUpscales: z.ZodOptional<z.ZodNumber>;
437
+ totalImages: z.ZodOptional<z.ZodNumber>;
438
+ totalPixels: z.ZodOptional<z.ZodNumber>;
439
+ width: z.ZodOptional<z.ZodNumber>;
440
+ height: z.ZodOptional<z.ZodNumber>;
441
+ repeats: z.ZodOptional<z.ZodNumber>;
442
+ }, z.core.$strip>>;
443
+ }, z.core.$strip>;
444
+ export type UpscaleStreamResponse = z.infer<typeof upscaleStreamResponseSchema>;
445
+ export type UpscaleClientParams = Omit<UpscaleRequest, "image"> & {
446
+ image: Uint8Array;
334
447
  };
448
+ export {};
335
449
  //# sourceMappingURL=sdcpp-config.d.ts.map
@@ -1,8 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import { modelSrcInputSchema } from "./model-src-utils.js";
3
3
  const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
4
+ const ABSOLUTE_PATH_PATTERN = /^(\/|[A-Za-z]:[\\/]|\\\\)/;
4
5
  export const sdcppConfigSchema = z
5
6
  .object({
7
+ mode: z.enum(["diffusion", "upscale"]).default("diffusion")
8
+ .describe("Operation mode for the diffusion plugin. " +
9
+ "`'diffusion'` (default) builds a full SD / SDXL / SD3 / FLUX pipeline from " +
10
+ "the primary model plus optional auxiliary text encoders, VAE, and ESRGAN " +
11
+ "upscaler, and exposes diffusion({ ... }). " +
12
+ "`'upscale'` builds a standalone ESRGAN upscaler from the primary model " +
13
+ "file alone (auxiliary model sources are ignored) and exposes upscale({ ... })."),
6
14
  threads: z.number().optional(),
7
15
  device: z.enum(["gpu", "cpu"]).optional(),
8
16
  prediction: z
@@ -23,6 +31,14 @@ export const sdcppConfigSchema = z
23
31
  vae_on_cpu: z.boolean().optional().describe("Force VAE decoder to run on CPU"),
24
32
  vae_tiling: z.boolean().optional().describe("Enable VAE tiling for large images on limited VRAM"),
25
33
  flash_attn: z.boolean().optional().describe("Enable flash attention to reduce memory usage"),
34
+ lora_apply_mode: z.enum(["auto", "immediately", "at_runtime"]).optional()
35
+ .describe("How LoRA adapters passed via diffusion({ lora }) are applied. " +
36
+ "'auto' (default): picked based on weight type — 'at_runtime' for " +
37
+ "quantized weights, 'immediately' for full-precision. " +
38
+ "'immediately': adapter is fused into the model on first use and " +
39
+ "persists across subsequent diffusion() calls until the model is " +
40
+ "unloaded. " +
41
+ "'at_runtime': adapter is applied per-call and not persisted."),
26
42
  verbosity: z.number().optional(),
27
43
  clipLModelSrc: modelSrcInputSchema.optional()
28
44
  .describe("CLIP-L text encoder model — required for SD3"),
@@ -34,6 +50,39 @@ export const sdcppConfigSchema = z
34
50
  .describe("LLM text encoder model (e.g. Qwen3) — required for FLUX.2 [klein]"),
35
51
  vaeModelSrc: modelSrcInputSchema.optional()
36
52
  .describe("VAE decoder model — required for FLUX.2 [klein], optional for SDXL"),
53
+ upscaler: z.object({
54
+ type: z.literal("esrgan").optional()
55
+ .describe("Type of upscaler to use for post-generation upscaling when requested in diffusion({ upscale })."),
56
+ model_src: modelSrcInputSchema.optional()
57
+ .describe("ESRGAN upscaler model (e.g. RealESRGAN_x4plus_anime_6B.pth). " +
58
+ "Required in diffusion mode when this `upscaler` block is set — " +
59
+ "configures the post-generation upscaler invoked via diffusion({ upscale }). " +
60
+ "In `mode: 'upscale'` the primary modelSrc itself is the ESRGAN model, " +
61
+ "so this field is ignored."),
62
+ tile_size: z.number().int().positive().optional()
63
+ .describe("ESRGAN upscaler tile size in pixels. Smaller tiles use less VRAM " +
64
+ "at the cost of more passes."),
65
+ direct: z.boolean().optional()
66
+ .describe("Use direct convolution in the ESRGAN upscaler instead of im2col + " +
67
+ "GEMM. Faster on some backends, slower on others."),
68
+ offload_params_to_cpu: z.boolean().optional()
69
+ .describe("Keep ESRGAN upscaler weights on CPU and offload them during compute. " +
70
+ "Trades latency for VRAM headroom on memory-constrained GPUs."),
71
+ threads: z.union([
72
+ z.literal(-1),
73
+ z.number().int().positive(),
74
+ ])
75
+ .optional()
76
+ .describe("Number of CPU threads dedicated to the ESRGAN upscaler. -1 = auto."),
77
+ }).strict().optional()
78
+ .describe("ESRGAN upscaler configuration. In diffusion mode this enables the " +
79
+ "post-generation upscale path invoked via diffusion({ upscale }) and " +
80
+ "requires `model_src`. In `mode: 'upscale'` only the tuning fields " +
81
+ "(tile_size, direct, offload_params_to_cpu, threads) are honored — " +
82
+ "the primary modelSrc IS the ESRGAN model in that mode and " +
83
+ "`model_src` here is ignored. Mode-dependent constraints (e.g. " +
84
+ "`model_src` required in diffusion mode) are enforced by the " +
85
+ "sdcpp-generation plugin at load time, not at the schema layer."),
37
86
  });
38
87
  export const diffusionStatsSchema = z.object({
39
88
  modelLoadMs: z
@@ -182,14 +231,127 @@ export const diffusionRequestSchema = z.object({
182
231
  .min(1)
183
232
  .regex(BASE64_PATTERN)
184
233
  .optional()
185
- .describe("Base64-encoded image for img2img generation"),
234
+ .describe("Base64-encoded image for img2img generation. Mutually exclusive with init_images."),
235
+ init_images: z.array(z.string().min(1).regex(BASE64_PATTERN))
236
+ .min(1)
237
+ .optional()
238
+ .describe("FLUX.2-only multi-reference fusion: array of base64-encoded PNG/JPEG buffers. " +
239
+ "Each buffer becomes a separate reference image that the FLUX.2 transformer attends to. " +
240
+ "Mutually exclusive with init_image; requires the model to be loaded with " +
241
+ "config.prediction='flux2_flow' and a Qwen3 text encoder via llmModelSrc."),
242
+ increase_ref_index: z.boolean().optional()
243
+ .describe("FLUX.2 fusion only. When omitted, the addon default (false) is used. When false, all " +
244
+ "reference latents share one RoPE index slot and blend via attention (recommended for " +
245
+ "FLUX.2-klein). When true, each reference gets its own RoPE index slot — use only with " +
246
+ "text encoders that receive per-image vision tokens."),
247
+ auto_resize_ref_image: z.boolean().optional()
248
+ .describe("FLUX.2 only. When omitted, the addon default (true) is used. When true, every reference " +
249
+ "image (single or fusion) is auto-resized to the target width/height before VAE-encoding. " +
250
+ "Disable only if the buffers are already at the exact target dimensions."),
251
+ lora: z
252
+ .string()
253
+ .min(1)
254
+ .regex(ABSOLUTE_PATH_PATTERN, {
255
+ message: "lora must be an absolute path",
256
+ })
257
+ .optional()
258
+ .describe("Optional local LoRA adapter path to apply for this generation. " +
259
+ "Must be an absolute filesystem path. " +
260
+ "Whether the adapter persists across subsequent diffusion() calls is controlled " +
261
+ "by sdcppConfigSchema.lora_apply_mode (set at loadModel time)."),
186
262
  strength: z
187
263
  .number()
188
264
  .min(0)
189
265
  .max(1)
190
266
  .optional()
191
267
  .describe("img2img denoising strength (0.0 = keep source, 1.0 = ignore source); used by the SD/SDXL SDEdit path. No-op for FLUX.2, which uses in-context conditioning and ignores this field."),
268
+ upscale: z
269
+ .union([
270
+ z.boolean(),
271
+ z.object({
272
+ repeats: z.number().int().positive().optional(),
273
+ }).strict(),
274
+ ])
275
+ .optional()
276
+ .describe("Post-generation ESRGAN upscale. " +
277
+ "`true` (or `{}` / `{ repeats: 1 }`) runs a single upscale pass at the " +
278
+ "model's native scale factor (e.g. x4 for RealESRGAN_x4plus). " +
279
+ "`false` is a no-op (same as omitting the field). " +
280
+ "`{ repeats: N }` runs the upscaler N times sequentially — each pass " +
281
+ "multiplies the output dimensions by the model's scale factor. When " +
282
+ "`batch_count > 1`, every output image is upscaled independently. " +
283
+ "Requires the model to be loaded with `upscaler.model_src` set in modelConfig."),
284
+ }).refine((d) => d.init_image === undefined || d.init_images === undefined, {
285
+ message: "init_image and init_images are mutually exclusive — pass one or the other, not both.",
192
286
  });
193
287
  export const diffusionStreamRequestSchema = diffusionRequestSchema.extend({
194
288
  type: z.literal("diffusionStream"),
195
289
  });
290
+ // ============================================
291
+ // Standalone ESRGAN upscale (mode: "upscale")
292
+ // ============================================
293
+ export const upscaleStatsSchema = z.object({
294
+ modelLoadMs: z
295
+ .number()
296
+ .optional()
297
+ .describe("Wall-clock time in milliseconds spent loading the upscaler model."),
298
+ upscaleMs: z
299
+ .number()
300
+ .optional()
301
+ .describe("Wall-clock time in milliseconds for the most recent upscale job."),
302
+ totalUpscaleMs: z
303
+ .number()
304
+ .optional()
305
+ .describe("Cumulative upscale time in milliseconds across all jobs."),
306
+ totalWallMs: z
307
+ .number()
308
+ .optional()
309
+ .describe("Total wall-clock time in milliseconds including model load and upscaling."),
310
+ totalUpscales: z
311
+ .number()
312
+ .optional()
313
+ .describe("Cumulative number of upscale calls."),
314
+ totalImages: z
315
+ .number()
316
+ .optional()
317
+ .describe("Cumulative number of images produced."),
318
+ totalPixels: z
319
+ .number()
320
+ .optional()
321
+ .describe("Cumulative number of pixels produced across all images."),
322
+ width: z.number().optional().describe("Width of the most recent emitted PNG."),
323
+ height: z.number().optional().describe("Height of the most recent emitted PNG."),
324
+ repeats: z
325
+ .number()
326
+ .optional()
327
+ .describe("Number of ESRGAN passes used by the most recent upscale job."),
328
+ });
329
+ export const upscaleRequestSchema = z.object({
330
+ modelId: z
331
+ .string()
332
+ .describe("Identifier of the loaded upscaler model. The model must have been loaded " +
333
+ "with `modelType: 'diffusion'` and `modelConfig.mode: 'upscale'`."),
334
+ image: z
335
+ .string()
336
+ .min(1)
337
+ .regex(BASE64_PATTERN)
338
+ .describe("Base64-encoded PNG/JPEG bytes of the source image."),
339
+ repeats: z
340
+ .number()
341
+ .int()
342
+ .positive()
343
+ .optional()
344
+ .describe("Number of ESRGAN passes to run sequentially. Each pass multiplies " +
345
+ "dimensions by the model's native scale factor; only the final image " +
346
+ "is emitted (`outputs.length === 1`). Defaults to 1."),
347
+ });
348
+ export const upscaleStreamRequestSchema = upscaleRequestSchema.extend({
349
+ type: z.literal("upscaleStream"),
350
+ });
351
+ export const upscaleStreamResponseSchema = z.object({
352
+ type: z.literal("upscaleStream"),
353
+ data: z.string().optional(),
354
+ outputIndex: z.number().optional(),
355
+ done: z.boolean().optional(),
356
+ stats: upscaleStatsSchema.optional(),
357
+ });