@qvac/sdk 0.8.2 → 0.9.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 (219) hide show
  1. package/NOTICE +267 -63
  2. package/README.md +2 -0
  3. package/dist/client/api/diffusion.d.ts +32 -0
  4. package/dist/client/api/diffusion.js +103 -0
  5. package/dist/client/api/embed.d.ts +9 -3
  6. package/dist/client/api/embed.js +4 -1
  7. package/dist/client/api/finetune.d.ts +69 -0
  8. package/dist/client/api/finetune.js +139 -0
  9. package/dist/client/api/get-model-info.d.ts +1 -1
  10. package/dist/client/api/index.d.ts +4 -0
  11. package/dist/client/api/index.js +4 -0
  12. package/dist/client/api/rag.d.ts +1 -1
  13. package/dist/client/api/rag.js +1 -1
  14. package/dist/client/api/resume.d.ts +14 -0
  15. package/dist/client/api/resume.js +20 -0
  16. package/dist/client/api/suspend.d.ts +13 -0
  17. package/dist/client/api/suspend.js +19 -0
  18. package/dist/client/api/transcribe.d.ts +25 -17
  19. package/dist/client/api/transcribe.js +115 -35
  20. package/dist/client/rpc/bare-client.d.ts +5 -1
  21. package/dist/client/rpc/bare-client.js +70 -57
  22. package/dist/client/rpc/expo-rpc-client.d.ts +4 -0
  23. package/dist/client/rpc/expo-rpc-client.js +8 -0
  24. package/dist/client/rpc/node-rpc-client.d.ts +4 -0
  25. package/dist/client/rpc/node-rpc-client.js +8 -0
  26. package/dist/client/rpc/rpc-client.d.ts +13 -0
  27. package/dist/client/rpc/rpc-client.js +131 -1
  28. package/dist/examples/delegated-inference/composite.d.ts +2 -0
  29. package/dist/examples/delegated-inference/composite.js +99 -0
  30. package/dist/examples/diffusion-flux2-klein.d.ts +2 -0
  31. package/dist/examples/diffusion-flux2-klein.js +46 -0
  32. package/dist/examples/diffusion-simple.d.ts +2 -0
  33. package/dist/examples/diffusion-simple.js +17 -0
  34. package/dist/examples/diffusion-txt2img.d.ts +2 -0
  35. package/dist/examples/diffusion-txt2img.js +40 -0
  36. package/dist/examples/embed-p2p.js +2 -2
  37. package/dist/examples/finetune/llamacpp-finetune.d.ts +2 -0
  38. package/dist/examples/finetune/llamacpp-finetune.js +78 -0
  39. package/dist/examples/logging-streaming.js +1 -1
  40. package/dist/examples/mcp-websearch.js +2 -0
  41. package/dist/examples/ocr-fasttext.js +11 -0
  42. package/dist/examples/profiling/per-call.js +3 -3
  43. package/dist/examples/rag/rag-chromadb.js +2 -2
  44. package/dist/examples/rag/rag-hyperdb/pipeline.js +1 -1
  45. package/dist/examples/rag/rag-lancedb.js +2 -2
  46. package/dist/examples/rag/rag-sqlite.js +2 -2
  47. package/dist/examples/suspend-resume.d.ts +2 -0
  48. package/dist/examples/suspend-resume.js +52 -0
  49. package/dist/examples/transcription/parakeet-ctc-filesystem.js +3 -5
  50. package/dist/examples/transcription/parakeet-microphone-record.js +42 -33
  51. package/dist/examples/transcription/parakeet-sortformer.js +13 -3
  52. package/dist/examples/transcription/parakeet-tdt-filesystem.js +5 -7
  53. package/dist/examples/transcription/whispercpp-filesystem-streaming.d.ts +2 -0
  54. package/dist/examples/transcription/whispercpp-filesystem-streaming.js +99 -0
  55. package/dist/examples/transcription/whispercpp-microphone-record.js +78 -299
  56. package/dist/examples/transcription/whispercpp-prompt.js +11 -0
  57. package/dist/examples/translation/translation-llm.js +2 -2
  58. package/dist/examples/tts/supertonic-multilingual.d.ts +2 -0
  59. package/dist/examples/tts/supertonic-multilingual.js +56 -0
  60. package/dist/examples/tts/supertonic.js +12 -7
  61. package/dist/index.d.ts +3 -2
  62. package/dist/index.js +3 -2
  63. package/dist/logging/utils.js +1 -1
  64. package/dist/models/registry/models.d.ts +15176 -4264
  65. package/dist/models/registry/models.js +18657 -7404
  66. package/dist/models/update-models/codegen.js +2 -2
  67. package/dist/models/update-models/naming.js +26 -0
  68. package/dist/pear/pre.js +2 -0
  69. package/dist/polyfills/bare-globals.d.ts +2 -0
  70. package/dist/polyfills/bare-globals.js +4 -0
  71. package/dist/polyfills/bare-globals.noop.d.ts +2 -0
  72. package/dist/polyfills/bare-globals.noop.js +1 -0
  73. package/dist/profiling/exporters.js +16 -11
  74. package/dist/profiling/model-execution.d.ts +16 -0
  75. package/dist/profiling/model-execution.js +33 -0
  76. package/dist/schemas/common.d.ts +967 -198
  77. package/dist/schemas/common.js +16 -1
  78. package/dist/schemas/completion-stream.d.ts +14 -6
  79. package/dist/schemas/completion-stream.js +4 -3
  80. package/dist/schemas/download-asset.d.ts +7 -3
  81. package/dist/schemas/embed.d.ts +19 -0
  82. package/dist/schemas/embed.js +7 -0
  83. package/dist/schemas/engine-addon-map.js +4 -1
  84. package/dist/schemas/finetune.d.ts +620 -0
  85. package/dist/schemas/finetune.js +161 -0
  86. package/dist/schemas/get-model-info.d.ts +2 -0
  87. package/dist/schemas/get-model-info.js +1 -0
  88. package/dist/schemas/index.d.ts +5 -1
  89. package/dist/schemas/index.js +5 -1
  90. package/dist/schemas/llamacpp-config.d.ts +26 -6
  91. package/dist/schemas/llamacpp-config.js +12 -0
  92. package/dist/schemas/load-model.d.ts +4005 -1400
  93. package/dist/schemas/load-model.js +34 -1
  94. package/dist/schemas/model-src-utils.d.ts +10 -2
  95. package/dist/schemas/model-types.d.ts +19 -1
  96. package/dist/schemas/model-types.js +11 -0
  97. package/dist/schemas/ocr.d.ts +2 -0
  98. package/dist/schemas/plugin.d.ts +24 -3
  99. package/dist/schemas/plugin.js +14 -0
  100. package/dist/schemas/profiling.d.ts +4 -0
  101. package/dist/schemas/profiling.js +4 -0
  102. package/dist/schemas/registry.d.ts +18 -0
  103. package/dist/schemas/registry.js +2 -0
  104. package/dist/schemas/reload-config.d.ts +9 -1
  105. package/dist/schemas/resume.d.ts +10 -0
  106. package/dist/schemas/resume.js +7 -0
  107. package/dist/schemas/sdcpp-config.d.ts +327 -0
  108. package/dist/schemas/sdcpp-config.js +102 -0
  109. package/dist/schemas/sdk-config.d.ts +1225 -235
  110. package/dist/schemas/sdk-config.js +4 -0
  111. package/dist/schemas/sdk-errors-server.d.ts +2 -0
  112. package/dist/schemas/sdk-errors-server.js +12 -0
  113. package/dist/schemas/suspend.d.ts +10 -0
  114. package/dist/schemas/suspend.js +7 -0
  115. package/dist/schemas/text-to-speech.d.ts +187 -10
  116. package/dist/schemas/text-to-speech.js +12 -4
  117. package/dist/schemas/transcription-config.d.ts +16 -56
  118. package/dist/schemas/transcription-config.js +0 -2
  119. package/dist/schemas/transcription.d.ts +66 -6
  120. package/dist/schemas/transcription.js +29 -7
  121. package/dist/schemas/translate.d.ts +14 -4
  122. package/dist/schemas/translate.js +10 -2
  123. package/dist/schemas/translation-config.d.ts +30 -10
  124. package/dist/server/bare/delegate-rpc-client.js +3 -3
  125. package/dist/server/bare/hyperswarm.js +15 -3
  126. package/dist/server/bare/ops/embed.d.ts +8 -4
  127. package/dist/server/bare/ops/embed.js +15 -4
  128. package/dist/server/bare/ops/transcribe.d.ts +6 -2
  129. package/dist/server/bare/ops/transcribe.js +53 -1
  130. package/dist/server/bare/ops/translate.d.ts +4 -1
  131. package/dist/server/bare/ops/translate.js +28 -65
  132. package/dist/server/bare/ops/unload-model.js +2 -0
  133. package/dist/server/bare/plugins/index.d.ts +1 -0
  134. package/dist/server/bare/plugins/index.js +1 -0
  135. package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +1 -0
  136. package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +3 -0
  137. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +3 -1
  138. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +57 -11
  139. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +11 -0
  140. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +112 -0
  141. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +175 -5
  142. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +45 -35
  143. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +11 -1
  144. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +9 -4
  145. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -2
  146. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +16 -15
  147. package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.d.ts +5 -7
  148. package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.js +11 -3
  149. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +2 -0
  150. package/dist/server/bare/plugins/onnx-ocr/plugin.js +24 -19
  151. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +7 -2
  152. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +22 -97
  153. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +98 -9
  154. package/dist/server/bare/plugins/onnx-tts/plugin.js +85 -46
  155. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +30 -60
  156. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +49 -37
  157. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +3 -0
  158. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +51 -0
  159. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +278 -0
  160. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +70 -0
  161. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +38 -2
  162. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +43 -22
  163. package/dist/server/bare/rag-hyperdb/handlers/ingest.js +2 -1
  164. package/dist/server/bare/rag-hyperdb/handlers/search.js +2 -1
  165. package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +7 -0
  166. package/dist/server/bare/registry/model-config-utils.js +3 -0
  167. package/dist/server/bare/registry/model-registry.d.ts +2 -2
  168. package/dist/server/bare/registry/model-registry.js +1 -1
  169. package/dist/server/bare/registry/registry-client.js +21 -0
  170. package/dist/server/bare/runtime-lifecycle.d.ts +28 -0
  171. package/dist/server/bare/runtime-lifecycle.js +132 -0
  172. package/dist/server/bare/types/addon-responses.d.ts +62 -0
  173. package/dist/server/bare/types/addon-responses.js +1 -0
  174. package/dist/server/env.js +3 -1
  175. package/dist/server/rpc/delegate-transport.js +1 -1
  176. package/dist/server/rpc/handle-request.js +50 -4
  177. package/dist/server/rpc/handler-registry.js +20 -1
  178. package/dist/server/rpc/handler-utils.d.ts +5 -3
  179. package/dist/server/rpc/handler-utils.js +52 -50
  180. package/dist/server/rpc/handlers/delete-cache.js +3 -0
  181. package/dist/server/rpc/handlers/diffusion-stream.d.ts +3 -0
  182. package/dist/server/rpc/handlers/diffusion-stream.js +4 -0
  183. package/dist/server/rpc/handlers/finetune.d.ts +3 -0
  184. package/dist/server/rpc/handlers/finetune.js +16 -0
  185. package/dist/server/rpc/handlers/index.d.ts +10 -0
  186. package/dist/server/rpc/handlers/index.js +10 -0
  187. package/dist/server/rpc/handlers/load-model/hyperdrive.js +24 -9
  188. package/dist/server/rpc/handlers/load-model/registry.d.ts +11 -0
  189. package/dist/server/rpc/handlers/load-model/registry.js +31 -4
  190. package/dist/server/rpc/handlers/plugin-dispatch.d.ts +1 -13
  191. package/dist/server/rpc/handlers/plugin-dispatch.js +21 -21
  192. package/dist/server/rpc/handlers/resume.d.ts +3 -0
  193. package/dist/server/rpc/handlers/resume.js +11 -0
  194. package/dist/server/rpc/handlers/suspend.d.ts +3 -0
  195. package/dist/server/rpc/handlers/suspend.js +11 -0
  196. package/dist/server/rpc/handlers/transcribe-stream.d.ts +1 -1
  197. package/dist/server/rpc/handlers/transcribe-stream.js +2 -2
  198. package/dist/server/rpc/handlers/transcribe.d.ts +3 -0
  199. package/dist/server/rpc/handlers/transcribe.js +4 -0
  200. package/dist/server/rpc/profiling/operation-metrics.js +107 -16
  201. package/dist/server/rpc/profiling/operation-wrappers.d.ts +1 -1
  202. package/dist/server/rpc/profiling/operation-wrappers.js +51 -19
  203. package/dist/server/rpc/progress-throttle.d.ts +8 -0
  204. package/dist/server/rpc/progress-throttle.js +47 -0
  205. package/dist/server/rpc/rpc-utils.d.ts +5 -0
  206. package/dist/server/rpc/rpc-utils.js +11 -0
  207. package/dist/server/utils/path-security.js +1 -1
  208. package/dist/server/utils/tool-integration.js +10 -0
  209. package/dist/server/utils/tool-parser.js +9 -5
  210. package/dist/server/worker-core.d.ts +2 -0
  211. package/dist/server/worker-core.js +26 -23
  212. package/dist/server/worker.js +2 -1
  213. package/dist/utils/encoding.d.ts +9 -0
  214. package/dist/utils/encoding.js +14 -0
  215. package/dist/utils/errors-server.d.ts +6 -0
  216. package/dist/utils/errors-server.js +11 -0
  217. package/package.json +81 -25
  218. package/dist/server/rpc/delegate-utils.d.ts +0 -2
  219. package/dist/server/rpc/delegate-utils.js +0 -5
