@qvac/sdk 0.19.1 → 0.20.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 (75) hide show
  1. package/NOTICE +78 -55
  2. package/README.md +3 -1
  3. package/dist/examples/abot-world.js +3 -3
  4. package/dist/examples/advisory-model-fit.d.ts +59 -0
  5. package/dist/examples/advisory-model-fit.js +156 -0
  6. package/dist/examples/asr/parakeet-nemotron-filesystem.d.ts +2 -0
  7. package/dist/examples/asr/parakeet-nemotron-filesystem.js +170 -0
  8. package/dist/examples/audiogen/edit-music.d.ts +2 -0
  9. package/dist/examples/audiogen/edit-music.js +121 -0
  10. package/dist/examples/audiogen/understand-music.d.ts +2 -0
  11. package/dist/examples/audiogen/understand-music.js +73 -0
  12. package/dist/examples/diffusion-ic-lora-ltx.js +3 -3
  13. package/dist/examples/diffusion-img2vid.js +1 -1
  14. package/dist/examples/diffusion-txt2vid-minimax-h3.d.ts +2 -0
  15. package/dist/examples/diffusion-txt2vid-minimax-h3.js +64 -0
  16. package/dist/examples/diffusion-txt2vid.js +1 -1
  17. package/dist/examples/rag/rag-turbovec.d.ts +2 -0
  18. package/dist/examples/rag/rag-turbovec.js +58 -0
  19. package/dist/examples/tts/audio8.js +5 -5
  20. package/dist/examples/tts/chatterbox-enhanced.js +4 -5
  21. package/dist/examples/tts/chatterbox-multilingual.js +5 -5
  22. package/dist/examples/tts/chatterbox.js +5 -5
  23. package/dist/examples/tts/cosyvoice3.js +5 -5
  24. package/dist/examples/tts/llm-to-tts-streaming.js +12 -2
  25. package/dist/examples/tts/parler.js +5 -5
  26. package/dist/examples/tts/supertonic-enhanced.js +4 -5
  27. package/dist/examples/tts/supertonic-multilingual.js +5 -5
  28. package/dist/examples/tts/supertonic.js +5 -5
  29. package/dist/scripts/contract/build-contract.d.ts +1 -1
  30. package/dist/scripts/contract/constants-registry.d.ts +31 -0
  31. package/dist/scripts/contract/constants-registry.js +13 -2
  32. package/dist/scripts/contract/method-shapes.d.ts +3 -0
  33. package/dist/scripts/contract/method-shapes.js +3 -0
  34. package/dist/src/client/api/assess-model-fit.d.ts +9 -4
  35. package/dist/src/client/api/assess-model-fit.js +9 -4
  36. package/dist/src/client/api/audio-edit.d.ts +36 -0
  37. package/dist/src/client/api/audio-edit.js +38 -0
  38. package/dist/src/client/api/audio-gen-result.d.ts +5 -1
  39. package/dist/src/client/api/audio-gen-result.js +105 -52
  40. package/dist/src/client/api/audio-gen.d.ts +38 -1
  41. package/dist/src/client/api/audio-gen.js +38 -1
  42. package/dist/src/client/api/audio-understand.d.ts +25 -0
  43. package/dist/src/client/api/audio-understand.js +27 -0
  44. package/dist/src/client/api/index.d.ts +3 -0
  45. package/dist/src/client/api/index.js +3 -0
  46. package/dist/src/client/api/text-to-speech.d.ts +31 -4
  47. package/dist/src/client/api/text-to-speech.js +118 -21
  48. package/dist/src/client/api/vector-index.d.ts +143 -0
  49. package/dist/src/client/api/vector-index.js +168 -0
  50. package/dist/src/client/api/world.d.ts +2 -2
  51. package/dist/src/commands/bundle/manifest.d.ts +2 -0
  52. package/dist/src/commands/verify/addon-source.d.ts +6 -0
  53. package/dist/src/commands/verify/bundle-source.d.ts +2 -0
  54. package/dist/src/commands/verify/bundle-source.js +155 -1
  55. package/dist/src/commands/verify/index.js +1 -0
  56. package/dist/src/commands/verify/prebuilds.d.ts +23 -0
  57. package/dist/src/commands/verify/prebuilds.js +129 -13
  58. package/dist/src/commands/verify/resource-collectors.js +2 -1
  59. package/dist/src/expo/plugins/patches/qvac-platform-addons.d.ts +23 -0
  60. package/dist/src/expo/plugins/patches/qvac-platform-addons.js +94 -0
  61. package/dist/src/expo/plugins/withMobileBundle.d.ts +9 -6
  62. package/dist/src/expo/plugins/withMobileBundle.js +54 -34
  63. package/dist/src/index.d.ts +3 -3
  64. package/dist/src/index.js +7 -3
  65. package/dist/src/schemas/sdk-errors-server.d.ts +4 -0
  66. package/dist/src/schemas/sdk-errors-server.js +22 -0
  67. package/dist/src/utils/aggregate-events.d.ts +3 -1
  68. package/dist/src/utils/aggregate-events.js +7 -1
  69. package/dist/src/utils/errors-server.d.ts +12 -0
  70. package/dist/src/utils/errors-server.js +21 -0
  71. package/package.json +23 -17
  72. package/src/electron-forge/index.cjs +86 -14
  73. package/src/expo/plugins/patches/android-link.mjs +18 -9
  74. package/src/expo/plugins/patches/ios-link.mjs +18 -9
  75. package/src/expo/plugins/patches/qvac-platform-addons.ts +124 -0
