@qvac/sdk 0.23.0 → 0.24.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 (239) hide show
  1. package/NOTICE +115 -58
  2. package/README.md +10 -13
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
  5. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  6. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  7. package/dist/examples/assess-model-fit.d.ts +7 -9
  8. package/dist/examples/assess-model-fit.js +22 -43
  9. package/dist/examples/calc-tokens.d.ts +2 -0
  10. package/dist/examples/calc-tokens.js +21 -0
  11. package/dist/examples/classification/classify-image.js +11 -5
  12. package/dist/examples/completion-stop-reason.d.ts +3 -3
  13. package/dist/examples/completion-stop-reason.js +4 -4
  14. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  15. package/dist/examples/diffusion-flux3-klein.js +102 -0
  16. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  17. package/dist/examples/diffusion-moss-image.js +126 -0
  18. package/dist/examples/diffusion-qwen-image-21.js +15 -4
  19. package/dist/examples/embed-multimodal.d.ts +2 -0
  20. package/dist/examples/embed-multimodal.js +80 -0
  21. package/dist/examples/embed-p2p.js +2 -2
  22. package/dist/examples/image/megaloc.d.ts +2 -0
  23. package/dist/examples/image/megaloc.js +37 -0
  24. package/dist/examples/llamacpp-multimodal.js +18 -0
  25. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  26. package/dist/examples/rag/rag-turbovec.js +2 -2
  27. package/dist/examples/sessions.d.ts +17 -0
  28. package/dist/examples/sessions.js +63 -0
  29. package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
  30. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  31. package/dist/scripts/contract/build-contract.d.ts +2 -1
  32. package/dist/scripts/contract/build-contract.js +13 -1
  33. package/dist/scripts/contract/constants-registry.d.ts +17 -0
  34. package/dist/scripts/contract/constants-registry.js +8 -2
  35. package/dist/scripts/contract/method-shapes.d.ts +4 -0
  36. package/dist/scripts/contract/method-shapes.js +4 -0
  37. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  38. package/dist/scripts/enforce-inference-versions.js +28 -18
  39. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  40. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  41. package/dist/src/client/api/assess-model-fit.js +18 -31
  42. package/dist/src/client/api/audio-edit.d.ts +5 -3
  43. package/dist/src/client/api/audio-edit.js +5 -3
  44. package/dist/src/client/api/audio-gen-result.js +134 -45
  45. package/dist/src/client/api/audio-gen.d.ts +40 -3
  46. package/dist/src/client/api/audio-gen.js +40 -3
  47. package/dist/src/client/api/audio-understand.d.ts +2 -2
  48. package/dist/src/client/api/audio-understand.js +2 -2
  49. package/dist/src/client/api/batch-completion.js +2 -1
  50. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  51. package/dist/src/client/api/calc-tokens.js +44 -0
  52. package/dist/src/client/api/cancel.d.ts +2 -2
  53. package/dist/src/client/api/cancel.js +2 -2
  54. package/dist/src/client/api/classify.d.ts +12 -5
  55. package/dist/src/client/api/classify.js +17 -5
  56. package/dist/src/client/api/client-request-id.d.ts +0 -15
  57. package/dist/src/client/api/client-request-id.js +15 -12
  58. package/dist/src/client/api/completion-stream.d.ts +8 -1
  59. package/dist/src/client/api/completion-stream.js +10 -1
  60. package/dist/src/client/api/delete-cache.d.ts +9 -2
  61. package/dist/src/client/api/delete-cache.js +13 -3
  62. package/dist/src/client/api/diffusion.d.ts +20 -4
  63. package/dist/src/client/api/diffusion.js +23 -5
  64. package/dist/src/client/api/embed.d.ts +82 -29
  65. package/dist/src/client/api/embed.js +64 -19
  66. package/dist/src/client/api/get-model-info.d.ts +2 -2
  67. package/dist/src/client/api/get-model-info.js +2 -2
  68. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  69. package/dist/src/client/api/get-system-resources.js +2 -2
  70. package/dist/src/client/api/heartbeat.d.ts +3 -2
  71. package/dist/src/client/api/heartbeat.js +3 -2
  72. package/dist/src/client/api/index.d.ts +4 -3
  73. package/dist/src/client/api/index.js +2 -1
  74. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  75. package/dist/src/client/api/invoke-plugin.js +17 -2
  76. package/dist/src/client/api/load-model.js +5 -2
  77. package/dist/src/client/api/ocr.d.ts +5 -3
  78. package/dist/src/client/api/ocr.js +44 -21
  79. package/dist/src/client/api/rag.d.ts +1 -1
  80. package/dist/src/client/api/rag.js +1 -1
  81. package/dist/src/client/api/registry.d.ts +17 -7
  82. package/dist/src/client/api/registry.js +37 -12
  83. package/dist/src/client/api/resume.d.ts +2 -1
  84. package/dist/src/client/api/resume.js +2 -2
  85. package/dist/src/client/api/rpc-server.d.ts +4 -4
  86. package/dist/src/client/api/rpc-server.js +10 -10
  87. package/dist/src/client/api/state.d.ts +2 -2
  88. package/dist/src/client/api/state.js +2 -2
  89. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  90. package/dist/src/client/api/subscribe-logs.js +2 -2
  91. package/dist/src/client/api/suspend.d.ts +4 -2
  92. package/dist/src/client/api/suspend.js +4 -3
  93. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  94. package/dist/src/client/api/text-to-speech.js +83 -29
  95. package/dist/src/client/api/transcribe.d.ts +6 -2
  96. package/dist/src/client/api/transcribe.js +7 -1
  97. package/dist/src/client/api/unload-model.d.ts +19 -7
  98. package/dist/src/client/api/unload-model.js +29 -11
  99. package/dist/src/client/api/upscale.d.ts +6 -3
  100. package/dist/src/client/api/upscale.js +9 -4
  101. package/dist/src/client/api/vector-index.d.ts +50 -16
  102. package/dist/src/client/api/vector-index.js +100 -48
  103. package/dist/src/client/api/video-request.d.ts +5 -5
  104. package/dist/src/client/api/video.d.ts +3 -2
  105. package/dist/src/client/api/video.js +3 -2
  106. package/dist/src/client/api/vla.d.ts +9 -5
  107. package/dist/src/client/api/vla.js +17 -8
  108. package/dist/src/client/api/world.d.ts +5 -5
  109. package/dist/src/client/api/world.js +4 -4
  110. package/dist/src/client/init-hooks.d.ts +6 -4
  111. package/dist/src/client/init-hooks.js +12 -15
  112. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  113. package/dist/src/client/logging-stream-registry.js +31 -12
  114. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  115. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  116. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  117. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  118. package/dist/src/client/rpc/expo-rpc-client.js +189 -135
  119. package/dist/src/client/rpc/node-rpc-client.js +322 -413
  120. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  121. package/dist/src/client/rpc/pear-runtime.js +12 -0
  122. package/dist/src/client/rpc/rpc-client.d.ts +5 -4
  123. package/dist/src/client/rpc/rpc-client.js +126 -23
  124. package/dist/src/client/rpc/rpc-error.js +21 -2
  125. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  126. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  127. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  128. package/dist/src/client/rpc/worker-failure.js +61 -0
  129. package/dist/src/client/session-registry.d.ts +75 -0
  130. package/dist/src/client/session-registry.js +149 -0
  131. package/dist/src/client/session.d.ts +125 -0
  132. package/dist/src/client/session.js +148 -0
  133. package/dist/src/commands/bundle/addons.d.ts +14 -0
  134. package/dist/src/commands/bundle/addons.js +65 -0
  135. package/dist/src/commands/bundle/constants.js +1 -0
  136. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  137. package/dist/src/commands/bundle/entry-gen.js +17 -50
  138. package/dist/src/commands/bundle/index.d.ts +59 -13
  139. package/dist/src/commands/bundle/index.js +345 -121
  140. package/dist/src/commands/bundle/link.d.ts +58 -0
  141. package/dist/src/commands/bundle/link.js +135 -0
  142. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  143. package/dist/src/commands/bundle/node-support.js +23 -0
  144. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  145. package/dist/src/commands/bundle/read-bundle.js +27 -0
  146. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  147. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  148. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  149. package/dist/src/commands/bundle/scratch.js +178 -0
  150. package/dist/src/commands/bundle/targets.d.ts +14 -0
  151. package/dist/src/commands/bundle/targets.js +37 -0
  152. package/dist/src/commands/host-prebuilds/index.d.ts +5 -4
  153. package/dist/src/commands/host-prebuilds/index.js +9 -7
  154. package/dist/src/commands/index.d.ts +4 -3
  155. package/dist/src/commands/verify/abi.d.ts +20 -14
  156. package/dist/src/commands/verify/abi.js +11 -79
  157. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  158. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  159. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  160. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  161. package/dist/src/commands/verify/bundle-source.js +25 -21
  162. package/dist/src/commands/verify/engines-advice.d.ts +2 -8
  163. package/dist/src/commands/verify/engines-advice.js +7 -54
  164. package/dist/src/commands/verify/index.d.ts +30 -29
  165. package/dist/src/commands/verify/index.js +92 -200
  166. package/dist/src/commands/verify/prebuilds.d.ts +3 -5
  167. package/dist/src/commands/verify/prebuilds.js +1 -2
  168. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  169. package/dist/src/commands/verify/resource-collectors.js +1 -50
  170. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  171. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  172. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  173. package/dist/src/expo/plugins/withBareKit.js +204 -0
  174. package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
  175. package/dist/src/expo/plugins/withMobileBundle.js +36 -57
  176. package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
  177. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  178. package/dist/src/index.d.ts +6 -5
  179. package/dist/src/index.js +10 -14
  180. package/dist/src/logging/utils.js +10 -2
  181. package/dist/src/plugin-ids.d.ts +2 -1
  182. package/dist/src/plugin-ids.js +2 -0
  183. package/dist/src/schemas/public.d.ts +1 -1
  184. package/dist/src/schemas/public.js +1 -1
  185. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  186. package/dist/src/schemas/sdk-errors-client.js +30 -36
  187. package/dist/src/schemas/sdk-errors-server.d.ts +11 -1
  188. package/dist/src/schemas/sdk-errors-server.js +60 -2
  189. package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
  190. package/dist/src/server/rpc/rpc-utils.js +39 -5
  191. package/dist/src/utils/errors-client.d.ts +37 -29
  192. package/dist/src/utils/errors-client.js +50 -41
  193. package/dist/src/utils/errors-server.d.ts +59 -1
  194. package/dist/src/utils/errors-server.js +110 -1
  195. package/dist/src/utils/withTimeout.js +34 -17
  196. package/dist/src/worker/handle-request.js +25 -22
  197. package/dist/src/worker/handler-utils.d.ts +2 -6
  198. package/dist/src/worker/handler-utils.js +2 -20
  199. package/dist/src/worker/index.d.ts +2 -4
  200. package/dist/src/worker/index.js +23 -35
  201. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  202. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  203. package/dist/src/worker/shim.d.ts +4 -0
  204. package/dist/src/worker/shim.js +7 -0
  205. package/dist/src/worker/start.d.ts +9 -0
  206. package/dist/src/worker/start.js +16 -0
  207. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  208. package/dist/src/worker/unbundled-shim.js +4 -0
  209. package/docs/system-resources-support-matrix.md +27 -19
  210. package/package.json +62 -51
  211. package/src/electron-forge/index.cjs +65 -91
  212. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  213. package/dist/examples/model-fit-ui/server.js +0 -221
  214. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  215. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  216. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  217. package/dist/src/client/rpc/init-timeout.js +0 -25
  218. package/dist/src/client/rpc/ipc-socket-path.d.ts +0 -11
  219. package/dist/src/client/rpc/ipc-socket-path.js +0 -30
  220. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  221. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  222. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  223. package/dist/src/commands/bundle/bare-pack.js +0 -77
  224. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  225. package/dist/src/commands/bundle/manifest.js +0 -192
  226. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  227. package/dist/src/expo/plugins/link-addons.js +0 -65
  228. package/dist/src/pear/pre.d.ts +0 -21
  229. package/dist/src/pear/pre.js +0 -450
  230. package/dist/src/server/env.d.ts +0 -22
  231. package/dist/src/server/env.js +0 -59
  232. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  233. package/dist/src/server/utils/qvac-paths.js +0 -5
  234. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  235. package/dist/src/server/utils/worker-lock.js +0 -67
  236. package/dist/src/worker/create-server.d.ts +0 -8
  237. package/dist/src/worker/create-server.js +0 -51
  238. package/dist/src/worker/lifecycle.d.ts +0 -23
  239. package/dist/src/worker/lifecycle.js +0 -149
