@qvac/sdk 0.10.2 → 0.12.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 (326) hide show
  1. package/NOTICE +1455 -29
  2. package/README.md +2 -0
  3. package/dist/client/api/cancel.d.ts +24 -32
  4. package/dist/client/api/cancel.js +58 -31
  5. package/dist/client/api/classify.d.ts +23 -0
  6. package/dist/client/api/classify.js +43 -0
  7. package/dist/client/api/client-request-id.d.ts +17 -0
  8. package/dist/client/api/client-request-id.js +27 -0
  9. package/dist/client/api/completion-stream.d.ts +1 -1
  10. package/dist/client/api/completion-stream.js +34 -3
  11. package/dist/client/api/diffusion.d.ts +46 -0
  12. package/dist/client/api/diffusion.js +50 -1
  13. package/dist/client/api/download-asset.d.ts +12 -2
  14. package/dist/client/api/download-asset.js +21 -3
  15. package/dist/client/api/embed.d.ts +8 -4
  16. package/dist/client/api/embed.js +14 -1
  17. package/dist/client/api/get-model-info.d.ts +1 -1
  18. package/dist/client/api/index.d.ts +5 -0
  19. package/dist/client/api/index.js +5 -0
  20. package/dist/client/api/load-model.d.ts +12 -4
  21. package/dist/client/api/load-model.js +49 -2
  22. package/dist/client/api/rag.d.ts +9 -3
  23. package/dist/client/api/rag.js +23 -3
  24. package/dist/client/api/transcribe.d.ts +23 -8
  25. package/dist/client/api/transcribe.js +69 -4
  26. package/dist/client/api/unload-model.d.ts +5 -2
  27. package/dist/client/api/unload-model.js +9 -4
  28. package/dist/client/api/upscale.d.ts +45 -0
  29. package/dist/client/api/upscale.js +99 -0
  30. package/dist/client/api/video.d.ts +64 -0
  31. package/dist/client/api/video.js +147 -0
  32. package/dist/client/api/vla-helpers.d.ts +45 -0
  33. package/dist/client/api/vla-helpers.js +130 -0
  34. package/dist/client/api/vla.d.ts +65 -0
  35. package/dist/client/api/vla.js +109 -0
  36. package/dist/client/config-loader/resolve-config.node.d.ts +16 -0
  37. package/dist/client/config-loader/resolve-config.node.js +77 -23
  38. package/dist/client/plugins-factory.d.ts +8 -0
  39. package/dist/client/plugins-factory.js +10 -0
  40. package/dist/client/rpc/bare-client.js +62 -66
  41. package/dist/client/rpc/ensure-worker-ready.d.ts +9 -0
  42. package/dist/client/rpc/ensure-worker-ready.js +17 -0
  43. package/dist/client/rpc/expo-rpc-client.js +2 -1
  44. package/dist/client/rpc/node-rpc-client.js +22 -8
  45. package/dist/client/rpc/rpc-client.d.ts +2 -2
  46. package/dist/client/rpc/rpc-client.js +10 -4
  47. package/dist/client/rpc/rpc-error.d.ts +9 -0
  48. package/dist/client/rpc/rpc-error.js +105 -0
  49. package/dist/commands/bundle/bare-pack.d.ts +13 -0
  50. package/dist/commands/bundle/bare-pack.js +54 -0
  51. package/dist/commands/bundle/constants.d.ts +7 -0
  52. package/dist/commands/bundle/constants.js +23 -0
  53. package/dist/commands/bundle/entry-gen.d.ts +2 -0
  54. package/dist/commands/bundle/entry-gen.js +48 -0
  55. package/dist/commands/bundle/index.d.ts +20 -0
  56. package/dist/commands/bundle/index.js +141 -0
  57. package/dist/commands/bundle/manifest.d.ts +21 -0
  58. package/dist/commands/bundle/manifest.js +193 -0
  59. package/dist/commands/bundle/plugins.d.ts +9 -0
  60. package/dist/commands/bundle/plugins.js +51 -0
  61. package/dist/commands/index.d.ts +5 -0
  62. package/dist/commands/index.js +2 -0
  63. package/dist/commands/verify/abi.d.ts +52 -0
  64. package/dist/commands/verify/abi.js +125 -0
  65. package/dist/commands/verify/addon-source.d.ts +43 -0
  66. package/dist/commands/verify/addon-source.js +75 -0
  67. package/dist/commands/verify/bundle-source.d.ts +12 -0
  68. package/dist/commands/verify/bundle-source.js +53 -0
  69. package/dist/commands/verify/index.d.ts +59 -0
  70. package/dist/commands/verify/index.js +371 -0
  71. package/dist/commands/verify/node-modules-source.d.ts +11 -0
  72. package/dist/commands/verify/node-modules-source.js +76 -0
  73. package/dist/commands/verify/prebuilds.d.ts +15 -0
  74. package/dist/commands/verify/prebuilds.js +39 -0
  75. package/dist/examples/cancel-by-request-id.d.ts +38 -0
  76. package/dist/examples/cancel-by-request-id.js +103 -0
  77. package/dist/examples/classification/classify-image.d.ts +2 -0
  78. package/dist/examples/classification/classify-image.js +23 -0
  79. package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
  80. package/dist/examples/diffusion-esrgan-upscale.js +78 -0
  81. package/dist/examples/diffusion-txt2vid.d.ts +2 -0
  82. package/dist/examples/diffusion-txt2vid.js +81 -0
  83. package/dist/examples/download-with-cancel.js +10 -10
  84. package/dist/examples/embed-multi-gpu.d.ts +2 -0
  85. package/dist/examples/embed-multi-gpu.js +46 -0
  86. package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
  87. package/dist/examples/llamacpp-multi-gpu.js +57 -0
  88. package/dist/examples/plugins.js +3 -7
  89. package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
  90. package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
  91. package/dist/examples/tools/llamacpp-tools-gemma4.js +73 -0
  92. package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
  93. package/dist/examples/tools/llamacpp-tools-qwen35.js +69 -0
  94. package/dist/examples/transcription/parakeet-ctc-filesystem.js +18 -12
  95. package/dist/examples/transcription/parakeet-microphone-record.js +7 -12
  96. package/dist/examples/transcription/parakeet-microphone-stream.d.ts +2 -0
  97. package/dist/examples/transcription/parakeet-microphone-stream.js +79 -0
  98. package/dist/examples/transcription/parakeet-sortformer-streaming.d.ts +2 -0
  99. package/dist/examples/transcription/parakeet-sortformer-streaming.js +121 -0
  100. package/dist/examples/transcription/parakeet-sortformer.js +58 -55
  101. package/dist/examples/transcription/parakeet-tdt-filesystem.js +18 -15
  102. package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
  103. package/dist/examples/transcription/whispercpp-microphone-conversation.js +107 -0
  104. package/dist/examples/tts/chatterbox.js +7 -16
  105. package/dist/examples/tts/llm-to-tts-streaming.js +3 -10
  106. package/dist/examples/tts/supertonic-multilingual.js +4 -12
  107. package/dist/examples/tts/supertonic.js +5 -12
  108. package/dist/examples/vla-smolvla.d.ts +2 -0
  109. package/dist/examples/vla-smolvla.js +75 -0
  110. package/dist/examples/voice-assistant/voice-assistant.js +3 -10
  111. package/dist/expo/plugins/find-in-ancestor-node-modules.d.ts +14 -0
  112. package/dist/expo/plugins/find-in-ancestor-node-modules.js +24 -0
  113. package/dist/expo/plugins/get-project-root.d.ts +22 -0
  114. package/dist/expo/plugins/get-project-root.js +23 -0
  115. package/dist/expo/plugins/index.d.ts +4 -0
  116. package/dist/expo/plugins/index.js +4 -0
  117. package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +9 -2
  118. package/dist/expo/plugins/resolve-sdk-package-dir.js +38 -11
  119. package/dist/expo/plugins/withDeviceInfo.js +2 -1
  120. package/dist/expo/plugins/withMobileBundle.d.ts +5 -4
  121. package/dist/expo/plugins/withMobileBundle.js +42 -58
  122. package/dist/index.d.ts +6 -2
  123. package/dist/index.js +23 -2
  124. package/dist/models/registry/models.d.ts +3725 -514
  125. package/dist/models/registry/models.js +7269 -3910
  126. package/dist/models/update-models/naming.js +22 -8
  127. package/dist/pear/pre.d.ts +3 -0
  128. package/dist/pear/pre.js +9 -2
  129. package/dist/schemas/cancel.d.ts +172 -28
  130. package/dist/schemas/cancel.js +120 -19
  131. package/dist/schemas/classification.d.ts +53 -0
  132. package/dist/schemas/classification.js +33 -0
  133. package/dist/schemas/common.d.ts +860 -1379
  134. package/dist/schemas/common.js +8 -1
  135. package/dist/schemas/completion-event.d.ts +17 -0
  136. package/dist/schemas/completion-event.js +12 -1
  137. package/dist/schemas/completion-stream.d.ts +16 -1
  138. package/dist/schemas/completion-stream.js +25 -7
  139. package/dist/schemas/download-asset.d.ts +25 -9
  140. package/dist/schemas/download-asset.js +17 -6
  141. package/dist/schemas/embed.d.ts +1 -0
  142. package/dist/schemas/embed.js +5 -0
  143. package/dist/schemas/engine-addon-map.d.ts +3 -0
  144. package/dist/schemas/engine-addon-map.js +18 -5
  145. package/dist/schemas/error.d.ts +31 -0
  146. package/dist/schemas/error.js +29 -1
  147. package/dist/schemas/finetune.d.ts +2 -0
  148. package/dist/schemas/finetune.js +5 -0
  149. package/dist/schemas/get-model-info.d.ts +10 -6
  150. package/dist/schemas/get-model-info.js +2 -0
  151. package/dist/schemas/index.d.ts +3 -0
  152. package/dist/schemas/index.js +3 -0
  153. package/dist/schemas/llamacpp-config.d.ts +64 -8
  154. package/dist/schemas/llamacpp-config.js +12 -0
  155. package/dist/schemas/load-model.d.ts +4644 -8605
  156. package/dist/schemas/load-model.js +90 -7
  157. package/dist/schemas/model-src-utils.d.ts +34 -14
  158. package/dist/schemas/model-types.d.ts +54 -14
  159. package/dist/schemas/model-types.js +28 -5
  160. package/dist/schemas/ocr.d.ts +8 -3
  161. package/dist/schemas/plugin.d.ts +60 -6
  162. package/dist/schemas/plugin.js +31 -5
  163. package/dist/schemas/rag.d.ts +9 -0
  164. package/dist/schemas/rag.js +17 -9
  165. package/dist/schemas/registry.d.ts +74 -30
  166. package/dist/schemas/registry.js +5 -0
  167. package/dist/schemas/reload-config.d.ts +34 -14
  168. package/dist/schemas/sdcpp-config.d.ts +445 -16
  169. package/dist/schemas/sdcpp-config.js +387 -26
  170. package/dist/schemas/sdk-config.d.ts +2431 -2723
  171. package/dist/schemas/sdk-config.js +16 -1
  172. package/dist/schemas/sdk-errors-client.d.ts +6 -0
  173. package/dist/schemas/sdk-errors-client.js +31 -1
  174. package/dist/schemas/sdk-errors-server.d.ts +8 -1
  175. package/dist/schemas/sdk-errors-server.js +45 -5
  176. package/dist/schemas/text-to-speech.d.ts +81 -698
  177. package/dist/schemas/text-to-speech.js +46 -19
  178. package/dist/schemas/transcription-config.d.ts +40 -229
  179. package/dist/schemas/transcription-config.js +76 -15
  180. package/dist/schemas/transcription.d.ts +108 -2
  181. package/dist/schemas/transcription.js +81 -0
  182. package/dist/schemas/translate.d.ts +2 -0
  183. package/dist/schemas/translate.js +13 -2
  184. package/dist/schemas/translation-config.d.ts +90 -40
  185. package/dist/schemas/unload-model.d.ts +2 -1
  186. package/dist/schemas/unload-model.js +4 -1
  187. package/dist/schemas/vla.d.ts +87 -0
  188. package/dist/schemas/vla.js +108 -0
  189. package/dist/scripts/run-unit-tests.js +22 -3
  190. package/dist/server/bare/ops/cancel.d.ts +27 -1
  191. package/dist/server/bare/ops/cancel.js +36 -10
  192. package/dist/server/bare/ops/embed.d.ts +3 -3
  193. package/dist/server/bare/ops/embed.js +144 -28
  194. package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
  195. package/dist/server/bare/ops/kv-cache-utils.js +8 -47
  196. package/dist/server/bare/ops/transcribe.d.ts +11 -5
  197. package/dist/server/bare/ops/transcribe.js +230 -50
  198. package/dist/server/bare/ops/translate.d.ts +1 -1
  199. package/dist/server/bare/ops/translate.js +197 -88
  200. package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +6 -0
  201. package/dist/server/bare/plugins/ggml-classification/ops/classify.js +30 -0
  202. package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +32 -0
  203. package/dist/server/bare/plugins/ggml-classification/plugin.js +55 -0
  204. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +3 -0
  205. package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +12 -0
  206. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +3 -0
  207. package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +75 -0
  208. package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +54 -0
  209. package/dist/server/bare/plugins/ggml-vla/plugin.js +57 -0
  210. package/dist/server/bare/plugins/index.d.ts +3 -1
  211. package/dist/server/bare/plugins/index.js +3 -1
  212. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
  213. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +173 -172
  214. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +29 -0
  215. package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +65 -0
  216. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
  217. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
  218. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
  219. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
  220. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
  221. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +36 -3
  222. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +183 -85
  223. package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
  224. package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
  225. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
  226. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
  227. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +42 -15
  228. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
  229. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +8 -3
  230. package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
  231. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +73 -244
  232. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +68 -96
  233. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
  234. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
  235. package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
  236. package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +3 -0
  237. package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +199 -0
  238. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +288 -15
  239. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +150 -7
  240. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.js +2 -15
  241. package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.js +2 -1
  242. package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +75 -0
  243. package/dist/server/bare/plugins/tts-ggml/plugin.js +189 -0
  244. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +47 -3
  245. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +61 -14
  246. package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
  247. package/dist/server/bare/rag-hyperdb/index.js +1 -1
  248. package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
  249. package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
  250. package/dist/server/bare/registry/model-config-utils.js +7 -0
  251. package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
  252. package/dist/server/bare/runtime/disposable-scope.js +69 -0
  253. package/dist/server/bare/runtime/index.d.ts +8 -0
  254. package/dist/server/bare/runtime/index.js +3 -0
  255. package/dist/server/bare/runtime/request-context.d.ts +49 -0
  256. package/dist/server/bare/runtime/request-context.js +1 -0
  257. package/dist/server/bare/runtime/request-id.d.ts +12 -0
  258. package/dist/server/bare/runtime/request-id.js +14 -0
  259. package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
  260. package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
  261. package/dist/server/bare/runtime/request-registry.d.ts +136 -0
  262. package/dist/server/bare/runtime/request-registry.js +297 -0
  263. package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
  264. package/dist/server/bare/runtime/with-request-context.js +53 -0
  265. package/dist/server/bare/runtime-lifecycle.js +9 -9
  266. package/dist/server/bare/types/addon-responses.d.ts +12 -1
  267. package/dist/server/env.js +4 -1
  268. package/dist/server/plugins/index.d.ts +1 -1
  269. package/dist/server/plugins/index.js +1 -1
  270. package/dist/server/plugins/registry.d.ts +1 -0
  271. package/dist/server/plugins/registry.js +5 -0
  272. package/dist/server/rpc/handler-registry.js +30 -7
  273. package/dist/server/rpc/handler-selection.d.ts +9 -0
  274. package/dist/server/rpc/handler-selection.js +14 -0
  275. package/dist/server/rpc/handler-utils.js +5 -13
  276. package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
  277. package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
  278. package/dist/server/rpc/handlers/cancelHandler.js +54 -22
  279. package/dist/server/rpc/handlers/classify.d.ts +3 -0
  280. package/dist/server/rpc/handlers/classify.js +4 -0
  281. package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
  282. package/dist/server/rpc/handlers/delete-cache.js +13 -15
  283. package/dist/server/rpc/handlers/download-asset.js +133 -40
  284. package/dist/server/rpc/handlers/index.d.ts +4 -0
  285. package/dist/server/rpc/handlers/index.js +4 -0
  286. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
  287. package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
  288. package/dist/server/rpc/handlers/load-model/handler.js +216 -98
  289. package/dist/server/rpc/handlers/load-model/http.js +3 -3
  290. package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
  291. package/dist/server/rpc/handlers/load-model/registry.js +1 -1
  292. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
  293. package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
  294. package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
  295. package/dist/server/rpc/handlers/load-model/resolve.js +18 -6
  296. package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
  297. package/dist/server/rpc/handlers/rag.js +133 -15
  298. package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
  299. package/dist/server/rpc/handlers/upscale-stream.js +4 -0
  300. package/dist/server/rpc/handlers/video-stream.d.ts +3 -0
  301. package/dist/server/rpc/handlers/video-stream.js +4 -0
  302. package/dist/server/rpc/profiling/operation-metrics.js +23 -0
  303. package/dist/server/utils/completion-normalizer.js +8 -0
  304. package/dist/server/utils/config-transform.js +1 -1
  305. package/dist/server/utils/tools/dialect.js +4 -0
  306. package/dist/server/utils/tools/parser.js +16 -1
  307. package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
  308. package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
  309. package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
  310. package/dist/server/utils/tools/parsers/qwen35.js +120 -0
  311. package/dist/server/worker.js +14 -11
  312. package/dist/utils/aggregate-events.d.ts +9 -0
  313. package/dist/utils/aggregate-events.js +18 -3
  314. package/dist/utils/decorate-promise.d.ts +34 -0
  315. package/dist/utils/decorate-promise.js +35 -0
  316. package/dist/utils/errors-client.d.ts +18 -0
  317. package/dist/utils/errors-client.js +31 -0
  318. package/dist/utils/errors-server.d.ts +115 -2
  319. package/dist/utils/errors-server.js +148 -3
  320. package/package.json +68 -77
  321. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -490
  322. package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -266
  323. package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
  324. package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
  325. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.d.ts +0 -0
  326. /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.d.ts +0 -0