@@ -6,8 +6,8 @@ export declare const embeddingsPlugin: {
6
6
  loadConfigSchema: import("zod").ZodObject<{
7
7
  gpuLayers: import("zod").ZodOptional<import("zod").ZodNumber>;
8
8
  device: import("zod").ZodOptional<import("zod").ZodEnum<{
9
- gpu: "gpu";
10
9
  cpu: "cpu";
10
+ gpu: "gpu";
11
11
  }>>;
12
12
  batchSize: import("zod").ZodOptional<import("zod").ZodNumber>;
13
13
  pooling: import("zod").ZodOptional<import("zod").ZodEnum<{
@@ -32,6 +32,7 @@ export declare const embeddingsPlugin: {
32
32
  dedicated: "dedicated";
33
33
  }>]>>;
34
34
  verbosity: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<0>, import("zod").ZodLiteral<1>, import("zod").ZodLiteral<2>, import("zod").ZodLiteral<3>]>>;
35
+ openclCacheDir: import("zod").ZodOptional<import("zod").ZodString>;
35
36
  }, import("zod/v4/core").$strip>;
36
37
  createModel(params: CreateModelParams): PluginModelResult;
37
38
  handlers: {
@@ -43,6 +44,15 @@ export declare const embeddingsPlugin: {
43
44
  type: import("zod").ZodLiteral<"embed">;
44
45
  success: import("zod").ZodBoolean;
45
46
  embedding: import("zod").ZodDefault<import("zod").ZodUnion<readonly [import("zod").ZodArray<import("zod").ZodNumber>, import("zod").ZodArray<import("zod").ZodArray<import("zod").ZodNumber>>]>>;
47
+ stats: import("zod").ZodOptional<import("zod").ZodObject<{
48
+ totalTime: import("zod").ZodOptional<import("zod").ZodNumber>;
49
+ tokensPerSecond: import("zod").ZodOptional<import("zod").ZodNumber>;
50
+ totalTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
51
+ backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
52
+ cpu: "cpu";
53
+ gpu: "gpu";
54
+ }>>;
55
+ }, import("zod/v4/core").$strip>>;
46
56
  error: import("zod").ZodOptional<import("zod").ZodString>;
47
57
  }, import("zod/v4/core").$strip>>;
