@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
@@ -0,0 +1,103 @@
1
+ import { diffusionStreamResponseSchema, } from "../../schemas/index.js";
2
+ import { stream as streamRpc } from "../rpc/rpc-client.js";
3
+ import { decodeBase64 } from "../../utils/encoding.js";
4
+ /**
5
+ * Generate images using a loaded diffusion model.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Basic usage
10
+ * const { outputs, stats } = diffusion({ modelId, prompt: "a cat" });
11
+ * const buffers = await outputs;
12
+ * fs.writeFileSync("output.png", buffers[0]);
13
+ *
14
+ * // With progress tracking
15
+ * const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" });
16
+ * for await (const { step, totalSteps } of progressStream) {
17
+ * console.log(`${step}/${totalSteps}`);
18
+ * }
19
+ * const buffers = await outputs;
20
+ * ```
21
+ */
22
+ export function diffusion(params) {
23
+ const request = {
24
+ type: "diffusionStream",
25
+ ...params,
26
+ };
27
+ let statsResolver = () => { };
28
+ let statsRejecter = () => { };
29
+ const statsPromise = new Promise((resolve, reject) => {
30
+ statsResolver = resolve;
31
+ statsRejecter = reject;
32
+ });
33
+ statsPromise.catch(() => { });
34
+ const progressQueue = [];
35
+ const collectedBuffers = [];
36
+ let progressDone = false;
37
+ let progressResolve = null;
38
+ let streamError = null;
39
+ let outputsResolver = () => { };
40
+ let outputsRejecter = () => { };
41
+ const outputsPromise = new Promise((resolve, reject) => {
42
+ outputsResolver = resolve;
43
+ outputsRejecter = reject;
44
+ });
45
+ outputsPromise.catch(() => { });
46
+ const processResponses = async () => {
47
+ try {
48
+ for await (const response of streamRpc(request)) {
49
+ if (response &&
50
+ typeof response === "object" &&
51
+ "type" in response &&
52
+ response.type === "diffusionStream") {
53
+ const parsed = diffusionStreamResponseSchema.parse(response);
54
+ if (parsed.step != null && parsed.totalSteps != null && parsed.elapsedMs != null) {
55
+ progressQueue.push({ step: parsed.step, totalSteps: parsed.totalSteps, elapsedMs: parsed.elapsedMs });
56
+ if (progressResolve) {
57
+ progressResolve();
58
+ progressResolve = null;
59
+ }
60
+ }
61
+ if (parsed.data) {
62
+ collectedBuffers.push(decodeBase64(parsed.data));
63
+ }
64
+ if (parsed.done) {
65
+ statsResolver(parsed.stats);
66
+ outputsResolver(collectedBuffers);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ catch (error) {
72
+ streamError = error instanceof Error ? error : new Error(String(error));
73
+ statsRejecter(streamError);
74
+ outputsRejecter(streamError);
75
+ }
76
+ progressDone = true;
77
+ if (progressResolve) {
78
+ progressResolve();
79
+ progressResolve = null;
80
+ }
81
+ };
82
+ void processResponses();
83
+ const progressStream = (async function* () {
84
+ while (true) {
85
+ if (progressQueue.length > 0) {
86
+ yield progressQueue.shift();
87
+ }
88
+ else if (progressDone) {
89
+ if (streamError)
90
+ throw streamError;
91
+ return;
92
+ }
93
+ else {
94
+ await new Promise((resolve) => { progressResolve = resolve; });
95
+ }
96
+ }
97
+ })();
98
+ return {
99
+ progressStream,
100
+ outputs: outputsPromise,
101
+ stats: statsPromise,
102
+ };
103
+ }
@@ -1,4 +1,4 @@
1
- import { type RPCOptions } from "../../schemas/index";
1
+ import { type EmbedStats, type RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * Generates embeddings for a single text using a specified model.
4
4
  *
@@ -11,7 +11,10 @@ import { type RPCOptions } from "../../schemas/index";
11
11
  export declare function embed(params: {
12
12
  modelId: string;
13
13
  text: string;
14
- }, options?: RPCOptions): Promise<number[]>;
14
+ }, options?: RPCOptions): Promise<{
15
+ embedding: number[];
16
+ stats?: EmbedStats;
17
+ }>;
15
18
  /**
16
19
  * Generates embeddings for multiple texts using a specified model.
17
20
  *
@@ -24,5 +27,8 @@ export declare function embed(params: {
24
27
  export declare function embed(params: {
25
28
  modelId: string;
26
29
  text: string[];
27
- }, options?: RPCOptions): Promise<number[][]>;
30
+ }, options?: RPCOptions): Promise<{
31
+ embedding: number[][];
32
+ stats?: EmbedStats;
33
+ }>;
28
34
  //# sourceMappingURL=embed.d.ts.map
@@ -10,5 +10,8 @@ export async function embed(params, options) {
10
10
  if (response.type !== "embed") {
11
11
  throw new InvalidResponseError("embed");
12
12
  }
13
- return response.embedding;
13
+ return {
14
+ embedding: response.embedding,
15
+ ...(response.stats !== undefined && { stats: response.stats }),
16
+ };
14
17
  }
@@ -0,0 +1,69 @@
1
+ import { type FinetuneGetStateParams, type FinetuneProgress, type FinetuneResult, type FinetuneRunParams, type FinetuneStopParams, type RPCOptions } from "../../schemas/index";
2
+ export interface FinetuneHandle {
3
+ progressStream: AsyncGenerator<FinetuneProgress>;
4
+ result: Promise<FinetuneResult>;
5
+ }
6
+ type FinetuneReplyParams = FinetuneStopParams | FinetuneGetStateParams;
7
+ /**
8
+ * Starts, resumes, inspects, pauses, or cancels a finetuning job for a loaded model.
9
+ *
10
+ * @param params - The finetuning parameters
11
+ * @param params.modelId - The identifier of the loaded model to finetune
12
+ * @param params.operation - The finetuning operation. Omit it to let the add-on
13
+ * choose whether to start fresh or resume automatically
14
+ * @param params.options - Finetuning options for run and `getState` operations
15
+ * @param params.options.trainDatasetDir - Directory containing the training dataset
16
+ * @param params.options.validation - Validation configuration for the finetuning run
17
+ * @param params.options.outputParametersDir - Directory where output adapter parameters are written
18
+ * @param params.options.numberOfEpochs - Optional number of epochs to run
19
+ * @param params.options.learningRate - Optional learning rate override
20
+ * @param params.options.contextLength - Optional context length override
21
+ * @param params.options.batchSize - Optional batch size override
22
+ * @param params.options.microBatchSize - Optional micro batch size override
23
+ * @param params.options.assistantLossOnly - Optional flag to compute loss only on assistant tokens
24
+ * @param params.options.loraRank - Optional LoRA rank override
25
+ * @param params.options.loraAlpha - Optional LoRA alpha override
26
+ * @param params.options.loraInitStd - Optional LoRA initialization standard deviation
27
+ * @param params.options.loraSeed - Optional LoRA initialization seed
28
+ * @param params.options.loraModules - Optional comma-separated LoRA module selection
29
+ * @param params.options.checkpointSaveDir - Optional directory for checkpoint snapshots
30
+ * @param params.options.checkpointSaveSteps - Optional checkpoint save interval
31
+ * @param params.options.chatTemplatePath - Optional custom chat template path
32
+ * @param params.options.lrScheduler - Optional learning rate scheduler
33
+ * @param params.options.lrMin - Optional minimum learning rate
34
+ * @param params.options.warmupRatio - Optional warmup ratio
35
+ * @param params.options.warmupRatioSet - Optional flag to enable warmup ratio
36
+ * @param params.options.warmupSteps - Optional warmup step count
37
+ * @param params.options.warmupStepsSet - Optional flag to enable explicit warmup steps
38
+ * @param params.options.weightDecay - Optional weight decay override
39
+ * @param rpcOptions - Optional RPC transport options
40
+ * @returns For omitted-operation runs, `start`, and `resume`, returns a handle
41
+ * with a `progressStream` generator and a terminal `result` promise. For
42
+ * `getState`, `pause`, and `cancel`, returns a promise that resolves to the
43
+ * current finetune state/result.
44
+ * @example
45
+ * ```typescript
46
+ * const handle = finetune({
47
+ * modelId,
48
+ * options: {
49
+ * trainDatasetDir: "./dataset/train",
50
+ * validation: { type: "split", fraction: 0.05 },
51
+ * outputParametersDir: "./artifacts/lora",
52
+ * numberOfEpochs: 2,
53
+ * },
54
+ * });
55
+ *
56
+ * for await (const progress of handle.progressStream) {
57
+ * console.log(progress.global_steps, progress.loss);
58
+ * }
59
+ *
60
+ * console.log(await handle.result);
61
+ *
62
+ * const pauseResult = await finetune({ modelId, operation: "pause" });
63
+ * console.log(pauseResult.status);
64
+ * ```
65
+ */
66
+ export declare function finetune(params: FinetuneRunParams, rpcOptions?: RPCOptions): FinetuneHandle;
67
+ export declare function finetune(params: FinetuneReplyParams, rpcOptions?: RPCOptions): Promise<FinetuneResult>;
68
+ export {};
69
+ //# sourceMappingURL=finetune.d.ts.map
@@ -0,0 +1,139 @@
1
+ import { send, stream as streamRpc } from "../rpc/rpc-client.js";
2
+ import { finetuneRunParamsSchema, finetuneRunRequestSchema, finetuneStopRequestSchema, finetuneGetStateParamsSchema, finetuneGetStateRequestSchema, finetuneProgressResponseSchema, finetuneResponseSchema, } from "../../schemas/index.js";
3
+ import { InvalidResponseError, StreamEndedError, } from "../../utils/errors-client.js";
4
+ function isFinetuneReplyParams(params) {
5
+ return (params.operation === "pause" ||
6
+ params.operation === "cancel" ||
7
+ params.operation === "getState");
8
+ }
9
+ function createFinetuneReplyRequest(params) {
10
+ if (params.operation === "getState") {
11
+ const getStateParams = finetuneGetStateParamsSchema.parse(params);
12
+ return finetuneGetStateRequestSchema.parse({
13
+ type: "finetune",
14
+ ...getStateParams,
15
+ });
16
+ }
17
+ return finetuneStopRequestSchema.parse({
18
+ type: "finetune",
19
+ modelId: params.modelId,
20
+ operation: params.operation,
21
+ });
22
+ }
23
+ export function finetune(params, rpcOptions) {
24
+ if (isFinetuneReplyParams(params)) {
25
+ const request = createFinetuneReplyRequest(params);
26
+ const resultPromise = (async () => {
27
+ const response = await send(request, rpcOptions);
28
+ if (!response ||
29
+ typeof response !== "object" ||
30
+ !("type" in response) ||
31
+ response.type !== "finetune") {
32
+ throw new InvalidResponseError("finetune");
33
+ }
34
+ return finetuneResponseSchema.parse(response);
35
+ })();
36
+ resultPromise.catch(() => { });
37
+ return resultPromise;
38
+ }
39
+ const runParams = finetuneRunParamsSchema.parse(params);
40
+ let resultResolver = () => { };
41
+ let resultRejecter = () => { };
42
+ const resultPromise = new Promise((resolve, reject) => {
43
+ resultResolver = resolve;
44
+ resultRejecter = reject;
45
+ });
46
+ resultPromise.catch(() => { });
47
+ const progressQueue = [];
48
+ let progressDone = false;
49
+ let progressResolve = null;
50
+ let streamError = null;
51
+ const processResponses = async () => {
52
+ try {
53
+ let sawTerminalResponse = false;
54
+ const request = finetuneRunRequestSchema.parse({
55
+ type: "finetune",
56
+ ...runParams,
57
+ withProgress: true,
58
+ });
59
+ const responses = streamRpc(request, rpcOptions);
60
+ for await (const response of responses) {
61
+ if (response &&
62
+ typeof response === "object" &&
63
+ "type" in response &&
64
+ response.type === "finetune:progress") {
65
+ const progressResponse = finetuneProgressResponseSchema.parse(response);
66
+ progressQueue.push({
67
+ is_train: progressResponse.is_train,
68
+ loss: progressResponse.loss,
69
+ loss_uncertainty: progressResponse.loss_uncertainty,
70
+ accuracy: progressResponse.accuracy,
71
+ accuracy_uncertainty: progressResponse.accuracy_uncertainty,
72
+ global_steps: progressResponse.global_steps,
73
+ current_epoch: progressResponse.current_epoch,
74
+ current_batch: progressResponse.current_batch,
75
+ total_batches: progressResponse.total_batches,
76
+ elapsed_ms: progressResponse.elapsed_ms,
77
+ eta_ms: progressResponse.eta_ms,
78
+ });
79
+ if (progressResolve) {
80
+ progressResolve();
81
+ progressResolve = null;
82
+ }
83
+ continue;
84
+ }
85
+ if (response &&
86
+ typeof response === "object" &&
87
+ "type" in response &&
88
+ response.type === "finetune") {
89
+ sawTerminalResponse = true;
90
+ const finetuneResponse = finetuneResponseSchema.parse(response);
91
+ resultResolver(finetuneResponse);
92
+ progressDone = true;
93
+ if (progressResolve) {
94
+ progressResolve();
95
+ progressResolve = null;
96
+ }
97
+ }
98
+ else {
99
+ throw new InvalidResponseError("finetune");
100
+ }
101
+ }
102
+ if (!sawTerminalResponse) {
103
+ throw new StreamEndedError();
104
+ }
105
+ }
106
+ catch (error) {
107
+ streamError = error instanceof Error ? error : new Error(String(error));
108
+ resultRejecter(error);
109
+ progressDone = true;
110
+ if (progressResolve) {
111
+ progressResolve();
112
+ progressResolve = null;
113
+ }
114
+ }
115
+ };
116
+ void processResponses();
117
+ const progressStream = (async function* () {
118
+ while (true) {
119
+ if (progressQueue.length > 0) {
120
+ yield progressQueue.shift();
121
+ }
122
+ else if (progressDone) {
123
+ if (streamError !== null) {
124
+ throw streamError;
125
+ }
126
+ break;
127
+ }
128
+ else {
129
+ await new Promise((resolve) => {
130
+ progressResolve = resolve;
131
+ });
132
+ }
133
+ }
134
+ })();
135
+ return {
136
+ progressStream,
137
+ result: resultPromise,
138
+ };
139
+ }
@@ -4,7 +4,7 @@ export declare function getModelInfo(params: GetModelInfoParams): Promise<{
4
4
  modelId: string;
5
5
  expectedSize: number;
6
6
  sha256Checksum: string;
7
- addon: "llm" | "whisper" | "embeddings" | "nmt" | "parakeet" | "tts" | "ocr" | "vad" | "other";
7
+ addon: "llm" | "whisper" | "embeddings" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | "other";
8
8
  isCached: boolean;
9
9
  isLoaded: boolean;
10
10
  cacheFiles: {
@@ -7,6 +7,7 @@ export { loggingStream } from "./logging-stream";
7
7
  export { heartbeat } from "./heartbeat";
8
8
  export { transcribe, transcribeStream } from "./transcribe";
9
9
  export { embed } from "./embed";
10
+ export { finetune, type FinetuneHandle } from "./finetune";
10
11
  export { translate } from "./translate";
11
12
  export { cancel } from "./cancel";
12
13
  export { startQVACProvider } from "./provide";
@@ -16,5 +17,8 @@ export { textToSpeech } from "./text-to-speech";
16
17
  export { getModelInfo } from "./get-model-info";
17
18
  export { ocr } from "./ocr";
18
19
  export { invokePlugin, invokePluginStream } from "./invoke-plugin";
20
+ export { diffusion, type DiffusionProgressTick } from "./diffusion";
19
21
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./registry";
22
+ export { suspend } from "./suspend";
23
+ export { resume } from "./resume";
20
24
  //# sourceMappingURL=index.d.ts.map
@@ -7,6 +7,7 @@ export { loggingStream } from "./logging-stream.js";
7
7
  export { heartbeat } from "./heartbeat.js";
8
8
  export { transcribe, transcribeStream } from "./transcribe.js";
9
9
  export { embed } from "./embed.js";
10
+ export { finetune } from "./finetune.js";
10
11
  export { translate } from "./translate.js";
11
12
  export { cancel } from "./cancel.js";
12
13
  export { startQVACProvider } from "./provide.js";
@@ -16,4 +17,7 @@ export { textToSpeech } from "./text-to-speech.js";
16
17
  export { getModelInfo } from "./get-model-info.js";
17
18
  export { ocr } from "./ocr.js";
18
19
  export { invokePlugin, invokePluginStream } from "./invoke-plugin.js";
20
+ export { diffusion } from "./diffusion.js";
19
21
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./registry.js";
22
+ export { suspend } from "./suspend.js";
23
+ export { resume } from "./resume.js";
@@ -84,7 +84,7 @@ export declare function ragIngest(params: RagIngestParams, options?: RPCOptions)
84
84
  * ```typescript
85
85
  * // Segregated flow
86
86
  * const chunks = await ragChunk({ documents: ["text1", "text2"] });
87
- * const embeddings = await embed({ modelId, text: chunks.map(c => c.content) });
87
+ * const { embedding: embeddings } = await embed({ modelId, text: chunks.map(c => c.content) });
88
88
  * const embeddedDocs = chunks.map((chunk, i) => ({
89
89
  * ...chunk,
90
90
  * embedding: embeddings[i],
@@ -145,7 +145,7 @@ export async function ragIngest(params, options) {
145
145
  * ```typescript
146
146
  * // Segregated flow
147
147
  * const chunks = await ragChunk({ documents: ["text1", "text2"] });
148
- * const embeddings = await embed({ modelId, text: chunks.map(c => c.content) });
148
+ * const { embedding: embeddings } = await embed({ modelId, text: chunks.map(c => c.content) });
149
149
  * const embeddedDocs = chunks.map((chunk, i) => ({
150
150
  * ...chunk,
151
151
  * embedding: embeddings[i],
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Resumes all suspended Hyperswarm and Corestore resources
3
+ *
4
+ * Idempotent — calling while already active is a no-op.
5
+ * Also serves as the recovery path after a partial suspend failure.
6
+ *
7
+ * @throws {RPCError} When one or more resources fail to resume.
8
+ *
9
+ * @example
10
+ * // Foreground handler
11
+ * await resume();
12
+ */
13
+ export declare function resume(): Promise<void>;
14
+ //# sourceMappingURL=resume.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { send } from "../rpc/rpc-client.js";
2
+ import { InvalidResponseError } from "../../utils/errors-client.js";
3
+ /**
4
+ * Resumes all suspended Hyperswarm and Corestore resources
5
+ *
6
+ * Idempotent — calling while already active is a no-op.
7
+ * Also serves as the recovery path after a partial suspend failure.
8
+ *
9
+ * @throws {RPCError} When one or more resources fail to resume.
10
+ *
11
+ * @example
12
+ * // Foreground handler
13
+ * await resume();
14
+ */
15
+ export async function resume() {
16
+ const response = await send({ type: "resume" });
17
+ if (response.type !== "resume") {
18
+ throw new InvalidResponseError("resume");
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Suspends all active Hyperswarm and Corestore resources
3
+ *
4
+ * Idempotent — calling while already suspended is a no-op.
5
+ *
6
+ * @throws {RPCError} When one or more resources fail to suspend (partial failure).
7
+ *
8
+ * @example
9
+ * // Background handler
10
+ * await suspend();
11
+ */
12
+ export declare function suspend(): Promise<void>;
13
+ //# sourceMappingURL=suspend.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { send } from "../rpc/rpc-client.js";
2
+ import { InvalidResponseError } from "../../utils/errors-client.js";
3
+ /**
4
+ * Suspends all active Hyperswarm and Corestore resources
5
+ *
6
+ * Idempotent — calling while already suspended is a no-op.
7
+ *
8
+ * @throws {RPCError} When one or more resources fail to suspend (partial failure).
9
+ *
10
+ * @example
11
+ * // Background handler
12
+ * await suspend();
13
+ */
14
+ export async function suspend() {
15
+ const response = await send({ type: "suspend" });
16
+ if (response.type !== "suspend") {
17
+ throw new InvalidResponseError("suspend");
18
+ }
19
+ }
@@ -1,28 +1,36 @@
1
- import { type TranscribeClientParams, type RPCOptions } from "../../schemas/index";
1
+ import { type TranscribeClientParams, type RPCOptions, type TranscribeStreamClientParams, type TranscribeStreamSession } from "../../schemas/index";
2
2
  /**
3
- * This function streams audio transcription results in real-time, yielding
4
- * text chunks as they become available from the model.
3
+ * Transcribe audio and return the complete text. Accepts either a file
4
+ * path or an audio buffer.
5
5
  *
6
- * @param params - The arguments for the transcription
7
6
  * @param params.modelId - The identifier of the transcription model to use
8
7
  * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
9
8
  * @param params.prompt - Optional initial prompt to guide the transcription
10
9
  * @param options - Optional RPC options including per-call profiling
11
- * @yields {string} Text chunks as they are transcribed
12
- * @throws {QvacErrorBase} When transcription fails with an error message
10
+ * @returns The complete transcribed text
13
11
  */
14
- export declare function transcribeStream(params: TranscribeClientParams, options?: RPCOptions): AsyncGenerator<string, void, unknown>;
12
+ export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;
15
13
  /**
16
- * This function provides a simple interface for transcribing audio by
17
- * collecting all streaming results into a single string response.
14
+ * @deprecated Pass audio via `transcribe()` instead. This overload will be
15
+ * removed in the next major version.
18
16
  *
19
- * @param params - The arguments for the transcription
20
- * @param params.modelId - The identifier of the transcription model to use
21
- * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
22
- * @param params.prompt - Optional initial prompt to guide the transcription
23
- * @param options - Optional RPC options including per-call profiling
24
- * @returns {Promise<string>} The complete transcribed text
25
- * @throws {QvacErrorBase} When transcription fails (propagated from transcribeStream)
17
+ * Streaming transcription with upfront audio: sends full audio, yields text
18
+ * chunks as they arrive.
26
19
  */
27
- export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;
20
+ export declare function transcribeStream(params: TranscribeClientParams, options?: RPCOptions): AsyncGenerator<string>;
21
+ /**
22
+ * Opens a bidirectional streaming transcription session. Audio is streamed
23
+ * in via `write()`, and transcription text is yielded as the model's VAD
24
+ * detects complete speech segments.
25
+ *
26
+ * The returned session is single-use. Attempting to iterate a second
27
+ * time will throw a `TranscriptionFailedError`.
28
+ *
29
+ * @param params.modelId - The loaded transcription model to use
30
+ * @param params.prompt - Optional initial prompt to guide transcription
31
+ * @returns A session object: call `write(buffer)` to feed audio,
32
+ * iterate with `for await (const text of session)` to receive
33
+ * transcription, and `end()` to signal end of audio.
34
+ */
35
+ export declare function transcribeStream(params: TranscribeStreamClientParams, options?: RPCOptions): Promise<TranscribeStreamSession>;
28
36
  //# sourceMappingURL=transcribe.d.ts.map