@qvac/sdk 0.6.0 → 0.7.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 (278) hide show
  1. package/LICENSE +1 -24
  2. package/NOTICE +632 -0
  3. package/README.md +2 -1
  4. package/dist/client/api/embed.js +1 -4
  5. package/dist/client/api/get-model-info.d.ts +10 -3
  6. package/dist/client/api/index.d.ts +2 -0
  7. package/dist/client/api/index.js +2 -0
  8. package/dist/client/api/invoke-plugin.d.ts +14 -0
  9. package/dist/client/api/invoke-plugin.js +38 -0
  10. package/dist/client/api/registry.d.ts +14 -0
  11. package/dist/client/api/registry.js +37 -0
  12. package/dist/client/api/transcribe.js +0 -4
  13. package/dist/client/api/unload-model.js +1 -1
  14. package/dist/client/config-loader/resolve-config.node.d.ts +3 -2
  15. package/dist/client/config-loader/resolve-config.node.js +31 -4
  16. package/dist/client/init-hooks.js +2 -1
  17. package/dist/client/rpc/bare-client.d.ts +2 -0
  18. package/dist/client/rpc/bare-client.js +48 -7
  19. package/dist/client/rpc/expo-device-info.d.ts +6 -0
  20. package/dist/client/rpc/expo-device-info.js +32 -0
  21. package/dist/client/rpc/expo-rpc-client.js +9 -32
  22. package/dist/client/rpc/node-rpc-client.d.ts +1 -1
  23. package/dist/client/rpc/node-rpc-client.js +201 -28
  24. package/dist/client/rpc/rpc-client.d.ts +1 -1
  25. package/dist/client/rpc/rpc-client.js +2 -2
  26. package/dist/constants/index.d.ts +1 -0
  27. package/dist/constants/index.js +1 -0
  28. package/dist/constants/registry.d.ts +2 -0
  29. package/dist/constants/registry.js +1 -0
  30. package/dist/examples/cache-management.js +2 -2
  31. package/dist/examples/config/plugins/plugins.config.d.ts +5 -0
  32. package/dist/examples/config/plugins/plugins.config.js +4 -0
  33. package/dist/examples/download-with-blind-relays.js +1 -1
  34. package/dist/examples/llamacpp-multimodal.js +3 -3
  35. package/dist/examples/llamacpp-native-tools.js +2 -2
  36. package/dist/examples/mcp-websearch.js +2 -2
  37. package/dist/examples/multi-model-demo.js +2 -2
  38. package/dist/examples/ocr-fasttext.js +4 -4
  39. package/dist/examples/parallel-download.js +2 -2
  40. package/dist/examples/plugins.d.ts +14 -0
  41. package/dist/examples/plugins.js +129 -0
  42. package/dist/examples/registry-query.d.ts +2 -0
  43. package/dist/examples/registry-query.js +87 -0
  44. package/dist/examples/translation/translation-bergamot-batch.js +2 -2
  45. package/dist/examples/translation/translation-bergamot.js +4 -4
  46. package/dist/examples/translation/translation-opus.js +2 -2
  47. package/dist/examples/translation/translation-stream.js +2 -2
  48. package/dist/examples/tts/chatterbox.d.ts +2 -0
  49. package/dist/examples/tts/chatterbox.js +59 -0
  50. package/dist/examples/tts/supertonic.d.ts +2 -0
  51. package/dist/examples/tts/supertonic.js +51 -0
  52. package/dist/examples/tts/utils.d.ts +17 -0
  53. package/dist/examples/tts/utils.js +93 -0
  54. package/dist/examples/whispercpp-filesystem.js +2 -3
  55. package/dist/examples/whispercpp-microphone-record.js +1 -2
  56. package/dist/examples/whispercpp-prompt.js +2 -3
  57. package/dist/expo/plugins/index.d.ts +3 -0
  58. package/dist/expo/plugins/index.js +3 -0
  59. package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +15 -0
  60. package/dist/expo/plugins/resolve-sdk-package-dir.js +31 -0
  61. package/dist/expo/plugins/withAndroidArchitecture.d.ts +8 -0
  62. package/dist/expo/plugins/withAndroidArchitecture.js +52 -0
  63. package/dist/expo/plugins/withAndroidNdkVersion.d.ts +8 -0
  64. package/dist/expo/plugins/withAndroidNdkVersion.js +31 -0
  65. package/dist/expo/plugins/withDeviceInfo.d.ts +10 -0
  66. package/dist/expo/plugins/withDeviceInfo.js +48 -0
  67. package/dist/expo/plugins/withMobileBundle.d.ts +5 -2
  68. package/dist/expo/plugins/withMobileBundle.js +121 -65
  69. package/dist/expo/plugins/withQvacSDK.d.ts +4 -0
  70. package/dist/expo/plugins/withQvacSDK.js +26 -1
  71. package/dist/index.d.ts +4 -4
  72. package/dist/index.js +5 -5
  73. package/dist/models/{hyperdrive → registry}/index.js +1 -1
  74. package/dist/models/registry/models.d.ts +9056 -0
  75. package/dist/models/registry/models.js +9351 -0
  76. package/dist/models/update-models/codegen.d.ts +3 -0
  77. package/dist/models/update-models/codegen.js +135 -0
  78. package/dist/models/update-models/history.d.ts +13 -0
  79. package/dist/models/update-models/history.js +88 -0
  80. package/dist/models/update-models/index.d.ts +2 -0
  81. package/dist/models/update-models/index.js +124 -0
  82. package/dist/models/update-models/naming.d.ts +4 -0
  83. package/dist/models/update-models/naming.js +314 -0
  84. package/dist/models/update-models/processing.d.ts +8 -0
  85. package/dist/models/update-models/processing.js +67 -0
  86. package/dist/models/update-models/registry.d.ts +4 -0
  87. package/dist/models/update-models/registry.js +67 -0
  88. package/dist/models/update-models/shards.d.ts +4 -0
  89. package/dist/models/update-models/shards.js +57 -0
  90. package/dist/models/update-models/types.d.ts +60 -0
  91. package/dist/models/update-models/types.js +1 -0
  92. package/dist/models/update-models/utils.d.ts +3 -0
  93. package/dist/models/update-models/utils.js +21 -0
  94. package/dist/pear/pre.d.ts +18 -0
  95. package/dist/pear/pre.js +433 -0
  96. package/dist/schemas/common.d.ts +286 -32
  97. package/dist/schemas/common.js +12 -0
  98. package/dist/schemas/download-asset.d.ts +35 -11
  99. package/dist/schemas/download-asset.js +5 -1
  100. package/dist/schemas/engine-addon-map.d.ts +5 -0
  101. package/dist/schemas/engine-addon-map.js +49 -0
  102. package/dist/schemas/get-model-info.d.ts +32 -16
  103. package/dist/schemas/get-model-info.js +17 -8
  104. package/dist/schemas/index.d.ts +4 -1
  105. package/dist/schemas/index.js +4 -4
  106. package/dist/schemas/load-model.d.ts +2224 -900
  107. package/dist/schemas/load-model.js +130 -25
  108. package/dist/schemas/model-src-utils.d.ts +30 -12
  109. package/dist/schemas/model-src-utils.js +5 -2
  110. package/dist/schemas/model-types.d.ts +15 -4
  111. package/dist/schemas/model-types.js +21 -4
  112. package/dist/schemas/path-validation.d.ts +10 -0
  113. package/dist/schemas/path-validation.js +22 -0
  114. package/dist/schemas/plugin.d.ts +180 -0
  115. package/dist/schemas/plugin.js +132 -0
  116. package/dist/schemas/rag.d.ts +2 -2
  117. package/dist/schemas/rag.js +7 -3
  118. package/dist/schemas/registry.d.ts +338 -0
  119. package/dist/schemas/registry.js +91 -0
  120. package/dist/schemas/sdk-errors-client.d.ts +6 -6
  121. package/dist/schemas/sdk-errors-client.js +15 -15
  122. package/dist/schemas/sdk-errors-registry.d.ts +6 -0
  123. package/dist/schemas/sdk-errors-registry.js +8 -0
  124. package/dist/schemas/sdk-errors-server.d.ts +16 -2
  125. package/dist/schemas/sdk-errors-server.js +90 -10
  126. package/dist/schemas/text-to-speech.d.ts +670 -1
  127. package/dist/schemas/text-to-speech.js +51 -2
  128. package/dist/schemas/translate.d.ts +2 -2
  129. package/dist/scripts/run-security-tests-bare.d.ts +2 -0
  130. package/dist/scripts/run-security-tests-bare.js +78 -0
  131. package/dist/scripts/run-security-tests.d.ts +2 -0
  132. package/dist/scripts/run-security-tests.js +22 -0
  133. package/dist/server/bare/delegate-rpc-client.d.ts +6 -0
  134. package/dist/server/bare/delegate-rpc-client.js +136 -56
  135. package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.d.ts +1 -1
  136. package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.js +3 -3
  137. package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.js +6 -6
  138. package/dist/server/bare/{addons → ops}/load-model.js +32 -42
  139. package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.d.ts +1 -1
  140. package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.js +5 -4
  141. package/dist/server/bare/plugins/index.d.ts +7 -0
  142. package/dist/server/bare/plugins/index.js +6 -0
  143. package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.js +1 -1
  144. package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.d.ts +1 -1
  145. package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.js +2 -3
  146. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +115 -0
  147. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +142 -0
  148. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +24 -0
  149. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +73 -0
  150. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +45 -0
  151. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +97 -0
  152. package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.js +2 -1
  153. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +38 -0
  154. package/dist/server/bare/{addons/onnx-ocr/create-model.js → plugins/onnx-ocr/plugin.js} +39 -2
  155. package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.js +23 -1
  156. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +26 -0
  157. package/dist/server/bare/plugins/onnx-tts/plugin.js +162 -0
  158. package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +14 -0
  159. package/dist/server/bare/plugins/onnx-tts/wav-helper.js +107 -0
  160. package/dist/server/bare/plugins/whispercpp-transcription/ops/transcribe-stream.d.ts +3 -0
  161. package/dist/server/bare/{addons/whispercpp-transcription/handlers → plugins/whispercpp-transcription/ops}/transcribe-stream.js +1 -2
  162. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +31 -0
  163. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +74 -0
  164. package/dist/server/bare/rag-hyperdb/handlers/ingest.js +1 -1
  165. package/dist/server/bare/rag-hyperdb/handlers/search.js +1 -1
  166. package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +2 -1
  167. package/dist/server/bare/registry/config-registry.js +1 -1
  168. package/dist/server/bare/registry/model-config-utils.js +0 -11
  169. package/dist/server/bare/registry/registry-client.d.ts +5 -0
  170. package/dist/server/bare/registry/registry-client.js +37 -0
  171. package/dist/server/env.d.ts +22 -0
  172. package/dist/server/env.js +57 -0
  173. package/dist/server/plugins/index.d.ts +2 -0
  174. package/dist/server/plugins/index.js +1 -0
  175. package/dist/server/plugins/registry.d.ts +9 -0
  176. package/dist/server/plugins/registry.js +75 -0
  177. package/dist/server/rpc/delegate-transport.d.ts +11 -0
  178. package/dist/server/rpc/delegate-transport.js +60 -0
  179. package/dist/server/rpc/handle-request.d.ts +0 -9
  180. package/dist/server/rpc/handle-request.js +13 -321
  181. package/dist/server/rpc/handler-registry.d.ts +3 -0
  182. package/dist/server/rpc/handler-registry.js +84 -0
  183. package/dist/server/rpc/handler-utils.d.ts +22 -0
  184. package/dist/server/rpc/handler-utils.js +87 -0
  185. package/dist/server/rpc/handlers/cancelHandler.js +1 -1
  186. package/dist/server/rpc/handlers/completion-stream-delegated.js +1 -1
  187. package/dist/server/rpc/handlers/completion-stream.js +2 -43
  188. package/dist/server/rpc/handlers/delete-cache.js +1 -1
  189. package/dist/server/rpc/handlers/embed.js +2 -21
  190. package/dist/server/rpc/handlers/get-model-info.js +19 -15
  191. package/dist/server/rpc/handlers/index.d.ts +9 -0
  192. package/dist/server/rpc/handlers/index.js +9 -0
  193. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +1 -0
  194. package/dist/server/rpc/handlers/load-model/download-manager.js +3 -0
  195. package/dist/server/rpc/handlers/load-model/handler.js +47 -24
  196. package/dist/server/rpc/handlers/load-model/http.js +3 -2
  197. package/dist/server/rpc/handlers/load-model/hyperdrive.js +14 -10
  198. package/dist/server/rpc/handlers/load-model/registry.d.ts +10 -0
  199. package/dist/server/rpc/handlers/load-model/registry.js +571 -0
  200. package/dist/server/rpc/handlers/load-model/resolve.js +18 -5
  201. package/dist/server/rpc/handlers/load-model-delegated.js +4 -2
  202. package/dist/server/rpc/handlers/ocr-stream.js +2 -37
  203. package/dist/server/rpc/handlers/ping.d.ts +3 -0
  204. package/dist/server/rpc/handlers/ping.js +3 -0
  205. package/dist/server/rpc/handlers/plugin-dispatch.d.ts +15 -0
  206. package/dist/server/rpc/handlers/plugin-dispatch.js +54 -0
  207. package/dist/server/rpc/handlers/plugin-invoke.d.ts +4 -0
  208. package/dist/server/rpc/handlers/plugin-invoke.js +87 -0
  209. package/dist/server/rpc/handlers/registry.d.ts +5 -0
  210. package/dist/server/rpc/handlers/registry.js +157 -0
  211. package/dist/server/rpc/handlers/text-to-speech.js +2 -5
  212. package/dist/server/rpc/handlers/transcribe-stream.js +2 -30
  213. package/dist/server/rpc/handlers/translate.js +2 -42
  214. package/dist/server/rpc/handlers/unload-model.js +1 -1
  215. package/dist/server/rpc/index.d.ts +1 -1
  216. package/dist/server/utils/archive.d.ts +1 -0
  217. package/dist/server/utils/archive.js +10 -2
  218. package/dist/server/utils/cache.d.ts +5 -0
  219. package/dist/server/utils/cache.js +26 -2
  220. package/dist/server/utils/gguf-tensor-extractor.js +3 -3
  221. package/dist/server/utils/index.d.ts +1 -1
  222. package/dist/server/utils/index.js +1 -1
  223. package/dist/server/utils/path-security.d.ts +12 -0
  224. package/dist/server/utils/path-security.js +25 -0
  225. package/dist/server/utils/shard-utils.js +3 -3
  226. package/dist/server/worker-core.d.ts +6 -0
  227. package/dist/server/worker-core.js +88 -0
  228. package/dist/server/worker.d.ts +4 -5
  229. package/dist/server/worker.js +18 -116
  230. package/dist/utils/errors-client.d.ts +9 -6
  231. package/dist/utils/errors-client.js +19 -11
  232. package/dist/utils/errors-server.d.ts +44 -5
  233. package/dist/utils/errors-server.js +82 -9
  234. package/dist/utils/path-sanitize.d.ts +17 -0
  235. package/dist/utils/path-sanitize.js +54 -0
  236. package/expo/plugins/patches/android-link.mjs +63 -0
  237. package/expo/plugins/patches/ios-link.mjs +63 -0
  238. package/package.json +74 -12
  239. package/dist/examples/text-to-speech.d.ts +0 -3
  240. package/dist/examples/text-to-speech.js +0 -137
  241. package/dist/models/hyperdrive/models.d.ts +0 -4003
  242. package/dist/models/hyperdrive/models.js +0 -4282
  243. package/dist/server/bare/addons/index.d.ts +0 -4
  244. package/dist/server/bare/addons/index.js +0 -3
  245. package/dist/server/bare/addons/llamacpp-completion/create-model.d.ts +0 -8
  246. package/dist/server/bare/addons/llamacpp-completion/create-model.js +0 -43
  247. package/dist/server/bare/addons/llamacpp-completion/index.d.ts +0 -4
  248. package/dist/server/bare/addons/llamacpp-completion/index.js +0 -3
  249. package/dist/server/bare/addons/llamacpp-embedding/create-model.d.ts +0 -8
  250. package/dist/server/bare/addons/llamacpp-embedding/create-model.js +0 -38
  251. package/dist/server/bare/addons/llamacpp-embedding/index.d.ts +0 -3
  252. package/dist/server/bare/addons/llamacpp-embedding/index.js +0 -2
  253. package/dist/server/bare/addons/nmtcpp-translation/create-model.d.ts +0 -8
  254. package/dist/server/bare/addons/nmtcpp-translation/create-model.js +0 -52
  255. package/dist/server/bare/addons/nmtcpp-translation/index.d.ts +0 -3
  256. package/dist/server/bare/addons/nmtcpp-translation/index.js +0 -2
  257. package/dist/server/bare/addons/onnx-ocr/create-model.d.ts +0 -10
  258. package/dist/server/bare/addons/onnx-ocr/index.d.ts +0 -3
  259. package/dist/server/bare/addons/onnx-ocr/index.js +0 -2
  260. package/dist/server/bare/addons/onnx-tts/create-model.d.ts +0 -10
  261. package/dist/server/bare/addons/onnx-tts/create-model.js +0 -25
  262. package/dist/server/bare/addons/onnx-tts/index.d.ts +0 -3
  263. package/dist/server/bare/addons/onnx-tts/index.js +0 -2
  264. package/dist/server/bare/addons/whispercpp-transcription/create-model.d.ts +0 -10
  265. package/dist/server/bare/addons/whispercpp-transcription/create-model.js +0 -37
  266. package/dist/server/bare/addons/whispercpp-transcription/handlers/transcribe-stream.d.ts +0 -3
  267. package/dist/server/bare/addons/whispercpp-transcription/index.d.ts +0 -3
  268. package/dist/server/bare/addons/whispercpp-transcription/index.js +0 -2
  269. /package/dist/models/{hyperdrive → registry}/index.d.ts +0 -0
  270. /package/dist/server/bare/{addons → ops}/cancel.d.ts +0 -0
  271. /package/dist/server/bare/{addons → ops}/cancel.js +0 -0
  272. /package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.d.ts +0 -0
  273. /package/dist/server/bare/{addons → ops}/load-model.d.ts +0 -0
  274. /package/dist/server/bare/{addons → ops}/unload-model.d.ts +0 -0
  275. /package/dist/server/bare/{addons → ops}/unload-model.js +0 -0
  276. /package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.d.ts +0 -0
  277. /package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.d.ts +0 -0
  278. /package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.d.ts +0 -0
