@qvac/inference 0.17.1 → 0.18.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 (110) hide show
  1. package/dist/api/completion-stream.d.ts +1 -1
  2. package/dist/api/completion-stream.js +1 -1
  3. package/dist/api/index.d.ts +1 -1
  4. package/dist/api/index.js +1 -1
  5. package/dist/api/text-to-speech.js +22 -2
  6. package/dist/api/transcribe.d.ts +19 -2
  7. package/dist/api/transcribe.js +66 -27
  8. package/dist/api/translate.js +6 -17
  9. package/dist/api/vla.d.ts +42 -1
  10. package/dist/api/vla.js +50 -1
  11. package/dist/constants/audio.d.ts +2 -1
  12. package/dist/constants/audio.js +17 -1
  13. package/dist/errors/index.d.ts +3 -0
  14. package/dist/errors/index.js +5 -0
  15. package/dist/handlers/load-model/handler.js +2 -2
  16. package/dist/handlers/load-model/resolve-session.d.ts +1 -1
  17. package/dist/handlers/load-model/resolve-session.js +3 -3
  18. package/dist/handlers/load-model/resolve.d.ts +12 -2
  19. package/dist/handlers/load-model/resolve.js +90 -12
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/models/registry/models.d.ts +782 -6
  23. package/dist/models/registry/models.js +2664 -1859
  24. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +19 -0
  25. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +153 -0
  26. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +54 -4
  27. package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +28 -0
  28. package/dist/plugins/builtin/ggml-ocr/plugin.js +3 -1
  29. package/dist/plugins/builtin/ggml-vla/ops/vla-set-embodiment.d.ts +2 -0
  30. package/dist/plugins/builtin/ggml-vla/ops/vla-set-embodiment.js +9 -0
  31. package/dist/plugins/builtin/ggml-vla/plugin.d.ts +37 -0
  32. package/dist/plugins/builtin/ggml-vla/plugin.js +21 -4
  33. package/dist/plugins/builtin/index.d.ts +1 -0
  34. package/dist/plugins/builtin/index.js +1 -0
  35. package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +16 -15
  36. package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.d.ts +1 -1
  37. package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.js +2 -2
  38. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +6 -0
  39. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.js +10 -0
  40. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +1 -0
  41. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +131 -123
  42. package/dist/plugins/builtin/llamacpp-completion/ops/finetune.js +110 -20
  43. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +50 -23
  44. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +308 -143
  45. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +1 -0
  46. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +2 -2
  47. package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +6 -6
  48. package/dist/plugins/builtin/llamacpp-completion/plugin.js +56 -36
  49. package/dist/plugins/builtin/llamacpp-completion/transform.js +0 -7
  50. package/dist/plugins/builtin/llamacpp-embedding/plugin.js +2 -3
  51. package/dist/plugins/builtin/nmtcpp-translation/plugin.js +6 -5
  52. package/dist/plugins/builtin/parakeet-transcription/plugin.js +27 -16
  53. package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +23 -3
  54. package/dist/plugins/builtin/tts-ggml/plugin.d.ts +302 -4
  55. package/dist/plugins/builtin/tts-ggml/plugin.js +131 -0
  56. package/dist/plugins/builtin/whispercpp-transcription/plugin.js +48 -39
  57. package/dist/plugins/ops/cancel.d.ts +1 -1
  58. package/dist/plugins/ops/cancel.js +1 -1
  59. package/dist/plugins/ops/kv-cache-retention.js +11 -0
  60. package/dist/plugins/ops/kv-cache-utils.d.ts +1 -1
  61. package/dist/plugins/ops/kv-cache-utils.js +40 -12
  62. package/dist/plugins/ops/transcribe.d.ts +2 -2
  63. package/dist/plugins/ops/transcribe.js +54 -48
  64. package/dist/plugins/ops/translate-stats.d.ts +4 -0
  65. package/dist/plugins/ops/translate-stats.js +11 -0
  66. package/dist/plugins/ops/translate.js +66 -38
  67. package/dist/plugins/ops/unload-model.js +30 -24
  68. package/dist/runtime/model-registry.d.ts +1 -0
  69. package/dist/runtime/request-context.js +29 -14
  70. package/dist/runtime/request-registry.d.ts +27 -0
  71. package/dist/runtime/request-registry.js +246 -76
  72. package/dist/schemas/audio-gen.d.ts +103 -0
  73. package/dist/schemas/audio-gen.js +135 -4
  74. package/dist/schemas/common.d.ts +550 -11
  75. package/dist/schemas/config.d.ts +60 -24
  76. package/dist/schemas/errors.d.ts +1 -0
  77. package/dist/schemas/errors.js +5 -0
  78. package/dist/schemas/index.d.ts +1 -1
  79. package/dist/schemas/index.js +1 -1
  80. package/dist/schemas/llamacpp-config.d.ts +10 -10
  81. package/dist/schemas/llamacpp-config.js +168 -82
  82. package/dist/schemas/load-model.d.ts +3691 -336
  83. package/dist/schemas/load-model.js +37 -19
  84. package/dist/schemas/text-to-speech.d.ts +1086 -110
  85. package/dist/schemas/text-to-speech.js +197 -7
  86. package/dist/schemas/tools.d.ts +0 -16
  87. package/dist/schemas/tools.js +0 -15
  88. package/dist/schemas/transcription-config.d.ts +2 -0
  89. package/dist/schemas/transcription-config.js +6 -0
  90. package/dist/schemas/transcription.d.ts +3 -0
  91. package/dist/schemas/vla.d.ts +83 -0
  92. package/dist/schemas/vla.js +105 -2
  93. package/dist/surface.d.ts +1 -1
  94. package/dist/surface.js +1 -1
  95. package/dist/utils/addon-responses.d.ts +4 -12
  96. package/dist/utils/audio/decoder.d.ts +37 -1
  97. package/dist/utils/audio/decoder.js +82 -52
  98. package/dist/utils/config-transform.d.ts +3 -0
  99. package/dist/utils/config-transform.js +6 -0
  100. package/dist/utils/index.d.ts +0 -1
  101. package/dist/utils/index.js +0 -1
  102. package/dist/utils/shard-utils.d.ts +1 -0
  103. package/dist/utils/shard-utils.js +14 -0
  104. package/dist/utils/tool-integration.d.ts +3 -10
  105. package/dist/utils/tool-integration.js +3 -12
  106. package/package.json +26 -22
  107. package/dist/plugins/builtin/llamacpp-completion/ops/batch-cancelled.d.ts +0 -22
  108. package/dist/plugins/builtin/llamacpp-completion/ops/batch-cancelled.js +0 -30
  109. package/dist/utils/expand-gguf-shards.d.ts +0 -2
  110. package/dist/utils/expand-gguf-shards.js +0 -22