48
58
  };
@@ -6,6 +6,7 @@ import { parseModelPath } from "../../../utils/index.js";
6
6
  import FilesystemDL from "@qvac/dl-filesystem";
7
7
  import { asLoader } from "../../utils/loader-adapter.js";
8
8
  import { embed } from "../../ops/embed.js";
9
+ import { forwardModelExecution } from "../../../../profiling/model-execution.js";
9
10
  function transformEmbedConfig(embedConfig) {
10
11
  const config = {
11
12
  device: embedConfig.device,
@@ -33,6 +34,9 @@ function transformEmbedConfig(embedConfig) {
33
34
  if (typeof embedConfig.verbosity === "number") {
34
35
  config.verbosity = `${embedConfig.verbosity}`;
35
36
  }
37
+ if (embedConfig.openclCacheDir) {
38
+ config.openclCacheDir = embedConfig.openclCacheDir;
39
+ }
36
40
  return config;
37
41
  }
38
42
  function createEmbeddingsModel(modelId, modelPath, embedConfig) {
@@ -68,15 +72,16 @@ export const embeddingsPlugin = definePlugin({
68
72
  responseSchema: embedResponseSchema,
69
73
  streaming: false,
70
74
  handler: async function (request) {
71
- const embedding = await embed({
75
+ const embedResult = await embed({
72
76
  modelId: request.modelId,
73
77
  text: request.text,
74
78
  });
75
- return {
79
+ return forwardModelExecution({
76
80
  type: "embed",
77
81
  success: true,
78
- embedding,
79
- };
82
+ embedding: embedResult.embedding,
83
+ ...(embedResult.stats && { stats: embedResult.stats }),
84
+ }, embedResult);
80
85
  },
81
86
  }),
82
87
  },
@@ -118,6 +118,7 @@ export declare const nmtPlugin: {
118
118
  "onnx-tts": "onnx-tts";
119
119
  "parakeet-transcription": "parakeet-transcription";
120
120
  "onnx-ocr": "onnx-ocr";
121
+ "sdcpp-generation": "sdcpp-generation";
121
122
  llm: "llm";
122
123
  whisper: "whisper";
123
124
  embeddings: "embeddings";
@@ -125,6 +126,7 @@ export declare const nmtPlugin: {
125
126
  parakeet: "parakeet";
126
127
  tts: "tts";
127
128
  ocr: "ocr";
129
+ diffusion: "diffusion";
128
130
  }>, import("zod").ZodLiteral<"vad">]>>;
129
131
  }, import("zod/v4/core").$strip>]>>;
130
132
  dstVocabSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
@@ -146,6 +148,7 @@ export declare const nmtPlugin: {
146
148
  "onnx-tts": "onnx-tts";
147
149
  "parakeet-transcription": "parakeet-transcription";
148
150
  "onnx-ocr": "onnx-ocr";
151
+ "sdcpp-generation": "sdcpp-generation";
149
152
  llm: "llm";
150
153
  whisper: "whisper";
151
154
  embeddings: "embeddings";
@@ -153,6 +156,7 @@ export declare const nmtPlugin: {
153
156
  parakeet: "parakeet";
154
157
  tts: "tts";
155
158
  ocr: "ocr";
159
+ diffusion: "diffusion";
156
160
  }>, import("zod").ZodLiteral<"vad">]>>;
157
161
  }, import("zod/v4/core").$strip>]>>;
