@qvac/sdk 0.6.1 → 0.7.1

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 (277) 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/registry-client.d.ts +5 -0
  169. package/dist/server/bare/registry/registry-client.js +37 -0
  170. package/dist/server/env.d.ts +22 -0
  171. package/dist/server/env.js +57 -0
  172. package/dist/server/plugins/index.d.ts +2 -0
  173. package/dist/server/plugins/index.js +1 -0
  174. package/dist/server/plugins/registry.d.ts +9 -0
  175. package/dist/server/plugins/registry.js +75 -0
  176. package/dist/server/rpc/delegate-transport.d.ts +11 -0
  177. package/dist/server/rpc/delegate-transport.js +60 -0
  178. package/dist/server/rpc/handle-request.d.ts +0 -9
  179. package/dist/server/rpc/handle-request.js +13 -321
  180. package/dist/server/rpc/handler-registry.d.ts +3 -0
  181. package/dist/server/rpc/handler-registry.js +84 -0
  182. package/dist/server/rpc/handler-utils.d.ts +22 -0
  183. package/dist/server/rpc/handler-utils.js +87 -0
  184. package/dist/server/rpc/handlers/cancelHandler.js +1 -1
  185. package/dist/server/rpc/handlers/completion-stream-delegated.js +1 -1
  186. package/dist/server/rpc/handlers/completion-stream.js +2 -43
  187. package/dist/server/rpc/handlers/delete-cache.js +1 -1
  188. package/dist/server/rpc/handlers/embed.js +2 -21
  189. package/dist/server/rpc/handlers/get-model-info.js +19 -15
  190. package/dist/server/rpc/handlers/index.d.ts +9 -0
  191. package/dist/server/rpc/handlers/index.js +9 -0
  192. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +1 -0
  193. package/dist/server/rpc/handlers/load-model/download-manager.js +3 -0
  194. package/dist/server/rpc/handlers/load-model/handler.js +47 -24
  195. package/dist/server/rpc/handlers/load-model/http.js +3 -2
  196. package/dist/server/rpc/handlers/load-model/hyperdrive.js +14 -10
  197. package/dist/server/rpc/handlers/load-model/registry.d.ts +10 -0
  198. package/dist/server/rpc/handlers/load-model/registry.js +571 -0
  199. package/dist/server/rpc/handlers/load-model/resolve.js +18 -5
  200. package/dist/server/rpc/handlers/load-model-delegated.js +4 -2
  201. package/dist/server/rpc/handlers/ocr-stream.js +2 -37
  202. package/dist/server/rpc/handlers/ping.d.ts +3 -0
  203. package/dist/server/rpc/handlers/ping.js +3 -0
  204. package/dist/server/rpc/handlers/plugin-dispatch.d.ts +15 -0
  205. package/dist/server/rpc/handlers/plugin-dispatch.js +54 -0
  206. package/dist/server/rpc/handlers/plugin-invoke.d.ts +4 -0
  207. package/dist/server/rpc/handlers/plugin-invoke.js +87 -0
  208. package/dist/server/rpc/handlers/registry.d.ts +5 -0
  209. package/dist/server/rpc/handlers/registry.js +157 -0
  210. package/dist/server/rpc/handlers/text-to-speech.js +2 -5
  211. package/dist/server/rpc/handlers/transcribe-stream.js +2 -30
  212. package/dist/server/rpc/handlers/translate.js +2 -42
  213. package/dist/server/rpc/handlers/unload-model.js +1 -1
  214. package/dist/server/rpc/index.d.ts +1 -1
  215. package/dist/server/utils/archive.d.ts +1 -0
  216. package/dist/server/utils/archive.js +10 -2
  217. package/dist/server/utils/cache.d.ts +5 -0
  218. package/dist/server/utils/cache.js +26 -2
  219. package/dist/server/utils/gguf-tensor-extractor.js +3 -3
  220. package/dist/server/utils/index.d.ts +1 -1
  221. package/dist/server/utils/index.js +1 -1
  222. package/dist/server/utils/path-security.d.ts +12 -0
  223. package/dist/server/utils/path-security.js +25 -0
  224. package/dist/server/utils/shard-utils.js +3 -3
  225. package/dist/server/worker-core.d.ts +6 -0
  226. package/dist/server/worker-core.js +88 -0
  227. package/dist/server/worker.d.ts +4 -5
  228. package/dist/server/worker.js +18 -116
  229. package/dist/utils/errors-client.d.ts +9 -6
  230. package/dist/utils/errors-client.js +19 -11
  231. package/dist/utils/errors-server.d.ts +44 -5
  232. package/dist/utils/errors-server.js +82 -9
  233. package/dist/utils/path-sanitize.d.ts +17 -0
  234. package/dist/utils/path-sanitize.js +54 -0
  235. package/expo/plugins/patches/android-link.mjs +63 -0
  236. package/expo/plugins/patches/ios-link.mjs +63 -0
  237. package/package.json +72 -10
  238. package/dist/examples/text-to-speech.d.ts +0 -3
  239. package/dist/examples/text-to-speech.js +0 -137
  240. package/dist/models/hyperdrive/models.d.ts +0 -4003
  241. package/dist/models/hyperdrive/models.js +0 -4282
  242. package/dist/server/bare/addons/index.d.ts +0 -4
  243. package/dist/server/bare/addons/index.js +0 -3
  244. package/dist/server/bare/addons/llamacpp-completion/create-model.d.ts +0 -8
  245. package/dist/server/bare/addons/llamacpp-completion/create-model.js +0 -43
  246. package/dist/server/bare/addons/llamacpp-completion/index.d.ts +0 -4
  247. package/dist/server/bare/addons/llamacpp-completion/index.js +0 -3
  248. package/dist/server/bare/addons/llamacpp-embedding/create-model.d.ts +0 -8
  249. package/dist/server/bare/addons/llamacpp-embedding/create-model.js +0 -38
  250. package/dist/server/bare/addons/llamacpp-embedding/index.d.ts +0 -3
  251. package/dist/server/bare/addons/llamacpp-embedding/index.js +0 -2
  252. package/dist/server/bare/addons/nmtcpp-translation/create-model.d.ts +0 -8
  253. package/dist/server/bare/addons/nmtcpp-translation/create-model.js +0 -52
  254. package/dist/server/bare/addons/nmtcpp-translation/index.d.ts +0 -3
  255. package/dist/server/bare/addons/nmtcpp-translation/index.js +0 -2
  256. package/dist/server/bare/addons/onnx-ocr/create-model.d.ts +0 -10
  257. package/dist/server/bare/addons/onnx-ocr/index.d.ts +0 -3
  258. package/dist/server/bare/addons/onnx-ocr/index.js +0 -2
  259. package/dist/server/bare/addons/onnx-tts/create-model.d.ts +0 -10
  260. package/dist/server/bare/addons/onnx-tts/create-model.js +0 -25
  261. package/dist/server/bare/addons/onnx-tts/index.d.ts +0 -3
  262. package/dist/server/bare/addons/onnx-tts/index.js +0 -2
  263. package/dist/server/bare/addons/whispercpp-transcription/create-model.d.ts +0 -10
  264. package/dist/server/bare/addons/whispercpp-transcription/create-model.js +0 -37
  265. package/dist/server/bare/addons/whispercpp-transcription/handlers/transcribe-stream.d.ts +0 -3
  266. package/dist/server/bare/addons/whispercpp-transcription/index.d.ts +0 -3
  267. package/dist/server/bare/addons/whispercpp-transcription/index.js +0 -2
  268. /package/dist/models/{hyperdrive → registry}/index.d.ts +0 -0
  269. /package/dist/server/bare/{addons → ops}/cancel.d.ts +0 -0
  270. /package/dist/server/bare/{addons → ops}/cancel.js +0 -0
  271. /package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.d.ts +0 -0
  272. /package/dist/server/bare/{addons → ops}/load-model.d.ts +0 -0
  273. /package/dist/server/bare/{addons → ops}/unload-model.d.ts +0 -0
  274. /package/dist/server/bare/{addons → ops}/unload-model.js +0 -0
  275. /package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.d.ts +0 -0
  276. /package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.d.ts +0 -0
  277. /package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.d.ts +0 -0
