@qvac/sdk 0.11.0 → 0.12.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 (205) hide show
  1. package/NOTICE +1427 -39
  2. package/README.md +2 -0
  3. package/dist/client/api/classify.d.ts +23 -0
  4. package/dist/client/api/classify.js +43 -0
  5. package/dist/client/api/get-model-info.d.ts +1 -1
  6. package/dist/client/api/index.d.ts +4 -0
  7. package/dist/client/api/index.js +4 -0
  8. package/dist/client/api/load-model.js +24 -1
  9. package/dist/client/api/transcribe.d.ts +3 -0
  10. package/dist/client/api/transcribe.js +13 -2
  11. package/dist/client/api/video.d.ts +64 -0
  12. package/dist/client/api/video.js +147 -0
  13. package/dist/client/api/vla-helpers.d.ts +45 -0
  14. package/dist/client/api/vla-helpers.js +130 -0
  15. package/dist/client/api/vla.d.ts +65 -0
  16. package/dist/client/api/vla.js +109 -0
  17. package/dist/client/config-loader/resolve-config.node.d.ts +16 -0
  18. package/dist/client/config-loader/resolve-config.node.js +77 -23
  19. package/dist/client/plugins-factory.d.ts +8 -0
  20. package/dist/client/plugins-factory.js +10 -0
  21. package/dist/client/rpc/bare-client.js +62 -66
  22. package/dist/client/rpc/ensure-worker-ready.d.ts +9 -0
  23. package/dist/client/rpc/ensure-worker-ready.js +17 -0
  24. package/dist/client/rpc/node-rpc-client.js +4 -1
  25. package/dist/client/rpc/rpc-error.js +14 -1
  26. package/dist/commands/bundle/bare-pack.d.ts +13 -0
  27. package/dist/commands/bundle/bare-pack.js +54 -0
  28. package/dist/commands/bundle/constants.d.ts +7 -0
  29. package/dist/commands/bundle/constants.js +23 -0
  30. package/dist/commands/bundle/entry-gen.d.ts +2 -0
  31. package/dist/commands/bundle/entry-gen.js +48 -0
  32. package/dist/commands/bundle/index.d.ts +20 -0
  33. package/dist/commands/bundle/index.js +141 -0
  34. package/dist/commands/bundle/manifest.d.ts +21 -0
  35. package/dist/commands/bundle/manifest.js +193 -0
  36. package/dist/commands/bundle/plugins.d.ts +9 -0
  37. package/dist/commands/bundle/plugins.js +51 -0
  38. package/dist/commands/index.d.ts +5 -0
  39. package/dist/commands/index.js +2 -0
  40. package/dist/commands/verify/abi.d.ts +52 -0
  41. package/dist/commands/verify/abi.js +125 -0
  42. package/dist/commands/verify/addon-source.d.ts +43 -0
  43. package/dist/commands/verify/addon-source.js +75 -0
  44. package/dist/commands/verify/bundle-source.d.ts +12 -0
  45. package/dist/commands/verify/bundle-source.js +53 -0
  46. package/dist/commands/verify/index.d.ts +59 -0
  47. package/dist/commands/verify/index.js +371 -0
  48. package/dist/commands/verify/node-modules-source.d.ts +11 -0
  49. package/dist/commands/verify/node-modules-source.js +76 -0
  50. package/dist/commands/verify/prebuilds.d.ts +15 -0
  51. package/dist/commands/verify/prebuilds.js +39 -0
  52. package/dist/examples/classification/classify-image.d.ts +2 -0
  53. package/dist/examples/classification/classify-image.js +23 -0
  54. package/dist/examples/diffusion-txt2vid.d.ts +2 -0
  55. package/dist/examples/diffusion-txt2vid.js +81 -0
  56. package/dist/examples/plugins.js +3 -7
  57. package/dist/examples/tools/llamacpp-tools-gemma4.js +2 -5
  58. package/dist/examples/tools/llamacpp-tools-qwen35.js +2 -3
  59. package/dist/examples/transcription/parakeet-ctc-filesystem.js +18 -12
  60. package/dist/examples/transcription/parakeet-microphone-record.js +7 -12
  61. package/dist/examples/transcription/parakeet-microphone-stream.d.ts +2 -0
  62. package/dist/examples/transcription/parakeet-microphone-stream.js +79 -0
  63. package/dist/examples/transcription/parakeet-sortformer-streaming.d.ts +2 -0
  64. package/dist/examples/transcription/parakeet-sortformer-streaming.js +121 -0
  65. package/dist/examples/transcription/parakeet-sortformer.js +58 -55
  66. package/dist/examples/transcription/parakeet-tdt-filesystem.js +18 -15
  67. package/dist/examples/transcription/whispercpp-microphone-conversation.js +6 -1
  68. package/dist/examples/tts/chatterbox.js +7 -16
  69. package/dist/examples/tts/llm-to-tts-streaming.js +3 -10
  70. package/dist/examples/tts/supertonic-multilingual.js +4 -12
  71. package/dist/examples/tts/supertonic.js +5 -12
  72. package/dist/examples/vla-smolvla.d.ts +2 -0
  73. package/dist/examples/vla-smolvla.js +75 -0
  74. package/dist/examples/voice-assistant/voice-assistant.js +3 -10
  75. package/dist/expo/plugins/find-in-ancestor-node-modules.d.ts +14 -0
  76. package/dist/expo/plugins/find-in-ancestor-node-modules.js +24 -0
  77. package/dist/expo/plugins/get-project-root.d.ts +22 -0
  78. package/dist/expo/plugins/get-project-root.js +23 -0
  79. package/dist/expo/plugins/index.d.ts +4 -0
  80. package/dist/expo/plugins/index.js +4 -0
  81. package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +9 -2
  82. package/dist/expo/plugins/resolve-sdk-package-dir.js +38 -11
  83. package/dist/expo/plugins/withDeviceInfo.js +2 -1
  84. package/dist/expo/plugins/withMobileBundle.d.ts +2 -17
  85. package/dist/expo/plugins/withMobileBundle.js +31 -85
  86. package/dist/index.d.ts +4 -3
  87. package/dist/index.js +4 -3
  88. package/dist/models/registry/models.d.ts +3711 -368
  89. package/dist/models/registry/models.js +7066 -3562
  90. package/dist/models/update-models/naming.js +22 -8
  91. package/dist/pear/pre.js +6 -2
  92. package/dist/schemas/cancel.d.ts +5 -0
  93. package/dist/schemas/cancel.js +1 -0
  94. package/dist/schemas/classification.d.ts +53 -0
  95. package/dist/schemas/classification.js +33 -0
  96. package/dist/schemas/common.d.ts +1001 -1739
  97. package/dist/schemas/common.js +6 -1
  98. package/dist/schemas/completion-event.d.ts +3 -0
  99. package/dist/schemas/completion-event.js +1 -0
  100. package/dist/schemas/completion-stream.d.ts +1 -0
  101. package/dist/schemas/download-asset.d.ts +13 -3
  102. package/dist/schemas/engine-addon-map.d.ts +3 -0
  103. package/dist/schemas/engine-addon-map.js +18 -5
  104. package/dist/schemas/get-model-info.d.ts +4 -0
  105. package/dist/schemas/get-model-info.js +2 -0
  106. package/dist/schemas/index.d.ts +3 -0
  107. package/dist/schemas/index.js +3 -0
  108. package/dist/schemas/llamacpp-config.d.ts +12 -2
  109. package/dist/schemas/load-model.d.ts +6152 -10764
  110. package/dist/schemas/load-model.js +75 -7
  111. package/dist/schemas/model-src-utils.d.ts +22 -2
  112. package/dist/schemas/model-types.d.ts +46 -6
  113. package/dist/schemas/model-types.js +28 -5
  114. package/dist/schemas/ocr.d.ts +5 -0
  115. package/dist/schemas/plugin.d.ts +20 -5
  116. package/dist/schemas/plugin.js +21 -4
  117. package/dist/schemas/registry.d.ts +44 -0
  118. package/dist/schemas/registry.js +5 -0
  119. package/dist/schemas/reload-config.d.ts +22 -2
  120. package/dist/schemas/sdcpp-config.d.ts +316 -1
  121. package/dist/schemas/sdcpp-config.js +232 -33
  122. package/dist/schemas/sdk-config.d.ts +654 -1324
  123. package/dist/schemas/sdk-config.js +16 -1
  124. package/dist/schemas/sdk-errors-client.d.ts +5 -0
  125. package/dist/schemas/sdk-errors-client.js +26 -1
  126. package/dist/schemas/sdk-errors-server.d.ts +3 -1
  127. package/dist/schemas/sdk-errors-server.js +20 -5
  128. package/dist/schemas/text-to-speech.d.ts +79 -696
  129. package/dist/schemas/text-to-speech.js +46 -19
  130. package/dist/schemas/transcription-config.d.ts +37 -226
  131. package/dist/schemas/transcription-config.js +76 -15
  132. package/dist/schemas/transcription.d.ts +63 -11
  133. package/dist/schemas/transcription.js +56 -2
  134. package/dist/schemas/translation-config.d.ts +60 -10
  135. package/dist/schemas/vla.d.ts +87 -0
  136. package/dist/schemas/vla.js +108 -0
  137. package/dist/scripts/run-unit-tests.js +8 -2
  138. package/dist/server/bare/ops/transcribe.d.ts +2 -1
  139. package/dist/server/bare/ops/transcribe.js +59 -34
  140. package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +6 -0
  141. package/dist/server/bare/plugins/ggml-classification/ops/classify.js +30 -0
  142. package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +32 -0
  143. package/dist/server/bare/plugins/ggml-classification/plugin.js +55 -0
  144. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +3 -0
  145. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +12 -0
  146. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +3 -0
  147. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +75 -0
  148. package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +54 -0
  149. package/dist/server/bare/plugins/ggml-vla/plugin.js +57 -0
  150. package/dist/server/bare/plugins/index.d.ts +3 -1
  151. package/dist/server/bare/plugins/index.js +3 -1
  152. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +3 -0
  153. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +29 -0
  154. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +65 -0
  155. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +6 -0
  156. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +26 -0
  157. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +25 -0
  158. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +5 -0
  159. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +67 -246
  160. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +66 -97
  161. package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +3 -0
  162. package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +199 -0
  163. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +200 -2
  164. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +61 -8
  165. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.js +2 -15
  166. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.js +2 -1
  167. package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +75 -0
  168. package/dist/server/bare/plugins/tts-ggml/plugin.js +189 -0
  169. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +29 -4
  170. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +12 -1
  171. package/dist/server/bare/registry/model-config-utils.js +7 -0
  172. package/dist/server/bare/runtime/request-context.d.ts +1 -1
  173. package/dist/server/bare/runtime-lifecycle.js +9 -9
  174. package/dist/server/bare/types/addon-responses.d.ts +1 -0
  175. package/dist/server/env.js +4 -1
  176. package/dist/server/plugins/index.d.ts +1 -1
  177. package/dist/server/plugins/index.js +1 -1
  178. package/dist/server/plugins/registry.d.ts +1 -0
  179. package/dist/server/plugins/registry.js +5 -0
  180. package/dist/server/rpc/handler-registry.js +4 -0
  181. package/dist/server/rpc/handler-selection.d.ts +9 -0
  182. package/dist/server/rpc/handler-selection.js +14 -0
  183. package/dist/server/rpc/handler-utils.js +5 -13
  184. package/dist/server/rpc/handlers/classify.d.ts +3 -0
  185. package/dist/server/rpc/handlers/classify.js +4 -0
  186. package/dist/server/rpc/handlers/index.d.ts +2 -0
  187. package/dist/server/rpc/handlers/index.js +2 -0
  188. package/dist/server/rpc/handlers/load-model/handler.js +4 -1
  189. package/dist/server/rpc/handlers/load-model/resolve.js +9 -0
  190. package/dist/server/rpc/handlers/video-stream.d.ts +3 -0
  191. package/dist/server/rpc/handlers/video-stream.js +4 -0
  192. package/dist/server/rpc/profiling/operation-metrics.js +23 -0
  193. package/dist/server/utils/config-transform.js +1 -1
  194. package/dist/server/worker.js +14 -11
  195. package/dist/utils/errors-client.d.ts +15 -0
  196. package/dist/utils/errors-client.js +26 -0
  197. package/dist/utils/errors-server.d.ts +30 -2
  198. package/dist/utils/errors-server.js +51 -3
  199. package/package.json +66 -80
  200. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -490
  201. package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -272
  202. package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
  203. package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
  204. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.d.ts +0 -0
  205. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.d.ts +0 -0