158
162
  normalize: import("zod").ZodOptional<import("zod").ZodNumber>;
@@ -187,6 +191,7 @@ export declare const nmtPlugin: {
187
191
  "onnx-tts": "onnx-tts";
188
192
  "parakeet-transcription": "parakeet-transcription";
189
193
  "onnx-ocr": "onnx-ocr";
194
+ "sdcpp-generation": "sdcpp-generation";
190
195
  llm: "llm";
191
196
  whisper: "whisper";
192
197
  embeddings: "embeddings";
@@ -194,6 +199,7 @@ export declare const nmtPlugin: {
194
199
  parakeet: "parakeet";
195
200
  tts: "tts";
196
201
  ocr: "ocr";
202
+ diffusion: "diffusion";
197
203
  }>, import("zod").ZodLiteral<"vad">]>>;
198
204
  }, import("zod/v4/core").$strip>]>;
199
205
  srcVocabSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
@@ -215,6 +221,7 @@ export declare const nmtPlugin: {
215
221
  "onnx-tts": "onnx-tts";
216
222
  "parakeet-transcription": "parakeet-transcription";
217
223
  "onnx-ocr": "onnx-ocr";
224
+ "sdcpp-generation": "sdcpp-generation";
218
225
  llm: "llm";
219
226
  whisper: "whisper";
220
227
  embeddings: "embeddings";
@@ -222,6 +229,7 @@ export declare const nmtPlugin: {
222
229
  parakeet: "parakeet";
223
230
  tts: "tts";
224
231
  ocr: "ocr";
232
+ diffusion: "diffusion";
225
233
  }>, import("zod").ZodLiteral<"vad">]>>;