@@ -28,7 +28,7 @@ type CompletionParams = Omit<CompletionClientParams, 'tools'> & {
28
28
  * @param params.mcp - Optional array of MCP client inputs for tool integration
29
29
  * @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
30
30
  * @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
31
- * @param params.toolDialect - Override name-based dialect detection. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6), `"gemma4"`. Use when the auto-router doesn't recognise your model name. Drives both streaming frame detection and finalization parsing.
31
+ * @param params.toolDialect - Override name-based dialect detection. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6), `"gemma4"`, `"dsml"` (DeepSeek V3.2/V4). Use when the auto-router doesn't recognise your model name. Drives both streaming frame detection and finalization parsing.
32
32
  * Common override case: Llama 3.x tool-calling fine-tunes that emit the native pythonic header (`<|start_header_id|>tool_call<|end_header_id|>...<|eot_id|>`).
33
33
  * @param params.responseFormat - Optional structured-output constraint applied to the model's output:
34
34
  * - `{ type: "text" }` — no constraint (default behavior)
@@ -28,7 +28,7 @@ const logger = getAppLogger();
28
28
  * @param params.mcp - Optional array of MCP client inputs for tool integration
29
29
  * @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
30
30
  * @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
31
- * @param params.toolDialect - Override name-based dialect detection. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6), `"gemma4"`. Use when the auto-router doesn't recognise your model name. Drives both streaming frame detection and finalization parsing.
31
+ * @param params.toolDialect - Override name-based dialect detection. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6), `"gemma4"`, `"dsml"` (DeepSeek V3.2/V4). Use when the auto-router doesn't recognise your model name. Drives both streaming frame detection and finalization parsing.
32
32
  * Common override case: Llama 3.x tool-calling fine-tunes that emit the native pythonic header (`<|start_header_id|>tool_call<|end_header_id|>...<|eot_id|>`).
33
33
  * @param params.responseFormat - Optional structured-output constraint applied to the model's output:
34
34
  * - `{ type: "text" }` — no constraint (default behavior)
@@ -31,5 +31,5 @@ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type Mod
31
31
  export { suspend } from '../api/suspend.js';