@@ -5,12 +5,15 @@
5
5
  * Otherwise, falls back to linking all installed addons.
6
6
  *
7
7
  * This file is copied over react-native-bare-kit/android/link.mjs
8
- * by withMobileBundle.ts during expo prebuild.
8
+ * by withMobileBundle.ts during expo prebuild. The resolver it imports is
9
+ * compiled from qvac-platform-addons.ts and installed beside this file as
10
+ * qvac-platform-addons.mjs.
9
11
  */
10
12
  import fs from 'fs'
11
13
  import path from 'path'
12
14
  import { fileURLToPath } from 'url'
13
15
  import link from 'bare-link'
16
+ import { resolvePlatformAddonRoots } from './qvac-platform-addons.mjs'
14
17
 
15
18
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
16
19
  const projectRoot = path.join(__dirname, '..', '..', '..')
@@ -24,10 +27,12 @@ if (fs.existsSync(addonsDir)) {
24
27
  const manifestPath = path.join(projectRoot, 'qvac', 'addons.manifest.json')
25
28
 
26
29
  let pkg = null
30
+ let addonNames = []
27
31
  if (fs.existsSync(manifestPath)) {
28
32
  try {
29
33
  const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
30
34
  const addons = Array.isArray(manifest.addons) ? manifest.addons : []
35
+ addonNames = addons
31
36
 
32
37
  if (addons.length > 0) {
33
38
  console.log(`[QVAC] Using addons manifest (${addons.length} addons): ${addons.join(', ')}`)
@@ -46,13 +51,17 @@ if (fs.existsSync(manifestPath)) {
46
51
  console.log('[QVAC] No addons manifest found, linking all addons')
47
52
  }
48
53
 
49
- for await (const resource of link(
50
- projectRoot,
51
- {
52
- hosts: ['android-arm64', 'android-arm', 'android-ia32', 'android-x64'],
53
- out: addonsDir
54
- },
55
- pkg
56
- )) {
54
+ const hosts = ['android-arm64', 'android-arm', 'android-ia32', 'android-x64']
55
+
56
+ for await (const resource of link(projectRoot, { hosts, out: addonsDir }, pkg)) {
57
57
  console.log('Wrote', resource)
58
58
  }
59
+
60
+ // Split addons keep their binaries in a per-platform package; bare-link only
61
+ // reaches the meta, which has shipped no prebuilds/ since the split.
62
+ for (const addon of resolvePlatformAddonRoots(projectRoot, addonNames, 'android')) {
63
+ console.log(`[QVAC] Linking split addon ${addon.pkg.name} from its platform package`)
64
+ for await (const resource of link(addon.dir, { hosts, out: addonsDir }, addon.pkg)) {
65
+ console.log('Wrote', resource)
66
+ }
67
+ }
@@ -5,12 +5,15 @@
5
5
  * Otherwise, falls back to linking all installed addons.
6
6
  *
7
7
  * This file is copied over react-native-bare-kit/ios/link.mjs
8
- * by withMobileBundle.ts during expo prebuild.
8
+ * by withMobileBundle.ts during expo prebuild. The resolver it imports is
9
+ * compiled from qvac-platform-addons.ts and installed beside this file as
10
+ * qvac-platform-addons.mjs.
9
11
  */
10
12
  import fs from 'fs'
11
13
  import path from 'path'
12
14
  import { fileURLToPath } from 'url'
13
15
  import link from 'bare-link'
16
+ import { resolvePlatformAddonRoots } from './qvac-platform-addons.mjs'
14
17
 
15
18
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
16
19
  const projectRoot = path.join(__dirname, '..', '..', '..')
@@ -24,10 +27,12 @@ if (fs.existsSync(addonsDir)) {
24
27
  const manifestPath = path.join(projectRoot, 'qvac', 'addons.manifest.json')
25
28
 
26
29
  let pkg = null
30
+ let addonNames = []
27
31
  if (fs.existsSync(manifestPath)) {
28
32
  try {
29
33
  const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
30
34
  const addons = Array.isArray(manifest.addons) ? manifest.addons : []
35
+ addonNames = addons
31
36
 
32
37
  if (addons.length > 0) {
33
38
  console.log(`[QVAC] Using addons manifest (${addons.length} addons): ${addons.join(', ')}`)
@@ -46,13 +51,17 @@ if (fs.existsSync(manifestPath)) {
46
51
  console.log('[QVAC] No addons manifest found, linking all addons')
47
52
  }
48
53
 
49
- for await (const resource of link(
50
- projectRoot,
51
- {
52
- hosts: ['ios-arm64', 'ios-arm64-simulator', 'ios-x64-simulator'],
53
- out: addonsDir
54
- },
55
- pkg
56
- )) {
54
+ const hosts = ['ios-arm64', 'ios-arm64-simulator', 'ios-x64-simulator']
55
+
56
+ for await (const resource of link(projectRoot, { hosts, out: addonsDir }, pkg)) {
57
57
  console.log('Wrote', resource)
58
58
  }
59
+
60
+ // Split addons keep their binaries in a per-platform package; bare-link only
61
+ // reaches the meta, which has shipped no prebuilds/ since the split.
62
+ for (const addon of resolvePlatformAddonRoots(projectRoot, addonNames, 'ios')) {
63
+ console.log(`[QVAC] Linking split addon ${addon.pkg.name} from its platform package`)
64
+ for await (const resource of link(addon.dir, { hosts, out: addonsDir }, addon.pkg)) {
65
+ console.log('Wrote', resource)
66
+ }
67
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Resolves split-addon platform packages from the meta package's `#host-addon`
3
+ * map. Linker, verify, and the missing-prebuild error all call this module so
4
+ * the slice name cannot drift from what the addon actually imports.
5
+ *
6
+ * Keep this file free of `@/` imports: the compiled JS is copied next to the
7
+ * patched `link.mjs` as `qvac-platform-addons.mjs`.
8
+ */
9
+ import * as fs from 'fs'
10
+ import * as path from 'path'
11
+
12
+ export const HOST_ADDON_IMPORT = '#host-addon'
13
+
14
+ const DEFAULT_ANDROID_CPU = 'arm64'
15
+
16
+ export interface PlatformAddonRoot {
17
+ dir: string
18
+ pkg: { name?: string; version?: string; addon?: boolean }
19
+ }
20
+
21
+ export function resolvePlatformAddonRoots(
22
+ projectRoot: string,
23
+ addonNames: string[],
24
+ platform: string
25
+ ): PlatformAddonRoot[] {
26
+ const roots: PlatformAddonRoot[] = []
27
+ for (const name of addonNames) {
28
+ const root = resolvePlatformAddonRoot(projectRoot, name, platform)
29
+ if (root !== null) roots.push(root)
30
+ }
31
+ return roots
32
+ }
33
+
34
+ function resolvePlatformAddonRoot(
35
+ projectRoot: string,
36
+ metaName: string,
37
+ platform: string
38
+ ): PlatformAddonRoot | null {
39
+ const metaManifest = readManifest(packageDir(projectRoot, metaName))
40
+ if (metaManifest === null) return null
41
+
42
+ const platformPackage = resolveAddonPlatformPackage(
43
+ metaName,
44
+ metaManifest.imports?.[HOST_ADDON_IMPORT],
45
+ platform
46
+ )
47
+ if (platformPackage === null) return null
48
+
49
+ const addonDir = path.join(packageDir(projectRoot, platformPackage), 'addon')
50
+ const addonManifest = readManifest(addonDir)
51
+ if (addonManifest === null || addonManifest.addon !== true) return null
52
+ if (!fs.existsSync(path.join(addonDir, 'prebuilds'))) return null
53
+
54
+ return { dir: addonDir, pkg: addonManifest }
55
+ }
56
+
57
+ function packageDir(projectRoot: string, packageName: string): string {
58
+ return path.join(projectRoot, 'node_modules', ...packageName.split('/'))
59
+ }
60
+
61
+ interface AddonManifest {
62
+ name?: string
63
+ version?: string
64
+ addon?: boolean
65
+ imports?: Record<string, unknown>
66
+ }
67
+
68
+ function readManifest(dir: string): AddonManifest | null {
69
+ try {
70
+ const parsed: unknown = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))
71
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null
72
+ return parsed as AddonManifest
73
+ } catch {
74
+ return null
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Package `#host-addon` names for `host`, if that name belongs to `metaName`.
80
+ * `host` is a Bare host (`android-arm64`, `ios-arm64-simulator`, `darwin-arm64`)
81
+ * or a mobile build target (`android`, `ios`).
82
+ */
83
+ export function resolveAddonPlatformPackage(
84
+ metaName: string,
85
+ hostAddon: unknown,
86
+ host: string
87
+ ): string | null {
88
+ const name = resolvePlatformPackageName(hostAddon, host)
89
+ if (name === null) return null
90
+ if (!name.startsWith(`${metaName}-`)) return null
91
+ return name
92
+ }
93
+
94
+ /**
95
+ * First package name a `#host-addon` map points at for `host`.
96
+ * Android nests the package under its architecture; iOS is a flat list.
97
+ * A platform-only `android` target uses arm64, matching the current mobile host.
98
+ */
99
+ export function resolvePlatformPackageName(hostAddon: unknown, host: string): string | null {
100
+ if (typeof host !== 'string' || host.length === 0) return null
101
+
102
+ const separator = host.indexOf('-')
103
+ const platform = separator === -1 ? host : host.slice(0, separator)
104
+ const cpu = separator === -1 ? '' : host.slice(separator + 1)
105
+
106
+ const branch = readBranch(hostAddon, platform)
107
+ const direct = packageName(branch)
108
+ if (direct !== null) return direct
109
+
110
+ const cpuKey = cpu.length > 0 ? cpu : DEFAULT_ANDROID_CPU
111
+ return packageName(readBranch(branch, cpuKey))
112
+ }
113
+
114
+ function packageName(candidate: unknown): string | null {
115
+ const name = Array.isArray(candidate) ? candidate[0] : candidate
116
+ if (typeof name !== 'string' || name.startsWith('.')) return null
117
+ return name
118
+ }
119
+
120
+ function readBranch(value: unknown, key: string): unknown {
121
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined
122
+ if (!Object.hasOwn(value, key)) return undefined
123
+ return (value as Record<string, unknown>)[key]
124
+ }