226
234
  }, import("zod/v4/core").$strip>]>>;
227
235
  dstVocabSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
@@ -243,6 +251,7 @@ export declare const nmtPlugin: {
243
251
  "onnx-tts": "onnx-tts";
244
252
  "parakeet-transcription": "parakeet-transcription";
245
253
  "onnx-ocr": "onnx-ocr";
254
+ "sdcpp-generation": "sdcpp-generation";
246
255
  llm: "llm";
247
256
  whisper: "whisper";
248
257
  embeddings: "embeddings";
@@ -250,6 +259,7 @@ export declare const nmtPlugin: {
250
259
  parakeet: "parakeet";
251
260
  tts: "tts";
252
261
  ocr: "ocr";
262
+ diffusion: "diffusion";
253
263
  }>, import("zod").ZodLiteral<"vad">]>>;
254
264
  }, import("zod/v4/core").$strip>]>>;
255
265
  normalize: import("zod").ZodOptional<import("zod").ZodNumber>;
@@ -353,8 +363,13 @@ export declare const nmtPlugin: {
353
363
  token: import("zod").ZodString;
354
364
  done: import("zod").ZodOptional<import("zod").ZodBoolean>;
355
365
  stats: import("zod").ZodOptional<import("zod").ZodObject<{
356
- processedTokens: import("zod").ZodNumber;
357
- processingTime: import("zod").ZodNumber;
366
+ totalTime: import("zod").ZodOptional<import("zod").ZodNumber>;
367
+ totalTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
368
+ tokensPerSecond: import("zod").ZodOptional<import("zod").ZodNumber>;
369
+ timeToFirstToken: import("zod").ZodOptional<import("zod").ZodNumber>;
370
+ decodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
371
+ encodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
372
+ cacheTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
358
373
  }, import("zod/v4/core").$strip>>;
359
374
  error: import("zod").ZodOptional<import("zod").ZodString>;
360
375
  }, import("zod/v4/core").$strip>>;
@@ -7,6 +7,7 @@ import FilesystemDL from "@qvac/dl-filesystem";
7
7
  import { ModelLoadFailedError } from "../../../../utils/errors-server.js";
8
8
  import { asLoader } from "../../utils/loader-adapter.js";
9
9
  import { translate } from "../../ops/translate.js";
10
+ import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
10
11
  const BERGAMOT_CJK_LANG_PAIRS = ["enja", "enko", "enzh"];