@@ -6,26 +6,53 @@ const SDK_PACKAGE_NAMES = [
6
6
  "@tetherto/sdk-mono",
7
7
  "@tetherto/sdk-dev",
8
8
  ];
9
+ function findAllInAncestorNodeModules(startDir, name) {
10
+ const matches = [];
11
+ let dir = startDir;
12
+ let parent = path.dirname(dir);
13
+ let depth = 0;
14
+ for (; dir !== parent; dir = parent, parent = path.dirname(dir), depth++) {
15
+ const candidate = path.join(dir, "node_modules", name);
16
+ if (fs.existsSync(candidate)) {
17
+ matches.push({ name, dir: candidate, depth });
18
+ }
19
+ }
20
+ return matches;
21
+ }
9
22
  /**
10
23
  * Resolves the installed SDK package directory from node_modules.
11
24
  *
12
- * Checks all known published package names and returns the one that exists.
13
- * Throws if none found or if multiple are found (ambiguous installation).
25
+ * Walks from `projectRoot` up to the filesystem root, checking each
26
+ * `node_modules` directory along the way. This matches Node's own module
27
+ * resolution so packages hoisted to a monorepo root (e.g. by bun or yarn
28
+ * workspaces) are found correctly.
29
+ *
30
+ * When multiple SDK installs are found across the tree, the one closest to
31
+ * `projectRoot` wins and a warning lists the others. Only throws
32
+ * `MultipleSDKInstallationsError` when two *different* SDK package names
33
+ * coexist at the same nesting level (a real ambiguity in package selection).
14
34
  */