@@ -0,0 +1,26 @@
1
+ import { type CreateModelParams, type PluginModelResult, type ResolveModelPath } from "../../../../schemas/index";
2
+ export declare const ttsPlugin: {
3
+ modelType: "onnx-tts";
4
+ displayName: string;
5
+ addonPackage: string;
6
+ resolveConfig(modelConfig: Record<string, unknown>, resolve: ResolveModelPath): Promise<Record<string, unknown>>;
7
+ createModel(params: CreateModelParams): PluginModelResult;
8
+ handlers: {
9
+ textToSpeech: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
10
+ modelId: import("zod").ZodString;
11
+ inputType: import("zod").ZodDefault<import("zod").ZodString>;
12
+ text: import("zod").ZodString;
13
+ stream: import("zod").ZodDefault<import("zod").ZodBoolean>;
14
+ type: import("zod").ZodLiteral<"textToSpeech">;
15
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
16
+ type: import("zod").ZodLiteral<"textToSpeech">;
17
+ buffer: import("zod").ZodArray<import("zod").ZodNumber>;
18
+ done: import("zod").ZodDefault<import("zod").ZodBoolean>;
19
+ }, import("zod/v4/core").$strip>>;
20
+ };
21
+ logging: {
22
+ module: import("@qvac/tts-onnx/addonLogging").AddonLogging;
23
+ namespace: "tts";
24
+ };
25
+ };
26
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1,162 @@
1
+ import path from "bare-path";
2
+ import ttsAddonLogging from "@qvac/tts-onnx/addonLogging.js";
3
+ import ONNXTTS from "@qvac/tts-onnx";
4
+ import { definePlugin, defineHandler, ttsRequestSchema, ttsResponseSchema, ModelType, } from "../../../../schemas/index.js";
5
+ import { ADDON_NAMESPACES, createStreamLogger } from "../../../../logging/index.js";
6
+ import { TtsArtifactsRequiredError, TtsReferenceAudioRequiredError, } from "../../../../utils/errors-server.js";
7
+ import { textToSpeech } from "./ops/text-to-speech.js";
8
+ import { loadReferenceAudioAt24k } from "./wav-helper.js";
9
+ async function resolveChatterboxConfig(config, resolve) {
10
+ const { ttsTokenizerSrc, ttsSpeechEncoderSrc, ttsEmbedTokensSrc, ttsConditionalDecoderSrc, ttsLanguageModelSrc, referenceAudioSrc, language, } = config;
11
+ if (!ttsTokenizerSrc ||
12
+ !ttsSpeechEncoderSrc ||
13
+ !ttsEmbedTokensSrc ||
14
+ !ttsConditionalDecoderSrc ||
15
+ !ttsLanguageModelSrc) {
16
+ throw new TtsArtifactsRequiredError();
17
+ }
18
+ if (!referenceAudioSrc) {
19
+ throw new TtsReferenceAudioRequiredError();
20
+ }
21
+ // Download sequentially to avoid race conditions with registry client
22
+ const resolvedTokenizer = await resolve(ttsTokenizerSrc);
23
+ const resolvedSpeechEncoder = await resolve(ttsSpeechEncoderSrc);
24
+ const resolvedEmbedTokens = await resolve(ttsEmbedTokensSrc);
25
+ const resolvedConditionalDecoder = await resolve(ttsConditionalDecoderSrc);
26
+ const resolvedLanguageModel = await resolve(ttsLanguageModelSrc);
27
+ const resolvedReferenceAudio = await resolve(referenceAudioSrc);
28
+ const result = {
29
+ ttsEngine: "chatterbox",
30
+ ttsTokenizerSrc: resolvedTokenizer,
31
+ ttsSpeechEncoderSrc: resolvedSpeechEncoder,
32
+ ttsEmbedTokensSrc: resolvedEmbedTokens,
33
+ ttsConditionalDecoderSrc: resolvedConditionalDecoder,
34
+ ttsLanguageModelSrc: resolvedLanguageModel,
35
+ referenceAudioSrc: resolvedReferenceAudio,
36
+ };
37
+ if (language)
38
+ result.language = language;
39
+ return result;
40
+ }
41
+ async function resolveSupertonicConfig(config, resolve) {
42
+ const { ttsTokenizerSrc, ttsTextEncoderSrc, ttsLatentDenoiserSrc, ttsVoiceDecoderSrc, ttsVoiceSrc, ttsSpeed, ttsNumInferenceSteps, language, } = config;
43
+ if (!ttsTokenizerSrc ||
44
+ !ttsTextEncoderSrc ||
45
+ !ttsLatentDenoiserSrc ||
46
+ !ttsVoiceDecoderSrc ||
47
+ !ttsVoiceSrc) {
48
+ throw new TtsArtifactsRequiredError();
49
+ }
50
+ // Download sequentially to avoid race conditions with registry client
51
+ const resolvedTokenizer = await resolve(ttsTokenizerSrc);
52
+ const resolvedTextEncoder = await resolve(ttsTextEncoderSrc);
53
+ const resolvedLatentDenoiser = await resolve(ttsLatentDenoiserSrc);
54
+ const resolvedVoiceDecoder = await resolve(ttsVoiceDecoderSrc);
55
+ const resolvedVoice = await resolve(ttsVoiceSrc);
56
+ const result = {
57
+ ttsEngine: "supertonic",
58
+ ttsTokenizerSrc: resolvedTokenizer,
59
+ ttsTextEncoderSrc: resolvedTextEncoder,
60
+ ttsLatentDenoiserSrc: resolvedLatentDenoiser,
61
+ ttsVoiceDecoderSrc: resolvedVoiceDecoder,
62
+ ttsVoiceSrc: resolvedVoice,
63
+ };
64
+ if (language)
65
+ result.language = language;
66
+ if (ttsSpeed !== undefined)
67
+ result.ttsSpeed = ttsSpeed;
68
+ if (ttsNumInferenceSteps !== undefined)
69
+ result.ttsNumInferenceSteps = ttsNumInferenceSteps;
70
+ return result;
71
+ }
72
+ function createChatterboxModel(modelId, config) {
73
+ const { ttsTokenizerSrc: tokenizerPath, ttsSpeechEncoderSrc: speechEncoderPath, ttsEmbedTokensSrc: embedTokensPath, ttsConditionalDecoderSrc: conditionalDecoderPath, ttsLanguageModelSrc: languageModelPath, referenceAudioSrc: referenceAudioPath, language, } = config;
74
+ if (!tokenizerPath ||
75
+ !speechEncoderPath ||
76
+ !embedTokensPath ||
77
+ !conditionalDecoderPath ||
78
+ !languageModelPath) {
79
+ throw new TtsArtifactsRequiredError();
80
+ }
81
+ if (!referenceAudioPath) {
82
+ throw new TtsReferenceAudioRequiredError();
83
+ }
84
+ const logger = createStreamLogger(modelId, "tts");
85
+ const referenceAudio = loadReferenceAudioAt24k(referenceAudioPath);
86
+ const args = {
87
+ tokenizerPath,
88
+ speechEncoderPath,
89
+ embedTokensPath,
90
+ conditionalDecoderPath,
91
+ languageModelPath,
92
+ referenceAudio,
93
+ logger,
94
+ opts: { stats: true },
95
+ };
96
+ const modelConfig = { language: language ?? "en", useGPU: false };
97
+ const model = new ONNXTTS(args, modelConfig);
98
+ return { model, loader: undefined };
99
+ }
100
+ function createSupertonicModel(modelId, config) {
101
+ const { ttsTokenizerSrc: tokenizerPath, ttsTextEncoderSrc: textEncoderPath, ttsLatentDenoiserSrc: latentDenoiserPath, ttsVoiceDecoderSrc: voiceDecoderPath, ttsVoiceSrc: voicePath, ttsSpeed: speed, ttsNumInferenceSteps: numInferenceSteps, language, } = config;
102
+ if (!tokenizerPath ||
103
+ !textEncoderPath ||
104
+ !latentDenoiserPath ||
105
+ !voiceDecoderPath ||
106
+ !voicePath) {
107
+ throw new TtsArtifactsRequiredError();
108
+ }
109
+ const logger = createStreamLogger(modelId, "tts");
110
+ const voicesDir = path.dirname(voicePath);
111
+ const voiceName = path.basename(voicePath).replace(/\.bin$/i, "") || "voice";
112
+ const args = {
113
+ tokenizerPath,
114
+ textEncoderPath,
115
+ latentDenoiserPath,
116
+ voiceDecoderPath,
117
+ voicesDir,
118
+ voiceName,
119
+ speed: speed ?? 1,
120
+ numInferenceSteps: numInferenceSteps ?? 5,
121
+ logger,
122
+ opts: { stats: true },
123
+ };
124
+ const modelConfig = { language: language ?? "en" };
125
+ const model = new ONNXTTS(args, modelConfig);
126
+ return { model, loader: undefined };
127
+ }
128
+ export const ttsPlugin = definePlugin({
129
+ modelType: ModelType.onnxTts,
130
+ displayName: "TTS (ONNX)",
131
+ addonPackage: "@qvac/tts-onnx",
132
+ async resolveConfig(modelConfig, resolve) {
133
+ const config = modelConfig;
134
+ if (config.ttsEngine === "supertonic") {
135
+ return resolveSupertonicConfig(config, resolve);
136
+ }
137
+ return resolveChatterboxConfig(config, resolve);
138
+ },
139
+ createModel(params) {
140
+ const config = (params.modelConfig ?? {});
141
+ if (config.ttsEngine === "supertonic") {
142
+ return createSupertonicModel(params.modelId, config);
143
+ }
144
+ return createChatterboxModel(params.modelId, config);
145
+ },
146
+ handlers: {
147
+ textToSpeech: defineHandler({
148
+ requestSchema: ttsRequestSchema,
149
+ responseSchema: ttsResponseSchema,
150
+ streaming: true,
151
+ handler: async function* (request) {
152
+ for await (const response of textToSpeech(request)) {
153
+ yield response;
154
+ }
155
+ },
156
+ }),
157
+ },
158
+ logging: {
159
+ module: ttsAddonLogging,
160
+ namespace: ADDON_NAMESPACES.TTS,
161
+ },
162
+ });
@@ -0,0 +1,14 @@
1
+ export type ReadWavResult = {
2
+ samples: Float32Array;
3
+ sampleRate: number;
4
+ };
5
+ /**
6
+ * Read a WAV file and return Float32Array of mono samples in [-1, 1].
7
+ * Supports 16-bit PCM and 32-bit float; stereo is converted to mono (left channel).
8
+ */
9
+ export declare function readWavAsFloat32(wavPath: string): ReadWavResult;
10
+ /**
11
+ * Load reference audio from a WAV path and return Float32Array at 24kHz for Chatterbox.
12
+ */
13
+ export declare function loadReferenceAudioAt24k(wavPath: string): Float32Array;
14
+ //# sourceMappingURL=wav-helper.d.ts.map
@@ -0,0 +1,107 @@
1
+ import fs from "bare-fs";
2
+ const CHATTERBOX_SAMPLE_RATE = 24000;
3
+ /**
4
+ * Read a WAV file and return Float32Array of mono samples in [-1, 1].
5
+ * Supports 16-bit PCM and 32-bit float; stereo is converted to mono (left channel).
6
+ */
7
+ export function readWavAsFloat32(wavPath) {
8
+ const buf = fs.readFileSync(wavPath);
9
+ if (buf.length < 44)
10
+ throw new Error("WAV file too small");
11
+ const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
12
+ const riff = String.fromCharCode(buf[0], buf[1], buf[2], buf[3]);
13
+ const wave = String.fromCharCode(buf[8], buf[9], buf[10], buf[11]);
14
+ if (riff !== "RIFF")
15
+ throw new Error("Not a RIFF file");
16
+ if (wave !== "WAVE")
17
+ throw new Error("Not WAVE format");
18
+ let fmtChunk = null;
19
+ let dataChunk = null;
20
+ let offset = 12;
21
+ while (offset + 8 <= buf.length) {
22
+ const chunkId = String.fromCharCode(buf[offset], buf[offset + 1], buf[offset + 2], buf[offset + 3]);
23
+ const chunkSize = view.getUint32(offset + 4, true);
24
+ if (chunkId === "fmt ")
25
+ fmtChunk = { offset: offset + 8, size: chunkSize };
26
+ else if (chunkId === "data")
27
+ dataChunk = { offset: offset + 8, size: chunkSize };
28
+ offset += 8 + chunkSize;
29
+ if (chunkSize % 2 === 1 && offset < buf.length)
30
+ offset += 1;
31
+ }
32
+ if (!fmtChunk)
33
+ throw new Error("WAV missing fmt chunk");
34
+ if (!dataChunk)
35
+ throw new Error("WAV missing data chunk");
36
+ const fmtOff = fmtChunk.offset;
37
+ if (fmtOff + 16 > buf.length)
38
+ throw new Error("fmt chunk truncated");
39
+ const audioFormat = view.getUint16(fmtOff, true);
40
+ const numChannels = view.getUint16(fmtOff + 2, true);
41
+ const sampleRate = view.getUint32(fmtOff + 4, true);
42
+ const bitsPerSample = view.getUint16(fmtOff + 14, true);
43
+ if (audioFormat !== 1 && audioFormat !== 3) {
44
+ throw new Error("Unsupported WAV audio format: " +
45
+ audioFormat +
46
+ " (only PCM=1 and IEEE_FLOAT=3 supported)");
47
+ }
48
+ const dataOff = dataChunk.offset;
49
+ const dataLen = Math.min(dataChunk.size, buf.length - dataOff);
50
+ let samples;
51
+ if (audioFormat === 1 && bitsPerSample === 16) {
52
+ const bytesPerSample = 2;
53
+ const numSamples = Math.floor(dataLen / bytesPerSample);
54
+ const numFrames = numChannels === 1 ? numSamples : Math.floor(numSamples / numChannels);
55
+ samples = new Float32Array(numFrames);
56
+ for (let i = 0; i < numFrames; i++) {
57
+ const idx = dataOff + (numChannels === 1 ? i * 2 : i * numChannels * 2);
58
+ if (idx + 2 > buf.length)
59
+ break;
60
+ const s = view.getInt16(idx, true);
61
+ samples[i] = s / 32768;
62
+ }
63
+ }
64
+ else if (audioFormat === 3 && bitsPerSample === 32) {
65
+ const bytesPerSample = 4;
66
+ const numSamples = Math.floor(dataLen / bytesPerSample);
67
+ const numFrames = numChannels === 1 ? numSamples : Math.floor(numSamples / numChannels);
68
+ samples = new Float32Array(numFrames);
69
+ for (let i = 0; i < numFrames; i++) {
70
+ const idx = dataOff + (numChannels === 1 ? i * 4 : i * numChannels * 4);
71
+ if (idx + 4 > buf.length)
72
+ break;
73
+ samples[i] = view.getFloat32(idx, true);
74
+ }
75
+ }
76
+ else {
77
+ throw new Error("Unsupported WAV format: audioFormat=" +
78
+ audioFormat +
79
+ ", bitsPerSample=" +
80
+ bitsPerSample);
81
+ }
82
+ return { samples, sampleRate };
83
+ }
84
+ function resampleLinear(samples, fromRate, toRate) {
85
+ if (fromRate === toRate)
86
+ return samples;
87
+ const ratio = fromRate / toRate;
88
+ const outputLen = Math.round(samples.length / ratio);
89
+ const output = new Float32Array(outputLen);
90
+ for (let i = 0; i < outputLen; i++) {
91
+ const srcIdx = i * ratio;
92
+ const lo = Math.floor(srcIdx);
93
+ const hi = Math.min(lo + 1, samples.length - 1);
94
+ const frac = srcIdx - lo;
95
+ output[i] = samples[lo] * (1 - frac) + samples[hi] * frac;
96
+ }
97
+ return output;
98
+ }
99
+ /**
100
+ * Load reference audio from a WAV path and return Float32Array at 24kHz for Chatterbox.
101
+ */
102
+ export function loadReferenceAudioAt24k(wavPath) {
103
+ const { samples, sampleRate } = readWavAsFloat32(wavPath);
104
+ if (sampleRate === CHATTERBOX_SAMPLE_RATE)
105
+ return samples;
106
+ return resampleLinear(samples, sampleRate, CHATTERBOX_SAMPLE_RATE);
107
+ }
@@ -0,0 +1,3 @@
1
+ import type { TranscribeParams } from "../../../../../schemas/index";
2
+ export declare function transcribe(params: TranscribeParams): AsyncGenerator<string, void, void>;
3
+ //# sourceMappingURL=transcribe-stream.d.ts.map
@@ -1,8 +1,7 @@
1
1
  import { getModel, getModelConfig, } from "../../../registry/model-registry.js";
