@qvac/inference 0.20.1 → 0.21.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 (212) hide show
  1. package/NOTICE +90 -24
  2. package/README.md +8 -5
  3. package/dist/api/bci-transcribe.d.ts +4 -1
  4. package/dist/api/index.d.ts +1 -0
  5. package/dist/api/index.js +1 -0
  6. package/dist/api/rpc-server.d.ts +19 -0
  7. package/dist/api/rpc-server.js +44 -0
  8. package/dist/api/text-to-speech.d.ts +9 -0
  9. package/dist/api/text-to-speech.js +9 -0
  10. package/dist/api/transcribe.d.ts +11 -7
  11. package/dist/api/transcribe.js +47 -15
  12. package/dist/api/video-request.d.ts +5 -5
  13. package/dist/dispatch.js +39 -7
  14. package/dist/errors/index.d.ts +7 -0
  15. package/dist/errors/index.js +15 -0
  16. package/dist/handlers/assess-model-fit.d.ts +8 -20
  17. package/dist/handlers/assess-model-fit.js +195 -77
  18. package/dist/handlers/completion-orchestrate.js +17 -0
  19. package/dist/handlers/get-loaded-model-info.js +4 -1
  20. package/dist/handlers/get-model-info.js +29 -1
  21. package/dist/handlers/load-model/coreml-sidecars.d.ts +25 -0
  22. package/dist/handlers/load-model/coreml-sidecars.js +274 -0
  23. package/dist/handlers/load-model/hyperdrive.js +2 -2
  24. package/dist/handlers/load-model/registry.js +59 -0
  25. package/dist/handlers/rpc-server.d.ts +23 -0
  26. package/dist/handlers/rpc-server.js +141 -0
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +2 -1
  29. package/dist/models/registry/models.d.ts +7731 -5672
  30. package/dist/models/registry/models.js +4652 -2526
  31. package/dist/models/registry/resource-profiles.js +481 -94
  32. package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +8 -6
  33. package/dist/plugins/builtin/audiogen-ggml/plugin.js +2 -1
  34. package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +73 -1
  35. package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +37 -19
  36. package/dist/plugins/builtin/ggml-vla/plugin.d.ts +1 -1
  37. package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +9 -5
  38. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +1 -1
  39. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +16 -7
  40. package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +22 -11
  41. package/dist/plugins/builtin/llamacpp-completion/plugin.js +9 -3
  42. package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +5 -3
  43. package/dist/plugins/builtin/llamacpp-embedding/plugin.js +2 -1
  44. package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +121 -0
  45. package/dist/plugins/builtin/parakeet-transcription/plugin.js +56 -27
  46. package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +8 -2
  47. package/dist/plugins/builtin/sdcpp-generation/plugin.js +7 -2
  48. package/dist/plugins/builtin/tts-ggml/ops/parler-options.d.ts +2 -0
  49. package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +5 -1
  50. package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +27 -10
  51. package/dist/plugins/builtin/tts-ggml/plugin.d.ts +181 -0
  52. package/dist/plugins/builtin/tts-ggml/plugin.js +84 -2
  53. package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +136 -0
  54. package/dist/plugins/builtin/whispercpp-transcription/plugin.js +18 -7
  55. package/dist/plugins/ops/bci-transcribe.d.ts +6 -2
  56. package/dist/plugins/ops/bci-transcribe.js +18 -13
  57. package/dist/plugins/ops/load-model.js +2 -2
  58. package/dist/plugins/ops/transcribe.d.ts +4 -2
  59. package/dist/plugins/ops/transcribe.js +39 -2
  60. package/dist/plugins/ops/translate-stats.d.ts +2 -1
  61. package/dist/plugins/ops/translate-stats.js +64 -7
  62. package/dist/plugins/ops/translate.js +20 -4
  63. package/dist/profiling/operation-metrics.js +56 -0
  64. package/dist/registry.js +4 -0
  65. package/dist/resources/model-fit/assess.d.ts +37 -2
  66. package/dist/resources/model-fit/assess.js +24 -3
  67. package/dist/resources/model-fit/estimators/llm.js +2 -2
  68. package/dist/resources/model-fit/estimators/whisper.js +3 -4
  69. package/dist/resources/model-fit/fit-stub/fetch-fit-stub.d.ts +20 -1
  70. package/dist/resources/model-fit/fit-stub/fetch-fit-stub.js +126 -47
  71. package/dist/resources/model-fit/fit-stub/project-fit-from-load.d.ts +27 -0
  72. package/dist/resources/model-fit/fit-stub/project-fit-from-load.js +31 -0
  73. package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts +38 -0
  74. package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.js +138 -0
  75. package/dist/resources/model-fit/floor.js +2 -2
  76. package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +9 -6
  77. package/dist/resources/model-fit/native-probe/advisory-fit.js +129 -80
  78. package/dist/resources/model-fit/native-probe/child-engine-fit.d.ts +2 -0
  79. package/dist/resources/model-fit/native-probe/child-engine-fit.js +41 -0
  80. package/dist/resources/model-fit/native-probe/classify-fit.d.ts +6 -0
  81. package/dist/resources/model-fit/native-probe/classify-fit.js +135 -0
  82. package/dist/resources/model-fit/native-probe/create-fit-request.d.ts +28 -0
  83. package/dist/resources/model-fit/native-probe/create-fit-request.js +51 -0
  84. package/dist/resources/model-fit/native-probe/engine-fit.d.ts +59 -0
  85. package/dist/resources/model-fit/native-probe/engine-fit.js +13 -0
  86. package/dist/resources/model-fit/native-probe/engines/asr.d.ts +10 -0
  87. package/dist/resources/model-fit/native-probe/engines/asr.js +103 -0
  88. package/dist/resources/model-fit/native-probe/engines/audiogen.d.ts +8 -0
  89. package/dist/resources/model-fit/native-probe/engines/audiogen.js +35 -0
  90. package/dist/resources/model-fit/native-probe/engines/diffusion.d.ts +7 -0
  91. package/dist/resources/model-fit/native-probe/engines/diffusion.js +55 -0
  92. package/dist/resources/model-fit/native-probe/engines/gpu.d.ts +10 -0
  93. package/dist/resources/model-fit/native-probe/engines/gpu.js +21 -0
  94. package/dist/resources/model-fit/native-probe/engines/llama.d.ts +13 -0
  95. package/dist/resources/model-fit/native-probe/engines/llama.js +145 -0
  96. package/dist/resources/model-fit/native-probe/engines/tts.d.ts +8 -0
  97. package/dist/resources/model-fit/native-probe/engines/tts.js +106 -0
  98. package/dist/resources/model-fit/native-probe/fit-outcome.d.ts +16 -0
  99. package/dist/resources/model-fit/native-probe/fit-outcome.js +1 -0
  100. package/dist/resources/model-fit/native-probe/fit-process.d.ts +27 -0
  101. package/dist/resources/model-fit/native-probe/fit-process.js +55 -0
  102. package/dist/resources/model-fit/native-probe/fit-runner.d.ts +1 -0
  103. package/dist/resources/model-fit/native-probe/fit-runner.js +58 -0
  104. package/dist/resources/model-fit/native-probe/run-fit.d.ts +24 -0
  105. package/dist/resources/model-fit/native-probe/run-fit.js +20 -0
  106. package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +14 -34
  107. package/dist/resources/model-fit/native-probe/run-in-process-fit.js +55 -139
  108. package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +5 -12
  109. package/dist/resources/model-fit/native-probe/run-isolated-fit.js +13 -8
  110. package/dist/resources/model-fit/platform.d.ts +9 -0
  111. package/dist/resources/model-fit/platform.js +28 -0
  112. package/dist/rpc/device-map.d.ts +13 -0
  113. package/dist/rpc/device-map.js +22 -0
  114. package/dist/rpc/discovery.d.ts +12 -0
  115. package/dist/rpc/discovery.js +225 -0
  116. package/dist/rpc/ggml-provider.d.ts +4 -0
  117. package/dist/rpc/ggml-provider.js +25 -0
  118. package/dist/rpc/index.d.ts +2 -0
  119. package/dist/rpc/index.js +1 -0
  120. package/dist/rpc/instance.d.ts +6 -0
  121. package/dist/rpc/instance.js +21 -0
  122. package/dist/rpc/inventory.d.ts +5 -0
  123. package/dist/rpc/inventory.js +144 -0
  124. package/dist/rpc/manager.d.ts +14 -0
  125. package/dist/rpc/manager.js +174 -0
  126. package/dist/rpc/network.d.ts +11 -0
  127. package/dist/rpc/network.js +85 -0
  128. package/dist/rpc/provider.d.ts +6 -0
  129. package/dist/rpc/provider.js +24 -0
  130. package/dist/runtime/lifecycle.js +31 -13
  131. package/dist/runtime/request-context.d.ts +1 -1
  132. package/dist/runtime/state.js +5 -0
  133. package/dist/schemas/assess-model-fit.d.ts +269 -85
  134. package/dist/schemas/assess-model-fit.js +78 -54
  135. package/dist/schemas/audio-gen.d.ts +6 -6
  136. package/dist/schemas/audio-gen.js +2 -2
  137. package/dist/schemas/batch-completion-stream.d.ts +13 -5
  138. package/dist/schemas/batch-completion-stream.js +5 -3
  139. package/dist/schemas/bci-config.js +1 -1
  140. package/dist/schemas/bci.d.ts +86 -1
  141. package/dist/schemas/bci.js +21 -2
  142. package/dist/schemas/cancel.d.ts +10 -0
  143. package/dist/schemas/cancel.js +2 -0
  144. package/dist/schemas/common.d.ts +708 -66
  145. package/dist/schemas/common.js +7 -0
  146. package/dist/schemas/completion-event.d.ts +6 -6
  147. package/dist/schemas/completion-stream.d.ts +27 -8
  148. package/dist/schemas/completion-stream.js +41 -4
  149. package/dist/schemas/config.d.ts +104 -36
  150. package/dist/schemas/config.js +10 -0
  151. package/dist/schemas/embed.d.ts +2 -2
  152. package/dist/schemas/error.js +13 -0
  153. package/dist/schemas/errors.d.ts +1 -0
  154. package/dist/schemas/errors.js +5 -0
  155. package/dist/schemas/index.d.ts +1 -0
  156. package/dist/schemas/index.js +1 -0
  157. package/dist/schemas/llamacpp-config.d.ts +25 -18
  158. package/dist/schemas/llamacpp-config.js +26 -16
  159. package/dist/schemas/load-model.d.ts +2608 -469
  160. package/dist/schemas/load-model.js +2 -2
  161. package/dist/schemas/mcp-adapter.d.ts +4 -0
  162. package/dist/schemas/model-config-schemas.d.ts +183 -6
  163. package/dist/schemas/model-info.d.ts +56 -0
  164. package/dist/schemas/model-info.js +5 -1
  165. package/dist/schemas/plugin.d.ts +8 -2
  166. package/dist/schemas/profiling.d.ts +4 -4
  167. package/dist/schemas/reload-config.d.ts +30 -0
  168. package/dist/schemas/rpc-server.d.ts +101 -0
  169. package/dist/schemas/rpc-server.js +87 -0
  170. package/dist/schemas/sdcpp-config.d.ts +7 -3
  171. package/dist/schemas/sdcpp-config.js +37 -2
  172. package/dist/schemas/system-resources.d.ts +4 -4
  173. package/dist/schemas/text-to-speech.d.ts +529 -1
  174. package/dist/schemas/text-to-speech.js +122 -12
  175. package/dist/schemas/tools.d.ts +2 -0
  176. package/dist/schemas/tools.js +8 -0
  177. package/dist/schemas/transcription-config.d.ts +5 -0
  178. package/dist/schemas/transcription-config.js +20 -2
  179. package/dist/schemas/transcription.d.ts +164 -0
  180. package/dist/schemas/transcription.js +71 -4
  181. package/dist/schemas/vla.d.ts +1 -1
  182. package/dist/surface.d.ts +4 -1
  183. package/dist/surface.js +3 -1
  184. package/dist/utils/addon-responses.d.ts +5 -1
  185. package/dist/utils/archive.js +5 -1
  186. package/dist/utils/asr-diagnostics.d.ts +12 -0
  187. package/dist/utils/asr-diagnostics.js +42 -0
  188. package/dist/utils/asr-events.d.ts +1 -0
  189. package/dist/utils/asr-events.js +3 -2
  190. package/dist/utils/cache/paths.js +3 -2
  191. package/dist/utils/mcp-adapter.js +7 -1
  192. package/dist/utils/multi-gpu-mobile.d.ts +1 -1
  193. package/dist/utils/multi-gpu-mobile.js +8 -6
  194. package/dist/utils/path-security.d.ts +5 -0
  195. package/dist/utils/path-security.js +14 -0
  196. package/dist/utils/tool-helpers.d.ts +4 -0
  197. package/dist/utils/tool-helpers.js +2 -0
  198. package/dist/utils/tools/defer.d.ts +93 -0
  199. package/dist/utils/tools/defer.js +290 -0
  200. package/dist/utils/tools/index.d.ts +1 -0
  201. package/dist/utils/tools/index.js +1 -0
  202. package/dist/utils/transcribe-metadata.d.ts +21 -7
  203. package/dist/utils/transcribe-metadata.js +24 -8
  204. package/dist/utils/tts-stats.d.ts +6 -0
  205. package/dist/utils/tts-stats.js +14 -1
  206. package/package.json +43 -29
  207. package/dist/resources/model-fit/fit-stub/index.d.ts +0 -2
  208. package/dist/resources/model-fit/fit-stub/index.js +0 -2
  209. package/dist/resources/model-fit/fit-stub/project-fit-from-stub.d.ts +0 -31
  210. package/dist/resources/model-fit/fit-stub/project-fit-from-stub.js +0 -36
  211. package/dist/resources/model-fit/native-probe/create-llama-fit-request.d.ts +0 -26
  212. package/dist/resources/model-fit/native-probe/create-llama-fit-request.js +0 -191