@@ -2,11 +2,9 @@ import { type GetModelInfoParams } from "../../schemas/index";
2
2
  export declare function getModelInfo(params: GetModelInfoParams): Promise<{
3
3
  name: string;
4
4
  modelId: string;
5
- hyperdriveKey: string;
6
- hyperbeeKey: string;
7
5
  expectedSize: number;
8
6
  sha256Checksum: string;
9
- addon: "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr" | "vad";
7
+ addon: "llm" | "whisper" | "embeddings" | "nmt" | "tts" | "ocr" | "vad" | "other";
10
8
  isCached: boolean;
11
9
  isLoaded: boolean;
12
10
  cacheFiles: {
@@ -18,6 +16,15 @@ export declare function getModelInfo(params: GetModelInfoParams): Promise<{
18
16
  actualSize?: number | undefined;
19
17
  cachedAt?: Date | undefined;
20
18
  }[];
19
+ registryPath?: string | undefined;
20
+ registrySource?: string | undefined;
21
+ blobCoreKey?: string | undefined;
22
+ blobBlockOffset?: number | undefined;
23
+ blobBlockLength?: number | undefined;
24
+ blobByteOffset?: number | undefined;
25
+ engine?: string | undefined;
26
+ quantization?: string | undefined;
27
+ params?: string | undefined;
21
28
  actualSize?: number | undefined;
22
29
  cachedAt?: Date | undefined;
23
30
  loadedInstances?: {
@@ -15,4 +15,6 @@ export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings,
15
15
  export { textToSpeech } from "./text-to-speech";
16
16
  export { getModelInfo } from "./get-model-info";
17
17
  export { ocr } from "./ocr";
18
+ export { invokePlugin, invokePluginStream } from "./invoke-plugin";
19
+ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./registry";
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -15,3 +15,5 @@ export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings,
15
15
  export { textToSpeech } from "./text-to-speech.js";
16
16
  export { getModelInfo } from "./get-model-info.js";
17
17
  export { ocr } from "./ocr.js";
18
+ export { invokePlugin, invokePluginStream } from "./invoke-plugin.js";
19
+ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./registry.js";
@@ -0,0 +1,14 @@
1
+ export interface InvokePluginOptions<TParams = unknown> {
2
+ modelId: string;
3
+ handler: string;
4
+ params: TParams;
5
+ }
6
+ /**
7
+ * Invoke a non-streaming plugin handler.
8
+ */
9
+ export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>): Promise<TResponse>;
10
+ /**
11
+ * Invoke a streaming plugin handler.
12
+ */
13
+ export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>): AsyncGenerator<TResponse>;
14
+ //# sourceMappingURL=invoke-plugin.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { send, stream } from "../rpc/rpc-client.js";
2
+ import { InvalidResponseError } from "../../utils/errors-client.js";
3
+ /**
4
+ * Invoke a non-streaming plugin handler.
5
+ */
6
+ export async function invokePlugin(options) {
7
+ const request = {
8
+ type: "pluginInvoke",
9
+ modelId: options.modelId,
10
+ handler: options.handler,
11
+ params: options.params,
12
+ };
13
+ const response = await send(request);
14
+ if (response.type !== "pluginInvoke") {
15
+ throw new InvalidResponseError("pluginInvoke");
16
+ }
17
+ return response.result;
18
+ }
19
+ /**
20
+ * Invoke a streaming plugin handler.
21
+ */
22
+ export async function* invokePluginStream(options) {
23
+ const request = {
24
+ type: "pluginInvokeStream",
25
+ modelId: options.modelId,
26
+ handler: options.handler,
27
+ params: options.params,
28
+ };
29
+ for await (const chunk of stream(request)) {
30
+ const response = chunk;
31
+ if (response.type !== "pluginInvokeStream") {
32
+ throw new InvalidResponseError("pluginInvokeStream");
33
+ }
34
+ if (!response.done) {
35
+ yield response.result;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,14 @@
1
+ import type { ModelRegistryEntry, ModelRegistryEntryAddon } from "../../schemas/index";
2
+ export type { ModelRegistryEntry, ModelRegistryEntryAddon };
3
+ export interface ModelRegistrySearchParams {
4
+ filter?: string;
5
+ engine?: string;
6
+ quantization?: string;
7
+ modelType?: ModelRegistryEntryAddon;
8
+ addon?: ModelRegistryEntryAddon;
9
+ }
10
+ declare function modelRegistryList(): Promise<ModelRegistryEntry[]>;
11
+ declare function modelRegistrySearch(params?: ModelRegistrySearchParams): Promise<ModelRegistryEntry[]>;
12
+ declare function modelRegistryGetModel(registryPath: string, registrySource: string): Promise<ModelRegistryEntry>;
13
+ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel };
14
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { send } from "../rpc/rpc-client.js";
2
+ import { ModelRegistryQueryFailedError } from "../../utils/errors-client.js";
3
+ function validateRegistryResponse(response, fallbackError) {
4
+ if (!response.success) {
5
+ throw new ModelRegistryQueryFailedError(response.error ?? fallbackError ?? "Unknown registry error");
6
+ }
7
+ }
8
+ async function modelRegistryList() {
9
+ const request = {
10
+ type: "modelRegistryList",
11
+ };
12
+ const response = (await send(request));
13
+ validateRegistryResponse(response);
14
+ return response.models;
15
+ }
16
+ async function modelRegistrySearch(params = {}) {
17
+ const { modelType, ...rest } = params;
18
+ const request = {
19
+ type: "modelRegistrySearch",
20
+ ...rest,
21
+ addon: modelType ?? rest.addon,
22
+ };
23
+ const response = (await send(request));
24
+ validateRegistryResponse(response);
25
+ return response.models;
26
+ }
27
+ async function modelRegistryGetModel(registryPath, registrySource) {
28
+ const request = {
29
+ type: "modelRegistryGetModel",
30
+ registryPath,
31
+ registrySource,
32
+ };
33
+ const response = (await send(request));
34
+ validateRegistryResponse(response, `Model not found: ${registrySource}/${registryPath}`);
35
+ return response.model;
36
+ }
37
+ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel };
@@ -1,6 +1,5 @@
1
1
  import { transcribeStreamResponseSchema, } from "../../schemas/index.js";
2
2
  import { stream } from "../rpc/rpc-client.js";
3
- import { TranscriptionFailedError } from "../../utils/errors-client.js";
4
3
  /**
5
4
  * This function streams audio transcription results in real-time, yielding
6
5
  * text chunks as they become available from the model.
@@ -24,9 +23,6 @@ export async function* transcribeStream(params) {
24
23
  for await (const response of stream(request)) {
25
24
  if (response.type === "transcribeStream") {
26
25
  const streamResponse = transcribeStreamResponseSchema.parse(response);
27
- if (streamResponse.error) {
28
- throw new TranscriptionFailedError(streamResponse.error);
29
- }
30
26
  if (streamResponse.text) {
31
27
  yield streamResponse.text;
32
28
  }
@@ -34,6 +34,6 @@ export async function unloadModel(params) {
34
34
  if (response.hasActiveModels === false &&
35
35
  response.hasActiveProviders === false) {
36
36
  logger.info("🧹 No models or providers active, automatically closing RPC connection...");
37
- close();
37
+ await close();
38
38
  }
39
39
  }
@@ -2,8 +2,9 @@ import { type QvacConfig } from "./config-utils";
2
2
  /**
3
3
  * Resolution order for Node.js:
4
4
  * 1. QVAC_CONFIG_PATH environment variable
5
- * 2. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
6
- * 3. SDK defaults
5
+ * 2. Packaged Electron app (via process.resourcesPath)
6
+ * 3. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
7
+ * 4. SDK defaults
7
8
  */
8
9
  export declare function resolveConfig(): Promise<QvacConfig | undefined>;
9
10
  //# sourceMappingURL=resolve-config.node.d.ts.map
@@ -28,8 +28,8 @@ async function findProjectRoot() {
28
28
  }
29
29
  }
30
30
  }