@@ -10,24 +10,14 @@ function hasRunStreaming(model) {
10
10
  "runStreaming" in model &&
11
11
  typeof model.runStreaming === "function");
12
12
  }
13
- // Callers (e.g. LLM token deltas) may write raw Buffer chunks whose
14
- // boundaries split a multi-byte UTF-8 codepoint. A naive `buf.toString("utf8")`
15
- // per chunk emits U+FFFD at every split point and silently corrupts CJK,
16
- // emoji, accented scripts, etc. before they reach the tokenizer. Keep a
17
- // tail-buffer of at most 3 bytes spanning an incomplete trailing codepoint
18
- // and decode only the complete-codepoint prefix of each combined chunk.
19
13
  function findLastCompleteUtf8End(buf) {
20
14
  const len = buf.length;
21
- // A UTF-8 codepoint is at most 4 bytes, so a split can only dangle in
22
- // the last 3 bytes. Scan backwards to find the most recent leading byte.
23
15
  for (let i = len - 1; i >= 0 && i >= len - 3; i--) {
24
16
  const b = buf[i];
25
17
  if ((b & 0x80) === 0) {
26
- // ASCII byte: everything up to and including i is complete.
27
18
  return i + 1;
28
19
  }
29
20
  if ((b & 0xc0) === 0xc0) {
30
- // Leading byte of a multi-byte sequence.
31
21
  let expected;
32
22
  if ((b & 0xe0) === 0xc0)
33
23
  expected = 2;
@@ -36,7 +26,7 @@ function findLastCompleteUtf8End(buf) {
36
26
  else if ((b & 0xf8) === 0xf0)
37
27
  expected = 4;
38
28
  else
39
- return len; // Invalid leader; let toString emit U+FFFD.
29
+ return len;
40
30
  return i + expected <= len ? len : i;
41
31
  }
42
32
  }
@@ -59,9 +49,6 @@ async function* buffersToUtf8Fragments(inputStream) {
59
49
  : Buffer.alloc(0);
60
50
  }
61
51
  if (pending.length > 0) {
62
- // Stream ended with a dangling partial codepoint — flush as-is so the
63
- // tokenizer sees the replacement character rather than silently dropping
64
- // the final byte(s).
65
52
  const s = pending.toString("utf8");
66
53
  if (s.length > 0) {
67
54
  yield s;
@@ -89,7 +76,7 @@ export async function* textToSpeechStream(params, inputStream) {
89
76
  const model = getModel(request.modelId);
90
77
  const modelStart = nowMs();
91
78
  if (!hasRunStreaming(model)) {
92
- throw new TextToSpeechStreamFailedError("textToSpeechStream requires an ONNX TTS model with runStreaming");
79
+ throw new TextToSpeechStreamFailedError("textToSpeechStream requires a TTS model with runStreaming");
93
80
  }
94
81
  const textSource = buffersToUtf8Fragments(inputStream);
95
82
  const streamOpts = buildRunStreamingOptions(request);
@@ -16,7 +16,7 @@ export async function* textToSpeech(params) {
16
16
  const modelStart = nowMs();
17
17
  if (sentenceStream) {
18
18
  if (!hasRunStream(model)) {
19
- throw new TextToSpeechFailedError("sentenceStream requires an ONNX TTS model with runStream (Supertonic)");
19
+ throw new TextToSpeechFailedError("sentenceStream requires a TTS model with runStream");
20
20
  }
21
21
  const streamOpts = sentenceStreamLocale !== undefined || sentenceStreamMaxChunkScalars !== undefined
22
22
  ? {
@@ -62,6 +62,7 @@ export async function* textToSpeech(params) {
62
62
  const response = (await model.run({
63
63
  input: text,
64
64
  inputType,
65
+ ...(stream ? { streamOutput: true } : {}),
65
66
  }));
66
67
  if (!stream) {
67
68
  let completeBuffer = [];
@@ -0,0 +1,75 @@
1
+ import { type CreateModelParams, type PluginModelResult, type ResolveContext, type ResolveResult } from "../../../../schemas/index";
2
+ export declare const ttsPlugin: {
3
+ modelType: "tts-ggml";
4
+ displayName: string;
5
+ addonPackage: "@qvac/tts-ggml";
6
+ loadConfigSchema: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
7
+ [x: string]: import("zod").ZodOptional<import("zod").ZodUnknown>;
8
+ }, import("zod/v4/core").$strict>, import("zod").ZodObject<{
9
+ [x: string]: import("zod").ZodOptional<import("zod").ZodUnknown>;
10
+ }, import("zod/v4/core").$strict>]>;
11
+ resolveConfig(cfg: Record<string, unknown>, ctx: ResolveContext): Promise<ResolveResult<{
12
+ ttsEngine: "supertonic";
13
+ language: "en" | "de" | "es" | "it";
14
+ voice?: string | undefined;
15
+ ttsSpeed?: number | undefined;
16
+ ttsNumInferenceSteps?: number | undefined;
17
+ useGPU?: boolean | undefined;
18
+ } | {
19
+ ttsEngine: "chatterbox";
20
+ language: "en" | "de" | "es" | "it";
21
+ voice?: string | undefined;
22
+ useGPU?: boolean | undefined;
23
+ }, string>>;
24
+ createModel(params: CreateModelParams): PluginModelResult;
25
+ handlers: {
26
+ textToSpeech: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
27
+ modelId: import("zod").ZodString;
28
+ inputType: import("zod").ZodDefault<import("zod").ZodString>;
29
+ text: import("zod").ZodString;
30
+ stream: import("zod").ZodDefault<import("zod").ZodBoolean>;
31
+ sentenceStream: import("zod").ZodDefault<import("zod").ZodBoolean>;
32
+ sentenceStreamLocale: import("zod").ZodOptional<import("zod").ZodString>;
33
+ sentenceStreamMaxChunkScalars: import("zod").ZodOptional<import("zod").ZodNumber>;
34
+ type: import("zod").ZodLiteral<"textToSpeech">;
35
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
36
+ type: import("zod").ZodLiteral<"textToSpeech">;
37
+ buffer: import("zod").ZodArray<import("zod").ZodNumber>;
38
+ done: import("zod").ZodDefault<import("zod").ZodBoolean>;
39
+ stats: import("zod").ZodOptional<import("zod").ZodObject<{
40
+ audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
41
+ totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
42
+ }, import("zod/v4/core").$strip>>;
43
+ chunkIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
44
+ sentenceChunk: import("zod").ZodOptional<import("zod").ZodString>;
45
+ }, import("zod/v4/core").$strip>>;
46
+ textToSpeechStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
47
+ modelId: import("zod").ZodString;
48
+ inputType: import("zod").ZodDefault<import("zod").ZodString>;
49
+ accumulateSentences: import("zod").ZodOptional<import("zod").ZodBoolean>;
50
+ sentenceDelimiterPreset: import("zod").ZodOptional<import("zod").ZodEnum<{
51
+ latin: "latin";
52
+ cjk: "cjk";
53
+ multilingual: "multilingual";
54
+ }>>;
55
+ maxBufferScalars: import("zod").ZodOptional<import("zod").ZodNumber>;
56
+ flushAfterMs: import("zod").ZodOptional<import("zod").ZodNumber>;
57
+ type: import("zod").ZodLiteral<"textToSpeechStream">;
58
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
59
+ type: import("zod").ZodLiteral<"textToSpeechStream">;
60
+ buffer: import("zod").ZodArray<import("zod").ZodNumber>;
61
+ done: import("zod").ZodDefault<import("zod").ZodBoolean>;
62
+ stats: import("zod").ZodOptional<import("zod").ZodObject<{
63
+ audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
64
+ totalSamples: import("zod").ZodOptional<import("zod").ZodNumber>;
65
+ }, import("zod/v4/core").$strip>>;
66
+ chunkIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
67
+ sentenceChunk: import("zod").ZodOptional<import("zod").ZodString>;
68
+ }, import("zod/v4/core").$strip>>;
69
+ };
70
+ logging: {
71
+ module: import("@qvac/tts-ggml/addonLogging").AddonLogging;
72
+ namespace: "tts-ggml";
73
+ };
74
+ };
75
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1,189 @@
1
+ import ttsAddonLogging from "@qvac/tts-ggml/addonLogging.js";
2
+ import TTSGgml from "@qvac/tts-ggml";
3
+ import { definePlugin, defineHandler, defineDuplexHandler, ttsRequestSchema, ttsResponseSchema, textToSpeechStreamRequestSchema, textToSpeechStreamResponseSchema, ModelType, ttsConfigSchema, ADDON_TTS, LEGACY_TTS_ONNX_MODEL_CONFIG_FIELDS, } from "../../../../schemas/index.js";
4
+ import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
5
+ import { TtsArtifactsRequiredError, LegacyTtsModelDeprecatedError, } from "../../../../utils/errors-server.js";
6
+ import { textToSpeech } from "./ops/text-to-speech.js";
7
+ import { textToSpeechStream } from "./ops/text-to-speech-stream.js";
8
+ import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
9
+ function rejectLegacyOnnxFields(cfg) {
10
+ const record = cfg;
11
+ const legacyFields = LEGACY_TTS_ONNX_MODEL_CONFIG_FIELDS.filter((name) => record[name] !== undefined);
12
+ if (legacyFields.length > 0) {
13
+ throw new LegacyTtsModelDeprecatedError(legacyFields);
14
+ }
15
+ }
16
+ async function resolveChatterboxConfig(config, ctx) {
17
+ rejectLegacyOnnxFields(config);
18
+ const { s3genModelSrc, referenceAudioSrc, ...runtime } = config;
19
+ if (!s3genModelSrc) {
20
+ throw new TtsArtifactsRequiredError();
21
+ }
22
+ const resolve = ctx.resolveModelPath;
23
+ const [s3genPath, referenceAudioPath] = await Promise.all([
24
+ resolve(s3genModelSrc),
25
+ referenceAudioSrc ? resolve(referenceAudioSrc) : Promise.resolve(undefined),
26
+ ]);
27
+ return {
28
+ config: runtime,
29
+ artifacts: {
30
+ s3genPath,
31
+ ...(referenceAudioPath ? { referenceAudioPath } : {}),
32
+ },
33
+ };
34
+ }
35
+ function resolveSupertonicConfig(config) {
36
+ rejectLegacyOnnxFields(config);
37
+ return Promise.resolve({ config });
38
+ }
39
+ function createChatterboxModel(modelId, config, params, artifacts) {
40
+ const t3Model = params.modelPath;
41
+ const s3genModel = artifacts["s3genPath"];
42
+ const referenceAudioPath = artifacts["referenceAudioPath"];
43
+ if (!t3Model || !s3genModel) {
44
+ throw new TtsArtifactsRequiredError();
45
+ }
46
+ const logger = createStreamLogger(modelId, ModelType.ttsGgml);
47
+ registerAddonLogger(modelId, ModelType.ttsGgml, logger);
48
+ const model = new TTSGgml({
49
+ engine: TTSGgml.ENGINE_CHATTERBOX,
50
+ files: { t3Model, s3genModel },
51
+ ...(referenceAudioPath ? { referenceAudio: referenceAudioPath } : {}),
52
+ config: {
53
+ language: config.language ?? "en",
54
+ ...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {}),
55
+ },
56
+ logger,
57
+ opts: { stats: true },
58
+ exclusiveRun: true,
59
+ });
60
+ return { model };
61
+ }
62
+ function createSupertonicModel(modelId, config, params) {
63
+ const supertonicModel = params.modelPath;
64
+ if (!supertonicModel) {
65
+ throw new TtsArtifactsRequiredError();
66
+ }
67
+ const logger = createStreamLogger(modelId, ModelType.ttsGgml);
68
+ registerAddonLogger(modelId, ModelType.ttsGgml, logger);
69
+ const model = new TTSGgml({
70
+ engine: TTSGgml.ENGINE_SUPERTONIC,
71
+ files: { supertonicModel },
72
+ voice: config.voice ?? "F1",
73
+ ...(config.ttsSpeed !== undefined ? { speed: config.ttsSpeed } : {}),
74
+ ...(config.ttsNumInferenceSteps !== undefined
75
+ ? { numInferenceSteps: config.ttsNumInferenceSteps }
76
+ : {}),
77
+ config: {
78
+ language: config.language ?? "en",
79
+ useGPU: config.useGPU ?? false,
80
+ },
81
+ logger,
82
+ opts: { stats: true },
83
+ exclusiveRun: true,
84
+ });
85
+ return { model };
86
+ }
87
+ export const ttsPlugin = definePlugin({
88
+ modelType: ModelType.ttsGgml,
89
+ displayName: "TTS (GGML)",
90
+ addonPackage: ADDON_TTS,
91
+ loadConfigSchema: ttsConfigSchema,
92
+ async resolveConfig(cfg, ctx) {
93
+ const { ttsEngine } = cfg;
94
+ // Same default as the former onnx-tts plugin: omitting `ttsEngine` → Chatterbox.
95
+ if (ttsEngine === "supertonic") {
96
+ return resolveSupertonicConfig(cfg);
97
+ }
98
+ return resolveChatterboxConfig(cfg, ctx);
99
+ },
100
+ createModel(params) {
101
+ const config = (params.modelConfig ?? {});
102
+ const artifacts = params.artifacts ?? {};
103
+ if (config.ttsEngine === "supertonic") {
104
+ return createSupertonicModel(params.modelId, config, params);
105
+ }
106
+ return createChatterboxModel(params.modelId, config, params, artifacts);
107
+ },
108
+ handlers: {
109
+ textToSpeech: defineHandler({
110
+ requestSchema: ttsRequestSchema,
111
+ responseSchema: ttsResponseSchema,
112
+ streaming: true,
113
+ cancel: { scope: "model", hard: true },
114
+ handler: async function* (request) {
115
+ const stream = textToSpeech(request);
116
+ try {
117
+ let result = await stream.next();
118
+ while (!result.done) {
119
+ yield {
120
+ type: "textToSpeech",
121
+ buffer: result.value.buffer,
122
+ done: false,
123
+ ...(result.value.chunkIndex !== undefined
124
+ ? { chunkIndex: result.value.chunkIndex }
125
+ : {}),
126
+ ...(typeof result.value.sentenceChunk === "string" &&
127
+ result.value.sentenceChunk.length > 0
128
+ ? { sentenceChunk: result.value.sentenceChunk }
129
+ : {}),
130
+ };
131
+ result = await stream.next();
132
+ }
133
+ const { modelExecutionMs, stats } = result.value;
134
+ yield attachModelExecutionMs({
135
+ type: "textToSpeech",
136
+ buffer: [],
137
+ done: true,
138
+ ...(stats && { stats }),
139
+ }, modelExecutionMs);
140
+ }
141
+ finally {
142
+ await stream.return?.(undefined);
143
+ }
144
+ },
145
+ }),
146
+ textToSpeechStream: defineDuplexHandler({
147
+ requestSchema: textToSpeechStreamRequestSchema,
148
+ responseSchema: textToSpeechStreamResponseSchema,
149
+ streaming: true,
150
+ duplex: true,
151
+ cancel: { scope: "model", hard: true },
152
+ handler: async function* (request, inputStream) {
153
+ const stream = textToSpeechStream(request, inputStream);
154
+ try {
155
+ let result = await stream.next();
156
+ while (!result.done) {
157
+ yield {
158
+ type: "textToSpeechStream",
159
+ buffer: result.value.buffer,
160
+ done: false,
161
+ ...(result.value.chunkIndex !== undefined
162
+ ? { chunkIndex: result.value.chunkIndex }
163
+ : {}),
164
+ ...(typeof result.value.sentenceChunk === "string" &&
165
+ result.value.sentenceChunk.length > 0
166
+ ? { sentenceChunk: result.value.sentenceChunk }
167
+ : {}),
168
+ };
169
+ result = await stream.next();
170
+ }
171
+ const { modelExecutionMs, stats } = result.value;
172
+ yield attachModelExecutionMs({
173
+ type: "textToSpeechStream",
174
+ buffer: [],
175
+ done: true,
176
+ ...(stats && { stats }),
177
+ }, modelExecutionMs);
178
+ }
179
+ finally {
180
+ await stream.return?.(undefined);
181
+ }
182
+ },
183
+ }),
184
+ },
185
+ logging: {
186
+ module: ttsAddonLogging,
187
+ namespace: ModelType.ttsGgml,
188
+ },
189
+ });
@@ -76,21 +76,26 @@ export declare const whisperPlugin: {
76
76
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
77
77
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
78
78
  embeddings: "embeddings";
79
+ diffusion: "diffusion";
80
+ tts: "tts";
81
+ ocr: "ocr";
82
+ vla: "vla";
79
83
  "llamacpp-completion": "llamacpp-completion";
80
84
  "whispercpp-transcription": "whispercpp-transcription";
81
85
  "llamacpp-embedding": "llamacpp-embedding";
82
86
  "nmtcpp-translation": "nmtcpp-translation";
83
87
  "onnx-tts": "onnx-tts";
88
+ "tts-ggml": "tts-ggml";
84
89
  "parakeet-transcription": "parakeet-transcription";
85
90
  "onnx-ocr": "onnx-ocr";
86
91
  "sdcpp-generation": "sdcpp-generation";
92
+ "ggml-vla": "ggml-vla";
93
+ "ggml-classification": "ggml-classification";
87
94
  llm: "llm";
88
95
  whisper: "whisper";
89
96
  nmt: "nmt";
90
97
  parakeet: "parakeet";
91
- tts: "tts";
92
- ocr: "ocr";
93
- diffusion: "diffusion";
98
+ classification: "classification";
94
99
  }>, import("zod").ZodLiteral<"vad">]>>;
95
100
  }, import("zod/v4/core").$strip>]>>;
96
101
  }, import("zod/v4/core").$strip>;
@@ -225,6 +230,7 @@ export declare const whisperPlugin: {
225
230
  value: import("zod").ZodString;
226
231
  }, import("zod/v4/core").$strip>], "type">;