@@ -2,31 +2,40 @@ import { promises as fsp } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import semver from 'semver';
5
- import { fetchBareKitVersionFromGitHub, fetchBareVersionFromGitHub, fetchText, REACT_NATIVE_BARE_KIT } from '../src/commands/verify/bare-kit-runtime.js';
6
- import { BARE_KIT_BARE_VERSIONS, REACT_NATIVE_BARE_KIT_RUNTIMES } from '../src/commands/verify/bare-kit-runtimes.js';
5
+ import { fetchBareVersionFromGitHub, fetchBindingBareKitFromGitHub, fetchText, NETWORK_TIMEOUT_MS } from '../src/commands/verify/bare-kit-runtime.js';
6
+ import { BARE_KIT_BARE_VERSIONS, BARE_KIT_KOTLIN_BARE_KITS, BARE_KIT_KOTLIN_WITHOUT_BARE_KIT, BARE_KIT_SWIFT_BARE_KITS, BARE_KIT_SWIFT_WITHOUT_BARE_KIT, BARE_KIT_WITHOUT_BARE } from '../src/commands/verify/bare-kit-runtimes.js';
7
7
  const CONCURRENCY = 8;
8
+ const TAGS_PER_PAGE = 100;
9
+ /** prettier-config-holepunch's printWidth, which decides when a list fits on one line. */
10
+ const PRINT_WIDTH = 100;
8
11
  const OUTPUT_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'src', 'commands', 'verify', 'bare-kit-runtimes.ts');