31
- catch {
32
- // Fall through
31
+ catch (error) {
32
+ logger.debug("Project root search failed, using cwd:", { error });
33
33
  }
34
34
  return process.cwd();
35
35
  }
@@ -79,11 +79,32 @@ async function findConfigFile(searchDir) {
79
79
  }
80
80
  return undefined;
81
81
  }
82
+ function getResourcesPath() {
83
+ const { resourcesPath } = process;
84
+ return typeof resourcesPath === "string" ? resourcesPath : undefined;
85
+ }
86
+ async function findPackagedConfig() {
87
+ const resourcesPath = getResourcesPath();
88
+ if (!resourcesPath)
89
+ return undefined;
90
+ const candidates = [
91
+ path.join(resourcesPath, "app", "qvac.config.json"),
92
+ path.join(resourcesPath, "app.asar.unpacked", "qvac.config.json"),
93
+ path.join(resourcesPath, "qvac.config.json"),
94
+ ];
95
+ for (const candidate of candidates) {
96
+ if (await fileExists(candidate)) {
97
+ return candidate;
98
+ }
99
+ }
100
+ return undefined;
101
+ }
82
102
  /**
83
103
  * Resolution order for Node.js:
84
104
  * 1. QVAC_CONFIG_PATH environment variable
85
- * 2. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
86
- * 3. SDK defaults
105
+ * 2. Packaged Electron app (via process.resourcesPath)
106
+ * 3. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
107
+ * 4. SDK defaults
87
108
  */