2
2
  import { Readable } from "bare-stream";
3
3
  import fs from "bare-fs";
4
- import { needsDecoding, decodeAudioToStream } from "../../../../utils/index.js";
5
- import {} from "../../../../../schemas/index.js";
4
+ import { needsDecoding, decodeAudioToStream, } from "../../../../utils/audio/decoder.js";
6
5
  import { AudioFileNotFoundError, InvalidAudioChunkError, } from "../../../../../utils/errors-server.js";
7
6
  import { getServerLogger } from "../../../../../logging/index.js";
8
7
  const logger = getServerLogger();
@@ -0,0 +1,31 @@
1
+ import { type CreateModelParams, type PluginModelResult } from "../../../../schemas/index";
2
+ export declare const whisperPlugin: {
3
+ modelType: "whispercpp-transcription";
4
+ displayName: string;
5
+ addonPackage: string;
6
+ createModel(params: CreateModelParams): PluginModelResult;
7
+ handlers: {
8
+ transcribeStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
9
+ modelId: import("zod").ZodString;
10
+ audioChunk: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
11
+ type: import("zod").ZodLiteral<"base64">;
12
+ value: import("zod").ZodString;
13
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
14
+ type: import("zod").ZodLiteral<"filePath">;
15
+ value: import("zod").ZodString;
16
+ }, import("zod/v4/core").$strip>], "type">;
17
+ prompt: import("zod").ZodOptional<import("zod").ZodString>;
18
+ type: import("zod").ZodLiteral<"transcribeStream">;
19
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
20
+ type: import("zod").ZodLiteral<"transcribeStream">;
21
+ text: import("zod").ZodOptional<import("zod").ZodString>;
22
+ done: import("zod").ZodOptional<import("zod").ZodBoolean>;
23
+ error: import("zod").ZodOptional<import("zod").ZodString>;
24
+ }, import("zod/v4/core").$strip>>;
25
+ };
26
+ logging: {
27
+ module: import("@qvac/transcription-whispercpp/addonLogging").AddonLogging;
28
+ namespace: "whispercpp";
29
+ };
30
+ };
31
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1,74 @@
1
+ import whisperAddonLogging from "@qvac/transcription-whispercpp/addonLogging.js";
2
+ import TranscriptionWhispercpp, {} from "@qvac/transcription-whispercpp";
3
+ import { definePlugin, defineHandler, transcribeStreamRequestSchema, transcribeStreamResponseSchema, ModelType, } from "../../../../schemas/index.js";
4
+ import { ADDON_NAMESPACES, createStreamLogger } from "../../../../logging/index.js";
5
+ import { parseModelPath } from "../../../utils/index.js";
6
+ import FilesystemDL from "@qvac/dl-filesystem";
7
+ import { transcribe } from "./ops/transcribe-stream.js";
8
+ function createWhisperModel(modelId, modelPath, whisperConfig, vadModelPath) {
9
+ const { dirPath, basePath } = parseModelPath(modelPath);
10
+ let vadModelName = "";
11
+ const effectiveVadPath = vadModelPath || whisperConfig.vad_model_path;
12
+ if (effectiveVadPath) {
13
+ const vadParsed = parseModelPath(effectiveVadPath);
14
+ vadModelName = vadParsed.basePath;
15
+ }
16
+ const loader = new FilesystemDL({ dirPath });
17
+ const logger = createStreamLogger(modelId, "whispercpp");
18
+ const args = {
19
+ loader,
20
+ logger,
21
+ modelName: basePath,
22
+ diskPath: dirPath,
23
+ vadModelName,
24
+ opts: {
25
+ stats: false,
26
+ },
27
+ };
28
+ const { contextParams, miscConfig, ...whisperParams } = whisperConfig;
29
+ const config = {
30
+ whisperConfig: whisperParams,
31
+ ...(contextParams && { contextParams }),
32
+ ...(miscConfig && { miscConfig }),
33
+ };
34
+ const model = new TranscriptionWhispercpp(args, config);
35
+ return { model, loader };
36
+ }
37
+ export const whisperPlugin = definePlugin({
38
+ modelType: ModelType.whispercppTranscription,
39
+ displayName: "Whisper (whisper.cpp)",
40
+ addonPackage: "@qvac/transcription-whispercpp",
41
+ createModel(params) {
42
+ const whisperConfig = (params.modelConfig ?? {});
43
+ const { model, loader } = createWhisperModel(params.modelId, params.modelPath, whisperConfig, params.artifacts?.["vadModelPath"]);
44
+ return { model, loader };
45
+ },
46
+ handlers: {
47
+ transcribeStream: defineHandler({
48
+ requestSchema: transcribeStreamRequestSchema,
49
+ responseSchema: transcribeStreamResponseSchema,
50
+ streaming: true,
51
+ handler: async function* (request) {
52
+ for await (const text of transcribe({
53
+ modelId: request.modelId,
54
+ audioChunk: request.audioChunk,
55
+ prompt: request.prompt,
56
+ })) {
57
+ yield {
58
+ type: "transcribeStream",
59
+ text,
60
+ };
61
+ }
62
+ yield {
63
+ type: "transcribeStream",
64
+ text: "",
65
+ done: true,
66
+ };
67
+ },
68
+ }),
69
+ },
70
+ logging: {
71
+ module: whisperAddonLogging,
72
+ namespace: ADDON_NAMESPACES.WHISPERCPP,
73
+ },
74
+ });
@@ -1,5 +1,5 @@
1
1
  import { getRagInstance } from "../rag-workspace-manager.js";