package/dist/surface.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { type LifecycleState, type ModelProgressUpdate, type LoadModelOptions, type LoadCustomPluginModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionEvent, type CompletionFinal, type CompletionRun, type CompletionStats, type BatchCompletionEvent, type BatchCompletionResult, type BatchCompletionRun, type BatchPrompt, type EmbedStats, VERBOSITY, type Attachment, type TranscribeStreamSession, type TranscribeStreamMetadataSession, type TranscribeStreamConversationSession, type TranscribeStreamEvent, type VadStateEvent, type EndOfTurnEvent, type TranscribeSegment, type BciConfig, type BciTranscribeClientParams, type BciTranscribeStreamClientParams, type BciTranscribeStreamSession, type BciTranscribeStreamMetadataSession, type BciStreamOpts, type NeuralInput, type TextToSpeechStreamSession, type TextToSpeechStreamResponse, type TextToSpeechStreamClientParams, type CompletionParams, type ToolDialect, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, ERROR_CODES, RAG_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type GetLoadedModelInfoParams, type LoadedModelInfo, type GetSystemResourcesInput, type ResourceScope, type ResourceProvenance, type ResourceMetric, type GraphicsDriver, type GraphicsDriverCapabilities, type BackendProbeResult, type BackendDevice, type BackendDriver, type BackendFallback, type InferenceBackendDiagnostics, type CPUResourceCapabilities, type GPUResourceCapabilities, type SystemResourceCapabilities, type GPUResourceSample, type SystemResourceSample, type SystemResources, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, type ClassifyClientParams, type ClassificationResult, type DiffusionClientParams, type DiffusionStreamResponse, type DiffusionStats, type VideoClientParams, type VideoStreamResponse, type VideoStats, type UpscaleClientParams, type UpscaleStreamResponse, type UpscaleStats, type VlaConfig, type VlaClientRunParams, type VlaClientRunResult, type VlaHparams, type VlaStats, definePlugin, defineHandler, defineDuplexHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, BUILTIN_PLUGINS, type BuiltinPlugin, type ProfilerMode, type FinetuneValidation, type FinetuneRunParams, type FinetuneGetStateParams, type FinetuneStopParams, type FinetuneParams, type FinetuneStatus, type FinetuneProgress, type FinetuneStats, type FinetuneResult, MODEL_TYPES, ModelType } from './schemas/index.js';
2
2
  export { type ToolInput, type ToolHandler } from './utils/tool-helpers.js';
