@qvac/sdk 0.21.1 → 0.22.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 (167) hide show
  1. package/NOTICE +84 -55
  2. package/README.md +167 -24
  3. package/dist/examples/abot-world.js +1 -1
  4. package/dist/examples/advisory-model-fit.d.ts +0 -58
  5. package/dist/examples/advisory-model-fit.js +23 -150
  6. package/dist/examples/asr/moss-transcribe-filesystem.d.ts +2 -0
  7. package/dist/examples/asr/moss-transcribe-filesystem.js +84 -0
  8. package/dist/examples/asr/moss-transcribe-fit.d.ts +2 -0
  9. package/dist/examples/asr/moss-transcribe-fit.js +40 -0
  10. package/dist/examples/asr/nemotron-diarization-filesystem.d.ts +2 -0
  11. package/dist/examples/asr/nemotron-diarization-filesystem.js +64 -0
  12. package/dist/examples/asr/parakeet-ctc-filesystem.js +2 -2
  13. package/dist/examples/asr/parakeet-indic-conformer-filesystem.js +2 -2
  14. package/dist/examples/asr/parakeet-microphone-record.js +1 -1
  15. package/dist/examples/asr/parakeet-microphone-stream.js +1 -1
  16. package/dist/examples/asr/parakeet-nemotron-filesystem.js +3 -3
  17. package/dist/examples/asr/parakeet-sortformer-streaming.js +2 -2
  18. package/dist/examples/asr/parakeet-sortformer.js +1 -1
  19. package/dist/examples/asr/parakeet-tdt-filesystem-chunked.js +2 -2
  20. package/dist/examples/asr/parakeet-tdt-filesystem.js +2 -2
  21. package/dist/examples/asr/parakeet-unified-coreml.js +2 -2
  22. package/dist/examples/asr/parakeet-unified-filesystem.js +2 -2
  23. package/dist/examples/asr/whispercpp-filesystem-streaming.js +1 -1
  24. package/dist/examples/asr/whispercpp-filesystem.js +1 -1
  25. package/dist/examples/asr/whispercpp-microphone-record.js +1 -1
  26. package/dist/examples/asr/whispercpp-prompt.js +1 -1
  27. package/dist/examples/assess-model-fit.js +3 -6
  28. package/dist/examples/audiogen/edit-music.js +2 -2
  29. package/dist/examples/audiogen/generate-cover.js +2 -2
  30. package/dist/examples/audiogen/generate-music-minimax.js +1 -1
  31. package/dist/examples/audiogen/generate-music.js +1 -1
  32. package/dist/examples/audiogen/understand-music.js +2 -2
  33. package/dist/examples/batch-completion.d.ts +1 -1
  34. package/dist/examples/batch-completion.js +1 -1
  35. package/dist/examples/bci/bci-filesystem-streaming.js +2 -2
  36. package/dist/examples/bci/bci-filesystem.js +2 -2
  37. package/dist/examples/concurrent-completion-collision.js +1 -1
  38. package/dist/examples/config-reload.js +1 -1
  39. package/dist/examples/decisions.d.ts +2 -0
  40. package/dist/examples/decisions.js +38 -0
  41. package/dist/examples/diffusion-esrgan-upscale.js +1 -1
  42. package/dist/examples/diffusion-flux2-klein-img2img.js +1 -1
  43. package/dist/examples/diffusion-img2img.js +1 -1
  44. package/dist/examples/diffusion-img2vid-ltx.js +1 -1
  45. package/dist/examples/diffusion-img2vid-minimax-h3.d.ts +2 -0
  46. package/dist/examples/diffusion-img2vid-minimax-h3.js +72 -0
  47. package/dist/examples/diffusion-img2vid.js +1 -1
  48. package/dist/examples/llamacpp-filesystem.js +1 -1
  49. package/dist/examples/llamacpp-multi-gpu.js +2 -2
  50. package/dist/examples/llamacpp-structured-output.js +1 -1
  51. package/dist/examples/mcp-websearch.d.ts +2 -2
  52. package/dist/examples/mcp-websearch.js +3 -3
  53. package/dist/examples/model-fit-ui/server.d.ts +1 -1
  54. package/dist/examples/model-fit-ui/server.js +1 -1
  55. package/dist/examples/multi-job-completion.d.ts +1 -1
  56. package/dist/examples/multi-job-completion.js +1 -1
  57. package/dist/examples/ocr-fasttext.js +1 -1
  58. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +1 -1
  59. package/dist/examples/tools/llamacpp-tools-gemma4.js +1 -1
  60. package/dist/examples/tools/llamacpp-tools-qwen35.js +1 -1
  61. package/dist/examples/tts/llm-to-tts-streaming.d.ts +2 -2
  62. package/dist/examples/tts/llm-to-tts-streaming.js +2 -2
  63. package/dist/examples/tts/moss-sound-effect-controls.d.ts +2 -0
  64. package/dist/examples/tts/moss-sound-effect-controls.js +88 -0
  65. package/dist/examples/tts/moss-sound-effect.d.ts +2 -0
  66. package/dist/examples/tts/moss-sound-effect.js +86 -0
  67. package/dist/examples/tts/moss-speech-audio.d.ts +2 -0
  68. package/dist/examples/tts/moss-speech-audio.js +159 -0
  69. package/dist/examples/tts/moss-speech.d.ts +2 -0
  70. package/dist/examples/tts/moss-speech.js +70 -0
  71. package/dist/examples/vla-groot.js +2 -2
  72. package/dist/examples/vla-pi05.js +2 -2
  73. package/dist/examples/vla-smolvla.js +2 -2
  74. package/dist/examples/voice-assistant/voice-assistant.js +1 -1
  75. package/dist/scripts/contract/build-contract.d.ts +3 -1
  76. package/dist/scripts/contract/build-contract.js +40 -2
  77. package/dist/scripts/contract/build-model-type-maps.d.ts +6 -1
  78. package/dist/scripts/contract/build-model-type-maps.js +3 -2
  79. package/dist/scripts/contract/constants-registry.d.ts +4 -0
  80. package/dist/scripts/contract/constants-registry.js +3 -1
  81. package/dist/scripts/contract/method-shapes.d.ts +1 -0
  82. package/dist/scripts/contract/method-shapes.js +1 -0
  83. package/dist/scripts/export-contract.js +20 -7
  84. package/dist/scripts/run-unit-tests.js +10 -5
  85. package/dist/src/client/api/assess-model-fit.d.ts +5 -5
  86. package/dist/src/client/api/assess-model-fit.js +5 -6
  87. package/dist/src/client/api/audio-edit.d.ts +14 -2
  88. package/dist/src/client/api/audio-edit.js +14 -2
  89. package/dist/src/client/api/audio-gen.d.ts +10 -2
  90. package/dist/src/client/api/audio-gen.js +10 -2
  91. package/dist/src/client/api/audio-understand.d.ts +1 -1
  92. package/dist/src/client/api/audio-understand.js +1 -1
  93. package/dist/src/client/api/batch-completion.js +1 -1
  94. package/dist/src/client/api/completion-stream.js +1 -1
  95. package/dist/src/client/api/decide.d.ts +31 -0
  96. package/dist/src/client/api/decide.js +29 -0
  97. package/dist/src/client/api/index.d.ts +1 -0
  98. package/dist/src/client/api/index.js +1 -0
  99. package/dist/src/client/api/load-model.d.ts +1 -0
  100. package/dist/src/client/api/text-to-speech.d.ts +1 -0
  101. package/dist/src/client/api/text-to-speech.js +15 -22
  102. package/dist/src/client/api/transcribe.js +5 -2
  103. package/dist/src/client/api/video-request.d.ts +5 -5
  104. package/dist/src/client/api/video.d.ts +23 -3
  105. package/dist/src/client/api/video.js +23 -3
  106. package/dist/src/commands/bundle/bare-pack.d.ts +8 -0
  107. package/dist/src/commands/bundle/bare-pack.js +28 -5
  108. package/dist/src/commands/bundle/constants.js +2 -0
  109. package/dist/src/commands/bundle/index.d.ts +7 -6
  110. package/dist/src/commands/bundle/index.js +126 -43
  111. package/dist/src/commands/bundle/manifest.d.ts +2 -0
  112. package/dist/src/commands/bundle/manifest.js +3 -2
  113. package/dist/src/commands/host-prebuilds/index.d.ts +15 -7
  114. package/dist/src/commands/host-prebuilds/index.js +35 -16
  115. package/dist/src/commands/index.d.ts +1 -1
  116. package/dist/src/commands/index.js +1 -1
  117. package/dist/src/commands/verify/addon-source.d.ts +12 -0
  118. package/dist/src/commands/verify/addon-source.js +36 -3
  119. package/dist/src/commands/verify/bare-kit-runtimes.js +2 -1
  120. package/dist/src/commands/verify/node-modules-source.js +10 -1
  121. package/dist/src/{expo/plugins/patches/qvac-platform-addons.d.ts → commands/verify/platform-addons.d.ts} +6 -10
  122. package/dist/src/{expo/plugins/patches/qvac-platform-addons.js → commands/verify/platform-addons.js} +2 -45
  123. package/dist/src/commands/verify/prebuilds.d.ts +7 -10
  124. package/dist/src/commands/verify/prebuilds.js +43 -34
  125. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  126. package/dist/src/expo/plugins/link-addons.d.ts +18 -0
  127. package/dist/src/expo/plugins/link-addons.js +65 -0
  128. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  129. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  130. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  131. package/dist/src/expo/plugins/withMobileBundle.d.ts +11 -21
  132. package/dist/src/expo/plugins/withMobileBundle.js +22 -112
  133. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  134. package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -1
  135. package/dist/src/index.d.ts +3 -3
  136. package/dist/src/index.js +2 -2
  137. package/dist/src/logging/base-logger.js +1 -1
  138. package/dist/src/logging/utils.js +1 -1
  139. package/dist/src/pear/pre.js +2 -0
  140. package/dist/src/plugin-ids.d.ts +3 -1
  141. package/dist/src/plugin-ids.js +4 -0
  142. package/dist/src/schemas/public.d.ts +2 -1
  143. package/dist/src/schemas/public.js +2 -1
  144. package/dist/src/schemas/sdk-errors-client.d.ts +3 -0
  145. package/dist/src/schemas/sdk-errors-client.js +16 -0
  146. package/dist/src/schemas/sdk-errors-server.d.ts +1 -0
  147. package/dist/src/schemas/sdk-errors-server.js +5 -0
  148. package/dist/src/utils/errors-client.d.ts +10 -0
  149. package/dist/src/utils/errors-client.js +18 -0
  150. package/dist/src/utils/mcp-adapter.js +12 -8
  151. package/dist/src/utils/tool-helpers.d.ts +1 -1
  152. package/dist/src/utils/tool-helpers.js +20 -52
  153. package/dist/src/worker/create-server.d.ts +1 -0
  154. package/dist/src/worker/create-server.js +5 -0
  155. package/dist/src/worker/index.js +4 -0
  156. package/dist/src/worker/lifecycle.js +9 -1
  157. package/dist/src/worker/plugins/llamacpp-decision.d.ts +2 -0
  158. package/dist/src/worker/plugins/llamacpp-decision.js +1 -0
  159. package/dist/src/worker/plugins/moss-transcribe.d.ts +2 -0
  160. package/dist/src/worker/plugins/moss-transcribe.js +1 -0
  161. package/package.json +39 -35
  162. package/src/electron-forge/index.cjs +12 -71
  163. package/dist/scripts/link-workspace-inference.d.ts +0 -2
  164. package/dist/scripts/link-workspace-inference.js +0 -31
  165. package/src/expo/plugins/patches/android-link.mjs +0 -67
  166. package/src/expo/plugins/patches/ios-link.mjs +0 -67
  167. package/src/expo/plugins/patches/qvac-platform-addons.ts +0 -124