15
35
  function resolveSDKPackageDir(projectRoot) {
16
- const found = [];
36
+ const allMatches = [];
17
37
  for (const name of SDK_PACKAGE_NAMES) {
18
- const dir = path.join(projectRoot, "node_modules", name);
19
- if (fs.existsSync(dir)) {
20
- found.push({ name, dir });
21
- }
38
+ allMatches.push(...findAllInAncestorNodeModules(projectRoot, name));
22
39
  }
23
- if (found.length === 0) {
40
+ if (allMatches.length === 0) {
24
41
  throw new SDKNotFoundInNodeModulesError();
25
42
  }
26
- if (found.length > 1) {
27
- throw new MultipleSDKInstallationsError(found.map((f) => f.name).join(", "));
43
+ const minDepth = Math.min(...allMatches.map((m) => m.depth));
44
+ const closest = allMatches.filter((m) => m.depth === minDepth);
45
+ if (closest.length > 1) {
46
+ throw new MultipleSDKInstallationsError(closest.map((m) => m.name).join(", "));
47
+ }
48
+ const winner = closest[0];
49
+ const shadowed = allMatches.filter((m) => m !== winner);
50
+ if (shadowed.length > 0) {
51
+ const others = shadowed.map((m) => `"${m.name}" at "${m.dir}"`).join(", ");
52
+ console.warn(`[resolveSDKPackageDir] Multiple SDK installations found; using ` +
53
+ `"${winner.name}" at "${winner.dir}" (closest to projectRoot). ` +
54
+ `Ignoring: ${others}.`);
28
55
  }
29
- return found[0];
56
+ return { name: winner.name, dir: winner.dir };
30
57
  }
31
58
  export { resolveSDKPackageDir, SDK_PACKAGE_NAMES };
@@ -1,6 +1,7 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
4
+ import { getProjectRootFromBaseConfig } from "./get-project-root.js";
4
5
  let didRun = false;
5
6
  /**
6
7
  * Expo plugin that stubs expo-device-info when expo-device is not a declared
@@ -13,7 +14,7 @@ function withDeviceInfo(config) {
13
14
  return config;
14
15
  }
15
16
  didRun = true;
16
- const projectRoot = config._internal?.["projectRoot"];
17
+ const projectRoot = getProjectRootFromBaseConfig(config);
17
18
  if (!projectRoot) {
18
19
  return config;
19
20
  }
@@ -3,25 +3,10 @@ declare const MOBILE_HOSTS: string[];
3
3
  /**
4
4
  * Expo plugin: bundle, verify, then copy the mobile worker bundle.
5
5
  *
6
- * Flow: `bundle sdk` -> assert `qvac/worker.bundle.js` exists ->
7
- * `verify bundle` -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
8
- * Requires a local `@qvac/cli` install. Uses `qvac.config.*` if present.
6
+ * Flow: bundleSdk -> verifyBundle -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
7
+ * Uses `qvac.config.*` if present.
9
8
  */
10
9
  declare function withMobileBundle(config: ExpoConfig): ExpoConfig;
11
- /**
12
- * Resolves the qvac CLI command.
13
- *
14
- * Prefers local @qvac/cli installation for version consistency,
15
- * falls back to npx for convenience when CLI is not installed.
16
- */
17
- export declare function resolveCliCommand(projectRoot: string): string;
18
- /** Builds the `qvac verify bundle` command string (pure helper for tests). */
19
- export declare function buildVerifyBundleCommand(opts: {
20
- cliCommand: string;
21
- bundlePath: string;
22
- hosts: string[];
23
- configPath?: string;
24
- }): string;
25
10
  export { MOBILE_HOSTS };
26
11
  export default withMobileBundle;
27
12
  //# sourceMappingURL=withMobileBundle.d.ts.map
@@ -1,15 +1,13 @@
1
1
  import configPlugins from "@expo/config-plugins";
2
- import { execSync } from "child_process";
3
2
  import * as fs from "fs";
4
3
  import * as path from "path";
4
+ import { bundleSdk, verifyBundle, hasErrors, formatVerifyBundleResult } from "../../commands/index.js";
5
+ import { CONFIG_CANDIDATES } from "../../client/config-loader/resolve-config.node.js";
5
6
  import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
7
+ import { getProjectRootFromMod } from "./get-project-root.js";
8
+ import { findInAncestorNodeModules } from "./find-in-ancestor-node-modules.js";
6
9
  import { BundleVerificationFailedError } from "../../utils/errors-client.js";
7
10
  const { withDangerousMod } = configPlugins;
8
- const CONFIG_CANDIDATES = [
9
- "qvac.config.json",
10
- "qvac.config.js",
11
- "qvac.config.mjs",
12
- ];
13
11
  /** Modules to defer from mobile bundles (not available at bundle time) */
14
12
  const DEFERRED_MODULES = ["expo-file-system", "react-native-bare-kit"];
15
13
  const MOBILE_HOSTS = [
@@ -21,17 +19,14 @@ const MOBILE_HOSTS = [
21
19
  /**
22
20
  * Expo plugin: bundle, verify, then copy the mobile worker bundle.
23
21
  *
24
- * Flow: `bundle sdk` -> assert `qvac/worker.bundle.js` exists ->
25
- * `verify bundle` -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
26
- * Requires a local `@qvac/cli` install. Uses `qvac.config.*` if present.
22
+ * Flow: bundleSdk -> verifyBundle -> copy to `<sdkPackageDir>/dist/worker.mobile.bundle.js`.
23
+ * Uses `qvac.config.*` if present.
27
24
  */
28
25
  function withMobileBundle(config) {
29
- function buildMobileBundle(config) {
30
- const projectRoot = config.modRequest.projectRoot;
26
+ async function buildMobileBundle(config) {
27
+ const projectRoot = getProjectRootFromMod(config);
31
28
  const sdkPackage = resolveSDKPackageDir(projectRoot);
32
29
  const outputPath = path.join(sdkPackage.dir, "dist", "worker.mobile.bundle.js");
33
- // Generate bundle via qvac CLI
34
- // (uses qvac.config.* if exists, else includes all built-in plugins)
35
30
  const configPath = findConfigFile(projectRoot);
36
31
  if (configPath) {
37
32
  console.log(`🕚 QVAC: Found ${path.basename(configPath)}, generating tree-shaken bundle...`);
@@ -43,15 +38,9 @@ function withMobileBundle(config) {
43
38
  ...DEFERRED_MODULES,
44
39
  `${sdkPackage.name}/worker.mobile.bundle`,
45
40
  ];
46
- runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
47
- // Copy the generated bundle to SDK location
41
+ await runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
48
42
  const generatedBundle = path.join(projectRoot, "qvac", "worker.bundle.js");
49
- if (!fs.existsSync(generatedBundle)) {
50
- throw new Error(`QVAC: Bundle generation failed — ${generatedBundle} not found. ` +
51
- `Check qvac CLI output above for errors.`);
52
- }
53
- // Verify before copying so the dist artifact only updates on success.
54
- runVerifier(projectRoot, generatedBundle, configPath);
43
+ await runVerifier(projectRoot, generatedBundle, configPath);
55
44
  fs.copyFileSync(generatedBundle, outputPath);
56
45
  console.log("🫡 QVAC: Mobile bundle generated and verified");
57
46
  return config;
@@ -70,83 +59,42 @@ function findConfigFile(projectRoot) {
70
59
  }
71
60
  return null;
72
61
  }
73
- /**
74
- * Resolves the qvac CLI command.
75
- *
76
- * Prefers local @qvac/cli installation for version consistency,
77
- * falls back to npx for convenience when CLI is not installed.
78
- */
79
- export function resolveCliCommand(projectRoot) {
80
- const cliPath = path.join(projectRoot, "node_modules", "@qvac", "cli", "dist", "index.js");
81
- if (fs.existsSync(cliPath)) {
82
- return `node "${cliPath}"`;
83
- }
84
- console.log("⚠️ QVAC: @qvac/cli not found in node_modules, falling back to npx");
85
- console.log(" Tip: Add @qvac/cli as a dependency for consistent versioning");
86
- return "npx --package=@qvac/cli qvac";
87
- }
88
- /** Builds the `qvac verify bundle` command string (pure helper for tests). */
89
- export function buildVerifyBundleCommand(opts) {
90
- const hostFlags = opts.hosts.map((h) => `--host ${h}`).join(" ");
91
- const configFlag = opts.configPath ? ` --config "${opts.configPath}"` : "";
92
- return `${opts.cliCommand} verify bundle --addons-source "${opts.bundlePath}" ${hostFlags}${configFlag}`;
93
- }
94
- /**
95
- * Runs `qvac verify bundle` against the freshly generated worker bundle.
96
- * Passes the discovered `qvac.config.*` so the CLI reads `bareRuntimeVersion`
97
- * and pins ABI checks deterministically. Without a config, the CLI falls back
98
- * to auto-detecting Bare runtime from `node_modules` (`bare-runtime`, then
99
- * `bare`); ABI checks stay strict when that lookup succeeds, and only skip
100
- * (with an `unknown-runtime-version` warning) when neither is installed.
101
- */
102
- function runVerifier(projectRoot, generatedBundle, configPath) {
103
- const cliCommand = resolveCliCommand(projectRoot);
62
+ async function runVerifier(projectRoot, generatedBundle, configPath) {
104
63
  if (!configPath) {
105
64
  console.log("⚠️ QVAC: no qvac.config.* found — Bare runtime will be auto-detected " +
106
65
  "from node_modules (bare-runtime, then bare). Add qvac.config.json " +
107
- 'with `bareRuntimeVersion` to pin ABI checks deterministically.');
66
+ "with `bareRuntimeVersion` to pin ABI checks deterministically.");
108
67
  }
109
- const verifyCommand = buildVerifyBundleCommand({
110
- cliCommand,
111
- bundlePath: generatedBundle,
68
+ const result = await verifyBundle({
69
+ projectRoot,
70
+ addonsSource: generatedBundle,
112
71
  hosts: MOBILE_HOSTS,
113
72
  ...(configPath ? { configPath } : {}),
114
73
  });
115
- try {
116
- execSync(verifyCommand, { stdio: "inherit", cwd: projectRoot });
117
- }
118
- catch (error) {
119
- throw new BundleVerificationFailedError(generatedBundle, error);
74
+ if (hasErrors(result)) {
75
+ throw new BundleVerificationFailedError(generatedBundle, new Error(formatVerifyBundleResult(result)));
120
76
  }
121
77
  }
122
- /** Runs qvac CLI with mobile-specific options */
123
- function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
124
- // Patch bare-kit linkers to use addons manifest
78
+ async function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
125
79
  patchBareKitLinkers(projectRoot, qvacSdkPath);
126
- const hostFlags = MOBILE_HOSTS.map((h) => `--host ${h}`).join(" ");
127
- const deferFlags = deferredModules.map((m) => `--defer "${m}"`).join(" ");
128
- const configFlag = configPath ? `--config "${configPath}"` : "";
129
- const sdkPathFlag = `--sdk-path "${qvacSdkPath}"`;
130
- const cliCommand = resolveCliCommand(projectRoot);
131
- try {
132
- execSync(`${cliCommand} bundle sdk ${sdkPathFlag} ${configFlag} ${hostFlags} ${deferFlags} --quiet`, { stdio: "inherit", cwd: projectRoot });
133
- }
134
- catch (error) {
135
- console.error("❌ QVAC: Failed to generate bundle:", error);
136
- throw error;
137
- }
80
+ await bundleSdk({
81
+ projectRoot,
82
+ sdkPath: qvacSdkPath,
83
+ ...(configPath ? { configPath } : {}),
84
+ hosts: MOBILE_HOSTS,
85
+ defer: deferredModules,
86
+ quiet: true,
87
+ });
138
88
  }
139
89
  /**
140
90
  * Patches react-native-bare-kit linkers to use the addons manifest.
141
- *
142
- * Copies the manifest-aware link.mjs files over the originals so that
143
- * bare-link only links the native addons actually required by the bundle.
144
- * This reduces app size by excluding unused native addon binaries.
145
91
  */
146
92
  function patchBareKitLinkers(projectRoot, qvacSdkPath) {
147
- const bareKitPath = path.join(projectRoot, "node_modules", "react-native-bare-kit");
148
- if (!fs.existsSync(bareKitPath)) {
149
- console.log("⚠️ QVAC: react-native-bare-kit not found, skipping linker patch");
93
+ const bareKitPath = findInAncestorNodeModules(projectRoot, "react-native-bare-kit");
94
+ if (bareKitPath === null) {
95
+ console.warn("⚠️ QVAC: react-native-bare-kit not found in any ancestor node_modules, " +
96
+ "skipping linker patch. The bundle will link all native addons " +
97
+ "rather than only those required by your bundle.");
150
98
  return;
151
99
  }
152
100
  const patchesDir = path.join(qvacSdkPath, "expo", "plugins", "patches");
@@ -154,7 +102,6 @@ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
154
102
  console.log(`⚠️ QVAC: patches directory not found (${patchesDir}), skipping linker patch`);
155
103
  return;
156
104
  }
157
- // Patch Android linker
158
105
  const androidPatch = path.join(patchesDir, "android-link.mjs");
159
106
  const androidTarget = path.join(bareKitPath, "android", "link.mjs");
160
107
  if (fs.existsSync(androidPatch)) {
@@ -164,7 +111,6 @@ function patchBareKitLinkers(projectRoot, qvacSdkPath) {
164
111
  else {
165
112
  console.log(`⚠️ QVAC: Android linker patch not found (${androidPatch})`);
166
113
  }
167
- // Patch iOS linker
168
114
  const iosPatch = path.join(patchesDir, "ios-link.mjs");
169
115
  const iosTarget = path.join(bareKitPath, "ios", "link.mjs");
170
116
  if (fs.existsSync(iosPatch)) {
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import "#polyfill-bare-globals";
2
- export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, type DiffusionProgressTick, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, suspend, resume, state, type FinetuneHandle, } from "./client/api/index";
2
+ export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, type DiffusionProgressTick, classify, video, type VideoProgressTick, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, suspend, resume, state, vla, vlaHparams, vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, type FinetuneHandle, } from "./client/api/index";
3
3
  export { close } from "./client/index";
4
- export { type LifecycleState, type ModelProgressUpdate, type LoadModelOptions, type LoadCustomPluginModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionEvent, type CompletionFinal, type CompletionRun, type CompletionStats, type EmbedStats, VERBOSITY, type Attachment, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStreamEvent, type VadStateEvent, type EndOfTurnEvent, type TranscribeSegment, type TextToSpeechStreamSession, type TextToSpeechStreamResponse, type TextToSpeechStreamClientParams, type CompletionParams, type ToolDialect, 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 GetLoadedModelInfoParams, type LoadedModelInfo, type LoadedInstance, type CacheFileInfo, toolSchema, TOOLS_MODE, type ToolsMode, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, type DiffusionClientParams, type DiffusionStreamResponse, type DiffusionStats, type UpscaleClientParams, type UpscaleStreamResponse, type UpscaleStats, definePlugin, defineHandler, defineDuplexHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, type ProfilerMode, type FinetuneValidation, type FinetuneRunParams, type FinetuneGetStateParams, type FinetuneStopParams, type FinetuneParams, type FinetuneStatus, type FinetuneProgress, type FinetuneStats, type FinetuneResult, } from "./schemas/index";
4
+ export { plugins } from "./client/plugins-factory";
5
+ export { type LifecycleState, type ModelProgressUpdate, type LoadModelOptions, type LoadCustomPluginModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionEvent, type CompletionFinal, type CompletionRun, type CompletionStats, type EmbedStats, VERBOSITY, type Attachment, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStreamEvent, type VadStateEvent, type EndOfTurnEvent, type TranscribeSegment, type TextToSpeechStreamSession, type TextToSpeechStreamResponse, type TextToSpeechStreamClientParams, type CompletionParams, type ToolDialect, 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, RAG_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type GetLoadedModelInfoParams, type LoadedModelInfo, type LoadedInstance, type CacheFileInfo, toolSchema, TOOLS_MODE, type ToolsMode, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, type ClassifyClientParams, type ClassificationResult, type DiffusionClientParams, type DiffusionStreamResponse, type DiffusionStats, type VideoClientParams, type VideoStreamResponse, type VideoStats, type UpscaleClientParams, type UpscaleStreamResponse, type UpscaleStats, type VlaConfig, type VlaClientRunParams, type VlaClientRunResult, type VlaHparams, type VlaStats, definePlugin, defineHandler, defineDuplexHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, type ProfilerMode, type FinetuneValidation, type FinetuneRunParams, type FinetuneGetStateParams, type FinetuneStopParams, type FinetuneParams, type FinetuneStatus, type FinetuneProgress, type FinetuneStats, type FinetuneResult, } from "./schemas/index";
5
6
  export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
6
7
  export { MODEL_TYPES, ModelType } from "./schemas/index";
7
8
  export * from "./models/registry/index";
8
9
  export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio";
9
10
  export { InferenceCancelledError } from "./utils/errors-server";
10
11
  export type { InferenceCancelledPartial } from "./utils/errors-server";
11
- export { RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server";
12
+ export { ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server";
12
13
  export { getLogger, SDK_LOG_ID } from "./logging/index";
13
14
  export type { Logger, LogTransport, LoggerOptions } from "./logging/index";
14
15
  export { profiler } from "./profiling/index";
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import "#polyfill-bare-globals";
2
2
  // Public API exports only
3
- export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, suspend, resume, state, } from "./client/api/index.js";
3
+ export { completion, deleteCache, loadModel, downloadAsset, heartbeat, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, finetune, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, textToSpeechStream, getModelInfo, getLoadedModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, diffusion, classify, video, upscale, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, suspend, resume, state, vla, vlaHparams, vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE, } from "./client/api/index.js";
4
4
  export { close } from "./client/index.js";
5
- export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, TOOLS_MODE, definePlugin, defineHandler, defineDuplexHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
5
+ export { plugins } from "./client/plugins-factory.js";
6
+ export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, RAG_ERROR_CODES, toolSchema, TOOLS_MODE, definePlugin, defineHandler, defineDuplexHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
6
7
  export {} from "./utils/tool-helpers.js";
7
8
  // Model types - canonical naming with backward-compatible aliases
8
9
  export { MODEL_TYPES, ModelType } from "./schemas/index.js";
@@ -28,7 +29,7 @@ export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio.js";
28
29
  // `err instanceof <Class>` works on the consumer side, not just on
29
30
  // the worker side.
30
31
  export { InferenceCancelledError } from "./utils/errors-server.js";
31
- export { RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server.js";
32
+ export { ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, } from "./utils/errors-server.js";
32
33
  // Logging exports
33
34
  export { getLogger, SDK_LOG_ID } from "./logging/index.js";
34
35
  // Profiler exports