3
+ export { TOOL_SEARCH_NAME, buildToolSearchTool, executeToolSearch, loadedToolNames, searchDeferredTools } from './utils/tools/defer.js';
3
4
  export * from './schemas/index.js';
4
5
  export * from './profiling/index.js';
5
6
  export * from './constants/index.js';
@@ -10,9 +11,11 @@ export { readBackendDiagnostics } from './profiling/backend-diagnostics.js';
10
11
  export { PUBLIC_MODEL_TYPES, ModelTypeAliases, modelTypeInputSchema, modelTypeSchema } from './schemas/model-types.js';
11
12
  export * from './models/registry/index.js';
12
13
  export { SUPPORTED_AUDIO_FORMATS } from './constants/audio.js';
13
- export { InferenceCancelledError, ContextOverflowError, type ContextOverflowErrorSizes, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, RequestValidationFailedError, ModelNotLoadedError, TranslationFailedError, PluginDefinitionInvalidError, PluginModelTypeReservedError, PluginAlreadyRegisteredError, PluginLoggingInvalidError } from './errors/index.js';
14
+ export { RpcServerOperationError, InferenceCancelledError, ContextOverflowError, type ContextOverflowErrorSizes, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, RequestValidationFailedError, ModelNotLoadedError, TranslationFailedError, PluginDefinitionInvalidError, PluginModelTypeReservedError, PluginAlreadyRegisteredError, PluginLoggingInvalidError } from './errors/index.js';
14
15
  export type { InferenceCancelledPartial } from './errors/index.js';