@@ -0,0 +1,86 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { loadModel, textToSpeech, unloadModel, close, AUDIOGEN_MOSS_SFX_V2_Q8_0 } from '@qvac/sdk';
3
+ // Desktop MOSS-SoundEffect-v2, 48 kHz mono output. A GPU is recommended.
4
+ // Run from packages/sdk: node --import tsx examples/tts/moss-sound-effect.ts
5
+ // Optional: QVAC_MOSS_SFX_MODEL=/absolute/path/moss-sfx-v2-q8_0.gguf
6
+ // Use the catalog source URL: its full descriptor selects the audiogen plugin.
7
+ // Each clip denoises a 30-second latent, regardless of its requested output duration.
8
+ // Use 20 steps for a practical demo; omitting steps uses the slower baked default (100).
9
+ function saveWav(samples, sampleRate, filename) {
10
+ if (samples.length === 0 || samples.some((sample) => !Number.isFinite(sample))) {
11
+ throw new Error('The model returned no usable audio.');
12
+ }
13
+ const wav = Buffer.alloc(44 + samples.length * 2);
14
+ wav.write('RIFF', 0);
15
+ wav.writeUInt32LE(wav.length - 8, 4);
16
+ wav.write('WAVEfmt ', 8);
17
+ wav.writeUInt32LE(16, 16);
18
+ wav.writeUInt16LE(1, 20);
19
+ wav.writeUInt16LE(1, 22);
20
+ wav.writeUInt32LE(sampleRate, 24);
21
+ wav.writeUInt32LE(sampleRate * 2, 28);
22
+ wav.writeUInt16LE(2, 32);
23
+ wav.writeUInt16LE(16, 34);
24
+ wav.write('data', 36);
25
+ wav.writeUInt32LE(samples.length * 2, 40);
26
+ for (let i = 0; i < samples.length; i++) {
27
+ wav.writeInt16LE(Math.max(-32768, Math.min(32767, Math.round(samples[i]))), 44 + i * 2);
28
+ }
29
+ writeFileSync(filename, wav);
30
+ console.error(`▸ Saved ${filename}: ${sampleRate} Hz, ${(samples.length / sampleRate).toFixed(2)} seconds`);
31
+ }
32
+ let lastPercentage = -1;
33
+ function progress(p) {
34
+ const percentage = Math.floor(p.percentage);
35
+ if (percentage === lastPercentage)
36
+ return;
37
+ lastPercentage = percentage;
38
+ const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${(p.downloaded / 1e6).toFixed(1)}/${(p.total / 1e6).toFixed(1)} MB)`;
39
+ process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
40
+ if (p.percentage >= 100)
41
+ process.stderr.write('\n');
42
+ }
43
+ async function main() {
44
+ const modelId = await loadModel({
45
+ modelSrc: process.env['QVAC_MOSS_SFX_MODEL'] ?? AUDIOGEN_MOSS_SFX_V2_Q8_0.src,
46
+ modelType: 'tts-ggml',
47
+ modelConfig: { ttsEngine: 'moss-sfx', useGPU: true, seed: 42 },
48
+ onProgress: progress
49
+ });
50
+ try {
51
+ console.error('▸ Generating a sound effect...');
52
+ const result = textToSpeech({
53
+ modelId,
54
+ text: 'Heavy rain falling on a tin roof.',
55
+ stream: false,
56
+ seconds: 2,
57
+ steps: 20
58
+ });
59
+ const samples = await result.buffer;
60
+ if (!(await result.done))
61
+ throw new Error('Sound-effect generation did not complete.');
62
+ const sampleRate = await result.sampleRate;
63
+ if (sampleRate !== 48000)
64
+ throw new Error(`Unexpected sound-effect sample rate: ${sampleRate}`);
65
+ saveWav(samples, sampleRate, 'moss-sound-effect-output.wav');
66
+ }
67
+ finally {
68
+ await unloadModel({ modelId });
69
+ }
70
+ }
71
+ try {
72
+ await main();
73
+ }
74
+ catch (error) {
75
+ console.error('✖', error);
76
+ process.exitCode = 1;
77
+ }
78
+ finally {
79
+ try {
80
+ await close();
81
+ }
82
+ catch (error) {
83
+ console.error('✖ Cleanup failed:', error);
84
+ process.exitCode = 1;
85
+ }
86
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=moss-speech-audio.d.ts.map
@@ -0,0 +1,159 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { loadModel, textToSpeech, unloadModel, close, TTS_MOSS_SPEECH_Q8_0, TTS_CODEC_MOSS_SPEECH_F16 } from '@qvac/sdk';
3
+ // Desktop MOSS-Speech: 9B language model + codec, 24 kHz spoken reply and text.
4
+ // Run from packages/sdk: node --import tsx examples/tts/moss-speech-audio.ts question.wav
5
+ // Use a GPU with enough memory. Registry sources download automatically.
6
+ // Optional local paths: QVAC_MOSS_SPEECH_MODEL and QVAC_MOSS_SPEECH_CODEC.
7
+ // Both engines run a batch job; stream: false collects the complete reply.
8
+ function saveWav(samples, sampleRate, filename) {
9
+ if (samples.length === 0 || samples.some((sample) => !Number.isFinite(sample))) {
10
+ throw new Error('The model returned no usable audio.');
11
+ }
12
+ const wav = Buffer.alloc(44 + samples.length * 2);
13
+ wav.write('RIFF', 0);
14
+ wav.writeUInt32LE(wav.length - 8, 4);
15
+ wav.write('WAVEfmt ', 8);
16
+ wav.writeUInt32LE(16, 16);
17
+ wav.writeUInt16LE(1, 20);
18
+ wav.writeUInt16LE(1, 22);
19
+ wav.writeUInt32LE(sampleRate, 24);
20
+ wav.writeUInt32LE(sampleRate * 2, 28);
21
+ wav.writeUInt16LE(2, 32);
22
+ wav.writeUInt16LE(16, 34);
23
+ wav.write('data', 36);
24
+ wav.writeUInt32LE(samples.length * 2, 40);
25
+ for (let i = 0; i < samples.length; i++) {
26
+ wav.writeInt16LE(Math.max(-32768, Math.min(32767, Math.round(samples[i]))), 44 + i * 2);
27
+ }
28
+ writeFileSync(filename, wav);
29
+ console.error(`▸ Saved ${filename}: ${sampleRate} Hz, ${(samples.length / sampleRate).toFixed(2)} seconds`);
30
+ }
31
+ let lastPercentage = -1;
32
+ function progress(p) {
33
+ const percentage = Math.floor(p.percentage);
34
+ if (percentage === lastPercentage)
35
+ return;
36
+ lastPercentage = percentage;
37
+ const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${(p.downloaded / 1e6).toFixed(1)}/${(p.total / 1e6).toFixed(1)} MB)`;
38
+ process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
39
+ if (p.percentage >= 100)
40
+ process.stderr.write('\n');
41
+ }
42
+ // Read standard mono/stereo PCM16 or float32 WAV without an audio-library dependency.
43
+ function readQuestion(filename) {
44
+ const wav = readFileSync(filename);
45
+ if (wav.length < 12 ||
46
+ wav.toString('ascii', 0, 4) !== 'RIFF' ||
47
+ wav.toString('ascii', 8, 12) !== 'WAVE') {
48
+ throw new Error('Question must be a RIFF WAV file.');
49
+ }
50
+ let format = 0;
51
+ let channels = 0;
52
+ let sampleRate = 0;
53
+ let bits = 0;
54
+ let data;
55
+ for (let offset = 12; offset + 8 <= wav.length;) {
56
+ const size = wav.readUInt32LE(offset + 4);
57
+ const start = offset + 8;
58
+ if (start + size > wav.length)
59
+ throw new Error('Truncated WAV chunk.');
60
+ const id = wav.toString('ascii', offset, offset + 4);
61
+ if (id === 'fmt ') {
62
+ if (size < 16)
63
+ throw new Error('Invalid WAV format chunk.');
64
+ format = wav.readUInt16LE(start);
65
+ channels = wav.readUInt16LE(start + 2);
66
+ sampleRate = wav.readUInt32LE(start + 4);
67
+ bits = wav.readUInt16LE(start + 14);
68
+ }
69
+ else if (id === 'data')
70
+ data = wav.subarray(start, start + size);
71
+ offset = start + size + (size % 2);
72
+ }
73
+ if (!data ||
74
+ ![1, 2].includes(channels) ||
75
+ !((format === 1 && bits === 16) || (format === 3 && bits === 32))) {
76
+ throw new Error('Use a mono/stereo PCM16 or float32 WAV question.');
77
+ }
78
+ if (sampleRate < 8000 || sampleRate > 192000) {
79
+ throw new Error('WAV sample rate must be 8000–192000 Hz.');
80
+ }
81
+ const bytesPerSample = bits / 8;
82
+ const frameBytes = bytesPerSample * channels;
83
+ if (data.length % frameBytes !== 0)
84
+ throw new Error('Incomplete WAV audio frame.');
85
+ const audio = [];
86
+ for (let offset = 0; offset < data.length; offset += frameBytes) {
87
+ let sample = 0;
88
+ for (let channel = 0; channel < channels; channel++) {
89
+ const at = offset + channel * bytesPerSample;
90
+ sample += format === 1 ? data.readInt16LE(at) / 32768 : data.readFloatLE(at);
91
+ }
92
+ audio.push(sample / channels);
93
+ }
94
+ if (audio.length === 0 || audio.length > sampleRate * 60) {
95
+ throw new Error('Use a non-empty question of at most 60 seconds.');
96
+ }
97
+ return { audio, sampleRate };
98
+ }
99
+ async function main() {
100
+ const filename = process.argv[2];
101
+ if (!filename) {
102
+ throw new Error('Usage: node --import tsx examples/tts/moss-speech-audio.ts question.wav');
103
+ }
104
+ const question = readQuestion(filename);
105
+ const modelId = await loadModel({
106
+ modelSrc: process.env['QVAC_MOSS_SPEECH_MODEL'] ?? TTS_MOSS_SPEECH_Q8_0,
107
+ modelType: 'tts-ggml',
108
+ modelConfig: {
109
+ ttsEngine: 'moss-speech',
110
+ mossSpeechCodecModelSrc: process.env['QVAC_MOSS_SPEECH_CODEC'] ?? TTS_CODEC_MOSS_SPEECH_F16,
111
+ useGPU: true,
112
+ seed: 42
113
+ },
114
+ onProgress: progress
115
+ });
116
+ try {
117
+ console.error('▸ Generating a spoken reply...');
118
+ const result = textToSpeech({
119
+ modelId,
120
+ ...question,
121
+ stream: false,
122
+ greedy: true,
123
+ maxNewTokens: 128,
124
+ maxReplySeconds: 5,
125
+ messages: [{ role: 'user', text: 'Please answer the next spoken turn briefly.' }]
126
+ });
127
+ const samples = await result.buffer;
128
+ const reply = await result.text;
129
+ if (!(await result.done))
130
+ throw new Error('Speech generation did not complete.');
131
+ if (reply?.trim())
132
+ console.log(reply);
133
+ else
134
+ console.error('▸ The model returned an audio-only reply.');
135
+ const sampleRate = await result.sampleRate;
136
+ if (sampleRate !== 24000)
137
+ throw new Error(`Unexpected reply sample rate: ${sampleRate}`);
138
+ saveWav(samples, sampleRate, 'moss-speech-audio-output.wav');
139
+ }
140
+ finally {
141
+ await unloadModel({ modelId });
142
+ }
143
+ }
144
+ try {
145
+ await main();
146
+ }
147
+ catch (error) {
148
+ console.error('✖', error);
149
+ process.exitCode = 1;
150
+ }
151
+ finally {
152
+ try {
153
+ await close();
154
+ }
155
+ catch (error) {
156
+ console.error('✖ Cleanup failed:', error);
157
+ process.exitCode = 1;
158
+ }
159
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=moss-speech.d.ts.map
@@ -0,0 +1,70 @@
1
+ import { loadModel, textToSpeech, unloadModel, close, TTS_MOSS_SPEECH_Q8_0, TTS_CODEC_MOSS_SPEECH_F16 } from '@qvac/sdk';
2
+ // Desktop MOSS-Speech: answer a typed question with textReply: true.
3
+ // This mode skips audio decoding and returns text with an empty PCM buffer.
4
+ // Run from packages/sdk: node --import tsx examples/tts/moss-speech.ts
5
+ // Use a GPU with enough memory. Registry sources download automatically.
6
+ // Optional local paths: QVAC_MOSS_SPEECH_MODEL and QVAC_MOSS_SPEECH_CODEC.
7
+ // Both engines run a batch job; stream: false collects the complete reply.
8
+ let lastPercentage = -1;
9
+ function progress(p) {
10
+ const percentage = Math.floor(p.percentage);
11
+ if (percentage === lastPercentage)
12
+ return;
13
+ lastPercentage = percentage;
14
+ const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${(p.downloaded / 1e6).toFixed(1)}/${(p.total / 1e6).toFixed(1)} MB)`;
15
+ process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
16
+ if (p.percentage >= 100)
17
+ process.stderr.write('\n');
18
+ }
19
+ async function main() {
20
+ const modelId = await loadModel({
21
+ modelSrc: process.env['QVAC_MOSS_SPEECH_MODEL'] ?? TTS_MOSS_SPEECH_Q8_0,
22
+ modelType: 'tts-ggml',
23
+ modelConfig: {
24
+ ttsEngine: 'moss-speech',
25
+ mossSpeechCodecModelSrc: process.env['QVAC_MOSS_SPEECH_CODEC'] ?? TTS_CODEC_MOSS_SPEECH_F16,
26
+ useGPU: true,
27
+ seed: 42
28
+ },
29
+ onProgress: progress
30
+ });
31
+ try {
32
+ console.error('▸ Generating a text-only reply...');
33
+ const result = textToSpeech({
34
+ modelId,
35
+ text: 'What is two plus two? Answer in one short sentence.',
36
+ stream: false,
37
+ textReply: true,
38
+ greedy: true,
39
+ maxNewTokens: 128,
40
+ maxReplySeconds: 5,
41
+ systemPrompt: 'You are a helpful assistant. Give short, direct answers.'
42
+ });
43
+ const samples = await result.buffer;
44
+ const reply = await result.text;
45
+ if (!(await result.done) || !reply?.trim())
46
+ throw new Error('The model returned no reply text.');
47
+ console.log(reply);
48
+ if (samples.length !== 0)
49
+ throw new Error('A text-only reply must not contain PCM audio.');
50
+ }
51
+ finally {
52
+ await unloadModel({ modelId });
53
+ }
54
+ }
55
+ try {
56
+ await main();
57
+ }
58
+ catch (error) {
59
+ console.error('✖', error);
60
+ process.exitCode = 1;
61
+ }
62
+ finally {
63
+ try {
64
+ await close();
65
+ }
66
+ catch (error) {
67
+ console.error('✖ Cleanup failed:', error);
68
+ process.exitCode = 1;
69
+ }
70
+ }
@@ -22,7 +22,7 @@
22
22
  * image tokens; we lay it out by hand for the smoke.
23
23
  *
24
24
  * Usage:
25
- * bun examples/vla-groot.ts [path-to-groot.gguf]
25
+ * npx tsx examples/vla-groot.ts [path-to-groot.gguf]
26
26
  *
27
27
  * By default the example pulls the registry-baked GR00T-LIBERO GGUF (~3.76 GB)
28
28
  * on first run and caches it locally. Pass an absolute path on the command line
@@ -68,7 +68,7 @@ try {
68
68
  const modelId = await loadModel({
69
69
  modelSrc,
70
70
  modelType: 'ggml-vla',
71
- modelConfig: { backend: 'cpu', ...(embodiment !== undefined && { embodiment }) },
71
+ modelConfig: { backend: ['cpu'], ...(embodiment !== undefined && { embodiment }) },
72
72
  onProgress: (p) => {
73
73
  const mb = (n) => (n / 1e6).toFixed(1);
74
74
  const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
@@ -12,7 +12,7 @@
12
12
  * `Float32Array(0)`. π₀.₅ also requires the `noise` prior.
13
13
  *
14
14
  * Usage:
15
- * bun examples/vla-pi05.ts [path-to-pi05.gguf]
15
+ * npx tsx examples/vla-pi05.ts [path-to-pi05.gguf]
16
16
  *
17
17
  * By default the example pulls the registry-baked π₀.₅ GGUF (~3.9 GB) on
18
18
  * first run and caches it locally. Pass an absolute path on the command line
@@ -26,7 +26,7 @@ try {
26
26
  const modelId = await loadModel({
27
27
  modelSrc,
28
28
  modelType: 'ggml-vla',
29
- modelConfig: { backend: 'cpu' },
29
+ modelConfig: { backend: ['cpu'] },
30
30
  onProgress: (p) => {
31
31
  const mb = (n) => (n / 1e6).toFixed(1);
32
32
  const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
@@ -6,7 +6,7 @@
6
6
  * zero noise), and prints the produced action chunk + per-stage timings.
7
7
  *
8
8
  * Usage:
9
- * bun examples/vla-smolvla.ts [path-to-smolvla.gguf]
9
+ * npx tsx examples/vla-smolvla.ts [path-to-smolvla.gguf]
10
10
  *
11
11
  * By default the example pulls the registry-baked SmolVLA-LIBERO GGUF
12
12
  * (~1.9 GB) on first run and caches it locally. Pass an absolute path on
@@ -20,7 +20,7 @@ try {
20
20
  const modelId = await loadModel({
21
21
  modelSrc,
22
22
  modelType: 'ggml-vla',
23
- modelConfig: { backend: 'cpu' },
23
+ modelConfig: { backend: ['cpu'] },
24
24
  onProgress: (p) => {
25
25
  const mb = (n) => (n / 1e6).toFixed(1);
26
26
  const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Real-time Voice Assistant: mic → Whisper (with Silero VAD) → Llama → Supertonic TTS.
3
3
  *
4
- * Usage: bun run examples/voice-assistant/voice-assistant.ts
4
+ * Usage: npx tsx examples/voice-assistant/voice-assistant.ts
5
5
  *
6
6
  * Speak a question; the VAD detects when you pause, the utterance is
7
7
  * transcribed, sent to the LLM, and the response is spoken back. The loop
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const contractDir: URL;
3
+ export declare const registryEngineManifestFile: URL;
3
4
  export declare const callShapeByHandlerType: {
4
5
  readonly reply: "request-reply";
5
6
  readonly stream: "server-stream";
@@ -20,7 +21,7 @@ export declare function buildContract(): {
20
21
  condition: string;
21
22
  responseSchema: string;
22
23
  };
23
- name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "finetune" | "rag" | "vectorIndex" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify";
24
+ name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "finetune" | "rag" | "vectorIndex" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify" | "decide";
24
25
  callShape: "duplex" | "request-reply" | "server-stream";
25
26
  requestSchema: string;
26
27
  responseSchema: string;
@@ -35,5 +36,6 @@ export declare function renderContractFiles(): Promise<{
35
36
  'error-codes.json': string;
36
37
  'numeric-constants.json': string;
37
38
  }>;
39
+ export declare function renderRegistryEngineManifest(): Promise<string>;
38
40
  export {};
39
41
  //# sourceMappingURL=build-contract.d.ts.map
@@ -9,6 +9,7 @@ import { buildModelTypeMaps } from './build-model-type-maps.js';
9
9
  import { buildErrorCodes } from './build-error-codes.js';
10
10
  import { buildNumericConstants } from './build-numeric-constants.js';
11
11
  export const contractDir = new URL('../../contract/', import.meta.url);
12
+ export const registryEngineManifestFile = new URL('../../../registry-server/lib/generated/engine-manifest.json', import.meta.url);
12
13
  export const callShapeByHandlerType = {
13
14
  reply: 'request-reply',
14
15
  stream: 'server-stream',
@@ -139,6 +140,37 @@ function flattenAllOfWithUnion(json, defName) {
139
140
  function isSchemaObject(node) {
140
141
  return node !== null && typeof node === 'object' && !Array.isArray(node);
141
142
  }
143
+ /**
144
+ * Zod 4.6 emits primitive unions as `type: [...]`. That is valid JSON Schema,
145
+ * but the Kotlin generator represents that form as an untyped JsonElement.
146
+ * Keep the equivalent `anyOf` form used by earlier Zod releases so generated
147
+ * clients retain their typed union wrappers.
148
+ */
149
+ function expandPrimitiveTypeArrays(node) {
150
+ if (Array.isArray(node))
151
+ return node.map(expandPrimitiveTypeArrays);
152
+ if (!isSchemaObject(node))
153
+ return node;
154
+ const expanded = Object.fromEntries(Object.entries(node).map(function ([key, value]) {
155
+ return [key, expandPrimitiveTypeArrays(value)];
156
+ }));
157
+ const types = expanded['type'];
158
+ if (!Array.isArray(types))
159
+ return expanded;
160
+ if (!types.every(function (type) {
161
+ return typeof type === 'string';
162
+ })) {
163
+ throw new Error('JSON Schema type arrays must contain only strings');
164
+ }
165
+ if (expanded['anyOf'] !== undefined || expanded['oneOf'] !== undefined) {
166
+ throw new Error('Cannot expand a JSON Schema type array beside an existing union');
167
+ }
168
+ delete expanded['type'];
169
+ expanded['anyOf'] = types.map(function (type) {
170
+ return { type };
171
+ });
172
+ return expanded;
173
+ }
142
174
  function unionArmsOf(node) {
143
175
  if (Array.isArray(node['oneOf']))
144
176
  return node['oneOf'];
@@ -429,7 +461,8 @@ export function toWireJsonSchema(schema, io, defName) {
429
461
  unrepresentable: 'any'
430
462
  });
431
463
  delete json['$schema'];
432
- const flattened = flattenAllOfWithUnion(json, defName);
464
+ const expanded = expandPrimitiveTypeArrays(json);
465
+ const flattened = flattenAllOfWithUnion(expanded, defName);
433
466
  const collapsed = collapseSingleMemberUnions(flattened);
434
467
  assertNoRefs(collapsed, defName);
435
468
  return collapsed;
@@ -591,7 +624,7 @@ export function buildContract() {
591
624
  const schemaDocument = {
592
625
  $schema: 'https://json-schema.org/draft/2020-12/schema',
593
626
  title: '@qvac/sdk wire contract',
594
- description: 'Generated from the SDK Zod schemas by `bun run contract:export`. Do not edit by hand. ' +
627
+ description: 'Generated from the SDK Zod schemas by `npm run contract:export`. Do not edit by hand. ' +
595
628
  'Requests use the schema input shape, responses the output shape; runtime-only ' +
596
629
  'refinements and transforms stay server-side.',
597
630
  $defs: defs
@@ -621,3 +654,8 @@ export async function renderContractFiles() {
621
654
  'numeric-constants.json': await formatJson(numericConstants, 'numeric-constants.json')
622
655
  };
623
656
  }
657
+ // Build-time export only: registry validation reads its own packaged artifact.
658
+ export async function renderRegistryEngineManifest() {
659
+ const { engineToAddon, legacyEngineToCanonical, legacyRegistryEngineRules } = buildModelTypeMaps();
660
+ return formatJson({ engineToAddon, legacyEngineToCanonical, legacyRegistryEngineRules }, 'engine-manifest.json');
661
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * JSON export of the model-type resolution maps that `loadModel`'s
3
3
  * client-side type-inference reads: alias → canonical model type, canonical
4
- * engine → addon, and legacy engine string → canonical engine.
4
+ * engine → addon, legacy engine string → canonical engine, and tagged rules
5
+ * for shared legacy registry packages.
5
6
  *
6
7
  * Inference itself stays in each client (a plain string `modelSrc` carries no
7
8
  * engine to infer from, so it can't move server-side), but the *data* it reads
@@ -17,6 +18,10 @@ export interface ModelTypeMaps {
17
18
  aliasToCanonical: Record<string, string>;
18
19
  engineToAddon: Record<string, string>;
19
20
  legacyEngineToCanonical: Record<string, string>;
21
+ legacyRegistryEngineRules: Record<string, readonly {
22
+ tag: string;
23
+ engine: string;
24
+ }[]>;
20
25
  }
21
26
  export declare function buildModelTypeMaps(): ModelTypeMaps;
22
27
  //# sourceMappingURL=build-model-type-maps.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ModelTypeAliases, ENGINE_TO_ADDON, LEGACY_ENGINE_TO_CANONICAL } from '@qvac/inference/surface';
1
+ import { ModelTypeAliases, ENGINE_TO_ADDON, LEGACY_ENGINE_TO_CANONICAL, LEGACY_REGISTRY_ENGINE_RULES } from '@qvac/inference/surface';
2
2
  function sortedEntries(record) {
3
3
  const entries = Object.entries(record);
4
4
  entries.sort(function (a, b) {
@@ -10,6 +10,7 @@ export function buildModelTypeMaps() {
10
10
  return {
11
11
  aliasToCanonical: sortedEntries(ModelTypeAliases),
12
12
  engineToAddon: sortedEntries(ENGINE_TO_ADDON),
13
- legacyEngineToCanonical: sortedEntries(LEGACY_ENGINE_TO_CANONICAL)
13
+ legacyEngineToCanonical: sortedEntries(LEGACY_ENGINE_TO_CANONICAL),
14
+ legacyRegistryEngineRules: sortedEntries(LEGACY_REGISTRY_ENGINE_RULES)
14
15
  };
15
16
  }
@@ -29,10 +29,12 @@ export declare const constantsRegistry: {
29
29
  readonly whispercppTranscription: "whispercpp-transcription";
30
30
  readonly bciWhispercppTranscription: "bci-whispercpp-transcription";
31
31
  readonly llamacppEmbedding: "llamacpp-embedding";
32
+ readonly llamacppDecision: "llamacpp-decision";
32
33
  readonly nmtcppTranslation: "nmtcpp-translation";
33
34
  readonly onnxTts: "onnx-tts";
34
35
  readonly ttsGgml: "tts-ggml";
35
36
  readonly parakeetTranscription: "parakeet-transcription";
37
+ readonly mossTranscribe: "moss-transcribe";
36
38
  readonly ggmlOcr: "ggml-ocr";
37
39
  readonly sdcppGeneration: "sdcpp-generation";
38
40
  readonly audiogenGgml: "audiogen-ggml";
@@ -48,8 +50,10 @@ export declare const constantsRegistry: {
48
50
  readonly PluginId: z.ZodEnum<{
49
51
  readonly LLM: "@qvac/sdk/llamacpp-completion/plugin";
50
52
  readonly EMBEDDING: "@qvac/sdk/llamacpp-embedding/plugin";
53
+ readonly DECISION: "@qvac/sdk/llamacpp-decision/plugin";
51
54
  readonly WHISPER: "@qvac/sdk/whispercpp-transcription/plugin";
52
55
  readonly BCI: "@qvac/sdk/bci-whispercpp-transcription/plugin";
56
+ readonly MOSS_TRANSCRIBE: "@qvac/sdk/moss-transcribe/plugin";
53
57
  readonly NMT: "@qvac/sdk/nmtcpp-translation/plugin";
54
58
  readonly TTS: "@qvac/sdk/tts-ggml/plugin";
55
59
  readonly OCR: "@qvac/sdk/ggml-ocr/plugin";
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { ModelType, VERBOSITY, SUPPORTED_AUDIO_FORMATS, AUDIOGEN_ENGINES, AUDIOGEN_TASK_TYPES, AUDIOGEN_EDIT_OPERATIONS, AUDIOGEN_REPAINT_MODES, AUDIOGEN_TRACKS, TTS_ENGINES, TTS_PACES, TTS_PARLER_EMOTIONS, TTS_SENTENCE_DELIMITER_PRESETS, TTS_CHATTERBOX_LANGUAGES, TTS_SUPERTONIC_LANGUAGES, TTS_COSYVOICE3_EMOTIONS, TTS_COSYVOICE3_INSTRUCT_DIALECTS, TTS_COSYVOICE3_INSTRUCT_VOLUMES, TTS_COSYVOICE3_INSTRUCT_STYLES, VectorIndexStorage } from '@qvac/inference/surface';
3
- import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
3
+ import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_DECISION, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_MOSS_TRANSCRIBE, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
4
4
  // Uppercases each vocabulary value into an identifier-safe varname (e.g.
5
5
  // 'slow' -> 'SLOW', 'cover-nofsq' -> 'COVER_NOFSQ'), mirroring the
6
6
  // SupportedAudioFormat derivation so names can't drift from the single
@@ -38,8 +38,10 @@ export const constantsRegistry = {
38
38
  PluginId: z.enum({
39
39
  LLM: PLUGIN_LLM,
40
40
  EMBEDDING: PLUGIN_EMBEDDING,
41
+ DECISION: PLUGIN_DECISION,
41
42
  WHISPER: PLUGIN_WHISPER,
42
43
  BCI: PLUGIN_BCI,
44
+ MOSS_TRANSCRIBE: PLUGIN_MOSS_TRANSCRIBE,
43
45
  NMT: PLUGIN_NMT,
44
46
  TTS: PLUGIN_TTS,
45
47
  OCR: PLUGIN_OCR,
@@ -25,6 +25,7 @@ export declare const methodShapes: {
25
25
  readonly diffusionStream: "stream";
26
26
  readonly downloadAsset: "reply";
27
27
  readonly embed: "reply";
28
+ readonly decide: "reply";
28
29
  readonly finetune: "reply";
29
30
  readonly getLoadedModelInfo: "reply";
30
31
  readonly getModelInfo: "reply";
@@ -25,6 +25,7 @@ export const methodShapes = {
25
25
  diffusionStream: 'stream',
26
26
  downloadAsset: 'reply',
27
27
  embed: 'reply',
28
+ decide: 'reply',
28
29
  finetune: 'reply',
29
30
  getLoadedModelInfo: 'reply',
30
31
  getModelInfo: 'reply',
@@ -1,27 +1,40 @@
1
1
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
2
3
  import { fileURLToPath } from 'node:url';
3
- import { contractDir, renderContractFiles } from './contract/build-contract.js';
4
+ import { contractDir, registryEngineManifestFile, renderContractFiles, renderRegistryEngineManifest } from './contract/build-contract.js';
4
5
  const checkOnly = process.argv.includes('--check');
5
6
  const files = await renderContractFiles();
6
- await mkdir(contractDir, { recursive: true });
7
+ const artifacts = [
8
+ ...Object.entries(files).map(([name, content]) => ({
9
+ label: `contract/${name}`,
10
+ file: new URL(name, contractDir),
11
+ content
12
+ })),
13
+ {
14
+ label: 'registry-server/lib/generated/engine-manifest.json',
15
+ file: registryEngineManifestFile,
16
+ content: await renderRegistryEngineManifest()
17
+ }
18
+ ];
7
19
  let stale = false;
8
- for (const [name, content] of Object.entries(files)) {
9
- const filePath = fileURLToPath(new URL(name, contractDir));
20
+ for (const { label, file, content } of artifacts) {
21
+ const filePath = fileURLToPath(file);
10
22
  if (checkOnly) {
11
23
  const existing = await readFile(filePath, 'utf8').catch(function () {
12
24
  return null;
13
25
  });
14
26
  if (existing !== content) {
15
- console.error(`contract/${name} is ${existing === null ? 'missing' : 'out of date'}`);
27
+ console.error(`${label} is ${existing === null ? 'missing' : 'out of date'}`);
16
28
  stale = true;
17
29
  }
18
30
  }
19
31
  else {
32
+ await mkdir(dirname(filePath), { recursive: true });
20
33
  await writeFile(filePath, content);
21
- console.log(`wrote contract/${name}`);
34
+ console.log(`wrote ${label}`);
22
35
  }
23
36
  }
24
37
  if (stale) {
25
- console.error("Contract artifacts are stale. Run 'bun run contract:export' and commit the result.");
38
+ console.error("Generated contract artifacts are stale. Run 'npm run contract:export' and commit the result.");
26
39
  process.exit(1);
27
40
  }