@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
@@ -1,7 +1,10 @@
1
1
  import type { ExpoConfig } from "expo/config";
2
2
  /**
3
- * Expo plugin that automatically generates the mobile worker bundle during build
4
- * using the user's installed bare library versions.
3
+ * Expo plugin that automatically generates the mobile worker bundle during build.
4
+ *
5
+ * Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
6
+ * Uses qvac.config.* if exists, else includes all built-in plugins.
7
+ * Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
5
8
  */
6
9
  declare function withMobileBundle(config: ExpoConfig): ExpoConfig;
7
10
  export default withMobileBundle;
@@ -2,84 +2,140 @@ import configPlugins from "@expo/config-plugins";
2
2
  import { execSync } from "child_process";
3
3
  import * as fs from "fs";
4
4
  import * as path from "path";
5
- import { SDKNotFoundInNodeModulesError, WorkerFileNotFoundError, } from "../../utils/errors-client.js";
5
+ import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
6
6
  const { withDangerousMod } = configPlugins;
7
+ const CONFIG_CANDIDATES = [
8
+ "qvac.config.json",
9
+ "qvac.config.js",
10
+ "qvac.config.mjs",
11
+ ];
12
+ /** Modules to defer from mobile bundles (not available at bundle time) */
13
+ const DEFERRED_MODULES = ["expo-file-system", "react-native-bare-kit"];
14
+ const MOBILE_HOSTS = [
15
+ "android-arm64",
16
+ "ios-arm64",
17
+ "ios-arm64-simulator",
18
+ "ios-x64-simulator",
19
+ ];
7
20
  /**
8
- * Expo plugin that automatically generates the mobile worker bundle during build
9
- * using the user's installed bare library versions.
21
+ * Expo plugin that automatically generates the mobile worker bundle during build.
22
+ *
23
+ * Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
24
+ * Uses qvac.config.* if exists, else includes all built-in plugins.
25
+ * Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
10
26
  */