15
16
  export { getLogger, LOG_ID, ALL_LOG_ID } from './logging/index.js';
16
17
  export type { Logger, LogTransport, LoggerOptions } from './logging/index.js';
17
18
  export { profiler, attachBackendDiagnostics } from './profiling/index.js';
18
19
  export type { ProfilerRuntimeOptions, ProfilerExport } from './profiling/index.js';
20
+ export type { RpcServerProvider, RpcServerHandle } from './schemas/rpc-server.js';
21
+ export { getRpcDeviceMap, type RpcDeviceMapping } from './rpc/device-map.js';
package/dist/surface.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // build), so it pulls no runtime dependency and no engine. `index.ts` re-exports
4
4
  // it alongside the engine.
5
5
  export { VERBOSITY, ERROR_CODES, RAG_ERROR_CODES, toolSchema, definePlugin, defineHandler, defineDuplexHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_VLA, PLUGIN_CLASSIFICATION, BUILTIN_PLUGINS, MODEL_TYPES, ModelType } from './schemas/index.js';
6
+ export { TOOL_SEARCH_NAME, buildToolSearchTool, executeToolSearch, loadedToolNames, searchDeferredTools } from './utils/tools/defer.js';
6
7
  // The full value-clean schema, profiling, and constant barrels: the @qvac/sdk client