2
- import { embed } from "../../addons/llamacpp-embedding/index.js";
2
+ import { embed } from "../../ops/embed.js";
3
3
  import { ragIngestParamsSchema } from "../../../../schemas/index.js";
4
4
  export async function ingest(params, options) {
5
5
  const { modelId, documents, chunk, chunkOpts, workspace, progressInterval } = ragIngestParamsSchema.parse(params);
@@ -1,5 +1,5 @@
1
1
  import { getRagInstance, hasRagWorkspaceStorage, } from "../rag-workspace-manager.js";
2
- import { embed } from "../../addons/llamacpp-embedding/index.js";
2
+ import { embed } from "../../ops/embed.js";
3
3
  import { ragSearchParamsSchema } from "../../../../schemas/index.js";
4
4
  export async function search(params) {
5
5
  const { modelId, query, topK, n, workspace } = ragSearchParamsSchema.parse(params);
@@ -4,6 +4,7 @@ import fs, { promises as fsPromises } from "bare-fs";
4
4
  import path from "bare-path";
5
5
  import { getConfiguredCacheDir } from "../registry/config-registry.js";
6
6
  import { RAGWorkspaceModelMismatchError, RAGWorkspaceNotOpenError, } from "../../../utils/errors-server.js";
7
+ import { validateAndJoinPath } from "../../utils/path-security.js";
7
8
  import { createStreamLogger, getServerLogger, ADDON_NAMESPACES, } from "../../../logging/index.js";
8
9
  import { cancelAllRagOperations } from "./rag-operation-manager.js";
9
10
  const logger = getServerLogger();
@@ -17,7 +18,7 @@ function getRagBaseDir() {
17
18
  return path.join(path.dirname(cacheDir), "rag-hyperdb");
18
19
  }
19
20
  function getStorePath(workspace) {
20
- return path.join(getRagBaseDir(), workspace);
21
+ return validateAndJoinPath(getRagBaseDir(), workspace);
21
22
  }
22
23
  export function hasRagWorkspaceStorage(workspace) {
23
24
  const key = getWorkspaceKey(workspace);
@@ -1,6 +1,6 @@
1
1
  import fs from "bare-fs";
2
2
  import path from "bare-path";
3
- import { getEnv } from "../../worker.js";
3
+ import { getEnv } from "../../env.js";
4
4
  import { CacheDirNotAbsoluteError, CacheDirNotWritableError, ConfigAlreadySetError, } from "../../../utils/errors-server.js";
5
5
  import { getServerLogger, setGlobalConsoleOutput, setGlobalLogLevel, } from "../../../logging/index.js";
6
6
  const logger = getServerLogger();
@@ -39,17 +39,6 @@ export const BUILTIN_DEVICE_PATTERNS = [
39
39
  [ModelType.llamacppEmbedding]: { device: "cpu" },
40
40
  },
41
41
  },
42
- {
43
- name: "iPhone 17",
44
- match: {
45
- platform: "ios",
46
- deviceModelPrefix: "iPhone 17",
47
- },
48
- defaults: {
49
- [ModelType.llamacppCompletion]: { device: "cpu" },
50
- [ModelType.llamacppEmbedding]: { device: "cpu" },
51
- },
52
- },
53
42
  ];
54
43
  export function matchesPattern(ctx, match) {
55
44
  if (match.platform !== undefined && ctx.platform !== match.platform) {
@@ -0,0 +1,5 @@
1
+ import { QVACRegistryClient } from "@qvac/registry-client";
2
+ export declare function getRegistryClient(): Promise<QVACRegistryClient>;
3
+ export declare function closeRegistryClient(): Promise<void>;
4
+ export declare function hasActiveRegistryClient(): boolean;
5
+ //# sourceMappingURL=registry-client.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { QVACRegistryClient } from "@qvac/registry-client";
2
+ import { getCacheDir } from "../../utils/cache.js";
3
+ import { getServerLogger } from "../../../logging/index.js";
4
+ import { DEFAULT_REGISTRY_CORE_KEY } from "../../../constants/index.js";
5
+ const logger = getServerLogger();
6
+ let registryClient = null;
7
+ export async function getRegistryClient() {
8
+ if (registryClient) {
9
+ logger.debug("Registry client reused");
10
+ return registryClient;
11
+ }
12
+ logger.info("🔗 Creating new registry client...");
13
+ registryClient = new QVACRegistryClient({
14
+ registryCoreKey: DEFAULT_REGISTRY_CORE_KEY,
15
+ storage: getCacheDir(`registry-corestore/${DEFAULT_REGISTRY_CORE_KEY}`),
16
+ });
17
+ await registryClient.ready();
18
+ logger.info("✅ Registry client ready");
19
+ return registryClient;
20
+ }
21
+ export async function closeRegistryClient() {
22
+ if (!registryClient)
23
+ return;
24
+ const client = registryClient;
25
+ registryClient = null;
26
+ logger.info("🔌 Closing registry client...");
27
+ try {
28
+ await client.close();
29
+ logger.info("✅ Registry client closed");
30
+ }
31
+ catch (error) {
32
+ logger.error("❌ Error closing registry client:", error instanceof Error ? error.message : String(error));
33
+ }
34
+ }
35
+ export function hasActiveRegistryClient() {
36
+ return registryClient !== null;
37
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Initialize the worker environment. Call once at worker startup.
3
+ * Returns whether RPC config was parsed from arguments.
4
+ */
5
+ export declare function initEnv(): {
6
+ hasRPCConfig: boolean;
7
+ };
8
+ /**
9
+ * Get the worker environment. Must call initEnv() first.
10
+ */
11
+ export declare function getEnv(): {
12
+ HOME_DIR: string;
13
+ QVAC_IPC_SOCKET_PATH?: string | undefined;
14
+ };
15
+ /**
16
+ * Get the validated env config. Must call initEnv() first.
17
+ */
18
+ export declare function getValidatedEnv(): {
19
+ HOME_DIR: string;
20
+ QVAC_IPC_SOCKET_PATH?: string | undefined;
21
+ };
22
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1,57 @@
1
+ import process from "bare-process";
2
+ import { isBareKit } from "which-runtime";
3
+ import { z } from "zod";
4
+ const envSchema = z.object({
5
+ QVAC_IPC_SOCKET_PATH: z.string().optional(),
6
+ HOME_DIR: z.string(),
7
+ });
8
+ let validatedEnv = null;
9
+ /**
10
+ * Initialize the worker environment. Call once at worker startup.
11
+ * Returns whether RPC config was parsed from arguments.
12
+ */
13
+ export function initEnv() {
14
+ const defaultHomeDir = process.env["HOME"] || process.env["USERPROFILE"] || "/tmp";
15
+ let envConfig = {
16
+ HOME_DIR: defaultHomeDir,
17
+ };
18
+ let hasRPCConfig = false;
19
+ if (isBareKit && process.argv[0]) {
20
+ envConfig["HOME_DIR"] = process.argv[0];
21
+ }
22
+ // Try to parse any argument as JSON config (fail gracefully)
23
+ if (process.argv[2]) {
24
+ try {
25
+ const rpcArgs = JSON.parse(process.argv[2]);
26
+ envConfig = { ...envConfig, ...rpcArgs };
27
+ hasRPCConfig = true;
28
+ }
29
+ catch {
30
+ // Not JSON or invalid - use defaults (direct mode)
31
+ }
32
+ }
33
+ validatedEnv = envSchema.parse(envConfig);
34
+ return { hasRPCConfig };
35
+ }
36
+ /**
37
+ * Get the worker environment. Must call initEnv() first.
38
+ */
39
+ export function getEnv() {
40
+ if (!validatedEnv) {
41
+ // Fallback initialization for cases where initEnv wasn't called
42
+ initEnv();
43
+ }
44
+ return {
45
+ ...process.env,
46
+ ...validatedEnv,
47
+ };
48
+ }
49
+ /**
50
+ * Get the validated env config. Must call initEnv() first.
51
+ */
52
+ export function getValidatedEnv() {
53
+ if (!validatedEnv) {
54
+ initEnv();
55
+ }
56
+ return validatedEnv;
57
+ }
@@ -0,0 +1,2 @@
1
+ export { registerPlugin, getPlugin, getPluginHandler, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin, } from "./registry";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export { registerPlugin, getPlugin, getPluginHandler, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin, } from "./registry.js";
@@ -0,0 +1,9 @@
1
+ import { type QvacPlugin, type PluginHandlerDefinition } from "../../schemas/plugin";
2
+ export declare function registerPlugin(plugin: QvacPlugin): void;
3
+ export declare function getPlugin(modelType: string): QvacPlugin | undefined;
4
+ export declare function getPluginHandler(modelType: string, handlerName: string): PluginHandlerDefinition | undefined;
5
+ export declare function hasPlugin(modelType: string): boolean;
6
+ export declare function unregisterPlugin(modelType: string): boolean;
7
+ export declare function getAllPlugins(): QvacPlugin[];
8
+ export declare function clearPlugins(): void;
9
+ //# sourceMappingURL=registry.d.ts.map