227
232
  type: import("zod").ZodLiteral<"transcribe">;
233
+ requestId: import("zod").ZodOptional<import("zod").ZodString>;
228
234
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
229
235
  text: import("zod").ZodOptional<import("zod").ZodString>;
230
236
  done: import("zod").ZodOptional<import("zod").ZodBoolean>;
@@ -248,6 +254,16 @@ export declare const whisperPlugin: {
248
254
  append: import("zod").ZodBoolean;
249
255
  id: import("zod").ZodNumber;
250
256
  }, import("zod/v4/core").$strip>>;
257
+ vad: import("zod").ZodOptional<import("zod").ZodObject<{
258
+ speaking: import("zod").ZodBoolean;
259
+ probability: import("zod").ZodNumber;
260
+ }, import("zod/v4/core").$strip>>;
261
+ endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
262
+ source: import("zod").ZodLiteral<"whisper">;
263
+ silenceDurationMs: import("zod").ZodNumber;
264
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
265
+ source: import("zod").ZodLiteral<"parakeet">;
266
+ }, import("zod/v4/core").$strip>], "source">>>;
251
267
  type: import("zod").ZodLiteral<"transcribe">;
252
268
  }, import("zod/v4/core").$strip>>;
253
269
  transcribeStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
@@ -255,6 +271,24 @@ export declare const whisperPlugin: {
255
271
  prompt: import("zod").ZodOptional<import("zod").ZodString>;
256
272
  metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
257
273
  type: import("zod").ZodLiteral<"transcribeStream">;
274
+ emitVadEvents: import("zod").ZodOptional<import("zod").ZodBoolean>;
275
+ endOfTurnSilenceMs: import("zod").ZodOptional<import("zod").ZodNumber>;
276
+ vadRunIntervalMs: import("zod").ZodOptional<import("zod").ZodNumber>;
277
+ parakeetStreamingConfig: import("zod").ZodOptional<import("zod").ZodObject<{
278
+ chunkMs: import("zod").ZodOptional<import("zod").ZodNumber>;
279
+ historyMs: import("zod").ZodOptional<import("zod").ZodNumber>;
280
+ leftContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
281
+ rightLookaheadMs: import("zod").ZodOptional<import("zod").ZodNumber>;
282
+ emitPartials: import("zod").ZodOptional<import("zod").ZodBoolean>;
283
+ emitEnergyVad: import("zod").ZodOptional<import("zod").ZodBoolean>;
284
+ spkCacheEnable: import("zod").ZodOptional<import("zod").ZodBoolean>;
285
+ spkCacheLen: import("zod").ZodOptional<import("zod").ZodNumber>;
286
+ fifoLen: import("zod").ZodOptional<import("zod").ZodNumber>;
287
+ chunkLeftContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
288
+ chunkRightContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
289
+ spkCacheUpdatePeriod: import("zod").ZodOptional<import("zod").ZodNumber>;
290
+ }, import("zod/v4/core").$strip>>;
291
+ requestId: import("zod").ZodOptional<import("zod").ZodString>;
258
292
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
259
293
  text: import("zod").ZodOptional<import("zod").ZodString>;
260
294
  done: import("zod").ZodOptional<import("zod").ZodBoolean>;
@@ -278,6 +312,16 @@ export declare const whisperPlugin: {
278
312
  append: import("zod").ZodBoolean;
279
313
  id: import("zod").ZodNumber;
280
314
  }, import("zod/v4/core").$strip>>;
315
+ vad: import("zod").ZodOptional<import("zod").ZodObject<{
316
+ speaking: import("zod").ZodBoolean;
317
+ probability: import("zod").ZodNumber;
318
+ }, import("zod/v4/core").$strip>>;
319
+ endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
320
+ source: import("zod").ZodLiteral<"whisper">;
321
+ silenceDurationMs: import("zod").ZodNumber;
322
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
323
+ source: import("zod").ZodLiteral<"parakeet">;
324
+ }, import("zod/v4/core").$strip>], "source">>>;
281
325
  type: import("zod").ZodLiteral<"transcribeStream">;