9
- async function listPublishedVersions() {
10
- const metadata = JSON.parse(await fetchText(`https://registry.npmjs.org/${REACT_NATIVE_BARE_KIT}`));
11
- return Object.keys(metadata.versions);
12
- }
13
- async function listBareKitTags() {
14
- const tags = JSON.parse(await fetchText('https://api.github.com/repos/holepunchto/bare-kit/tags?per_page=100'));
15
- return tags.map((tag) => tag.name.replace(/^v/, ''));
16
- }
17
- function latest(versions) {
18
- const valid = versions.filter((version) => semver.valid(version) !== null);
19
- return valid.length === 0 ? null : valid.sort(semver.rcompare)[0];
12
+ async function listTags(repo) {
13
+ const names = [];
14
+ for (let page = 1;; page++) {
15
+ const tags = JSON.parse(await fetchText(`https://api.github.com/repos/holepunchto/${repo}/tags?per_page=${TAGS_PER_PAGE}&page=${page}`));
16
+ names.push(...tags.map((tag) => tag.name.replace(/^v/, '')));
17
+ if (tags.length < TAGS_PER_PAGE)
18
+ return names;
19
+ }
20
20
  }
21
21
  /**
22
- * Releases newer than the newest one already in the table, oldest first.
23
- * Everything at or below it was probed on an earlier run, including the old
24
- * react-native-bare-kit releases that have no CMakeLists.txt to parse.
22
+ * A release without the file reads as empty, so it parses as naming no
23
+ * version. Any other failure throws, so it is never recorded as a release
24
+ * without a version.
25
25
  */
26
- function newerThan(versions, lastKnown) {
26
+ async function fetchReleaseFile(url) {
27
+ const response = await fetch(url, { signal: AbortSignal.timeout(NETWORK_TIMEOUT_MS) });
28
+ if (response.status === 404)
29
+ return '';
30
+ if (!response.ok)
31
+ throw new Error(`GET ${url} returned HTTP ${response.status}`);
32
+ return response.text();
33
+ }
34
+ /** Releases not yet in the table or the list of releases without a version, oldest first. */
35
+ function unchecked(versions, table, without) {
27
36
  return versions
28
37
  .filter((version) => semver.valid(version) !== null)
29
- .filter((version) => lastKnown === null || semver.gt(version, lastKnown))
38
+ .filter((version) => table[version] === undefined && !without.has(version))
30
39
  .sort(semver.compare);
31
40
  }
32
41
  async function mapConcurrent(items, fn) {
@@ -41,66 +50,89 @@ async function mapConcurrent(items, fn) {
41
50
  await Promise.all(Array.from({ length: CONCURRENCY }, worker));
42
51
  return results;
43
52
  }
44
- async function tryFetch(fn) {
45
- try {
46
- return await fn();
47
- }
48
- catch {
49
- return null;
50
- }
53
+ /**
54
+ * Adds each release of `repo` not checked before to `table` with the version
55
+ * `lookUp` finds, or to `without` when its CMakeLists.txt names none.
56
+ */
57
+ async function extend(table, without, repo, lookUp) {
58
+ const versions = unchecked(await listTags(repo), table, without);
59
+ console.log(`Resolving ${versions.length} new ${repo} releases...`);
60
+ const found = await mapConcurrent(versions, lookUp);
61
+ versions.forEach((version, index) => {
62
+ const value = found[index];
63
+ if (value)
64
+ table[version] = value;
65
+ else
66
+ without.add(version);
67
+ });
68
+ }
69
+ function bindingLookUp(binding) {
70
+ return (version) => fetchBindingBareKitFromGitHub(binding, version, fetchReleaseFile);
51
71
  }
52
72
  function sortedEntries(record) {
53
73
  return Object.entries(record).sort(([a], [b]) => semver.compare(a, b));
54
74
  }
55
- function render(runtimes, bareByBareKit) {
56
- const lines = [
75
+ /** Object entries in the repo's Prettier style: no trailing comma. */
76
+ function entryLines(record) {
77
+ const entries = sortedEntries(record).map(([key, value]) => `'${key}': '${value}'`);
78
+ return entries.map((entry, index) => ` ${entry}${index === entries.length - 1 ? '' : ','}`);
79
+ }
80
+ function table(doc, name, record) {
81
+ return [
82
+ `/** ${doc} */`,
83
+ `export const ${name}: Record<string, string> = {`,
84
+ ...entryLines(record),
85
+ '}'
86
+ ];
87
+ }
88
+ /** A string array in the repo's Prettier style: on one line when it fits. */
89
+ function list(doc, name, versions) {
90
+ const items = [...versions].sort(semver.compare).map((version) => `'${version}'`);
91
+ const head = `export const ${name}: string[] = [`;
92
+ const oneLine = `${head}${items.join(', ')}]`;
93
+ if (oneLine.length <= PRINT_WIDTH)
94
+ return [`/** ${doc} */`, oneLine];
95
+ return [
96
+ `/** ${doc} */`,
97
+ head,
98
+ ...items.map((item, index) => ` ${item}${index === items.length - 1 ? '' : ','}`),
99
+ ']'
100
+ ];
101
+ }
102
+ function render(tables) {
103
+ return [
57
104
  '// Generated by scripts/generate-bare-kit-runtimes.ts. Do not edit by hand.',
58
105
  '',
59
- 'export interface BareKitRuntime {',
60
- ' bareKit: string',
61
- ' bare: string',
62
- '}',
106
+ ...table('bare-kit release each bare-kit-kotlin release is built from.', 'BARE_KIT_KOTLIN_BARE_KITS', tables.kotlin),
63
107
  '',
64
- '/**',
65
- ' * react-native-bare-kit releases whose CMakeLists.txt names the bare-kit',
66
- ' * prebuilds it ships. Older releases carry no such reference.',
67
- ' */',
68
- 'export const REACT_NATIVE_BARE_KIT_RUNTIMES: Record<string, BareKitRuntime> = {'
69
- ];
70
- lines.push(...entryLines(sortedEntries(runtimes).map(([version, runtime]) => `'${version}': { bareKit: '${runtime.bareKit}', bare: '${runtime.bare}' }`)));
71
- lines.push('}', '', '/** Bare version each bare-kit release is built against. */');
72
- lines.push('export const BARE_KIT_BARE_VERSIONS: Record<string, string> = {');
73
- lines.push(...entryLines(sortedEntries(bareByBareKit).map(([bareKit, bare]) => `'${bareKit}': '${bare}'`)));
74
- lines.push('}', '');
75
- return lines.join('\n');
76
- }
77
- /** Object entries in the repo's Prettier style: no trailing comma. */
78
- function entryLines(entries) {
79
- return entries.map((entry, index) => ` ${entry}${index === entries.length - 1 ? '' : ','}`);
108
+ ...list('bare-kit-kotlin releases whose CMakeLists.txt names no bare-kit version.', 'BARE_KIT_KOTLIN_WITHOUT_BARE_KIT', tables.kotlinWithout),
109
+ '',
110
+ ...table('bare-kit release each bare-kit-swift release is built from.', 'BARE_KIT_SWIFT_BARE_KITS', tables.swift),
111
+ '',
112
+ ...list('bare-kit-swift releases whose CMakeLists.txt names no bare-kit version.', 'BARE_KIT_SWIFT_WITHOUT_BARE_KIT', tables.swiftWithout),
113
+ '',
114
+ ...table('Bare version each bare-kit release is built against.', 'BARE_KIT_BARE_VERSIONS', tables.bare),
115
+ '',
116
+ ...list('bare-kit releases whose CMakeLists.txt names no Bare version.', 'BARE_KIT_WITHOUT_BARE', tables.bareWithout),
117
+ ''
118
+ ].join('\n');
80
119
  }
81
120
  async function main() {
82
121
  const full = process.argv.includes('--full');
83
- const bareByBareKit = full ? {} : { ...BARE_KIT_BARE_VERSIONS };
84
- const runtimes = full ? {} : { ...REACT_NATIVE_BARE_KIT_RUNTIMES };
85
- const bareKitTags = newerThan(await listBareKitTags(), latest(Object.keys(bareByBareKit)));
86
- console.log(`Resolving ${bareKitTags.length} new bare-kit releases...`);
87
- const bareVersions = await mapConcurrent(bareKitTags, (bareKit) => tryFetch(() => fetchBareVersionFromGitHub(bareKit)));
88
- bareKitTags.forEach((bareKit, index) => {
89
- const bare = bareVersions[index];
90
- if (bare)
91
- bareByBareKit[bareKit] = bare;
92
- });
93
- const versions = newerThan(await listPublishedVersions(), latest(Object.keys(runtimes)));
94
- console.log(`Resolving ${versions.length} new ${REACT_NATIVE_BARE_KIT} releases...`);
95
- const bareKitByVersion = await mapConcurrent(versions, (version) => tryFetch(() => fetchBareKitVersionFromGitHub(version)));
96
- versions.forEach((version, index) => {
97
- const bareKit = bareKitByVersion[index];
98
- const bare = bareKit ? bareByBareKit[bareKit] : undefined;
99
- if (bareKit && bare)
100
- runtimes[version] = { bareKit, bare };
101
- });
102
- await fsp.writeFile(OUTPUT_PATH, render(runtimes, bareByBareKit));
103
- console.log(`Wrote ${Object.keys(runtimes).length} ${REACT_NATIVE_BARE_KIT} and ` +
104
- `${Object.keys(bareByBareKit).length} bare-kit entries to ${OUTPUT_PATH}`);
122
+ const tables = {
123
+ kotlin: full ? {} : { ...BARE_KIT_KOTLIN_BARE_KITS },
124
+ kotlinWithout: new Set(full ? [] : BARE_KIT_KOTLIN_WITHOUT_BARE_KIT),
125
+ swift: full ? {} : { ...BARE_KIT_SWIFT_BARE_KITS },
126
+ swiftWithout: new Set(full ? [] : BARE_KIT_SWIFT_WITHOUT_BARE_KIT),
127
+ bare: full ? {} : { ...BARE_KIT_BARE_VERSIONS },
128
+ bareWithout: new Set(full ? [] : BARE_KIT_WITHOUT_BARE)
129
+ };
130
+ await extend(tables.bare, tables.bareWithout, 'bare-kit', (version) => fetchBareVersionFromGitHub(version, fetchReleaseFile));
131
+ await extend(tables.kotlin, tables.kotlinWithout, 'bare-kit-kotlin', bindingLookUp('bare-kit-kotlin'));
132
+ await extend(tables.swift, tables.swiftWithout, 'bare-kit-swift', bindingLookUp('bare-kit-swift'));
133
+ await fsp.writeFile(OUTPUT_PATH, render(tables));
134
+ console.log(`Wrote ${Object.keys(tables.kotlin).length} bare-kit-kotlin, ` +
135
+ `${Object.keys(tables.swift).length} bare-kit-swift and ` +
136
+ `${Object.keys(tables.bare).length} bare-kit entries to ${OUTPUT_PATH}`);
105
137
  }
106
138
  await main();
@@ -1,23 +1,23 @@
1
- import { type AssessModelFitInput, type AssessModelFitResult } from '@qvac/inference/surface';
1
+ import { type AssessModelFitInput, type AssessModelFitResult, type RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
- * Assesses, before anything is downloaded, whether the given models are likely
4
- * to fit in this device's memory.
3
+ * Whether a set of models fits in this device's memory when loaded together,
4
+ * without downloading them.
5
5
  *
6
- * Advisory only: it does not download weights, block `loadModel`, reserve
7
- * memory, or make a performance claim. `unknown` is a real answer — it means
8
- * the available evidence does not support a verdict either way, and callers
9
- * should treat it as "cannot say", not "no".
6
+ * Each model's engine fitter runs against the registry's weightless description
7
+ * of the model, or the model itself when it is on disk. The memory each load
8
+ * takes is summed per device and compared against what is free.
10
9
  *
11
- * For each candidate it fetches the registry's weightless description of every
12
- * source that load names — tens of KB each, never the weights — and runs the
13
- * engine's own fitter against them, reported as `native-fit` evidence. Where
14
- * that is unavailable the computed floor stands, which can refuse a model but
15
- * never confirm one.
10
+ * `unknown` is the answer for a load that would start but cannot be sized: an
11
+ * engine with no fitter, a load the fitter cannot project, a model with no
12
+ * registry description that is not on disk, or a device that reported no free
13
+ * memory.
16
14
  *
17
- * @param input - Loads to assess in `loadModel`'s own parameters, the declared
18
- * execution mode, and the headroom policy.
19
- * @returns Per-model and combined verdicts, with the budget and bounds they came
20
- * from, plus every assumption that was made.
15
+ * @param input - The models, each as `loadModel` takes it.
16
+ * @returns The verdict for the set, the memory pools it was judged on, and
17
+ * each model's addon result: its status, device rows and stats.
18
+ * @throws The error `loadModel` would throw for a load it refuses: no plugin
19
+ * for the model type, a config the plugin refuses, or a model the fitter
20
+ * cannot read.
21
21
  */
22
- export declare function assessModelFit(input: AssessModelFitInput): Promise<AssessModelFitResult>;
22
+ export declare function assessModelFit(input: AssessModelFitInput, options?: RPCOptions): Promise<AssessModelFitResult>;
23
23
  //# sourceMappingURL=assess-model-fit.d.ts.map
@@ -15,47 +15,34 @@ function withModelType(candidate) {
15
15
  return { ...candidate, modelType: inferred };
16
16
  }
17
17
  /**
18
- * Assesses, before anything is downloaded, whether the given models are likely
19
- * to fit in this device's memory.
18
+ * Whether a set of models fits in this device's memory when loaded together,
19
+ * without downloading them.
20
20
  *
21
- * Advisory only: it does not download weights, block `loadModel`, reserve
22
- * memory, or make a performance claim. `unknown` is a real answer — it means
23
- * the available evidence does not support a verdict either way, and callers
24
- * should treat it as "cannot say", not "no".
21
+ * Each model's engine fitter runs against the registry's weightless description
22
+ * of the model, or the model itself when it is on disk. The memory each load
23
+ * takes is summed per device and compared against what is free.
25
24
  *
26
- * For each candidate it fetches the registry's weightless description of every
27
- * source that load names — tens of KB each, never the weights — and runs the
28
- * engine's own fitter against them, reported as `native-fit` evidence. Where
29
- * that is unavailable the computed floor stands, which can refuse a model but
30
- * never confirm one.
25
+ * `unknown` is the answer for a load that would start but cannot be sized: an
26
+ * engine with no fitter, a load the fitter cannot project, a model with no
27
+ * registry description that is not on disk, or a device that reported no free
28
+ * memory.
31
29
  *
32
- * @param input - Loads to assess in `loadModel`'s own parameters, the declared
33
- * execution mode, and the headroom policy.
34
- * @returns Per-model and combined verdicts, with the budget and bounds they came
35
- * from, plus every assumption that was made.
30
+ * @param input - The models, each as `loadModel` takes it.
31
+ * @returns The verdict for the set, the memory pools it was judged on, and
32
+ * each model's addon result: its status, device rows and stats.
33
+ * @throws The error `loadModel` would throw for a load it refuses: no plugin
34
+ * for the model type, a config the plugin refuses, or a model the fitter
35
+ * cannot read.
36
36
  */
37
- export async function assessModelFit(input) {
37
+ export async function assessModelFit(input, options) {
38
38
  const parsed = assessModelFitInputSchema.parse({
39
39
  ...input,
40
40
  models: input.models.map(withModelType)
41
41
  });
42
42
  const request = { type: 'assessModelFit', ...parsed };
43
- const response = await send(request);
43
+ const response = await send(request, options);
44
44
  if (response.type !== 'assessModelFit') {
45
45
  throw new InvalidResponseError('assessModelFit');
46
46
  }
47
- // Rebuilt field by field rather than by rest-destructuring the discriminant,
48
- // matching the other client wrappers and keeping optionals absent rather than
49
- // explicitly undefined.
50
- return {
51
- verdict: response.verdict,
52
- basis: response.basis,
53
- execution: response.execution,
54
- ...(response.evidence && { evidence: response.evidence }),
55
- ...(response.budget && { budget: response.budget }),
56
- ...(response.floorBytes !== undefined && { floorBytes: response.floorBytes }),
57
- models: response.models,
58
- reasons: response.reasons,
59
- assumptions: response.assumptions
60
- };
47
+ return { verdict: response.verdict, pools: response.pools, models: response.models };
61
48
  }
@@ -1,4 +1,4 @@
1
- import type { AudioEditClientParams, AudioGenResult } from '@qvac/inference/surface';
1
+ import type { AudioEditClientParams, AudioGenResult, RPCOptions } from '@qvac/inference/surface';
2
2
  /**
3
3
  * Edits a source recording with a loaded ACE-Step AudioGen model: an ordered
4
4
  * pipeline of `flow-edit` and `repaint` operations, executed in array order.
@@ -20,7 +20,9 @@ import type { AudioEditClientParams, AudioGenResult } from '@qvac/inference/surf
20
20
  * `repaint` regenerates the `start`..`end` range (seconds) against a new `caption`, keeping the
21
21
  * rest of the clip. Operations may repeat or mix.
22
22
  * @param params.seed - Seeds the first operation; each following operation uses `seed + index`.
23
- * @returns The same run shape as `audioGen()`: a synchronous request ID, generation progress stream, PCM audio promise, stats promise, and diagnostics promise. `stats.metadata.seed` reports the base seed the edit used.
23
+ * @param params.outputFormat - Also deliver the edited audio as a file in this container, through
24
+ * `run.encoded`, as on a generation.
25
+ * @returns The same run shape as `audioGen()`: a synchronous request ID, generation progress stream, PCM audio promise, `chunkStream`, `encoded`, stats promise, and diagnostics promise. `stats.metadata.seed` reports the base seed the edit used.
24
26
  *
25
27
  * @example
26
28
  * ```typescript
@@ -44,5 +46,5 @@ import type { AudioEditClientParams, AudioGenResult } from '@qvac/inference/surf
44
46
  * const { pcm, sampleRate, channels, bitsPerSample } = await run.audio;
45
47
  * ```
46
48
  */
47
- export declare function audioEdit(params: AudioEditClientParams): AudioGenResult;
49
+ export declare function audioEdit(params: AudioEditClientParams, options?: RPCOptions): AudioGenResult;
48
50
  //# sourceMappingURL=audio-edit.d.ts.map
@@ -21,7 +21,9 @@ import { createAudioEditResult } from '../../client/api/audio-gen-result.js';
21
21
  * `repaint` regenerates the `start`..`end` range (seconds) against a new `caption`, keeping the
22
22
  * rest of the clip. Operations may repeat or mix.
23
23
  * @param params.seed - Seeds the first operation; each following operation uses `seed + index`.
24
- * @returns The same run shape as `audioGen()`: a synchronous request ID, generation progress stream, PCM audio promise, stats promise, and diagnostics promise. `stats.metadata.seed` reports the base seed the edit used.
24
+ * @param params.outputFormat - Also deliver the edited audio as a file in this container, through
25
+ * `run.encoded`, as on a generation.
26
+ * @returns The same run shape as `audioGen()`: a synchronous request ID, generation progress stream, PCM audio promise, `chunkStream`, `encoded`, stats promise, and diagnostics promise. `stats.metadata.seed` reports the base seed the edit used.
25
27
  *
26
28
  * @example
27
29
  * ```typescript
@@ -45,6 +47,6 @@ import { createAudioEditResult } from '../../client/api/audio-gen-result.js';
45
47
  * const { pcm, sampleRate, channels, bitsPerSample } = await run.audio;
46
48
  * ```
47
49
  */
48
- export function audioEdit(params) {
49
- return createAudioEditResult(params, streamRpc);
50
+ export function audioEdit(params, options) {
51
+ return createAudioEditResult(params, (request) => streamRpc(request, options));
50
52
  }
@@ -3,7 +3,66 @@ import { parseClientInput } from '../../client/parse-input.js';
3
3
  import { generateClientRequestId } from '../../client/api/client-request-id.js';
4
4
  import { decodeBase64 } from '../../utils/encoding.js';
5
5
  import { InvalidResponseError } from '../../utils/errors-client.js';
6
- import { InferenceCancelledError } from '../../utils/errors-server.js';
6
+ import { AudioEncodeFailedError, InferenceCancelledError } from '../../utils/errors-server.js';
7
+ /**
8
+ * A queue one consumer drains as an async generator. It ends when the run
9
+ * does, and throws the run's error once the queued items are delivered.
10
+ */
11
+ function createFeed() {
12
+ const queue = [];
13
+ let closed = false;
14
+ let failure;
15
+ let wake;
16
+ function notify() {
17
+ wake?.();
18
+ wake = undefined;
19
+ }
20
+ async function* drain() {
21
+ while (true) {
22
+ if (queue.length > 0) {
23
+ yield queue.shift();
24
+ continue;
25
+ }
26
+ if (closed) {
27
+ if (failure !== undefined)
28
+ throw failure;
29
+ return;
30
+ }
31
+ await new Promise((resolve) => {
32
+ wake = resolve;
33
+ });
34
+ }
35
+ }
36
+ return {
37
+ push(item) {
38
+ queue.push(item);
39
+ notify();
40
+ },
41
+ close(error) {
42
+ closed = true;
43
+ failure = error;
44
+ notify();
45
+ },
46
+ stream: drain()
47
+ };
48
+ }
49
+ /**
50
+ * Copies one PCM frame into its own `Int16Array`. The copy keeps a caller
51
+ * that edits a chunk in place from changing `audio`, and gives the samples
52
+ * the alignment a view over the decoded bytes might lack.
53
+ */
54
+ function toInt16Chunk(bytes, wireType) {
55
+ if (bytes.byteLength % Int16Array.BYTES_PER_ELEMENT !== 0) {
56
+ throw new InvalidResponseError(`${wireType} audio chunk`);
57
+ }
58
+ const samples = new Int16Array(bytes.byteLength / Int16Array.BYTES_PER_ELEMENT);
59
+ new Uint8Array(samples.buffer).set(bytes);
60
+ return samples;
61
+ }
62
+ async function* int16Chunks(indexes, read, wireType) {
63
+ for await (const index of indexes)
64
+ yield toInt16Chunk(read(index), wireType);
65
+ }
7
66
  function concatenateChunks(chunks) {
8
67
  const totalLength = chunks.reduce((total, chunk) => total + chunk.length, 0);
9
68
  const pcm = new Uint8Array(totalLength);
@@ -22,7 +81,7 @@ export function createAudioGenResult(params, streamFactory) {
22
81
  type: 'audioGenStream',
23
82
  requestId
24
83
  };
25
- return collectAudioRun(requestId, 'audioGenStream', audioGenStreamResponseSchema, () => streamFactory(request));
84
+ return collectAudioRun(requestId, 'audioGenStream', audioGenStreamResponseSchema, () => streamFactory(request), request.outputFormat !== undefined);
26
85
  }
27
86
  export function createAudioEditResult(params, streamFactory) {
28
87
  const parsed = parseClientInput(audioEditClientParamsSchema, params);
@@ -32,7 +91,7 @@ export function createAudioEditResult(params, streamFactory) {
32
91
  type: 'audioEditStream',
33
92
  requestId
34
93
  };
35
- return collectAudioRun(requestId, 'audioEditStream', audioEditStreamResponseSchema, () => streamFactory(request));
94
+ return collectAudioRun(requestId, 'audioEditStream', audioEditStreamResponseSchema, () => streamFactory(request), request.outputFormat !== undefined);
36
95
  }
37
96
  export function createAudioUnderstandResult(params, streamFactory) {
38
97
  const parsed = parseClientInput(audioUnderstandClientParamsSchema, params);
@@ -45,10 +104,7 @@ export function createAudioUnderstandResult(params, streamFactory) {
45
104
  return collectUnderstandRun(requestId, () => streamFactory(request));
46
105
  }
47
106
  function collectRun(requestId, wireType, responseSchema, open, sink) {
48
- const progressQueue = [];
49
- let progressDone = false;
50
- let progressError;
51
- let progressResolve;
107
+ const progress = createFeed();
52
108
  let resolvePayload = () => { };
53
109
  let rejectPayload = () => { };
54
110
  const payload = new Promise((resolve, reject) => {
@@ -70,10 +126,6 @@ function collectRun(requestId, wireType, responseSchema, open, sink) {
70
126
  rejectDiagnostics = reject;
71
127
  });
72
128
  diagnostics.catch(() => { });
73
- function notifyProgress() {
74
- progressResolve?.();
75
- progressResolve = undefined;
76
- }
77
129
  function rejectAll(error) {
78
130
  rejectPayload(error);
79
131
  rejectStats(error);
@@ -81,6 +133,7 @@ function collectRun(requestId, wireType, responseSchema, open, sink) {
81
133
  }
82
134
  async function processResponses() {
83
135
  let receivedDone = false;
136
+ let failure;
84
137
  try {
85
138
  for await (const response of open()) {
86
139
  if (!response ||
@@ -90,10 +143,8 @@ function collectRun(requestId, wireType, responseSchema, open, sink) {
90
143
  continue;
91
144
  }
92
145
  const frame = responseSchema.parse(response);
93
- if (frame.progress) {
94
- progressQueue.push(frame.progress);
95
- notifyProgress();
96
- }
146
+ if (frame.progress)
147
+ progress.push(frame.progress);
97
148
  sink.absorb(frame);
98
149
  if (frame.done) {
99
150
  receivedDone = true;
@@ -113,33 +164,16 @@ function collectRun(requestId, wireType, responseSchema, open, sink) {
113
164
  }
114
165
  }
115
166
  catch (error) {
116
- progressError = error instanceof Error ? error : new InvalidResponseError(wireType, error);
117
- rejectAll(progressError);
167
+ failure = error instanceof Error ? error : new InvalidResponseError(wireType, error);
168
+ rejectAll(failure);
118
169
  }
119
170
  finally {
120
- progressDone = true;
121
- notifyProgress();
122
- }
123
- }
124
- async function* progressStream() {
125
- while (true) {
126
- const tick = progressQueue.shift();
127
- if (tick) {
128
- yield tick;
129
- continue;
130
- }
131
- if (progressDone) {
132
- if (progressError !== undefined)
133
- throw progressError;
134
- return;
135
- }
136
- await new Promise((resolve) => {
137
- progressResolve = resolve;
138
- });
171
+ progress.close(failure);
172
+ sink.close?.(failure);
139
173
  }
140
174
  }
141
175
  void processResponses();
142
- return { requestId, progressStream: progressStream(), payload, stats, diagnostics };
176
+ return { requestId, progressStream: progress.stream, payload, stats, diagnostics };
143
177
  }
144
178
  /**
145
179
  * Consumes an `audioUnderstand()` stream: the engine streams the description
@@ -164,18 +198,44 @@ function collectUnderstandRun(requestId, openStream) {
164
198
  }
165
199
  /**
166
200
  * Consumes one generation or editing stream: PCM chunks accumulate into
167
- * `audio`, carrying the format reported alongside them.
201
+ * `audio`, carrying the format reported alongside them, and are offered one
202
+ * by one on `chunkStream`. The encoded file, when the request asked for one,
203
+ * settles `encoded`; a failed encode rejects `encoded` and nothing else.
168
204
  */
169
- function collectAudioRun(requestId, wireType, responseSchema, open) {
205
+ function collectAudioRun(requestId, wireType, responseSchema, open, expectsEncoded) {
170
206
  const pcmChunks = [];
171
207
  let sampleRate;
172
208
  let channels;
173
209
  let bitsPerSample;
210
+ let encoded;
211
+ let encodeFailure;
212
+ // The PCM is held once. Until the run settles it is the received chunks;
213
+ // from then on it is `audio.pcm` alone, and the chunks are views into it.
214
+ // `chunkStream` queues chunk indexes rather than bytes, so an unread
215
+ // stream keeps no second copy of the audio alive.
216
+ let settledPcm;
217
+ const chunkEnds = [];
218
+ const chunks = createFeed();
219
+ function chunkBytes(index) {
220
+ if (settledPcm === undefined)
221
+ return pcmChunks[index] ?? new Uint8Array(0);
222
+ const start = index > 0 ? (chunkEnds[index - 1] ?? 0) : 0;
223
+ return settledPcm.subarray(start, chunkEnds[index] ?? start);
224
+ }
174
225
  const { progressStream, payload, stats, diagnostics } = collectRun(requestId, wireType, responseSchema, open, {
175
226
  absorb(frame) {
227
+ if (frame.encoded !== undefined) {
228
+ encoded = { ...frame.encoded, data: decodeBase64(frame.encoded.data) };
229
+ }
230
+ if (frame.encodeError !== undefined) {
231
+ encodeFailure = new AudioEncodeFailedError(frame.encodeError.format, frame.encodeError.details);
232
+ }
176
233
  if (frame.data === undefined)
177
234
  return;
178
- pcmChunks.push(decodeBase64(frame.data));
235
+ const bytes = decodeBase64(frame.data);
236
+ chunks.push(pcmChunks.length);
237
+ pcmChunks.push(bytes);
238
+ chunkEnds.push((chunkEnds.at(-1) ?? 0) + bytes.byteLength);
179
239
  sampleRate = frame.sampleRate;
180
240
  channels = frame.channels;
181
241
  bitsPerSample = frame.bitsPerSample;
@@ -184,13 +244,42 @@ function collectAudioRun(requestId, wireType, responseSchema, open) {
184
244
  if (sampleRate === undefined || channels === undefined || bitsPerSample === undefined) {
185
245
  throw new InvalidResponseError(`${wireType} audio chunk`);
186
246
  }
247
+ if (expectsEncoded && encoded === undefined && encodeFailure === undefined) {
248
+ throw new InvalidResponseError(`${wireType} encoded audio`);
249
+ }
250
+ settledPcm = concatenateChunks(pcmChunks);
251
+ pcmChunks.length = 0;
187
252
  return {
188
- pcm: concatenateChunks(pcmChunks),
189
- sampleRate,
190
- channels,
191
- bitsPerSample
253
+ audio: {
254
+ pcm: settledPcm,
255
+ sampleRate,
256
+ channels,
257
+ bitsPerSample
258
+ },
259
+ encoded,
260
+ encodeFailure
192
261
  };
262
+ },
263
+ close(error) {
264
+ chunks.close(error);
193
265
  }
194
266
  });
195
- return { requestId, progressStream, audio: payload, stats, diagnostics };
267
+ const audio = payload.then((settled) => settled.audio);
268
+ // A failed encode rejects the file alone; the run itself completed.
269
+ const encodedAudio = payload.then((settled) => {
270
+ if (settled.encodeFailure !== undefined)
271
+ throw settled.encodeFailure;
272
+ return settled.encoded;
273
+ });
274
+ audio.catch(() => { });
275
+ encodedAudio.catch(() => { });
276
+ return {
277
+ requestId,
278
+ progressStream,
279
+ chunkStream: int16Chunks(chunks.stream, chunkBytes, wireType),
280
+ audio,
281
+ encoded: encodedAudio,
282
+ stats,
283
+ diagnostics
284
+ };
196
285
  }