@qvac/sdk 0.7.0 → 0.8.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 (218) hide show
  1. package/NOTICE +57 -331
  2. package/README.md +2 -2
  3. package/bare-imports.json +9 -0
  4. package/dist/client/api/completion-stream.d.ts +2 -1
  5. package/dist/client/api/completion-stream.js +2 -1
  6. package/dist/client/api/download-asset.d.ts +3 -2
  7. package/dist/client/api/download-asset.js +4 -3
  8. package/dist/client/api/embed.d.ts +5 -2
  9. package/dist/client/api/embed.js +2 -2
  10. package/dist/client/api/get-model-info.d.ts +1 -1
  11. package/dist/client/api/invoke-plugin.d.ts +3 -2
  12. package/dist/client/api/invoke-plugin.js +4 -4
  13. package/dist/client/api/load-model.d.ts +12 -10
  14. package/dist/client/api/load-model.js +3 -3
  15. package/dist/client/api/rag.d.ts +10 -10
  16. package/dist/client/api/rag.js +21 -21
  17. package/dist/client/api/text-to-speech.d.ts +2 -2
  18. package/dist/client/api/text-to-speech.js +3 -3
  19. package/dist/client/api/transcribe.d.ts +5 -3
  20. package/dist/client/api/transcribe.js +6 -4
  21. package/dist/client/api/translate.d.ts +2 -2
  22. package/dist/client/api/translate.js +3 -3
  23. package/dist/client/rpc/node-rpc-client.d.ts +2 -7
  24. package/dist/client/rpc/node-rpc-client.js +2 -39
  25. package/dist/client/rpc/profiling/index.d.ts +2 -0
  26. package/dist/client/rpc/profiling/index.js +1 -0
  27. package/dist/client/rpc/profiling/profiler.d.ts +27 -0
  28. package/dist/client/rpc/profiling/profiler.js +139 -0
  29. package/dist/client/rpc/rpc-client.d.ts +2 -2
  30. package/dist/client/rpc/rpc-client.js +174 -12
  31. package/dist/examples/delegated-inference/consumer-profiled.d.ts +2 -0
  32. package/dist/examples/delegated-inference/consumer-profiled.js +67 -0
  33. package/dist/examples/llamacpp-multimodal.js +1 -1
  34. package/dist/examples/parallel-download.js +45 -13
  35. package/dist/examples/profiling/basic.d.ts +2 -0
  36. package/dist/examples/profiling/basic.js +71 -0
  37. package/dist/examples/profiling/per-call.d.ts +2 -0
  38. package/dist/examples/profiling/per-call.js +30 -0
  39. package/dist/examples/transcription/parakeet-ctc-filesystem.d.ts +2 -0
  40. package/dist/examples/transcription/parakeet-ctc-filesystem.js +40 -0
  41. package/dist/examples/transcription/parakeet-microphone-record.d.ts +2 -0
  42. package/dist/examples/transcription/parakeet-microphone-record.js +95 -0
  43. package/dist/examples/transcription/parakeet-sortformer.d.ts +2 -0
  44. package/dist/examples/transcription/parakeet-sortformer.js +115 -0
  45. package/dist/examples/transcription/parakeet-tdt-filesystem.d.ts +2 -0
  46. package/dist/examples/transcription/parakeet-tdt-filesystem.js +44 -0
  47. package/dist/examples/translation/translation-bergamot-pivot.d.ts +2 -0
  48. package/dist/examples/translation/translation-bergamot-pivot.js +73 -0
  49. package/dist/examples/translation/translation-llm-afriquegemma.d.ts +2 -0
  50. package/dist/examples/translation/translation-llm-afriquegemma.js +39 -0
  51. package/dist/index.d.ts +3 -1
  52. package/dist/index.js +2 -0
  53. package/dist/logging/index.d.ts +1 -1
  54. package/dist/logging/index.js +1 -1
  55. package/dist/logging/namespaces.d.ts +3 -9
  56. package/dist/logging/namespaces.js +2 -8
  57. package/dist/logging/registry.js +15 -1
  58. package/dist/models/registry/models.d.ts +1606 -245
  59. package/dist/models/registry/models.js +2127 -721
  60. package/dist/models/update-models/codegen.js +2 -2
  61. package/dist/models/update-models/history.d.ts +11 -0
  62. package/dist/models/update-models/history.js +24 -5
  63. package/dist/models/update-models/index.js +17 -16
  64. package/dist/models/update-models/naming.js +56 -0
  65. package/dist/profiling/aggregator.d.ts +15 -0
  66. package/dist/profiling/aggregator.js +100 -0
  67. package/dist/profiling/clock.d.ts +12 -0
  68. package/dist/profiling/clock.js +51 -0
  69. package/dist/profiling/controller.d.ts +33 -0
  70. package/dist/profiling/controller.js +123 -0
  71. package/dist/profiling/envelope.d.ts +10 -0
  72. package/dist/profiling/envelope.js +36 -0
  73. package/dist/profiling/events.d.ts +20 -0
  74. package/dist/profiling/events.js +37 -0
  75. package/dist/profiling/exporters.d.ts +10 -0
  76. package/dist/profiling/exporters.js +236 -0
  77. package/dist/profiling/index.d.ts +36 -0
  78. package/dist/profiling/index.js +31 -0
  79. package/dist/profiling/ring-buffer.d.ts +19 -0
  80. package/dist/profiling/ring-buffer.js +83 -0
  81. package/dist/profiling/types.d.ts +47 -0
  82. package/dist/profiling/types.js +1 -0
  83. package/dist/schemas/common.d.ts +1888 -133
  84. package/dist/schemas/common.js +2 -0
  85. package/dist/schemas/completion-stream.d.ts +31 -0
  86. package/dist/schemas/completion-stream.js +13 -0
  87. package/dist/schemas/download-asset.d.ts +14 -3
  88. package/dist/schemas/download-asset.js +3 -1
  89. package/dist/schemas/engine-addon-map.js +9 -6
  90. package/dist/schemas/get-model-info.d.ts +2 -0
  91. package/dist/schemas/get-model-info.js +1 -0
  92. package/dist/schemas/index.d.ts +2 -1
  93. package/dist/schemas/index.js +2 -1
  94. package/dist/schemas/llamacpp-config.d.ts +140 -14
  95. package/dist/schemas/llamacpp-config.js +11 -7
  96. package/dist/schemas/load-model.d.ts +9649 -2515
  97. package/dist/schemas/load-model.js +142 -182
  98. package/dist/schemas/model-src-utils.d.ts +10 -2
  99. package/dist/schemas/model-types.d.ts +19 -1
  100. package/dist/schemas/model-types.js +11 -0
  101. package/dist/schemas/ocr.d.ts +37 -0
  102. package/dist/schemas/ocr.js +5 -0
  103. package/dist/schemas/plugin.d.ts +51 -5
  104. package/dist/schemas/plugin.js +26 -0
  105. package/dist/schemas/profiling.d.ts +105 -0
  106. package/dist/schemas/profiling.js +66 -0
  107. package/dist/schemas/registry.d.ts +18 -0
  108. package/dist/schemas/registry.js +2 -0
  109. package/dist/schemas/reload-config.d.ts +126 -6
  110. package/dist/schemas/reload-config.js +1 -1
  111. package/dist/schemas/sdk-config.d.ts +2280 -24
  112. package/dist/schemas/sdk-config.js +6 -1
  113. package/dist/schemas/sdk-errors-client.d.ts +1 -0
  114. package/dist/schemas/sdk-errors-client.js +7 -0
  115. package/dist/schemas/sdk-errors-server.d.ts +3 -0
  116. package/dist/schemas/sdk-errors-server.js +15 -0
  117. package/dist/schemas/text-to-speech.d.ts +90 -68
  118. package/dist/schemas/text-to-speech.js +16 -33
  119. package/dist/schemas/transcription-config.d.ts +383 -0
  120. package/dist/schemas/{whispercpp-config.js → transcription-config.js} +29 -1
  121. package/dist/schemas/translation-config.d.ts +463 -8
  122. package/dist/schemas/translation-config.js +35 -2
  123. package/dist/server/bare/delegate-rpc-client.js +11 -1
  124. package/dist/server/bare/ops/load-model.d.ts +7 -1
  125. package/dist/server/bare/ops/load-model.js +41 -42
  126. package/dist/server/bare/ops/transcribe.d.ts +3 -0
  127. package/dist/server/bare/ops/transcribe.js +75 -0
  128. package/dist/server/bare/ops/translate.d.ts +2 -0
  129. package/dist/server/bare/ops/translate.js +12 -4
  130. package/dist/server/bare/plugins/index.d.ts +1 -0
  131. package/dist/server/bare/plugins/index.js +1 -0
  132. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +2 -1
  133. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +8 -6
  134. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +108 -3
  135. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +19 -6
  136. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +32 -2
  137. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +31 -17
  138. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +325 -3
  139. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +117 -10
  140. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +50 -2
  141. package/dist/server/bare/plugins/onnx-ocr/plugin.js +46 -5
  142. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +351 -4
  143. package/dist/server/bare/plugins/onnx-tts/plugin.js +81 -61
  144. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +317 -0
  145. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +154 -0
  146. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +209 -3
  147. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +21 -9
  148. package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +2 -2
  149. package/dist/server/bare/registry/model-config-utils.js +3 -1
  150. package/dist/server/bare/utils/audio-input.d.ts +10 -0
  151. package/dist/server/bare/utils/audio-input.js +33 -0
  152. package/dist/server/error-handlers.d.ts +3 -2
  153. package/dist/server/error-handlers.js +11 -8
  154. package/dist/server/plugins/registry.js +5 -1
  155. package/dist/server/rpc/delegate-transport.d.ts +11 -3
  156. package/dist/server/rpc/delegate-transport.js +158 -3
  157. package/dist/server/rpc/handle-request.js +43 -4
  158. package/dist/server/rpc/handler-registry.js +7 -1
  159. package/dist/server/rpc/handler-utils.d.ts +5 -4
  160. package/dist/server/rpc/handler-utils.js +72 -31
  161. package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +3 -1
  162. package/dist/server/rpc/handlers/completion-stream-delegated.js +11 -2
  163. package/dist/server/rpc/handlers/download-asset.js +55 -3
  164. package/dist/server/rpc/handlers/load-model/download-stats.d.ts +6 -0
  165. package/dist/server/rpc/handlers/load-model/download-stats.js +87 -0
  166. package/dist/server/rpc/handlers/load-model/handler.js +108 -123
  167. package/dist/server/rpc/handlers/load-model/http.d.ts +2 -1
  168. package/dist/server/rpc/handlers/load-model/http.js +21 -5
  169. package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -1
  170. package/dist/server/rpc/handlers/load-model/hyperdrive.js +19 -14
  171. package/dist/server/rpc/handlers/load-model/registry.d.ts +2 -1
  172. package/dist/server/rpc/handlers/load-model/registry.js +123 -130
  173. package/dist/server/rpc/handlers/load-model/resolve.d.ts +2 -0
  174. package/dist/server/rpc/handlers/load-model/resolve.js +55 -22
  175. package/dist/server/rpc/handlers/load-model/types.d.ts +29 -0
  176. package/dist/server/rpc/handlers/load-model/types.js +1 -0
  177. package/dist/server/rpc/handlers/load-model-delegated.d.ts +5 -1
  178. package/dist/server/rpc/handlers/load-model-delegated.js +35 -7
  179. package/dist/server/rpc/handlers/plugin-dispatch.js +15 -10
  180. package/dist/server/rpc/handlers/plugin-invoke.js +56 -51
  181. package/dist/server/rpc/handlers/rag.js +24 -0
  182. package/dist/server/rpc/handlers/unload-model-delegated.d.ts +3 -0
  183. package/dist/server/rpc/handlers/unload-model-delegated.js +32 -0
  184. package/dist/server/rpc/profiling/context.d.ts +18 -0
  185. package/dist/server/rpc/profiling/context.js +38 -0
  186. package/dist/server/rpc/profiling/delegation-profiler.d.ts +32 -0
  187. package/dist/server/rpc/profiling/delegation-profiler.js +154 -0
  188. package/dist/server/rpc/profiling/index.d.ts +5 -0
  189. package/dist/server/rpc/profiling/index.js +4 -0
  190. package/dist/server/rpc/profiling/operation-metrics.d.ts +25 -0
  191. package/dist/server/rpc/profiling/operation-metrics.js +199 -0
  192. package/dist/server/rpc/profiling/operation-wrappers.d.ts +18 -0
  193. package/dist/server/rpc/profiling/operation-wrappers.js +124 -0
  194. package/dist/server/rpc/profiling/profiler.d.ts +13 -0
  195. package/dist/server/rpc/profiling/profiler.js +97 -0
  196. package/dist/server/utils/cache.d.ts +2 -1
  197. package/dist/server/utils/cache.js +5 -1
  198. package/dist/server/utils/checksum.d.ts +2 -0
  199. package/dist/server/utils/checksum.js +7 -0
  200. package/dist/server/utils/formatting.d.ts +6 -0
  201. package/dist/server/utils/formatting.js +35 -0
  202. package/dist/server/worker.js +2 -1
  203. package/dist/utils/errors-client.d.ts +3 -0
  204. package/dist/utils/errors-client.js +6 -0
  205. package/dist/utils/errors-server.d.ts +9 -0
  206. package/dist/utils/errors-server.js +15 -0
  207. package/dist/utils/global-singleton.d.ts +2 -0
  208. package/dist/utils/global-singleton.js +10 -0
  209. package/package.json +14 -17
  210. package/dist/schemas/whispercpp-config.d.ts +0 -70
  211. package/dist/server/bare/plugins/whispercpp-transcription/ops/transcribe-stream.d.ts +0 -3
  212. package/dist/server/bare/plugins/whispercpp-transcription/ops/transcribe-stream.js +0 -81
  213. /package/dist/examples/{whispercpp-filesystem.d.ts → transcription/whispercpp-filesystem.d.ts} +0 -0
  214. /package/dist/examples/{whispercpp-filesystem.js → transcription/whispercpp-filesystem.js} +0 -0
  215. /package/dist/examples/{whispercpp-microphone-record.d.ts → transcription/whispercpp-microphone-record.d.ts} +0 -0
  216. /package/dist/examples/{whispercpp-microphone-record.js → transcription/whispercpp-microphone-record.js} +0 -0
  217. /package/dist/examples/{whispercpp-prompt.d.ts → transcription/whispercpp-prompt.d.ts} +0 -0
  218. /package/dist/examples/{whispercpp-prompt.js → transcription/whispercpp-prompt.js} +0 -0