32
32
  export { resume } from '../api/resume.js';
33
33
  export { state } from '../api/state.js';
34
- export { vla, vlaHparams } from '../api/vla.js';
34
+ export { vla, vlaHparams, vlaSetEmbodiment } from '../api/vla.js';
35
35
  export { vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE } from '../api/vla-helpers.js';
package/dist/api/index.js CHANGED
@@ -31,5 +31,5 @@ export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel } from '.
31
31
  export { suspend } from '../api/suspend.js';
32
32
  export { resume } from '../api/resume.js';
33
33
  export { state } from '../api/state.js';
34
- export { vla, vlaHparams } from '../api/vla.js';
34
+ export { vla, vlaHparams, vlaSetEmbodiment } from '../api/vla.js';
35
35
  export { vlaPreprocessImage, vlaPadState, VLA_DEFAULT_IMAGE_SIZE } from '../api/vla-helpers.js';
@@ -142,7 +142,17 @@ function buildTtsRequest(params) {
142
142
  }),
143
143
  ...(params.sentenceStreamMaxChunkScalars !== undefined && {
144
144
  sentenceStreamMaxChunkScalars: params.sentenceStreamMaxChunkScalars
145
- })
145
+ }),
146
+ ...(params.description !== undefined && { description: params.description }),
147
+ ...(params.voiceDescription !== undefined && { voiceDescription: params.voiceDescription }),
148
+ ...(params.voice !== undefined && { voice: params.voice }),
149
+ ...(params.emotion !== undefined && { emotion: params.emotion }),
150
+ ...(params.pitch !== undefined && { pitch: params.pitch }),
151
+ ...(params.pace !== undefined && { pace: params.pace }),
152
+ ...(params.expressivity !== undefined && { expressivity: params.expressivity }),
153
+ ...(params.noise !== undefined && { noise: params.noise }),
154
+ ...(params.reverb !== undefined && { reverb: params.reverb }),
155
+ ...(params.quality !== undefined && { quality: params.quality })
146
156
  };
147
157
  }
148
158
  function buildTextToSpeechStreamRequest(params) {
@@ -161,7 +171,17 @@ function buildTextToSpeechStreamRequest(params) {
161
171
  }),
162
172
  ...(params.flushAfterMs !== undefined && {
163
173
  flushAfterMs: params.flushAfterMs
164
- })
174
+ }),
175
+ ...(params.description !== undefined && { description: params.description }),
176
+ ...(params.voiceDescription !== undefined && { voiceDescription: params.voiceDescription }),
177
+ ...(params.voice !== undefined && { voice: params.voice }),
178
+ ...(params.emotion !== undefined && { emotion: params.emotion }),
179
+ ...(params.pitch !== undefined && { pitch: params.pitch }),
180
+ ...(params.pace !== undefined && { pace: params.pace }),
181
+ ...(params.expressivity !== undefined && { expressivity: params.expressivity }),
182
+ ...(params.noise !== undefined && { noise: params.noise }),
183
+ ...(params.reverb !== undefined && { reverb: params.reverb }),
184
+ ...(params.quality !== undefined && { quality: params.quality })
165
185
  };
166
186
  }
167
187
  /**
@@ -1,4 +1,6 @@
1
- import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession } from '../schemas/index.js';
1
+ import { type TranscribeClientParams, type RPCOptions, type TranscribeSegment, type TranscribeStreamRequest, type TranscribeStreamClientParams, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStats } from '../schemas/index.js';
2
+ import { duplex } from '../dispatch.js';
3
+ type TranscribeDuplexFactory = (request: TranscribeStreamRequest, options?: RPCOptions) => ReturnType<typeof duplex>;
2
4
  /**
3
5
  * Transcribe audio and return the complete text. Accepts either a file
4
6
  * path or an audio buffer.
@@ -61,7 +63,8 @@ export declare function transcribeStream(params: TranscribeClientParams, options
61
63
  * @returns A session object: call `write(audioChunk)` with a `Uint8Array`
62
64
  * (Node `Buffer` is a `Uint8Array` subtype) to feed audio,
63
65
  * iterate with `for await (...)` to receive transcription, and
64
- * `end()` to signal end of audio.
66
+ * `end()` to signal end of audio. After consuming the iterator,
67
+ * await `session.stats` for terminal engine statistics.
65
68
  */