88
109
  export async function resolveConfig() {
89
110
  const configPath = process.env["QVAC_CONFIG_PATH"];
@@ -102,6 +123,12 @@ export async function resolveConfig() {
102
123
  return config;
103
124
  }
104
125
  }
126
+ const packagedConfig = await findPackagedConfig();
127
+ if (packagedConfig) {
128
+ const config = await loadJsonConfig(packagedConfig);
129
+ logger.info(`✅ Loaded config from packaged app: ${packagedConfig}`);
130
+ return config;
131
+ }
105
132
  const projectRoot = await findProjectRoot();
106
133
  if (projectRoot) {
107
134
  const configFile = await findConfigFile(projectRoot);
@@ -1,4 +1,5 @@
1
1
  import { getClientLogger, setGlobalLogLevel, setGlobalConsoleOutput, } from "../logging/index.js";
2
+ import { SetConfigFailedError } from "../utils/errors-client.js";
2
3
  const logger = getClientLogger();
3
4
  function applyClientLoggerSettings(config) {
4
5
  if (config.loggerLevel !== undefined) {
@@ -23,7 +24,7 @@ async function sendInitMessage(rpc, config, runtimeContext) {
23
24
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
24
25
  const parsed = JSON.parse(response.toString());
25
26
  if (!parsed.success) {
26
- throw new Error(parsed.error ?? "Unknown error");
27
+ throw new SetConfigFailedError(parsed.error ?? "Unknown error");
27
28
  }
28
29
  }
29
30
  /**
@@ -1,3 +1,5 @@
1
+ import type { Request, Response } from "../../schemas/index";
2
+ export declare function send<T extends Request>(request: T): Promise<Response>;
1
3
  export declare function getRPC(): Promise<{
2
4
  request(): {
3
5
  send(payload: string): void;
@@ -1,12 +1,52 @@
1
1
  import { normalizeModelType } from "../../schemas/index.js";
2
2
  import os from "bare-os";
3
3
  import { handlers } from "../../server/rpc/handlers/index.js";
4
- import { RPCNoHandlerError, RPCRequestNotSentError, } from "../../utils/errors-client.js";
4
+ import { PearWorkerEntryRequiredError, RPCNoHandlerError, RPCRequestNotSentError, } from "../../utils/errors-client.js";
5
5
  import { initializeConfig } from "../init-hooks.js";
6
6
  import { setSDKConfig } from "../../server/bare/registry/config-registry.js";
7
7
  import { setRuntimeContext } from "../../server/bare/registry/runtime-context-registry.js";
8
8
  import { resolveModelConfig } from "../../server/bare/registry/model-config-registry.js";
9
9
  import { resolveConfig } from "../config-loader/resolve-config.bare.js";
10
+ import { getClientLogger } from "../../logging/index.js";
11
+ import { getAllPlugins } from "../../server/plugins/index.js";
12
+ import { initializeWorkerCore } from "../../server/worker-core.js";
13
+ const logger = getClientLogger();
14
+ /**
15
+ * Load worker entry to register plugins before any SDK calls.
16
+ *
17
+ * If plugins are already registered (e.g., by a Pear worker bootstrap),
18
+ * skip loading the default worker but still initialize worker core.
19
+ *
20
+ * NOTE: For Pear apps, the fallback (loading default worker) cannot work.
21
+ *
22
+ * The default worker is intentionally excluded from `pear stage --compact`
23
+ * to enable tree-shaking of unused built-in plugins. When a Pear app tries
24
+ * to dynamically import it at runtime, the path resolves to a pear:// URL.
25
+ * The default worker imports built-in plugins, which load native addons
26
+ * (.bare files). Native addons cannot be loaded from pear:// URLs, causing
27
+ * UNSUPPORTED_PROTOCOL errors.
28
+ *
29
+ * Instead, we detect Pear runtime and throw a clear error directing users
30
+ * to use the generated worker entry (qvac/worker.pear.entry.mjs).
31
+ *
32
+ * The fallback only works in non-Pear environments.
33
+ */
34
+ async function loadWorkerEntry() {
35
+ initializeWorkerCore();
36
+ if (getAllPlugins().length > 0) {
37
+ logger.info("📦 Plugins already registered, worker core initialized");
38
+ return;
39
+ }
40
+ const { isPear } = await import("which-runtime");
41
+ if (isPear) {
42
+ throw new PearWorkerEntryRequiredError("qvac/worker.pear.entry.mjs");
43
+ }
44
+ // Fallback: load default worker (all built-in plugins)
45
+ logger.info("📦 Loading default worker (all built-in plugins)");
46
+ const workerPath = "../../server/" + "worker.js";
47
+ await import(workerPath);
48
+ }
49
+ let workerEntryLoaded = false;
10
50
  // Get the handler for a request type
11
51
  function getHandler(type) {
12
52
  const handler = handlers[type];
@@ -27,10 +67,7 @@ function applyDeviceDefaultsToLoadModel(request) {
27
67
  const configWithDefaults = resolveModelConfig(canonicalType, rawConfig);
28
68
  return { ...request, modelConfig: configWithDefaults };
29
69
  }
30
- async function send(request) {
31
- if (request.type === "ping") {
32
- return { type: "pong", number: Math.random() * 100 };
33
- }
70
+ export async function send(request) {
34
71
  const handler = getHandler(request.type);
35
72
  if (!handler)
36
73
  throw new RPCNoHandlerError(request.type);
@@ -110,7 +147,7 @@ async function* stream(request) {
110
147
  }
111
148
  }
112
149
  }
113
- const createMockRPCRequest = () => {
150
+ function createMockRPCRequest() {
114
151
  let requestData = null;
115
152
  return {
116
153
  send(payload) {
@@ -154,9 +191,13 @@ const createMockRPCRequest = () => {
154
191
  }
155
192
  },
156
193
  };
157
- };
194
+ }
158
195
  let configInitialized = false;
159
196
  export async function getRPC() {
197
+ if (!workerEntryLoaded) {
198
+ await loadWorkerEntry();
199
+ workerEntryLoaded = true;
200
+ }
160
201
  const mockRPC = {
161
202
  request() {
162
203
  return createMockRPCRequest();
@@ -0,0 +1,6 @@
1
+ export declare function getDeviceInfo(): Promise<{
2
+ platform: "android" | "ios" | undefined;
3
+ deviceModel: string | undefined;
4
+ deviceBrand: string | undefined;
5
+ }>;
6
+ //# sourceMappingURL=expo-device-info.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { getClientLogger } from "../../logging/index.js";
2
+ const logger = getClientLogger();
3
+ export async function getDeviceInfo() {
4
+ try {
5
+ const expoModulesCore = await import("expo-modules-core");
6
+ // this looks odd, but is necessary to ensure that import can be used safely.
7
+ // It will crash the app if the module is not installed, but the node dependency is present.
8
+ const nativeDeviceModule = expoModulesCore.requireOptionalNativeModule("ExpoDevice");
9
+ if (nativeDeviceModule) {
10
+ const Device = await import("expo-device");
11
+ logger.info(`Device: ${Device.modelName} ${Device.brand} ${Device.osName}`);
12
+ const osName = Device?.osName?.toLowerCase();
13
+ return {
14
+ platform: osName?.includes("ios")
15
+ ? "ios"
16
+ : osName?.includes("android")
17
+ ? "android"
18
+ : undefined,
19
+ deviceModel: Device.modelName ?? undefined,
20
+ deviceBrand: Device.brand ?? undefined,
21
+ };
22
+ }
23
+ }
24
+ catch {
25
+ logger.debug("expo-device not available, device info will be omitted");
26
+ }
27
+ return {
28
+ platform: undefined,
29
+ deviceModel: undefined,
30
+ deviceBrand: undefined,
31
+ };
32
+ }
@@ -3,6 +3,7 @@ import { RPCConnectionFailedError } from "../../utils/errors-client.js";
3
3
  import { initializeConfig } from "../init-hooks.js";
4
4
  import { resolveConfig } from "../config-loader/resolve-config.expo.js";
5
5
  import { getClientLogger } from "../../logging/index.js";
6
+ import { getDeviceInfo } from "./expo-device-info.js";
6
7
  const logger = getClientLogger();
7
8
  let rpcInstance = null;
8
9
  let rpcPromise = null;
@@ -14,32 +15,7 @@ async function getRuntimeContext() {
14
15
  if (cachedRuntimeContext) {
15
16
  return cachedRuntimeContext;
16
17
  }
17
- // expo-device is optional - gracefully handle if not installed
18
- let deviceModel;
19
- let deviceBrand;
20
- let platform;
21
- try {
22
- const expoModulesCore = await import("expo-modules-core");
23
- // this looks odd, but is necessary to ensure that import can be used safely.
24
- // It will crash the app if the module is not installed, but the node dependency is present.
25
- const nativeDeviceModule = expoModulesCore.requireOptionalNativeModule("ExpoDevice");
26
- if (nativeDeviceModule) {
27
- const Device = await import("expo-device");
28
- logger.info(`Device: ${Device.modelName} ${Device.brand} ${Device.osName}`);
29
- const osName = Device?.osName?.toLowerCase();
30
- if (osName?.includes("ios")) {
31
- platform = "ios";
32
- }
33
- else if (osName?.includes("android")) {
34
- platform = "android";
35
- }
36
- deviceModel = Device.modelName ?? undefined;
37
- deviceBrand = Device.brand ?? undefined;
38
- }
39
- }
40
- catch {
41
- logger.debug("expo-device not available, device info will be omitted");
42
- }
18
+ const { platform, deviceModel, deviceBrand } = await getDeviceInfo();
43
19
  cachedRuntimeContext = {
44
20
  runtime: "react-native",
45
21
  platform,
@@ -72,14 +48,15 @@ export async function getRPC() {
72
48
  const worklet = new bareKitModule.Worklet();
73
49
  workletInstance = worklet;
74
50
  logger.debug("Starting new worklet");
75
- // Load the mobile bundle - this will be generated by the Expo plugin
76
- // using the user's installed bare library versions
51
+ // Load the mobile bundle - generated by expo plugin during prebuild
52
+ // The expo plugin handles bundle selection:
53
+ // 1. Uses qvac/worker.bundle.js if exists (user pre-generated)
54
+ // 2. Generates tree-shaken bundle if qvac.config.* exists
55
+ // 3. Generates default bundle (all plugins) otherwise
77
56
  let mobileBundle;
78
57
  try {
79
- // We need require here or the contents of the bundle will be interpreted as a module
80
- mobileBundle =
81
- // eslint-disable-next-line @typescript-eslint/no-require-imports
82
- require("@qvac/sdk/worker.mobile.bundle");
58
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
59
+ mobileBundle = require("@qvac/sdk/worker.mobile.bundle");
83
60
  }
84
61
  catch (error) {
85
62
  const message = "Failed to load mobile worker bundle. Make sure the QVAC Expo plugin is configured. " +
@@ -5,5 +5,5 @@ export declare function getRPC(): {
5
5
  createResponseStream: () => AsyncGenerator<unknown, void, unknown>;
6
6
  };
7
7
  };
8
- export declare function close(): void;
8
+ export declare function close(): Promise<void>;
9
9
  //# sourceMappingURL=node-rpc-client.d.ts.map