11
27
  function withMobileBundle(config) {
12
28
  function buildMobileBundle(config) {
13
- console.log("🕚 QVAC: Generating mobile worker bundle with current dependencies...");
14
29
  const projectRoot = config.modRequest.projectRoot;
15
- const qvacSdkPath = path.join(projectRoot, "node_modules", "@qvac/sdk");
16
- // Ensure package exists
17
- if (!fs.existsSync(qvacSdkPath)) {
18
- throw new SDKNotFoundInNodeModulesError();
30
+ const sdkPackage = resolveSDKPackageDir(projectRoot);
31
+ const outputPath = path.join(sdkPackage.dir, "dist", "worker.mobile.bundle.js");
32
+ // Generate bundle via qvac CLI
33
+ // (uses qvac.config.* if exists, else includes all built-in plugins)
34
+ const configPath = findConfigFile(projectRoot);
35
+ if (configPath) {
36
+ console.log(`🕚 QVAC: Found ${path.basename(configPath)}, generating tree-shaken bundle...`);
19
37
  }
20
- const workerPath = path.join(qvacSdkPath, "dist", "server", "worker.js");
21
- const outputPath = path.join(qvacSdkPath, "dist/worker.mobile.bundle.js");
22
- // Check if worker.js exists
23
- if (!fs.existsSync(workerPath)) {
24
- throw new WorkerFileNotFoundError(workerPath);
38
+ else {
39
+ console.log("🕚 QVAC: No config found, generating default bundle (all plugins)...");
25
40
  }
26
- try {
27
- // Truncate incompatible RPC clients for mobile
28
- // Keep: rpc-client.js, expo-rpc-client.js, bare-client.js (needed for worker bundle)
29
- const rpcClientsToTruncate = ["node-rpc-client.js"];
30
- const truncatedContent = "// This RPC client is not available in mobile environments";
31
- for (const clientFile of rpcClientsToTruncate) {
32
- const clientPath = path.join(qvacSdkPath, "dist", "client", "rpc", clientFile);
33
- if (fs.existsSync(clientPath)) {
34
- fs.writeFileSync(clientPath, truncatedContent);
35
- console.log(`🔧 QVAC: Truncated ${clientFile} for mobile compatibility`);
36
- }
37
- }
38
- // Copy bare imports configuration for bare-pack
39
- const bareImportsSource = path.join(qvacSdkPath, "bare-imports.json");
40
- const importsMapPath = path.join(qvacSdkPath, "dist", "imports.json");
41
- if (fs.existsSync(bareImportsSource)) {
42
- fs.copyFileSync(bareImportsSource, importsMapPath);
43
- console.log("🔧 QVAC: Copied bare-imports.json for mobile bundle");
44
- }
45
- // Remove optional modules from the bundle
46
- const optionalModules = [
47
- "expo-file-system",
48
- "react-native-bare-kit",
49
- "@qvac/sdk/worker.mobile.bundle",
50
- ];
51
- const deferFlags = optionalModules
52
- .map((mod) => `--defer "${mod}"`)
53
- .join(" ");
54
- // Detect bare-pack version (v1.x uses --target, v2.x uses --host)
55
- let platformFlag = "--host";
56
- try {
57
- const versionOutput = execSync(`npx bare-pack --version "${workerPath}"`, { cwd: projectRoot, encoding: "utf-8" }).trim();
58
- const versionMatch = versionOutput.match(/v?(\d+)\./);
59
- const majorVersion = versionMatch && versionMatch[1] ? parseInt(versionMatch[1], 10) : 2;
60
- if (majorVersion < 2) {
61
- platformFlag = "--target";
62
- }
63
- }
64
- catch (error) {
65
- throw new Error(`Failed to detect bare-pack version. Ensure bare-pack is installed: npm install bare-pack`, { cause: error });
66
- }
67
- const platforms = ["android-arm64", "ios-arm64", "ios-arm64-simulator"];
68
- const platformFlags = platforms
69
- .map((p) => `${platformFlag} ${p}`)
70
- .join(" ");
71
- // Generate the bundle using bare-pack with the current project's dependencies
72
- execSync(`cd "${projectRoot}" && npx bare-pack ${platformFlags} --linked --imports "${importsMapPath}" ${deferFlags} --out "${outputPath}" "${workerPath}"`, { stdio: "inherit", cwd: projectRoot });
73
- console.log("🫡 QVAC: Mobile worker bundle generated successfully");
74
- }
75
- catch (error) {
76
- console.error("❌ QVAC: Failed to generate mobile worker bundle:", error);
77
- throw error;
41
+ const deferredModules = [
42
+ ...DEFERRED_MODULES,
43
+ `${sdkPackage.name}/worker.mobile.bundle`,
44
+ ];
45
+ runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
46
+ // Copy the generated bundle to SDK location
47
+ const generatedBundle = path.join(projectRoot, "qvac", "worker.bundle.js");
48
+ if (!fs.existsSync(generatedBundle)) {
49
+ throw new Error(`QVAC: Bundle generation failed — ${generatedBundle} not found. ` +
50
+ `Check qvac CLI output above for errors.`);
78
51
  }
52
+ fs.copyFileSync(generatedBundle, outputPath);
53
+ console.log("🫡 QVAC: Mobile bundle generated");
79
54
  return config;
80
55
  }
81
56
  config = withDangerousMod(config, ["android", buildMobileBundle]);
82
57
  config = withDangerousMod(config, ["ios", buildMobileBundle]);
83
58
  return config;
84
59
  }
60
+ /** Finds qvac.config.* file in project root */
61
+ function findConfigFile(projectRoot) {
62
+ for (const candidate of CONFIG_CANDIDATES) {
63
+ const configPath = path.join(projectRoot, candidate);
64
+ if (fs.existsSync(configPath)) {
65
+ return configPath;
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+ /**
71
+ * Resolves the qvac CLI command.
72
+ *
73
+ * Prefers local @qvac/cli installation for version consistency,
74
+ * falls back to npx for convenience when CLI is not installed.
75
+ */
76
+ function resolveCliCommand(projectRoot) {
77
+ const cliPath = path.join(projectRoot, "node_modules", "@qvac", "cli", "src", "index.js");
78
+ if (fs.existsSync(cliPath)) {
79
+ return `node "${cliPath}"`;
80
+ }
81
+ console.log("⚠️ QVAC: @qvac/cli not found in node_modules, falling back to npx");
82
+ console.log(" Tip: Add @qvac/cli as a dependency for consistent versioning");
83
+ return "npx --package=@qvac/cli qvac";
84
+ }
85
+ /** Runs qvac CLI with mobile-specific options */
86
+ function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
87
+ // Patch bare-kit linkers to use addons manifest
88
+ patchBareKitLinkers(projectRoot, qvacSdkPath);
89
+ const hostFlags = MOBILE_HOSTS.map((h) => `--host ${h}`).join(" ");
90
+ const deferFlags = deferredModules.map((m) => `--defer "${m}"`).join(" ");
91
+ const configFlag = configPath ? `--config "${configPath}"` : "";
92
+ const sdkPathFlag = `--sdk-path "${qvacSdkPath}"`;
93
+ const cliCommand = resolveCliCommand(projectRoot);
94
+ try {
95
+ execSync(`${cliCommand} bundle sdk ${sdkPathFlag} ${configFlag} ${hostFlags} ${deferFlags} --quiet`, { stdio: "inherit", cwd: projectRoot });
96
+ }
97
+ catch (error) {
98
+ console.error("❌ QVAC: Failed to generate bundle:", error);
99
+ throw error;
100
+ }
101
+ }
102
+ /**
103
+ * Patches react-native-bare-kit linkers to use the addons manifest.
104
+ *
105
+ * Copies the manifest-aware link.mjs files over the originals so that
106
+ * bare-link only links the native addons actually required by the bundle.
107
+ * This reduces app size by excluding unused native addon binaries.
108
+ */
109
+ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
110
+ const bareKitPath = path.join(projectRoot, "node_modules", "react-native-bare-kit");
111
+ if (!fs.existsSync(bareKitPath)) {
112
+ console.log("⚠️ QVAC: react-native-bare-kit not found, skipping linker patch");
113
+ return;
114
+ }
115
+ const patchesDir = path.join(qvacSdkPath, "expo", "plugins", "patches");
116
+ if (!fs.existsSync(patchesDir)) {
117
+ console.log(`⚠️ QVAC: patches directory not found (${patchesDir}), skipping linker patch`);
118
+ return;
119
+ }
120
+ // Patch Android linker
121
+ const androidPatch = path.join(patchesDir, "android-link.mjs");
122
+ const androidTarget = path.join(bareKitPath, "android", "link.mjs");
123
+ if (fs.existsSync(androidPatch)) {
124
+ fs.copyFileSync(androidPatch, androidTarget);
125
+ console.log("✅ QVAC: Patched android/link.mjs for manifest-aware linking");
126
+ }
127
+ else {
128
+ console.log(`⚠️ QVAC: Android linker patch not found (${androidPatch})`);
129
+ }
130
+ // Patch iOS linker
131
+ const iosPatch = path.join(patchesDir, "ios-link.mjs");
132
+ const iosTarget = path.join(bareKitPath, "ios", "link.mjs");
133
+ if (fs.existsSync(iosPatch)) {
134
+ fs.copyFileSync(iosPatch, iosTarget);
135
+ console.log("✅ QVAC: Patched ios/link.mjs for manifest-aware linking");
136
+ }
137
+ else {
138
+ console.log(`⚠️ QVAC: iOS linker patch not found (${iosPatch})`);
139
+ }
140
+ }
85
141
  export default withMobileBundle;
@@ -2,6 +2,10 @@ import type { ExpoConfig } from "expo/config";
2
2
  /**
3
3
  * Main Qvac SDK Expo plugin that combines all necessary mobile configurations:
4
4
  * - Mobile worker bundle generation
5
+ * - Device info stubbing when expo-device is not installed
6
+ * - Android build properties (minSdkVersion, NDK, proguard)
7
+ * - Android NDK version pinning in build.gradle
8
+ * - Android architecture filtering (arm64-v8a only)
5
9
  * - OpenCL native library support for Android
6
10
  */
7
11
  declare function withQvacSDK(config: ExpoConfig): ExpoConfig;
@@ -1,13 +1,38 @@
1
1
  import configPlugins from "@expo/config-plugins";
2
+ import withAndroidArchitecture from "./withAndroidArchitecture.js";
3
+ import withAndroidNdkVersion from "./withAndroidNdkVersion.js";
4
+ import withDeviceInfo from "./withDeviceInfo.js";
2
5
  import withMobileBundle from "./withMobileBundle.js";
3
6
  import withOpenCL from "./withOpenCL.js";
4
7
  const { withPlugins } = configPlugins;
5
8
  /**
6
9
  * Main Qvac SDK Expo plugin that combines all necessary mobile configurations:
7
10
  * - Mobile worker bundle generation
11
+ * - Device info stubbing when expo-device is not installed
12
+ * - Android build properties (minSdkVersion, NDK, proguard)
13
+ * - Android NDK version pinning in build.gradle
14
+ * - Android architecture filtering (arm64-v8a only)
8
15
  * - OpenCL native library support for Android
9
16
  */
10
17
  function withQvacSDK(config) {
11
- return withPlugins(config, [withMobileBundle, withOpenCL]);
18
+ return withPlugins(config, [
19
+ withMobileBundle,
20
+ withDeviceInfo,
21
+ [
22
+ "expo-build-properties",
23
+ {
24
+ android: {
25
+ minSdkVersion: 29,
26
+ ndkVersion: "29.0.14206865",
27
+ enableProguardInReleaseBuilds: true,
28
+ enableShrinkResourcesInReleaseBuilds: true,
29
+ enableMinifyInReleaseBuilds: true,
30
+ },
31
+ },
32
+ ],
33
+ withAndroidNdkVersion,
34
+ withAndroidArchitecture,
35
+ withOpenCL,
36
+ ]);
12
37
  }
13
38
  export default withQvacSDK;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index";
1
+ export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./client/api/index";
2
2
  export { close } from "./client/index";
3
- export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, } from "./schemas/index";
3
+ export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, definePlugin, defineHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, } from "./schemas/index";
4
4
  export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
5
- export { PUBLIC_MODEL_TYPES as MODEL_TYPES } from "./schemas/index";
6
- export * from "./models/hyperdrive/index";
5
+ export { MODEL_TYPES, ModelType } from "./schemas/index";
6
+ export * from "./models/registry/index";
7
7
  export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio";
8
8
  export { getLogger, SDK_LOG_ID } from "./logging/index";
9
9
  export type { Logger, LogTransport, LoggerOptions } from "./logging/index";
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // Public API exports only
2
- export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index.js";
2
+ export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./client/api/index.js";
3
3
  export { close } from "./client/index.js";
4
- export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, } from "./schemas/index.js";
4
+ export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, definePlugin, defineHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
5
5
  export {} from "./utils/tool-helpers.js";
6
6
  // Model types - canonical naming with backward-compatible aliases
7
- export { PUBLIC_MODEL_TYPES as MODEL_TYPES } from "./schemas/index.js";
8
- // Hyperdrive model constants
9
- export * from "./models/hyperdrive/index.js";
7
+ export { MODEL_TYPES, ModelType } from "./schemas/index.js";
8
+ // Model registry constants
9
+ export * from "./models/registry/index.js";
10
10
  export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio.js";
11
11
  // Logging exports
12
12
  export { getLogger, SDK_LOG_ID } from "./logging/index.js";
@@ -1,2 +1,2 @@
1
- // Simplified re-exports
1
+ // Re-export all models
2
2
  export * from "./models.js";