@@ -3,14 +3,14 @@ import { InvalidResponseError } from "../../utils/errors-client.js";
3
3
  /**
4
4
  * Invoke a non-streaming plugin handler.
5
5
  */
6
- export async function invokePlugin(options) {
6
+ export async function invokePlugin(options, rpcOptions) {
7
7
  const request = {
8
8
  type: "pluginInvoke",
9
9
  modelId: options.modelId,
10
10
  handler: options.handler,
11
11
  params: options.params,
12
12
  };
13
- const response = await send(request);
13
+ const response = await send(request, rpcOptions);
14
14
  if (response.type !== "pluginInvoke") {
15
15
  throw new InvalidResponseError("pluginInvoke");
16
16
  }
@@ -19,14 +19,14 @@ export async function invokePlugin(options) {
19
19
  /**
20
20
  * Invoke a streaming plugin handler.
21
21
  */
22
- export async function* invokePluginStream(options) {
22
+ export async function* invokePluginStream(options, rpcOptions) {
23
23
  const request = {
24
24
  type: "pluginInvokeStream",
25
25
  modelId: options.modelId,
26
26
  handler: options.handler,
27
27
  params: options.params,
28
28
  };
29
- for await (const chunk of stream(request)) {
29
+ for await (const chunk of stream(request, rpcOptions)) {
30
30
  const response = chunk;
31
31
  if (response.type !== "pluginInvokeStream") {
32
32
  throw new InvalidResponseError("pluginInvokeStream");
@@ -1,4 +1,4 @@
1
- import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/index";
1
+ import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * Loads a machine learning model from a local path, remote URL, or Hyperdrive key.
4
4
  *
@@ -11,11 +11,10 @@ import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/i
11
11
  * @param options - An object that defines all configuration parameters required for loading the model, including:
12
12
  * - modelSrc: The location from which the model weights are fetched (local path, remote URL, or Hyperdrive URL)
13
13
  * - modelType: The type of model ("llm", "whisper", "embeddings", "nmt", or "tts")
14
- * - modelConfig: Model-specific configuration options
15
- * - projectionModelSrc: (LLM only) Projection model source for multimodal models
16
- * - vadModelSrc: (Whisper only) VAD model source for voice activity detection
14
+ * - modelConfig: Model-specific configuration options (companion sources, model parameters, etc.)
17
15
  * - onProgress: Callback for download progress updates
18
16
  * - logger: Logger instance for model operation logs
17
+ * @param rpcOptions - Optional RPC options including per-call profiling configuration
19
18
  *
20
19
  * @returns Promise that resolves to the model ID (either the provided modelSrc or a generated ID)
21
20
  *
@@ -58,8 +57,10 @@ import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/i
58
57
  * const multimodalId = await loadModel({
59
58
  * modelSrc: "https://huggingface.co/.../main-model.gguf",
60
59
  * modelType: "llm",
61
- * projectionModelSrc: "https://huggingface.co/.../projection-model.gguf",
62
- * modelConfig: { ctx_size: 512 },
60
+ * modelConfig: {
61
+ * ctx_size: 512,
62
+ * projectionModelSrc: "https://huggingface.co/.../projection-model.gguf"
63
+ * },
63
64
  * onProgress: (progress) => {
64
65
  * console.log(`Loading: ${progress.percentage}%`);
65
66
  * }
@@ -69,12 +70,12 @@ import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/i
69
70
  * const whisperId = await loadModel({
70
71
  * modelSrc: "https://huggingface.co/.../whisper-model.gguf",
71
72
  * modelType: "whisper",
72
- * vadModelSrc: "https://huggingface.co/.../vad-model.bin",
73
73
  * modelConfig: {
74
74
  * mode: "caption",
75
75
  * output_format: "plaintext",
76
76
  * min_seconds: 2,
77
- * max_seconds: 6
77
+ * max_seconds: 6,
78
+ * vadModelSrc: "https://huggingface.co/.../vad-model.bin"
78
79
  * }
79
80
  * });
80
81
  *
@@ -89,7 +90,7 @@ import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/i
89
90
  * });
90
91
  * ```
91
92
  */
92
- export declare function loadModel(options: LoadModelOptions): Promise<string>;
93
+ export declare function loadModel(options: LoadModelOptions, rpcOptions?: RPCOptions): Promise<string>;
93
94
  /**
94
95
  * Hot-reloads configuration on an already loaded model.
95
96
  *
@@ -97,6 +98,7 @@ export declare function loadModel(options: LoadModelOptions): Promise<string>;
97
98
  * - modelId: The ID of an existing loaded model
98
99
  * - modelType: The type of model (must match the loaded model)
99
100
  * - modelConfig: New configuration to apply
101
+ * @param rpcOptions - Optional RPC options including per-call profiling configuration
100
102
  *
101
103
  * @returns Promise that resolves to the model ID
102
104
  *
@@ -120,5 +122,5 @@ export declare function loadModel(options: LoadModelOptions): Promise<string>;
120
122
  * });
121
123
  * ```
122
124
  */
123
- export declare function loadModel(options: ReloadConfigOptions): Promise<string>;
125
+ export declare function loadModel(options: ReloadConfigOptions, rpcOptions?: RPCOptions): Promise<string>;
124
126
  //# sourceMappingURL=load-model.d.ts.map
@@ -4,7 +4,7 @@ import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, is
4
4
  import { ModelLoadFailedError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
5
5
  import { getClientLogger } from "../../logging/index.js";
6
6
  const logger = getClientLogger();
7
- export async function loadModel(options) {
7
+ export async function loadModel(options, rpcOptions) {
8
8
  const isReloadConfig = "modelId" in options && !("modelSrc" in options);
9
9
  // Warn about deprecated alias usage
10
10
  if (!isReloadConfig && isModelTypeAlias(options.modelType)) {
@@ -18,7 +18,7 @@ export async function loadModel(options) {
18
18
  const onProgress = isReloadConfig ? undefined : options.onProgress;
19
19
  if (onProgress) {
20
20
  // Use streaming for progress updates
21
- for await (const response of stream(request)) {
21
+ for await (const response of stream(request, rpcOptions)) {
22
22
  if (response.type === "modelProgress") {
23
23
  onProgress(response);
24
24
  }
@@ -42,7 +42,7 @@ export async function loadModel(options) {
42
42
  throw new StreamEndedError();
43
43
  }
44
44
  // Use regular send for simple loading
45
- const response = await send(request);
45
+ const response = await send(request, rpcOptions);
46
46
  if (response.type !== "loadModel") {
47
47
  throw new InvalidResponseError("loadModel");
48
48
  }
@@ -1,4 +1,4 @@
1
- import type { RagChunkParams, RagDoc, RagIngestParams, RagSaveEmbeddingsParams, RagSaveEmbeddingsResult, RagSearchParams, RagSearchResult, RagDeleteEmbeddingsParams, RagReindexParams, RagReindexResult, RagWorkspaceInfo, RagCloseWorkspaceParams, RagDeleteWorkspaceParams } from "../../schemas/index";
1
+ import type { RagChunkParams, RagDoc, RagIngestParams, RagSaveEmbeddingsParams, RagSaveEmbeddingsResult, RagSearchParams, RagSearchResult, RagDeleteEmbeddingsParams, RagReindexParams, RagReindexResult, RagWorkspaceInfo, RagCloseWorkspaceParams, RagDeleteWorkspaceParams, RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * Chunks documents into smaller pieces for embedding.
4
4
  * Part of the segregated flow: ragChunk() → embed() → ragSaveEmbeddings()
@@ -21,7 +21,7 @@ import type { RagChunkParams, RagDoc, RagIngestParams, RagSaveEmbeddingsParams,
21
21
  * });
22
22
  * ```
23
23
  */
24
- export declare function ragChunk(params: RagChunkParams): Promise<RagDoc[]>;
24
+ export declare function ragChunk(params: RagChunkParams, options?: RPCOptions): Promise<RagDoc[]>;
25
25
  /**
26
26
  * Ingests documents into the RAG vector database.
27
27
  * Full pipeline: chunk → embed → save
@@ -60,7 +60,7 @@ export declare function ragChunk(params: RagChunkParams): Promise<RagDoc[]>;
60
60
  * });
61
61
  * ```
62
62
  */
63
- export declare function ragIngest(params: RagIngestParams): Promise<{
63
+ export declare function ragIngest(params: RagIngestParams, options?: RPCOptions): Promise<{
64
64
  processed: RagSaveEmbeddingsResult[];
65
65
  droppedIndices: number[];
66
66
  }>;
@@ -96,7 +96,7 @@ export declare function ragIngest(params: RagIngestParams): Promise<{
96
96
  * });
97
97
  * ```
98
98
  */
99
- export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams): Promise<RagSaveEmbeddingsResult[]>;
99
+ export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, options?: RPCOptions): Promise<RagSaveEmbeddingsResult[]>;
100
100
  /**
101
101
  * Searches for similar documents in the RAG vector database.
102
102
  *
@@ -122,7 +122,7 @@ export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams): Prom
122
122
  * });
123
123
  * ```
124
124
  */
125
- export declare function ragSearch(params: RagSearchParams): Promise<RagSearchResult[]>;
125
+ export declare function ragSearch(params: RagSearchParams, options?: RPCOptions): Promise<RagSearchResult[]>;
126
126
  /**
127
127
  * Deletes document embeddings from the RAG vector database.
128
128
  *
@@ -141,7 +141,7 @@ export declare function ragSearch(params: RagSearchParams): Promise<RagSearchRes
141
141
  * });
142
142
  * ```
143
143
  */
144
- export declare function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams): Promise<void>;
144
+ export declare function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams, options?: RPCOptions): Promise<void>;
145
145
  /**
146
146
  * Reindexes the RAG database to optimize search performance.
147
147
  * For HyperDB, this rebalances centroids using k-means clustering.
@@ -180,7 +180,7 @@ export declare function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams):
180
180
  * });
181
181
  * ```
182
182
  */
183
- export declare function ragReindex(params: RagReindexParams): Promise<RagReindexResult>;
183
+ export declare function ragReindex(params: RagReindexParams, options?: RPCOptions): Promise<RagReindexResult>;
184
184
  /**
185
185
  * Lists all RAG workspaces with their open status.
186
186
  *
@@ -197,7 +197,7 @@ export declare function ragReindex(params: RagReindexParams): Promise<RagReindex
197
197
  * // [{ name: "default", open: true }, { name: "my-docs", open: false }]
198
198
  * ```
199
199
  */
200
- export declare function ragListWorkspaces(): Promise<RagWorkspaceInfo[]>;
200
+ export declare function ragListWorkspaces(options?: RPCOptions): Promise<RagWorkspaceInfo[]>;
201
201
  /**
202
202
  * Closes a RAG workspace, releasing in-memory resources (Corestore, HyperDB adapter, RAG instance).
203
203
  *
@@ -219,7 +219,7 @@ export declare function ragListWorkspaces(): Promise<RagWorkspaceInfo[]>;
219
219
  * await ragCloseWorkspace({ workspace: "my-docs", deleteOnClose: true });
220
220
  * ```
221
221
  */
222
- export declare function ragCloseWorkspace(params?: RagCloseWorkspaceParams): Promise<void>;
222
+ export declare function ragCloseWorkspace(params?: RagCloseWorkspaceParams, options?: RPCOptions): Promise<void>;
223
223
  /**
224
224
  * Deletes a RAG workspace and all its data.
225
225
  * The workspace must not be currently loaded/in-use.
@@ -233,5 +233,5 @@ export declare function ragCloseWorkspace(params?: RagCloseWorkspaceParams): Pro
233
233
  * await ragDeleteWorkspace({ workspace: "my-docs" });
234
234
  * ```
235
235
  */
236
- export declare function ragDeleteWorkspace(params: RagDeleteWorkspaceParams): Promise<void>;
236
+ export declare function ragDeleteWorkspace(params: RagDeleteWorkspaceParams, options?: RPCOptions): Promise<void>;
237
237
  //# sourceMappingURL=rag.d.ts.map
@@ -23,13 +23,13 @@ import { InvalidResponseError, InvalidOperationError, StreamEndedError, RAGChunk
23
23
  * });
24
24
  * ```
25
25
  */
26
- export async function ragChunk(params) {
26
+ export async function ragChunk(params, options) {
27
27
  const request = {
28
28
  type: "rag",
29
29
  operation: "chunk",
30
30
  ...params,
31
31
  };
32
- const response = await send(request);
32
+ const response = await send(request, options);
33
33
  if (response.type !== "rag") {
34
34
  throw new InvalidResponseError("rag");
35
35
  }
@@ -80,7 +80,7 @@ export async function ragChunk(params) {
80
80
  * });
81
81
  * ```
82
82
  */
83
- export async function ragIngest(params) {
83
+ export async function ragIngest(params, options) {
84
84
  const { onProgress, ...requestParams } = params;
85
85
  const request = {
86
86
  type: "rag",
@@ -91,7 +91,7 @@ export async function ragIngest(params) {
91
91
  };
92
92
  if (onProgress) {
93
93
  // Use streaming for progress updates
94
- for await (const event of stream(request)) {
94
+ for await (const event of stream(request, options)) {
95
95
  if (event.type === "rag:progress" && event.operation === "ingest") {
96
96
  const progress = event;
97
97
  onProgress(progress.stage, progress.current, progress.total);
@@ -109,7 +109,7 @@ export async function ragIngest(params) {
109
109
  }
110
110
  throw new StreamEndedError();
111
111
  }
112
- const response = await send(request);
112
+ const response = await send(request, options);
113
113
  if (response.type !== "rag") {
114
114
  throw new InvalidResponseError("rag");
115
115
  }
@@ -157,7 +157,7 @@ export async function ragIngest(params) {
157
157
  * });
158
158
  * ```
159
159
  */
160
- export async function ragSaveEmbeddings(params) {
160
+ export async function ragSaveEmbeddings(params, options) {
161
161
  const { onProgress, ...requestParams } = params;
162
162
  const request = {
163
163
  type: "rag",
@@ -166,7 +166,7 @@ export async function ragSaveEmbeddings(params) {
166
166
  withProgress: onProgress ? true : undefined,
167
167
  };
168
168
  if (onProgress) {
169
- for await (const event of stream(request)) {
169
+ for await (const event of stream(request, options)) {
170
170
  if (event.type === "rag:progress" &&
171
171
  event.operation === "saveEmbeddings") {
172
172
  const progress = event;
@@ -182,7 +182,7 @@ export async function ragSaveEmbeddings(params) {
182
182
  }
183
183
  throw new StreamEndedError();
184
184
  }
185
- const response = await send(request);
185
+ const response = await send(request, options);
186
186
  if (response.type !== "rag") {
187
187
  throw new InvalidResponseError("rag");
188
188
  }
@@ -220,7 +220,7 @@ export async function ragSaveEmbeddings(params) {
220
220
  * });
221
221
  * ```
222
222
  */
223
- export async function ragSearch(params) {
223
+ export async function ragSearch(params, options) {
224
224
  const request = {
225
225
  type: "rag",
226
226
  operation: "search",
@@ -228,7 +228,7 @@ export async function ragSearch(params) {
228
228
  topK: params.topK ?? 5,
229
229
  n: params.n ?? 3,
230
230
  };
231
- const response = await send(request);
231
+ const response = await send(request, options);
232
232
  if (response.type !== "rag") {
233
233
  throw new InvalidResponseError("rag");
234
234
  }
@@ -259,13 +259,13 @@ export async function ragSearch(params) {
259
259
  * });
260
260
  * ```
261
261
  */
262
- export async function ragDeleteEmbeddings(params) {
262
+ export async function ragDeleteEmbeddings(params, options) {
263
263
  const request = {
264
264
  type: "rag",
265
265
  operation: "deleteEmbeddings",
266
266
  ...params,
267
267
  };
268
- const response = await send(request);
268
+ const response = await send(request, options);
269
269
  if (response.type !== "rag") {
270
270
  throw new InvalidResponseError("rag");
271
271
  }
@@ -315,7 +315,7 @@ export async function ragDeleteEmbeddings(params) {
315
315
  * });
316
316
  * ```
317
317
  */
318
- export async function ragReindex(params) {
318
+ export async function ragReindex(params, options) {
319
319
  const { onProgress, ...requestParams } = params;
320
320
  const request = {
321
321
  type: "rag",
@@ -324,7 +324,7 @@ export async function ragReindex(params) {
324
324
  withProgress: onProgress ? true : undefined,
325
325
  };
326
326
  if (onProgress) {
327
- for await (const event of stream(request)) {
327
+ for await (const event of stream(request, options)) {
328
328
  if (event.type === "rag:progress" && event.operation === "reindex") {
329
329
  const progress = event;
330
330
  onProgress(progress.stage, progress.current, progress.total);
@@ -339,7 +339,7 @@ export async function ragReindex(params) {
339
339
  }
340
340
  throw new StreamEndedError();
341
341
  }
342
- const response = await send(request);
342
+ const response = await send(request, options);
343
343
  if (response.type !== "rag") {
344
344
  throw new InvalidResponseError("rag");
345
345
  }
@@ -368,12 +368,12 @@ export async function ragReindex(params) {
368
368
  * // [{ name: "default", open: true }, { name: "my-docs", open: false }]
369
369
  * ```
370
370
  */
371
- export async function ragListWorkspaces() {
371
+ export async function ragListWorkspaces(options) {
372
372
  const request = {
373
373
  type: "rag",
374
374
  operation: "listWorkspaces",
375
375
  };
376
- const response = await send(request);
376
+ const response = await send(request, options);
377
377
  if (response.type !== "rag") {
378
378
  throw new InvalidResponseError("rag");
379
379
  }
@@ -407,13 +407,13 @@ export async function ragListWorkspaces() {
407
407
  * await ragCloseWorkspace({ workspace: "my-docs", deleteOnClose: true });
408
408
  * ```
409
409
  */
410
- export async function ragCloseWorkspace(params) {
410
+ export async function ragCloseWorkspace(params, options) {
411
411
  const request = {
412
412
  type: "rag",
413
413
  operation: "closeWorkspace",
414
414
  ...params,
415
415
  };
416
- const response = await send(request);
416
+ const response = await send(request, options);
417
417
  if (response.type !== "rag") {
418
418
  throw new InvalidResponseError("rag");
419
419
  }
@@ -438,13 +438,13 @@ export async function ragCloseWorkspace(params) {
438
438
  * await ragDeleteWorkspace({ workspace: "my-docs" });
439
439
  * ```
440
440
  */
441
- export async function ragDeleteWorkspace(params) {
441
+ export async function ragDeleteWorkspace(params, options) {
442
442
  const request = {
443
443
  type: "rag",
444
444
  operation: "deleteWorkspace",
445
445
  ...params,
446
446
  };
447
- const response = await send(request);
447
+ const response = await send(request, options);
448
448
  if (response.type !== "rag") {
449
449
  throw new InvalidResponseError("rag");
450
450
  }
@@ -1,5 +1,5 @@
1
- import { type TtsClientParams } from "../../schemas/index";
2
- export declare function textToSpeech(params: TtsClientParams): {
1
+ import { type TtsClientParams, type RPCOptions } from "../../schemas/index";
2
+ export declare function textToSpeech(params: TtsClientParams, options?: RPCOptions): {
3
3
  bufferStream: AsyncGenerator<number>;
4
4
  buffer: Promise<number[]>;
5
5
  done: Promise<boolean>;
@@ -1,6 +1,6 @@
1
1
  import { ttsResponseSchema, } from "../../schemas/index.js";
2
2
  import { stream as streamRpc } from "../rpc/rpc-client.js";
3
- export function textToSpeech(params) {
3
+ export function textToSpeech(params, options) {
4
4
  const request = {
5
5
  type: "textToSpeech",
6
6
  modelId: params.modelId,
@@ -14,7 +14,7 @@ export function textToSpeech(params) {
14
14
  });
15
15
  if (params.stream) {
16
16
  const bufferStream = (async function* () {
17
- for await (const response of streamRpc(request)) {
17
+ for await (const response of streamRpc(request, options)) {
18
18
  if (response.type === "textToSpeech") {
19
19
  const streamResponse = ttsResponseSchema.parse(response);
20
20
  if (streamResponse.buffer.length > 0) {
@@ -38,7 +38,7 @@ export function textToSpeech(params) {
38
38
  })();
39
39
  const bufferPromise = (async () => {
40
40
  let buffer = [];
41
- for await (const response of streamRpc(request)) {
41
+ for await (const response of streamRpc(request, options)) {
42
42
  if (response.type === "textToSpeech") {
43
43
  const streamResponse = ttsResponseSchema.parse(response);
44
44
  buffer = buffer.concat(streamResponse.buffer);
@@ -1,4 +1,4 @@
1
- import { type TranscribeClientParams } from "../../schemas/index";
1
+ import { type TranscribeClientParams, type RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * This function streams audio transcription results in real-time, yielding
4
4
  * text chunks as they become available from the model.
@@ -7,10 +7,11 @@ import { type TranscribeClientParams } from "../../schemas/index";
7
7
  * @param params.modelId - The identifier of the transcription model to use
8
8
  * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
9
9
  * @param params.prompt - Optional initial prompt to guide the transcription
10
+ * @param options - Optional RPC options including per-call profiling
10
11
  * @yields {string} Text chunks as they are transcribed
11
12
  * @throws {QvacErrorBase} When transcription fails with an error message
12
13
  */
13
- export declare function transcribeStream(params: TranscribeClientParams): AsyncGenerator<string, void, unknown>;
14
+ export declare function transcribeStream(params: TranscribeClientParams, options?: RPCOptions): AsyncGenerator<string, void, unknown>;
14
15
  /**
15
16
  * This function provides a simple interface for transcribing audio by
16
17
  * collecting all streaming results into a single string response.
@@ -19,8 +20,9 @@ export declare function transcribeStream(params: TranscribeClientParams): AsyncG
19
20
  * @param params.modelId - The identifier of the transcription model to use
20
21
  * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
21
22
  * @param params.prompt - Optional initial prompt to guide the transcription
23
+ * @param options - Optional RPC options including per-call profiling
22
24
  * @returns {Promise<string>} The complete transcribed text
23
25
  * @throws {QvacErrorBase} When transcription fails (propagated from transcribeStream)
24
26
  */
25
- export declare function transcribe(params: TranscribeClientParams): Promise<string>;
27
+ export declare function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;
26
28
  //# sourceMappingURL=transcribe.d.ts.map
@@ -8,10 +8,11 @@ import { stream } from "../rpc/rpc-client.js";
8
8
  * @param params.modelId - The identifier of the transcription model to use
9
9
  * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
10
10
  * @param params.prompt - Optional initial prompt to guide the transcription
11
+ * @param options - Optional RPC options including per-call profiling
11
12
  * @yields {string} Text chunks as they are transcribed
12
13
  * @throws {QvacErrorBase} When transcription fails with an error message
13
14
  */
14
- export async function* transcribeStream(params) {
15
+ export async function* transcribeStream(params, options) {
15
16
  const request = {
16
17
  type: "transcribeStream",
17
18
  modelId: params.modelId,
@@ -20,7 +21,7 @@ export async function* transcribeStream(params) {
20
21
  : { type: "base64", value: params.audioChunk.toString("base64") },
21
22
  ...(params.prompt && { prompt: params.prompt }),
22
23
  };
23
- for await (const response of stream(request)) {
24
+ for await (const response of stream(request, options)) {
24
25
  if (response.type === "transcribeStream") {
25
26
  const streamResponse = transcribeStreamResponseSchema.parse(response);
26
27
  if (streamResponse.text) {
@@ -40,12 +41,13 @@ export async function* transcribeStream(params) {
40
41
  * @param params.modelId - The identifier of the transcription model to use
41
42
  * @param params.audioChunk - Audio input as either a file path (string) or audio buffer
42
43
  * @param params.prompt - Optional initial prompt to guide the transcription
44
+ * @param options - Optional RPC options including per-call profiling
43
45
  * @returns {Promise<string>} The complete transcribed text
44
46
  * @throws {QvacErrorBase} When transcription fails (propagated from transcribeStream)
45
47
  */
46
- export async function transcribe(params) {
48
+ export async function transcribe(params, options) {
47
49
  let fullText = "";
48
- for await (const textChunk of transcribeStream(params)) {
50
+ for await (const textChunk of transcribeStream(params, options)) {
49
51
  fullText += textChunk;
50
52
  }
51
53
  return fullText;
@@ -1,4 +1,4 @@
1
- import { type TranslateClientParams, type TranslationStats } from "../../schemas/index";
1
+ import { type TranslateClientParams, type TranslationStats, type RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * Translates text from one language to another using a specified translation model.
4
4
  * Supports both NMT (Neural Machine Translation) and LLM models.
@@ -39,7 +39,7 @@ import { type TranslateClientParams, type TranslationStats } from "../../schemas
39
39
  * console.log(await response.text);
40
40
  * ```
41
41
  */
42
- export declare function translate(params: TranslateClientParams): {
42
+ export declare function translate(params: TranslateClientParams, options?: RPCOptions): {
43
43
  tokenStream: AsyncGenerator<string>;
44
44
  stats: Promise<TranslationStats | undefined>;
45
45
  text: Promise<string>;
@@ -42,7 +42,7 @@ import { TranslationFailedError } from "../../utils/errors-client.js";
42
42
  * console.log(await response.text);
43
43
  * ```
44
44
  */
45
- export function translate(params) {
45
+ export function translate(params, options) {
46
46
  const canonicalModelType = normalizeModelType(params.modelType);
47
47
  const isLlm = canonicalModelType === ModelType.llamacppCompletion;
48
48
  let sourceLanguage = isLlm ? params.from : undefined;
@@ -67,7 +67,7 @@ export function translate(params) {
67
67
  });
68
68
  if (params.stream) {
69
69
  const tokenStream = (async function* () {
70
- for await (const response of streamRpc(request)) {
70
+ for await (const response of streamRpc(request, options)) {
71
71
  if (response.type === "translate") {
72
72
  const streamResponse = translateResponseSchema.parse(response);
73
73
  if (!streamResponse.done) {
@@ -93,7 +93,7 @@ export function translate(params) {
93
93
  })();
94
94
  const textPromise = (async () => {
95
95
  let buffer = "";
96
- for await (const response of streamRpc(request)) {
96
+ for await (const response of streamRpc(request, options)) {
97
97
  if (response.type === "translate") {
98
98
  const streamResponse = translateResponseSchema.parse(response);
99
99
  buffer += streamResponse.token;
@@ -1,9 +1,4 @@
1
- export declare function getRPC(): {
2
- request: (command: number) => {
3
- send: (data: string, encoding: BufferEncoding) => void;
4
- reply: (encoding: BufferEncoding) => Promise<Buffer>;
5
- createResponseStream: () => AsyncGenerator<unknown, void, unknown>;
6
- };
7
- };
1
+ import RPC from "bare-rpc";
2
+ export declare function getRPC(): Promise<RPC>;
8
3
  export declare function close(): Promise<void>;
9
4
  //# sourceMappingURL=node-rpc-client.d.ts.map
@@ -7,7 +7,6 @@ import fs from "node:fs";
7
7
  import os from "node:os";
8
8
  import path from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
- import { RPCRequestNotSentError } from "../../utils/errors-client.js";
11
10
  import { initializeConfig } from "../init-hooks.js";
12
11
  import { resolveConfig } from "../config-loader/resolve-config.node.js";
13
12
  import { getClientLogger } from "../../logging/index.js";
@@ -202,44 +201,8 @@ async function ensureRPC() {
202
201
  await initializeConfig(rpc, resolveConfig, runtimeContext);
203
202
  return rpc;
204
203
  }
205
- const mockRPC = {
206
- request: (command) => {
207
- let sentData = null;
208
- return {
209
- send: (data, encoding) => {
210
- sentData = { data, encoding };
211
- },
212
- reply: async (encoding) => {
213
- if (!sentData) {
214
- throw new RPCRequestNotSentError();
215
- }
216
- const rpc = await ensureRPC();
217
- const req = rpc.request(command);
218
- req.send(sentData.data, sentData.encoding);
219
- const response = await req.reply(encoding);
220
- return Buffer.isBuffer(response)
221
- ? response
222
- : Buffer.from(typeof response === "string" ? response : "", encoding);
223
- },
224
- createResponseStream: async function* () {
225
- if (!sentData) {
226
- throw new RPCRequestNotSentError();
227
- }
228
- const rpc = await ensureRPC();
229
- const req = rpc.request(command);
230
- req.send(sentData.data, sentData.encoding);
231
- const stream = req.createResponseStream({
232
- encoding: sentData.encoding,
233
- });
234
- for await (const chunk of stream) {
235
- yield chunk;
236
- }
237
- },
238
- };
239
- },
240
- };
241
- export function getRPC() {
242
- return mockRPC;
204
+ export async function getRPC() {
205
+ return ensureRPC();
243
206
  }
244
207
  export async function close() {
245
208
  if (closePromise) {
@@ -0,0 +1,2 @@
1
+ export * from "./profiler";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export * from "./profiler.js";
@@ -0,0 +1,27 @@
1
+ import { type BaseTimings } from "../../../profiling/index";
2
+ import type { ProfilingResponseMeta } from "../../../schemas/index";
3
+ interface BaseClientTimings extends BaseTimings {
4
+ requestZodValidationMs?: number;
5
+ requestStringifyMs?: number;
6
+ sendStart?: number;
7
+ requestEnd?: number;
8
+ }
9
+ export interface ClientTimings extends BaseClientTimings {
10
+ firstResponseAt?: number;
11
+ responseJsonParseMs?: number;
12
+ responseZodValidationMs?: number;
13
+ }
14
+ export interface ClientStreamTimings extends BaseClientTimings {
15
+ firstChunkAt?: number;
16
+ lastChunkAt?: number;
17
+ chunkCount: number;
18
+ }
19
+ export declare function createClientTimings(profileId: string, requestType: string): ClientTimings;
20
+ export declare function createClientStreamTimings(profileId: string, requestType: string): ClientStreamTimings;
21
+ export declare function cacheConnectionTime(durationMs: number): void;
22
+ export declare function flushConnectionTime(): void;
23
+ export declare function recordClientEvents(timings: ClientTimings, serverMeta?: ProfilingResponseMeta): void;
24
+ export declare function recordClientStreamEvents(timings: ClientStreamTimings, serverMeta?: ProfilingResponseMeta): void;
25
+ export declare function resetConnectionTracking(): void;
26
+ export {};
27
+ //# sourceMappingURL=profiler.d.ts.map