7
8
  // and worker source every internal schema/const/profiling name from here, so it
8
9
  // carries no duplicate copies. All value-clean (only erased `import type` touches
@@ -23,8 +24,9 @@ export { SUPPORTED_AUDIO_FORMATS } from './constants/audio.js';
23
24
  // Error classes consumers need for `instanceof` checks: on rejected promises,
24
25
  // and on the synchronous throws of `plugins()` / `registerPlugin` (the plugin
25
26
  // group below).
26
- export { InferenceCancelledError, ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, RequestValidationFailedError, ModelNotLoadedError, TranslationFailedError, PluginDefinitionInvalidError, PluginModelTypeReservedError, PluginAlreadyRegisteredError, PluginLoggingInvalidError } from './errors/index.js';
27
+ export { RpcServerOperationError, InferenceCancelledError, ContextOverflowError, RequestIdConflictError, RequestNotFoundError, RequestRejectedByPolicyError, RequestValidationFailedError, ModelNotLoadedError, TranslationFailedError, PluginDefinitionInvalidError, PluginModelTypeReservedError, PluginAlreadyRegisteredError, PluginLoggingInvalidError } from './errors/index.js';
27
28
  // Logging
28
29
  export { getLogger, LOG_ID, ALL_LOG_ID } from './logging/index.js';
29
30
  // Profiler
30
31
  export { profiler, attachBackendDiagnostics } from './profiling/index.js';
32
+ export { getRpcDeviceMap } from './rpc/device-map.js';
@@ -29,13 +29,17 @@ export interface TtsStats {
29
29
  realTimeFactor?: number;
30
30
  tokensPerSecond?: number;
31
31
  totalSamples?: number;
32
- /** Audio8 only: codec frames generated, on a fixed 46 ms grid. */
32
+ /** Audio8 and MOSS only: codec frames generated (Audio8 on a 46 ms grid, MOSS at 12.5/s). */
33
33
  generatedFrames?: number;
34
34
  backendDevice?: number;
35
35
  backendId?: number;
36
36
  gpuUnsupported?: number;
37
37
  enhancerBackendDevice?: number;
38
38
  enhancerBackendId?: number;
39
+ /** Audio8 only, macOS / iOS: 1 while the Core ML codec sidecar is attached. */
40
+ codecSidecarLoaded?: number;
41
+ /** Audio8 only: 1 when the synthesis ran its codec on that sidecar, 0 on ggml. */
42
+ codecOnCoreml?: number;
39
43
  }
40
44
  /**
41
45
  * @qvac/tts-ggml `TTSOutputChunk & SentenceStreamChunkMeta`. The chunker runs
@@ -117,11 +117,15 @@ export async function extractTarStream(archivePath, extractDir, useGunzip, signa
117
117
  gunzip.on('error', reject);
118
118
  }
119
119
  readStream = fs.createReadStream(archivePath);
120
+ readStream.on('error', reject);
120
121
  // tar-stream's extract is a streamx Writable at runtime; cast past the
121
122
  // nominal private brand its shim can't carry (see types/tar-stream).
122
123
  const extractDest = extract;
123
124
  if (gunzip) {
124
- readStream.pipe(gunzip).pipe(extractDest);
125
+ // bare-fs and bare-zlib ship distinct stream type declarations even
126
+ // though both expose the same pipe chain at runtime.
127
+ const gzipPipe = readStream;
128
+ gzipPipe.pipe(gunzip).pipe(extractDest);
125
129
  }
126
130
  else {
127
131
  readStream.pipe(extractDest);
@@ -0,0 +1,12 @@
1
+ import type { InferenceBackendDiagnostics, TranscribeStats } from '../schemas/index.js';
2
+ /**
3
+ * Map the whisper.cpp-family backend stats onto the shared diagnostics shape,
4
+ * the same way the audiogen op does. Shared by the `@qvac/asr-ggml` engines
5
+ * and `@qvac/bci-whispercpp`. `backendDevice` is the addon's own verdict:
6
+ * `1` means it ran on the GPU, anything else means CPU.
7
+ *
8
+ * The engines report no fallback reason, so `fallback` is never populated —
9
+ * unlike audiogen, a CPU run here is indistinguishable from one that never
10
+ * asked for a GPU.
11
+ */
12
+ export declare function buildAsrBackendDiagnostics(stats: TranscribeStats | undefined): InferenceBackendDiagnostics | undefined;
@@ -0,0 +1,42 @@
1
+ import { graphicsDriverSchema, ASR_BACKEND_IDS } from '../schemas/index.js';
2
+ /**
3
+ * Backend name for a numeric `backendId`, lowercased to match the shared
4
+ * `graphicsDriverSchema` vocabulary. `Other` has no name a caller could act
5
+ * on, so it resolves to `undefined` rather than a guess.
6
+ */
7
+ function asrBackendName(backendId) {
8
+ if (backendId === undefined)
9
+ return undefined;
10
+ for (const [name, id] of Object.entries(ASR_BACKEND_IDS)) {
11
+ if (id === backendId && name !== 'Other')
12
+ return name.toLowerCase();
13
+ }
14
+ return undefined;
15
+ }
16
+ /**
17
+ * Map the whisper.cpp-family backend stats onto the shared diagnostics shape,
18
+ * the same way the audiogen op does. Shared by the `@qvac/asr-ggml` engines
19
+ * and `@qvac/bci-whispercpp`. `backendDevice` is the addon's own verdict:
20
+ * `1` means it ran on the GPU, anything else means CPU.
21
+ *
22
+ * The engines report no fallback reason, so `fallback` is never populated —
23
+ * unlike audiogen, a CPU run here is indistinguishable from one that never
24
+ * asked for a GPU.
25
+ */
26
+ export function buildAsrBackendDiagnostics(stats) {
27
+ if (!stats || stats.backendDevice === undefined)
28
+ return undefined;
29
+ if (stats.backendDevice !== 1) {
30
+ return { selectedBackend: 'cpu', selectedDevice: 'cpu' };
31
+ }
32
+ // A 'cpu' name against backendDevice 1 is the addon contradicting itself.
33
+ const selectedBackend = asrBackendName(stats.backendId);
34
+ if (selectedBackend === undefined || selectedBackend === 'cpu')
35
+ return undefined;
36
+ const graphicsApi = graphicsDriverSchema.safeParse(selectedBackend);
37
+ return {
38
+ selectedBackend,
39
+ selectedDevice: 'gpu',
40
+ ...(graphicsApi.success && { graphicsApi: graphicsApi.data })
41
+ };
42
+ }
@@ -4,6 +4,7 @@ export declare function isEndOfTurnEvent(event: ASRGgml.ASRStreamOutput): event
4
4
  export declare function toVadStateEvent(event: ASRGgml.VadEvent): {
5
5
  speaking: boolean;
6
6
  probability: number;
7
+ source: "silero" | "energy" | "sortformer";
7
8
  };