11
12
  function buildBergamotVocabSources(basePath, langPair) {
12
13
  if (BERGAMOT_CJK_LANG_PAIRS.includes(langPair)) {
@@ -45,6 +46,7 @@ function createNmtModel(modelId, modelPath, nmtConfig, srcVocabPath, dstVocabPat
45
46
  logger,
46
47
  modelName: basePath,
47
48
  diskPath: dirPath,
49
+ opts: { stats: true },
48
50
  params: {
49
51
  mode,
50
52
  srcLang: from,
@@ -170,27 +172,26 @@ export const nmtPlugin = definePlugin({
170
172
  streaming: true,
171
173
  handler: async function* (request) {
172
174
  const stream = translate(request);
173
- let done = false;
174
- let stats;
175
- while (!done) {
176
- const result = await stream.next();
177
- if (result.done) {
178
- stats = result.value;
179
- done = true;
180
- }
181
- else {
175
+ try {
176
+ let result = await stream.next();
177
+ while (!result.done) {
182
178
  yield {
183
179
  type: "translate",
184
180
  token: result.value,
185
181
  };
182
+ result = await stream.next();
186
183
  }
184
+ const { modelExecutionMs, stats } = result.value;
185
+ yield attachModelExecutionMs({
186
+ type: "translate",
187
+ token: "",
188
+ done: true,
189
+ ...(stats && { stats }),
190
+ }, modelExecutionMs);
191
+ }
192
+ finally {
193
+ await stream.return?.(undefined);
187
194
  }
188
- yield {
189
- type: "translate",
190
- token: "",
191
- done: true,
192
- ...(stats && { stats }),
193
- };
194
195
  },
195
196
  }),
196
197
  },
@@ -1,10 +1,8 @@
1
- import type { OCRParams, OCRTextBlock } from "../../../../../schemas/ocr";
1
+ import { type OCRParams, type OCRTextBlock, type OCRStats } from "../../../../../schemas/index";
2
2
  export declare function ocr(params: OCRParams): AsyncGenerator<{
3
3
  blocks: OCRTextBlock[];
4
- stats?: {
5
- detectionTime?: number;
6
- recognitionTime?: number;
7
- totalTime?: number;
8
- };
9
- }, void, void>;
4
+ }, {
5
+ modelExecutionMs: number;
6
+ stats?: OCRStats;
7
+ }, void>;
10
8
  //# sourceMappingURL=ocr-stream.d.ts.map
@@ -1,8 +1,11 @@
1
1
  import { getModel } from "../../../registry/model-registry.js";
2
2
  import fs from "bare-fs";
3
3
  import path from "bare-path";
4
+ import {} from "../../../../../schemas/index.js";
5
+ import { buildStreamResult, hasDefinedValues } from "../../../../../profiling/model-execution.js";
4
6
  import { getCacheDir } from "../../../../utils/index.js";
5
7
  import { ImageFileNotFoundError, InvalidImageInputError, } from "../../../../../utils/errors-server.js";
8
+ import { nowMs } from "../../../../../profiling/index.js";
6
9
  function polygonToBbox(polygon) {
7
10
  const xs = polygon.map((p) => p[0]);
8
11
  const ys = polygon.map((p) => p[1]);
@@ -75,6 +78,7 @@ export async function* ocr(params) {
75
78
  throw new InvalidImageInputError();
76
79
  }
77
80
  try {
81
+ const modelStart = nowMs();
78
82
  const response = (await model.run({
79
83
  path: imagePath,
80
84
  ...(params.options && { options: params.options }),
@@ -86,6 +90,7 @@ export async function* ocr(params) {
86
90
  return [];
87
91
  })
88
92
  .await();
93
+ const modelExecutionMs = nowMs() - modelStart;
89
94
  const blocks = rawData
90
95
  .flat(1)
91
96
  .map(normalizeBlock)
@@ -93,9 +98,12 @@ export async function* ocr(params) {
93
98
  if (blocks.length > 0) {
94
99
  yield { blocks };
95
100
  }
96
- if (response.stats) {
97
- yield { blocks: [], stats: response.stats };
98
- }
101
+ const stats = {
102
+ ...(response.stats?.detectionTime !== undefined && { detectionTime: response.stats.detectionTime }),
103
+ ...(response.stats?.recognitionTime !== undefined && { recognitionTime: response.stats.recognitionTime }),
104
+ ...(response.stats?.totalTime !== undefined && { totalTime: response.stats.totalTime }),
105
+ };
106
+ return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
99
107
  }
100
108
  finally {
101
109
  if (cleanupPath) {
@@ -40,6 +40,7 @@ export declare const ocrPlugin: {
40
40
  "onnx-tts": "onnx-tts";
41
41
  "parakeet-transcription": "parakeet-transcription";
42
42
  "onnx-ocr": "onnx-ocr";
43
+ "sdcpp-generation": "sdcpp-generation";
43
44
  llm: "llm";
44
45
  whisper: "whisper";
45
46
  embeddings: "embeddings";
@@ -47,6 +48,7 @@ export declare const ocrPlugin: {
47
48
  parakeet: "parakeet";
48
49
  tts: "tts";
49
50
  ocr: "ocr";
51
+ diffusion: "diffusion";
50
52
  }>, import("zod").ZodLiteral<"vad">]>>;
51
53
  }, import("zod/v4/core").$strip>]>>;
52
54
  }, import("zod/v4/core").$strip>;
@@ -2,10 +2,9 @@ import { definePlugin, defineHandler, ocrStreamRequestSchema, ocrStreamResponseS
2
2
  import { ModelLoadFailedError } from "../../../../utils/errors-server.js";
3
3
  import { hyperdriveUrlSchema } from "../../../../schemas/load-model.js";
4
4
  import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
5
- import { parseModelPath } from "../../../utils/index.js";
6
- import FilesystemDL from "@qvac/dl-filesystem";
7
5
  import { ONNXOcr } from "@qvac/ocr-onnx";
8
6
  import { ocr } from "./ops/ocr-stream.js";
7
+ import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
9
8
  import { OCR_CRAFT_DETECTOR } from "../../../../models/registry/index.js";
10
9
  const OCR_DETECTOR_FILENAME = "detector_craft.onnx";
11
10
  function deriveDetectorSource(modelSrc) {
@@ -19,8 +18,6 @@ function deriveDetectorSource(modelSrc) {
19
18
  return undefined;
20
19
  }
21
20
  function createOCRModel(modelId, detectorPath, recognizerPath, ocrConfig) {
22
- const { dirPath } = parseModelPath(detectorPath);
23
- const loader = new FilesystemDL({ dirPath });
24
21
  const logger = createStreamLogger(modelId, ModelType.onnxOcr);
25
22
  registerAddonLogger(modelId, ModelType.onnxOcr, logger);
26
23
  const params = {
@@ -53,14 +50,13 @@ function createOCRModel(modelId, detectorPath, recognizerPath, ocrConfig) {
53
50
  }),
54
51
  };
55
52
  const args = {
56
- loader: loader,
57
53
  logger,
58
54
  params,
59
55
  opts: { stats: true },
60
56
  };
61
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
62
58
  const model = new ONNXOcr(args);
63
- return { model, loader };
59
+ return model;
64
60
  }
65
61
  export const ocrPlugin = definePlugin({
66
62
  modelType: ModelType.onnxOcr,
@@ -85,9 +81,9 @@ export const ocrPlugin = definePlugin({
85
81
  if (!detectorModelPath) {
86
82
  throw new ModelLoadFailedError("Detector model path missing. Ensure detectorModelSrc is provided in modelConfig.");
87
83
  }
88
- const { model, loader } = createOCRModel(params.modelId, detectorModelPath, params.modelPath, // recognizerPath
84
+ const model = createOCRModel(params.modelId, detectorModelPath, params.modelPath, // recognizerPath
89
85
  ocrConfig);
90
- return { model, loader };
86
+ return { model, loader: null };
91
87
  },
92
88
  handlers: {
93
89
  ocrStream: defineHandler({
@@ -95,22 +91,31 @@ export const ocrPlugin = definePlugin({
95
91
  responseSchema: ocrStreamResponseSchema,
96
92
  streaming: true,
97
93
  handler: async function* (request) {
98
- for await (const result of ocr({
94
+ const stream = ocr({
99
95
  modelId: request.modelId,
100
96
  image: request.image,
101
97
  options: request.options,
102
- })) {
103
- yield {
98
+ });
99
+ try {
100
+ let result = await stream.next();
101
+ while (!result.done) {
102
+ yield {
103
+ type: "ocrStream",
104
+ blocks: result.value.blocks,
105
+ };
106
+ result = await stream.next();
107
+ }
108
+ const { modelExecutionMs, stats } = result.value;
109
+ yield attachModelExecutionMs({
104
110
  type: "ocrStream",
105
- blocks: result.blocks,
106
- ...(result.stats && { stats: result.stats }),
107
- };
111
+ blocks: [],
112
+ done: true,
113
+ ...(stats && { stats }),
114
+ }, modelExecutionMs);
115
+ }
116
+ finally {
117
+ await stream.return?.(undefined);
108
118
  }
109
- yield {
110
- type: "ocrStream",
111
- blocks: [],
112
- done: true,
113
- };
114
119
  },
115
120
  }),
116
121
  },
@@ -1,3 +1,8 @@
1
- import { type TtsRequest, type TtsResponse } from "../../../../../schemas/index";
2
- export declare function textToSpeech(params: TtsRequest): AsyncGenerator<TtsResponse>;
1
+ import { type TtsRequest, type TtsStats } from "../../../../../schemas/index";
2
+ export declare function textToSpeech(params: TtsRequest): AsyncGenerator<{
3
+ buffer: number[];
4
+ }, {
5
+ modelExecutionMs: number;
6
+ stats?: TtsStats;
7
+ }>;
3
8
  //# sourceMappingURL=text-to-speech.d.ts.map
@@ -1,109 +1,34 @@
1
1
  import { getModel } from "../../../registry/model-registry.js";
2
2
  import { ttsRequestSchema } from "../../../../../schemas/index.js";
3
+ import { nowMs } from "../../../../../profiling/index.js";
4
+ import { buildStreamResult, hasDefinedValues } from "../../../../../profiling/model-execution.js";
3
5
  export async function* textToSpeech(params) {
4
6
  const { modelId, inputType, text, stream } = ttsRequestSchema.parse(params);
5
7
  const model = getModel(modelId);
6
- const response = await model.run({ input: text, inputType });
8
+ const modelStart = nowMs();
9
+ const response = (await model.run({ input: text, inputType }));
7
10
  if (!stream) {
8
- // Non-streaming mode: wait for complete response and yield once
11
+ // Non-streaming mode: collect all chunks and return once
9
12
  let completeBuffer = [];
10
- await response
11
- .onUpdate((data) => {
13
+ for await (const data of response.iterate()) {
12
14
  completeBuffer = completeBuffer.concat(Array.from(data.outputArray));
13
- })
14
- .await();
15
- yield {
16
- type: "textToSpeech",
17
- buffer: completeBuffer,
18
- done: true,
15
+ }
16
+ const modelExecutionMs = nowMs() - modelStart;
17
+ const stats = {
18
+ ...(response.stats?.audioDurationMs !== undefined && { audioDuration: response.stats.audioDurationMs }),
19
+ ...(response.stats?.totalSamples !== undefined && { totalSamples: response.stats.totalSamples }),
19
20
  };
21
+ yield { buffer: completeBuffer };
22
+ return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
20
23
  }
21
- else {
22
- // Streaming mode: use async iterator pattern
23
- const outputQueue = [];
24
- let isComplete = false;
25
- let streamError = null;
26
- let resolveNext = null;
27
- let rejectNext = null;
28
- // Start the response processing
29
- const responsePromise = response
30
- .onUpdate((data) => {
31
- if (resolveNext) {
32
- // If there's a pending read, resolve it immediately
33
- resolveNext({
34
- value: {
35
- type: "textToSpeech",
36
- buffer: Array.from(data.outputArray),
37
- done: false,
38
- },
39
- done: false,
40
- });
41
- resolveNext = null;
42
- rejectNext = null;
43
- }
44
- else {
45
- // Otherwise, queue the output
46
- outputQueue.push(data);
47
- }
48
- })
49
- .await()
50
- .then(() => {
51
- isComplete = true;
52
- if (resolveNext) {
53
- resolveNext({ value: undefined, done: true });
54
- resolveNext = null;
55
- rejectNext = null;
56
- }
57
- })
58
- .catch((err) => {
59
- streamError = err;
60
- isComplete = true;
61
- if (rejectNext) {
62
- rejectNext(err);
63
- resolveNext = null;
64
- rejectNext = null;
65
- }
66
- });
67
- // Create an async iterator
68
- const asyncIterator = {
69
- async next() {
70
- if (streamError) {
71
- if (streamError instanceof Error)
72
- throw streamError;
73
- const message = typeof streamError === "string"
74
- ? streamError
75
- : JSON.stringify(streamError);
76
- throw new Error(message);
77
- }
78
- if (outputQueue.length > 0) {
79
- const data = outputQueue.shift();
80
- return {
81
- value: {
82
- type: "textToSpeech",
83
- buffer: Array.from(data.outputArray),
84
- done: false,
85
- },
86
- done: false,
87
- };
88
- }
89
- if (isComplete) {
90
- return { value: undefined, done: true };
91
- }
92
- // Wait for the next output
93
- return new Promise((resolve, reject) => {
94
- resolveNext = resolve;
95
- rejectNext = reject;
96
- });
97
- },
98
- [Symbol.asyncIterator]() {
99
- return this;
100
- },
101
- };
102
- // Yield outputs as they come
103
- for await (const output of asyncIterator) {
104
- yield output;
105
- }
106
- // Ensure the response is fully processed
107
- await responsePromise;
24
+ // Streaming mode: yield chunks as they arrive
25
+ for await (const data of response.iterate()) {
26
+ yield { buffer: Array.from(data.outputArray) };
108
27
  }
28
+ const modelExecutionMs = nowMs() - modelStart;
29
+ const stats = {
30
+ ...(response.stats?.audioDurationMs !== undefined && { audioDuration: response.stats.audioDurationMs }),
31
+ ...(response.stats?.totalSamples !== undefined && { totalSamples: response.stats.totalSamples }),
32
+ };
33
+ return buildStreamResult(modelExecutionMs, hasDefinedValues(stats) ? stats : undefined);
109
34
  }