66
69
  export declare function transcribeStream(params: TranscribeStreamClientParams & {
67
70
  emitVadEvents: true;
@@ -73,3 +76,17 @@ export declare function transcribeStream(params: TranscribeStreamClientParams &
73
76
  metadata: true;
74
77
  }, options?: RPCOptions): Promise<TranscribeStreamMetadataSession>;
75
78
  export declare function transcribeStream(params: TranscribeStreamClientParams, options?: RPCOptions): Promise<TranscribeStreamSession>;
79
+ /**
80
+ * Shared duplex session factory. The per-call line processor decides whether
81
+ * to surface strings or segments; `sessionName` is only used to label the
82
+ * "already iterated" error so callers see the correct session type.
83
+ */
84
+ export declare function createTranscribeStreamSession<T>(params: TranscribeStreamClientParams, options: RPCOptions | undefined, process: (line: string, onStats: (stats: TranscribeStats | undefined) => void) => T | undefined | null, sessionName: string, duplexFactory?: TranscribeDuplexFactory): Promise<{
85
+ stats: Promise<TranscribeStats | undefined>;
86
+ write(audioChunk: Uint8Array): void;
87
+ end(): void;
88
+ destroy(): void;
89
+ [Symbol.asyncIterator](): AsyncIterator<T>;
90
+ }>;
91
+ export declare function processLine(line: string, onStats: (stats: TranscribeStats | undefined) => void): string | undefined | null;
92
+ export {};
@@ -121,12 +121,39 @@ function buildTranscribeStreamRequest(params) {
121
121
  * to surface strings or segments; `sessionName` is only used to label the
122
122
  * "already iterated" error so callers see the correct session type.
123
123
  */
124
- async function createTranscribeStreamSession(params, options, process, sessionName) {
124
+ export async function createTranscribeStreamSession(params, options, process, sessionName, duplexFactory = duplex) {
125
125
  const request = buildTranscribeStreamRequest(params);
126
- const { requestStream, responseStream } = await duplex(request, options);
127
- const responses = parseLines(responseStream, process);
126
+ const { requestStream, responseStream } = await duplexFactory(request, options);
127
+ let statsSettled = false;
128
+ let resolveStatsPromise = () => { };
129
+ let rejectStatsPromise = () => { };
130
+ const stats = new Promise((resolve, reject) => {
131
+ resolveStatsPromise = resolve;
132
+ rejectStatsPromise = reject;
133
+ });
134
+ stats.catch(() => { });
135
+ function resolveStats(value) {
136
+ if (statsSettled)
137
+ return;
138
+ statsSettled = true;
139
+ resolveStatsPromise(value);
140
+ }
141
+ function rejectStats(error) {
142
+ if (statsSettled)
143
+ return;
144
+ statsSettled = true;
145
+ rejectStatsPromise(error);
146
+ }
147
+ function resolveEmptyStats() {
148
+ resolveStats(undefined);
149
+ }
150
+ function processResponse(line) {
151
+ return process(line, resolveStats);
152
+ }
153
+ const responses = parseLines(responseStream, processResponse, resolveEmptyStats, rejectStats);
128
154
  let consumed = false;
129
155
  return {
156
+ stats,
130
157
  write(audioChunk) {
131
158
  requestStream.write(audioChunk);
132
159
  },
@@ -134,6 +161,7 @@ async function createTranscribeStreamSession(params, options, process, sessionNa
134
161
  requestStream.end();
135
162
  },
136
163
  destroy() {
164
+ resolveStats(undefined);
137
165
  requestStream.destroy();
138
166
  responseStream.destroy();
139
167
  },
@@ -154,32 +182,41 @@ function transcribeStreamDuplexMetadata(params, options) {
154
182
  }
155
183
  function transcribeStreamDuplexConversation(params, options) {
156
184
  const wantsMetadata = params.metadata === true;
157
- return createTranscribeStreamSession(params, options, (line) => processLineConversation(line, wantsMetadata), 'TranscribeStreamConversationSession');
185
+ return createTranscribeStreamSession(params, options, (line, onStats) => processLineConversation(line, wantsMetadata, onStats), 'TranscribeStreamConversationSession');
158
186
  }
159
187
  /**
160
188
  * Line-delimited parser: reads newline-separated frames from a duplex
161
189
  * response stream, passes each non-empty line through `process`, and yields
162
190
  * whatever values it returns. `null` from `process` terminates the stream.
163
191
  */
164
- async function* parseLines(responseStream, process) {
192
+ async function* parseLines(responseStream, process, onClose, onError) {
165
193
  let buf = '';
166
- for await (const chunk of responseStream) {
167
- buf += chunk.toString();
168
- const lines = buf.split('\n');
169
- buf = lines.pop() || '';
170
- for (const line of lines) {
171
- const result = process(line);
172
- if (result === null)
173
- return;
174
- if (result !== undefined)
194
+ try {
195
+ for await (const chunk of responseStream) {
196
+ buf += chunk.toString();
197
+ const lines = buf.split('\n');
198
+ buf = lines.pop() || '';
199
+ for (const line of lines) {
200
+ const result = process(line);
201
+ if (result === null)
202
+ return;
203
+ if (result !== undefined)
204
+ yield result;
205
+ }
206
+ }
207
+ // Process any residual data after stream ends
208
+ if (buf.trim()) {
209
+ const result = process(buf);
210
+ if (result !== null && result !== undefined)
175
211
  yield result;
176
212
  }
177
213
  }
178
- // Process any residual data after stream ends
179
- if (buf.trim()) {
180
- const result = process(buf);
181
- if (result !== null && result !== undefined)
182
- yield result;
214
+ catch (error) {
215
+ onError(error);
216
+ throw error;
217
+ }
218
+ finally {
219
+ onClose();
183
220
  }
184
221
  }
185
222
  function parseResponseLine(line) {
@@ -204,23 +241,25 @@ function parseResponseLine(line) {
204
241
  * `undefined` for frames the caller should skip, or the value extracted from
205
242
  * the frame.
206
243
  */
207
- function processWith(line, extract) {
244
+ function processWith(line, extract, onStats) {
208
245
  const response = parseResponseLine(line);
209
246
  if (response === null)
210
247
  return undefined;
211
248
  if (response.error)
212
249
  throw new TranscriptionFailedError(response.error);
213
- if (response.done)
250
+ if (response.done) {
251
+ onStats(response.stats);
214
252
  return null;
253
+ }
215
254
  return extract(response);
216
255
  }
217
- function processLine(line) {
218
- return processWith(line, (response) => (response.text?.trim() ? response.text : undefined));
256
+ export function processLine(line, onStats) {
257
+ return processWith(line, (response) => (response.text?.trim() ? response.text : undefined), onStats);
219
258
  }
220
- function processLineMetadata(line) {
221
- return processWith(line, (response) => response.segment);
259
+ function processLineMetadata(line, onStats) {
260
+ return processWith(line, (response) => response.segment, onStats);
222
261
  }
223
- function processLineConversation(line, wantsMetadata) {
262
+ function processLineConversation(line, wantsMetadata, onStats) {
224
263
  return processWith(line, (response) => {
225
264
  if (response.vad) {
226
265
  return {
@@ -252,5 +291,5 @@ function processLineConversation(line, wantsMetadata) {
252
291
  return { type: 'text', text: response.text };
253
292
  }
254
293
  return undefined;
255
- });
294
+ }, onStats);
256
295
  }
@@ -1,7 +1,5 @@
1
1
  import { stream as streamRpc } from '../dispatch.js';
2
- import { translateResponseSchema, normalizeModelType, ModelType } from '../schemas/index.js';
3
- import { detectOne } from '@qvac/langdetect-text';
4
- import { TranslationFailedError } from '../errors/index.js';
2
+ import { translateResponseSchema } from '../schemas/index.js';
5
3
  /**
6
4
  * Translates text from one language to another using a specified translation model.
7
5
  * Supports both NMT (Neural Machine Translation) and LLM models.
@@ -44,22 +42,13 @@ import { TranslationFailedError } from '../errors/index.js';
44
42
  * ```
45
43
  */
46
44
  export function translate(params, options) {
47
- const canonicalModelType = normalizeModelType(params.modelType);
48
- const isLlm = canonicalModelType === ModelType.llamacppCompletion;
49
- let sourceLanguage = isLlm ? params.from : undefined;
50
- if (!sourceLanguage && isLlm) {
51
- const detected = detectOne(params.text);
52
- if (detected.code === 'und' || detected.language === 'Undetermined') {
53
- throw new TranslationFailedError("Could not detect the source language. Please specify the 'from' parameter explicitly.");
54
- }
55
- sourceLanguage = detected.language;
56
- }
45
+ // Source-language auto-detection lives in the engine op
46
+ // (plugins/ops/translate.ts): `from` is passed through when present and
47
+ // resolved engine-side when absent, so every language binding shares one
48
+ // detector instead of each shipping its own.
57
49
  const request = {
58
50
  type: 'translate',
59
- ...params,
60
- ...(isLlm && {
61
- from: sourceLanguage
62
- })
51
+ ...params
63
52
  };
64
53
  let stats;
65
54
  let statsResolver = () => { };
package/dist/api/vla.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type VlaClientRunParams, type VlaClientRunResult, type VlaHparams } from '../schemas/index.js';
1
+ import { type VlaClientRunParams, type VlaClientRunResult, type VlaEmbodimentSelection, type VlaHparams } from '../schemas/index.js';
2
2
  /**
3
3
  * Run VLA inference on a loaded model (SmolVLA or π₀.₅) and return the
4
4
  * produced action chunk plus per-stage timings.
@@ -66,3 +66,44 @@ export declare function vlaHparams(params: {
66
66
  hparams: VlaHparams;
67
67
  backendName: string | null;
68
68
  }>;
69
+ /**
70
+ * Switch a loaded multi-embodiment GR00T model to another embodiment shipped
71
+ * in the same GGUF — no reload, only that embodiment's weight rows are re-read.
72
+ *
73
+ * The returned hparams follow the newly active embodiment: re-read
74
+ * `numCameras` (and re-size buffers if needed) before the next `vla()` call.
75
+ * `selectedEmbodimentTag` / `selectedEmbodimentCatId` report what was
76
+ * resolved. Selecting by `catId` reports that id's canonical tag, which may
77
+ * differ from the alias used to select — the id is the stable identity.
78
+ *
79
+ * Rejects (leaving the current embodiment active) for a non-GR00T or
80
+ * single-embodiment model, an unknown tag or `cat_id`, one not stored in the
81
+ * GGUF, an embodiment with no known camera count and no `numCameras`
82
+ * override, or while an inference response is still pending — await the
83
+ * in-flight `vla()` call first.
84
+ *
85
+ * @param params.modelId - Identifier of the loaded VLA model.
86
+ * @param params.embodiment - The embodiment to activate: a tag string, a
87
+ * numeric `cat_id` (0..31), or `{ tag | catId, numCameras }` where
88
+ * `numCameras` overrides the camera count stored in the GGUF.
89
+ * @returns The refreshed model hparams after the switch.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * import { loadModel, vlaSetEmbodiment, vlaHparams } from "@qvac/inference";
94
+ *
95
+ * const modelId = await loadModel({
96
+ * modelSrc: "/path/to/groot-multi.gguf",
97
+ * modelType: "vla",
98
+ * modelConfig: { embodiment: "libero_sim" }, // initial selection at load
99
+ * });
100
+ * const { hparams } = await vlaSetEmbodiment({ modelId, embodiment: "real_droid" });
101
+ * console.log(hparams.selectedEmbodimentTag, hparams.numCameras);
102
+ * ```
103
+ */
104
+ export declare function vlaSetEmbodiment(params: {
105
+ modelId: string;
106
+ embodiment: VlaEmbodimentSelection;
107
+ }): Promise<{
108
+ hparams: VlaHparams;
109
+ }>;
package/dist/api/vla.js CHANGED
@@ -1,8 +1,9 @@
1
- import { vlaHparamsResponseSchema, vlaRunResponseSchema } from '../schemas/index.js';
1
+ import { vlaHparamsResponseSchema, vlaRunResponseSchema, vlaSetEmbodimentResponseSchema } from '../schemas/index.js';
2
2
  import { decodeBase64, encodeBase64 } from '../utils/encoding.js';
3
3
  import { invokePlugin } from '../api/invoke-plugin.js';
4
4
  const VLA_RUN_HANDLER = 'vlaRun';
5
5
  const VLA_HPARAMS_HANDLER = 'vlaHparams';
6
+ const VLA_SET_EMBODIMENT_HANDLER = 'vlaSetEmbodiment';
6
7
  function bytesOf(arr) {
7
8
  return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
8
9
  }
@@ -111,3 +112,51 @@ export async function vlaHparams(params) {
111
112
  });
112
113
  return vlaHparamsResponseSchema.parse(result);
113
114
  }
115
+ /**
116
+ * Switch a loaded multi-embodiment GR00T model to another embodiment shipped
117
+ * in the same GGUF — no reload, only that embodiment's weight rows are re-read.
118
+ *
119
+ * The returned hparams follow the newly active embodiment: re-read
120
+ * `numCameras` (and re-size buffers if needed) before the next `vla()` call.
121
+ * `selectedEmbodimentTag` / `selectedEmbodimentCatId` report what was
122
+ * resolved. Selecting by `catId` reports that id's canonical tag, which may
123
+ * differ from the alias used to select — the id is the stable identity.
124
+ *
125
+ * Rejects (leaving the current embodiment active) for a non-GR00T or
126
+ * single-embodiment model, an unknown tag or `cat_id`, one not stored in the
127
+ * GGUF, an embodiment with no known camera count and no `numCameras`
128
+ * override, or while an inference response is still pending — await the
129
+ * in-flight `vla()` call first.
130
+ *
131
+ * @param params.modelId - Identifier of the loaded VLA model.
132
+ * @param params.embodiment - The embodiment to activate: a tag string, a
133
+ * numeric `cat_id` (0..31), or `{ tag | catId, numCameras }` where
134
+ * `numCameras` overrides the camera count stored in the GGUF.
135
+ * @returns The refreshed model hparams after the switch.
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * import { loadModel, vlaSetEmbodiment, vlaHparams } from "@qvac/inference";
140
+ *
141
+ * const modelId = await loadModel({
142
+ * modelSrc: "/path/to/groot-multi.gguf",
143
+ * modelType: "vla",
144
+ * modelConfig: { embodiment: "libero_sim" }, // initial selection at load
145
+ * });
146
+ * const { hparams } = await vlaSetEmbodiment({ modelId, embodiment: "real_droid" });
147
+ * console.log(hparams.selectedEmbodimentTag, hparams.numCameras);
148
+ * ```
149
+ */
150
+ export async function vlaSetEmbodiment(params) {
151
+ const wireRequest = {
152
+ type: 'vlaSetEmbodiment',
153
+ modelId: params.modelId,
154
+ embodiment: params.embodiment
155
+ };
156
+ const result = await invokePlugin({
157
+ modelId: params.modelId,
158
+ handler: VLA_SET_EMBODIMENT_HANDLER,
159
+ params: wireRequest
160
+ });
161
+ return vlaSetEmbodimentResponseSchema.parse(result);
162
+ }
@@ -1 +1,2 @@
1
- export { FORMATS_NEEDING_DECODE, SUPPORTED_AUDIO_FORMATS } from '@qvac/decoder-audio/constants';
1
+ export declare const FORMATS_NEEDING_DECODE: readonly string[];
2
+ export declare const SUPPORTED_AUDIO_FORMATS: readonly string[];
@@ -1 +1,17 @@
1
- export { FORMATS_NEEDING_DECODE, SUPPORTED_AUDIO_FORMATS } from '@qvac/decoder-audio/constants';
1
+ export const FORMATS_NEEDING_DECODE = [
2
+ '.mp3',
3
+ '.m4a',
4
+ '.ogg',
5
+ '.flac',
6
+ '.aac',
7
+ '.wav'
8
+ ];
9
+ export const SUPPORTED_AUDIO_FORMATS = [
10
+ '.mp3',
11
+ '.m4a',
12
+ '.ogg',
13
+ '.wav',
14
+ '.flac',
15
+ '.aac',
16
+ '.raw'
17
+ ];
@@ -247,6 +247,9 @@ export declare class ImageFileNotFoundError extends QvacErrorBase {
247
247
  export declare class InvalidImageInputError extends QvacErrorBase {
248
248
  constructor(cause?: unknown);
249
249
  }
250
+ export declare class InvalidAudioInputError extends QvacErrorBase {
251
+ constructor(details?: string, cause?: unknown);
252
+ }
250
253
  export declare class RAGSaveFailedError extends QvacErrorBase {
251
254
  constructor(details?: string, cause?: unknown);
252
255
  }
@@ -391,6 +391,11 @@ export class InvalidImageInputError extends QvacErrorBase {
391
391
  super(createErrorOptions(ERROR_CODES.INVALID_IMAGE_INPUT, undefined, cause));
392
392
  }
393
393
  }
394
+ export class InvalidAudioInputError extends QvacErrorBase {
395
+ constructor(details, cause) {
396
+ super(createErrorOptions(ERROR_CODES.INVALID_AUDIO_INPUT, details ? [details] : undefined, cause));
397
+ }
398
+ }
394
399
  // ============== RAG operations ==============
395
400
  export class RAGSaveFailedError extends QvacErrorBase {
396
401
  constructor(details, cause) {
@@ -74,7 +74,7 @@ export async function handleLoadModel(request, progressCallback) {
74
74
  if (isReloadConfigRequest(request)) {
75
75
  return handleConfigReload(request);
76
76
  }
77
- const { modelSrc, modelName, seed } = request;
77
+ const { modelSrc, modelName, seed, fallbackSrc } = request;
78
78
  const canonicalModelType = normalizeModelType(request.modelType);
79
79
  const profilingMeta = request[PROFILING_KEY];
80
80
  const profilingEnabled = profilingMeta?.enabled !== false && !!profilingMeta;
@@ -113,7 +113,7 @@ export async function handleLoadModel(request, progressCallback) {
113
113
  requestId
114
114
  }
115
115
  });
116
- const primaryResolve = session.resolvePrimaryModelPath(modelSrc);
116
+ const primaryResolve = session.resolvePrimaryModelPath(modelSrc, fallbackSrc);
117
117
  let resolvedModelPath;
118
118
  let pluginResolveResult;
119
119
  try {
@@ -25,7 +25,7 @@ export interface ResolveSessionOptions {
25
25
  requestBinding?: DownloadRequestBinding | undefined;
26
26
  }
27
27
  export interface ResolveSession {
28
- resolvePrimaryModelPath(modelSrc: unknown): Promise<string>;
28
+ resolvePrimaryModelPath(modelSrc: unknown, fallbackSrc?: string): Promise<string>;
29
29
  createResolveContext(modelSrc: string, modelType: string, modelName?: string): ResolveContext;
30
30
  getAggregateResult(): ResolveResult | undefined;
31
31
  cancelAll(): void;
@@ -12,14 +12,14 @@ export function createResolveSession(options) {
12
12
  },
13
13
  ...(requestBinding !== undefined && { requestBinding })
14
14
  };
15
- async function resolvePrimaryModelPath(modelSrc) {
15
+ async function resolvePrimaryModelPath(modelSrc, fallbackSrc) {
16
16
  if (profilingEnabled) {
17
- const result = await resolveModelPathWithStats(modelSrc, progressCallback, seed, signal, downloadHooks);
17
+ const result = await resolveModelPathWithStats(modelSrc, progressCallback, seed, signal, downloadHooks, fallbackSrc);
18
18
  primaryResult = result;
19
19
  resolveResults.push(result);
20
20
  return result.path;
21
21
  }
22
- return resolveModelPath(modelSrc, progressCallback, seed, signal, downloadHooks);
22
+ return resolveModelPath(modelSrc, progressCallback, seed, signal, downloadHooks, fallbackSrc);
23
23
  }
24
24
  async function resolveForPlugin(src) {
25
25
  if (profilingEnabled) {
@@ -1,5 +1,15 @@
1
1
  import { type ModelProgressUpdate } from '../../schemas/index.js';
2
2
  import type { ResolveResult, DownloadHooks } from '../../handlers/load-model/types.js';
3
3
  import type { AbortSignal } from 'bare-abort-controller';
4
- export declare function resolveModelPath(modelSrc: unknown, progressCallback?: (progress: ModelProgressUpdate) => void, seed?: boolean, signal?: AbortSignal, hooks?: DownloadHooks): Promise<string>;
5
- export declare function resolveModelPathWithStats(modelSrc: unknown, progressCallback?: (progress: ModelProgressUpdate) => void, seed?: boolean, signal?: AbortSignal, hooks?: DownloadHooks): Promise<ResolveResult>;
4
+ type ResolveMode = 'base' | 'stats';
5
+ export declare function resolveFallbackModel(fallbackSrc: string, expectedChecksum: string | undefined, progressCallback: ((progress: ModelProgressUpdate) => void) | undefined, mode: ResolveMode, signal: AbortSignal | undefined, hooks: DownloadHooks | undefined): Promise<ResolveResult>;
6
+ export declare function resolveRegistryModel(params: {
7
+ hasFallback: boolean;
8
+ isKnownModel: boolean;
9
+ downloadPrimary: () => Promise<ResolveResult>;
10
+ resolveFallback: () => Promise<ResolveResult>;
11
+ buildUnreachableError: (cause: unknown) => Error;
12
+ }): Promise<ResolveResult>;
13
+ export declare function resolveModelPath(modelSrc: unknown, progressCallback?: (progress: ModelProgressUpdate) => void, seed?: boolean, signal?: AbortSignal, hooks?: DownloadHooks, fallbackSrc?: string): Promise<string>;
14
+ export declare function resolveModelPathWithStats(modelSrc: unknown, progressCallback?: (progress: ModelProgressUpdate) => void, seed?: boolean, signal?: AbortSignal, hooks?: DownloadHooks, fallbackSrc?: string): Promise<ResolveResult>;
15
+ export {};