8
9
  export declare function toEndOfTurnEvent(event: ASRGgml.EndOfTurnEvent): {
9
10
  source: "parakeet";
@@ -3,7 +3,7 @@ export function isVadEvent(event) {
3
3
  event.type === 'vad' &&
4
4
  typeof event.speaking === 'boolean' &&
5
5
  typeof event.score === 'number' &&
6
- (event.source === 'silero' || event.source === 'energy'));
6
+ (event.source === 'silero' || event.source === 'energy' || event.source === 'sortformer'));
7
7
  }
8
8
  export function isEndOfTurnEvent(event) {
9
9
  return (!Array.isArray(event) &&
@@ -13,7 +13,8 @@ export function isEndOfTurnEvent(event) {
13
13
  export function toVadStateEvent(event) {
14
14
  return {
15
15
  speaking: event.speaking,
16
- probability: event.score
16
+ probability: event.score,
17
+ source: event.source
17
18
  };
18
19
  }
19
20
  export function toEndOfTurnEvent(event) {
@@ -3,7 +3,7 @@ import path from 'bare-path';
3
3
  import { getConfiguredCacheDir } from '../../runtime/state.js';
4
4
  import { getQvacPath } from '../qvac-paths.js';
5
5
  import { calculateFileChecksum } from '../checksum.js';
6
- import { validateAndJoinPath } from '../path-security.js';
6
+ import { validateAndJoinPath, joinWithinBase } from '../path-security.js';
7
7
  import { generateShortHash } from '../formatting.js';
8
8
  import { getEngineLogger } from '../../logging/index.js';
9
9
  import { nowMs } from '../../profiling/index.js';
@@ -74,9 +74,10 @@ export function getCompanionSetPath(setKey, targetName) {
74
74
  * Get cache path for a single (non-sharded, non-companion) registry model.
75
75
  */
76
76
  export function getSingleFileCachePath(registryPath) {
77
+ // A path ending in "/" falls back to the whole path, separators included.
77
78
  const filename = registryPath.split('/').pop() || registryPath;
78
79
  const sourceHash = generateShortHash(registryPath);
79
- return path.join(getModelsCacheDir(), `${sourceHash}_${filename}`);
80
+ return joinWithinBase(getModelsCacheDir(), `${sourceHash}_${filename}`);
80
81
  }
81
82
  /**
82
83
  * Get full path to specific shard file
@@ -34,7 +34,8 @@ function createMcpToolHandler(client, toolName) {
34
34
  export async function getMcpToolsWithHandlers(clients) {
35
35
  const allTools = [];
36
36
  const handlers = new Map();
37
- for (const { client, includeResources } of clients) {
37
+ for (const { client, includeResources, deferLoading, group } of clients) {
38
+ const start = allTools.length;
38
39
  const { tools: mcpTools } = await client.listTools();
39
40
  for (const mcpTool of mcpTools) {
40
41
  allTools.push(convertMcpToolToTool(mcpTool));
@@ -87,6 +88,11 @@ export async function getMcpToolsWithHandlers(clients) {
87
88
  });
88
89
  }
89
90
  }
91
+ if (deferLoading === true) {
92
+ for (let i = start; i < allTools.length; i++) {
93
+ allTools[i] = { ...allTools[i], deferLoading: true, ...(group !== undefined && { group }) };
94
+ }
95
+ }
90
96
  }
91
97
  return { tools: allTools, handlers };
92
98
  }
@@ -1,4 +1,4 @@
1
1
  export declare const MULTI_GPU_KEYS: readonly ["main-gpu", "split-mode", "tensor-split"];
2
2
  type MultiGpuKey = (typeof MULTI_GPU_KEYS)[number];
3
- export declare function stripMultiGpuKeys(config: Record<string, unknown>): readonly MultiGpuKey[];
3
+ export declare function stripMultiGpuKeys(config: Record<string, unknown>, preserveRpcSplits?: boolean): readonly MultiGpuKey[];
4
4
  export {};
@@ -1,10 +1,12 @@
1
1
  export const MULTI_GPU_KEYS = ['main-gpu', 'split-mode', 'tensor-split'];
2
- // Deletes any multi-GPU keys from `config` IN PLACE and returns the removed
3
- // keys. Mutation is intentional: callers strip before the config reaches the
4
- // model constructor. gpu_layers (single-GPU layer offload) is intentionally
5
- // absent from MULTI_GPU_KEYS.
6
- export function stripMultiGpuKeys(config) {
7
- const stripped = MULTI_GPU_KEYS.filter((k) => k in config);
2
+ // Deletes unsupported mobile multi-GPU keys in place and returns the removed keys.
3
+ // RPC loads can retain split settings, but main-gpu is always unsupported.
4
+ // gpu_layers controls single-GPU offload and is left unchanged.
5
+ export function stripMultiGpuKeys(config, preserveRpcSplits = false) {
6
+ const keepSplits = preserveRpcSplits &&
7
+ typeof config['rpc-servers'] === 'string' &&
8
+ config['rpc-servers'].trim().length > 0;
9
+ const stripped = MULTI_GPU_KEYS.filter((k) => k in config && (!keepSplits || k === 'main-gpu'));
8
10
  stripped.forEach((k) => delete config[k]);
9
11
  return stripped;
10
12
  }
@@ -13,3 +13,8 @@ export declare function isPathWithinBase(basePath: string, targetPath: string):
13
13
  * stays within the base directory. Throws PathTraversalError on escape.
14
14
  */
15
15
  export declare function validateAndJoinPath(basePath: string, ...components: string[]): string;
16
+ /**
17
+ * Joins `name` under `basePath` without sanitizing it, so cache filenames stay
18
+ * byte-stable. Throws PathTraversalError on a null byte or a `..` segment.
19
+ */
20
+ export declare function joinWithinBase(basePath: string, name: string): string;
@@ -32,3 +32,17 @@ export function validateAndJoinPath(basePath, ...components) {
32
32
  }
33
33
  return resolved;
34
34
  }
35
+ /**
36
+ * Joins `name` under `basePath` without sanitizing it, so cache filenames stay
37
+ * byte-stable. Throws PathTraversalError on a null byte or a `..` segment.
38
+ */
39
+ export function joinWithinBase(basePath, name) {
40
+ if (name.includes('\0') || name.split(/[\\/]/).includes('..')) {
41
+ throw new PathTraversalError(name, basePath);
42
+ }
43
+ const joined = path.join(basePath, name);
44
+ if (!isPathWithinBase(basePath, joined)) {
45
+ throw new PathTraversalError(name, basePath);
46
+ }
47
+ return joined;
48
+ }
@@ -7,6 +7,10 @@ export type ToolInput<T extends ZodObjectType = ZodObjectType> = {
7
7
  description: string;
8
8
  parameters: T;
9
9
  handler?: ToolHandler;
10
+ /** Keep this tool's parameter schema out of the initial prompt; see `Tool.deferLoading`. */
11
+ deferLoading?: boolean;
12
+ /** Heading this tool is listed under in the deferred catalog. */
13
+ group?: string;
10
14
  };
11
15
  export declare function convertToolInput(input: ToolInput): Tool;
12
16
  export declare function convertTools(inputs: ToolInput[]): Tool[];
@@ -54,6 +54,8 @@ export function convertToolInput(input) {
54
54
  type: 'function',
55
55
  name: input.name,
56
56
  description: input.description,
57
+ ...(input.deferLoading !== undefined && { deferLoading: input.deferLoading }),
58
+ ...(input.group !== undefined && { group: input.group }),
57
59
  parameters: {
58
60
  type: 'object',
59
61
  properties,
@@ -0,0 +1,93 @@
1
+ import type { Tool } from '../../schemas/tools.js';
2
+ import { type ToolInput } from '../tool-helpers.js';
3
+ /**
4
+ * Reserved name of the built-in search tool. A caller cannot register a tool
5
+ * under this name, and it is never itself deferred — the model needs one
6
+ * callable entry point to reach everything else.
7
+ */
8
+ export declare const TOOL_SEARCH_NAME = "tool_search";
9
+ export type HistoryMessage = {
10
+ role: string;
11
+ content: string;
12
+ };
13
+ export declare function isDeferred(tool: Tool): boolean;
14
+ export declare function partitionTools(tools: readonly Tool[]): {
15
+ alwaysLoaded: Tool[];
16
+ deferred: Tool[];
17
+ };
18
+ /** Strip the registration-only fields so what reaches the model is a plain definition. */
19
+ export declare function toWireTool(tool: Tool): Tool;
20
+ /**
21
+ * Compact listing of the deferred inventory: one line per tool, name and
22
+ * description only, grouped by `group` where present.
23
+ *
24
+ * Caller order is preserved and groups appear in first-use order, because this
25
+ * text sits in the prompt prefix — a reordering between turns would move the
26
+ * divergence point and cost a re-prefill.
27
+ */
28
+ export declare function buildCatalog(deferred: readonly Tool[]): string;
29
+ /**
30
+ * The built-in search tool, carrying the catalog in its description.
31
+ *
32
+ * The catalog is deliberately not a set of parameterless tool entries: those
33
+ * render into the same native block and the grammar would accept a call to a
34
+ * tool whose schema the model has never seen. Description text cannot be
35
+ * called, which is the whole point.
36
+ */
37
+ export declare function buildToolSearchTool(deferred: readonly Tool[]): Tool;
38
+ /**
39
+ * Rank the deferred inventory against a query. Exact name first, then text
40
+ * match. Ties keep registration order so repeated searches are deterministic.
41
+ */
42
+ export declare function searchDeferredTools(deferred: readonly Tool[], query: string, limit?: number): Tool[];
43
+ export declare function buildToolSearchResult(query: string, matches: readonly Tool[], alreadyLoaded: readonly string[]): string;
44
+ /**
45
+ * Which deferred definitions this conversation already carries.
46
+ *
47
+ * Read back from the history rather than held in the session, so `completion()`
48
+ * stays stateless: a reopened chat replaying the same messages resolves the
49
+ * same loaded set, and two concurrent conversations cannot see each other's.
50
+ */
51
+ export declare function loadedToolNames(history: readonly HistoryMessage[]): Set<string>;
52
+ export type DeferredResolution = {
53
+ /** Definitions that go into the prompt: always-loaded tools plus `tool_search`. */
54
+ toolsToRender: Tool[];
55
+ /** Names the model may call now: rendered tools plus whatever history has loaded. */
56
+ callableTools: Tool[];
57
+ /** The full deferred inventory, for `tool_search` to search over. */
58
+ deferred: Tool[];
59
+ };
60
+ /**
61
+ * Split a registered tool list into what the prompt carries and what the
62
+ * parser accepts.
63
+ *
64
+ * Loaded definitions stay out of `toolsToRender` on purpose. They live in the
65
+ * history as tool results, which appends to the prefix instead of rewriting
66
+ * the block at the front of it — a tool loaded mid-conversation must not cost
67
+ * a re-prefill of everything before it.
68
+ *
69
+ * Returns `null` when nothing defers, so the existing path is untouched.
70
+ */
71
+ export declare function resolveDeferredTools(tools: readonly Tool[] | undefined, history: readonly HistoryMessage[]): DeferredResolution | null;
72
+ /**
73
+ * Generation params for a turn whose history may have loaded deferred definitions.
74
+ *
75
+ * The addon builds its tool-call grammar from the rendered tools only, and a
76
+ * loaded definition lives in the history rather than that block, so under the
77
+ * default grammar the model can never produce the name it just loaded. Unless
78
+ * the caller asked for more than the default, those turns run with the grammar
79
+ * off and the parser, which does accept loaded names, validates the call.
80
+ */
81
+ export declare function withDeferredToolChoice<T extends {
82
+ tool_choice?: string | undefined;
83
+ }>(generationParams: T | undefined, resolution: DeferredResolution | null): T | undefined;
84
+ /**
85
+ * Run a `tool_search` call and produce the `tool` message that carries its
86
+ * result. Pure over the history it is given; the caller appends the message.
87
+ *
88
+ * Takes either wire `Tool`s or the Zod-schema `ToolInput` form, because what a
89
+ * caller holds is whatever they passed to `completion()`. A `ToolInput` whose
90
+ * `parameters` is still a Zod object would otherwise be serialised as Zod
91
+ * internals and reach the model as a definition it cannot call.
92
+ */
93
+ export declare function executeToolSearch(tools: readonly Tool[] | readonly ToolInput[], args: Record<string, unknown>, history: readonly HistoryMessage[]): string;