282
326
  }, import("zod/v4/core").$strip>>;
283
327
  };
@@ -52,6 +52,9 @@ export const whisperPlugin = definePlugin({
52
52
  requestSchema: transcribeRequestSchema,
53
53
  responseSchema: transcribeResponseSchema,
54
54
  streaming: true,
55
+ // whisper.cpp addon exposes a model-wide hard cancel — compute
56
+ // is interrupted on the currently-running transcription.
57
+ cancel: { scope: "model", hard: true },
55
58
  handler: async function* (request) {
56
59
  const metadata = request.metadata === true;
57
60
  const stream = metadata
@@ -60,12 +63,12 @@ export const whisperPlugin = definePlugin({
60
63
  audioChunk: request.audioChunk,
61
64
  prompt: request.prompt,
62
65
  metadata: true,
63
- })
66
+ }, request.requestId)
64
67
  : transcribe({
65
68
  modelId: request.modelId,
66
69
  audioChunk: request.audioChunk,
67
70
  prompt: request.prompt,
68
- });
71
+ }, request.requestId);
69
72
  try {
70
73
  let result = await stream.next();
71
74
  while (!result.done) {
@@ -98,22 +101,66 @@ export const whisperPlugin = definePlugin({
98
101
  responseSchema: transcribeStreamResponseSchema,
99
102
  streaming: true,
100
103
  duplex: true,
104
+ // Same model-wide hard cancel surface as `transcribe` — both
105
+ // route through the whisper.cpp addon.
106
+ cancel: { scope: "model", hard: true },
101
107
  handler: async function* (request, inputStream) {
102
- if (request.metadata === true) {
103
- for await (const segment of transcribeStream(request.modelId, inputStream, request.prompt, true)) {
104
- yield {
105
- type: "transcribeStream",
106
- segment,
107
- };
108
+ const streamOpts = {
109
+ ...(request.emitVadEvents !== undefined && {
110
+ emitVadEvents: request.emitVadEvents,
111
+ }),
112
+ ...(request.endOfTurnSilenceMs !== undefined && {
113
+ endOfTurnSilenceMs: request.endOfTurnSilenceMs,
114
+ }),
115
+ ...(request.vadRunIntervalMs !== undefined && {
116
+ vadRunIntervalMs: request.vadRunIntervalMs,
117
+ }),
118
+ };
119
+ const metadata = request.metadata === true;
120
+ const iterator = metadata
121
+ ? transcribeStream(request.modelId, inputStream, request.prompt, true, streamOpts, request.requestId)
122
+ : transcribeStream(request.modelId, inputStream, request.prompt, false, streamOpts, request.requestId);
123
+ for await (const value of iterator) {
124
+ if (typeof value === "object" && value !== null && "type" in value) {
125
+ if (value.type === "vad") {
126
+ yield {
127
+ type: "transcribeStream",
128
+ vad: {
129
+ speaking: value.speaking,
130
+ probability: value.probability,
131
+ },
132
+ };
133
+ continue;
134
+ }
135
+ if (value.type === "endOfTurn") {
136
+ // Whisper addon emits legacy `{ type, silenceDurationMs }` frames
137
+ // without `source`. Parakeet must never surface here.
138
+ if (value.source === "parakeet") {
139
+ continue;
140
+ }
141
+ if (typeof value.silenceDurationMs !== "number") {
142
+ continue;
143
+ }
144
+ yield {
145
+ type: "transcribeStream",
146
+ endOfTurn: {
147
+ source: "whisper",
148
+ silenceDurationMs: value.silenceDurationMs,
149
+ },
150
+ };
151
+ continue;
152
+ }
153
+ continue;
108
154
  }
109
- }
110
- else {
111
- for await (const text of transcribeStream(request.modelId, inputStream, request.prompt)) {
112
- yield {
155
+ yield metadata
156
+ ? {
113
157
  type: "transcribeStream",
114
- text,
158
+ segment: value,
159
+ }
160
+ : {
161
+ type: "transcribeStream",
162
+ text: value,
115
163
  };
116
- }
117
164
  }
118
165
  yield {
119
166
  type: "transcribeStream",
@@ -8,5 +8,5 @@ export { listWorkspaces } from "./handlers/list-workspaces";
8
8
  export { closeWorkspace } from "./handlers/close-workspace";
9
9
  export { deleteWorkspace } from "./handlers/delete-workspace";
10
10
  export { closeAllRagInstances, DEFAULT_WORKSPACE, type RagWorkspaceInfo, } from "./rag-workspace-manager";
11
- export { registerRagOperation, unregisterRagOperation, cancelRagOperation, } from "./rag-operation-manager";
11
+ export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey, } from "./rag-operation-manager";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -8,4 +8,4 @@ export { listWorkspaces } from "./handlers/list-workspaces.js";
8
8
  export { closeWorkspace } from "./handlers/close-workspace.js";
9
9
  export { deleteWorkspace } from "./handlers/delete-workspace.js";
10
10
  export { closeAllRagInstances, DEFAULT_WORKSPACE, } from "./rag-workspace-manager.js";
11
- export { registerRagOperation, unregisterRagOperation, cancelRagOperation, } from "./rag-operation-manager.js";
11
+ export { getActiveRagRequest, setActiveRagRequest, clearActiveRagRequest, getWorkspaceKey, } from "./rag-operation-manager.js";
@@ -1,7 +1,29 @@
1
- import { type AbortSignal } from "bare-abort-controller";
2
1
  export declare function getWorkspaceKey(workspace?: string): string;
3
- export declare function registerRagOperation(workspace: string | undefined, operation: string): AbortSignal;
4
- export declare function unregisterRagOperation(workspace?: string): void;
5
- export declare function cancelRagOperation(workspace?: string): boolean;
2
+ /**
3
+ * Returns the `requestId` of any in-flight RAG operation on the workspace
4
+ * (or `undefined` if none). The dispatcher uses this to decide whether to
5
+ * pre-empt before calling `registry.begin(...)`.
6
+ */
7
+ export declare function getActiveRagRequest(workspace?: string): string | undefined;
8
+ /**
9
+ * Records the `requestId` of a freshly-begun RAG operation. Called by the
10
+ * dispatcher in `rag.ts` after `registry.begin(...)` succeeds; paired with
11
+ * `clearActiveRagRequest` via the request scope's deferred cleanup so the
12
+ * map never outlives the request.
13
+ */
14
+ export declare function setActiveRagRequest(workspace: string | undefined, requestId: string): void;
15
+ /**
16
+ * Clears the workspace's mapping iff it still belongs to `requestId`. The
17
+ * conditional guard handles the natural race between two ingest calls on
18
+ * the same workspace: the older context's scope unwind must not stomp the
19
+ * newer context's mapping installed by the pre-emption sequence.
20
+ */
21
+ export declare function clearActiveRagRequest(workspace: string | undefined, requestId: string): void;
22
+ /**
23
+ * Shutdown / workspace-close sweep. Cancels every tracked RAG request via
24
+ * the registry and clears the workspace map. Idempotent — callers that
25
+ * re-invoke during a teardown (workspace-close fired twice, shutdown
26
+ * racing with `close-all`) get a no-op on the second pass.
27
+ */
6
28
  export declare function cancelAllRagOperations(): void;
7
29
  //# sourceMappingURL=rag-operation-manager.d.ts.map