@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
@@ -2,21 +2,24 @@
2
2
  * Default worker entry point that registers ALL built-in plugins.
3
3
  */
4
4
  import { initializeWorkerCore, ensureRPCSetup } from "./worker-core.js";
5
- import { registerPlugin } from "./plugins/index.js";
5
+ import { registerPlugins } from "./plugins/index.js";
6
6
  import { getServerLogger } from "../logging/index.js";
7
- import { llmPlugin, embeddingsPlugin, whisperPlugin, parakeetPlugin, nmtPlugin, ttsPlugin, ocrPlugin, diffusionPlugin, } from "./bare/plugins/index.js";
7
+ import { llmPlugin, embeddingsPlugin, whisperPlugin, parakeetPlugin, nmtPlugin, ttsPlugin, ocrPlugin, diffusionPlugin, vlaPlugin, classificationPlugin, } from "./bare/plugins/index.js";
8
8
  const { hasRPCConfig } = initializeWorkerCore();
9
9
  const logger = getServerLogger();
10
10
  logger.info("🐻 Hello from Bare");
11
- // Register all built-in plugins
12
- registerPlugin(llmPlugin);
13
- registerPlugin(embeddingsPlugin);
14
- registerPlugin(whisperPlugin);
15
- registerPlugin(parakeetPlugin);
16
- registerPlugin(nmtPlugin);
17
- registerPlugin(ttsPlugin);
18
- registerPlugin(ocrPlugin);
19
- registerPlugin(diffusionPlugin);
11
+ registerPlugins([
12
+ llmPlugin,
13
+ embeddingsPlugin,
14
+ whisperPlugin,
15
+ parakeetPlugin,
16
+ nmtPlugin,
17
+ ttsPlugin,
18
+ ocrPlugin,
19
+ diffusionPlugin,
20
+ vlaPlugin,
21
+ classificationPlugin,
22
+ ]);
20
23
  logger.info(hasRPCConfig
21
24
  ? "Parsed RPC configuration from arguments"
22
25
  : "Using default configuration (direct mode)");
@@ -7,10 +7,19 @@ export type AggregatedEvents = {
7
7
  toolCalls: ToolCall[];
8
8
  rawFullText: string | undefined;
9
9
  error: CompletionError | undefined;
10
+ /**
11
+ * True when the terminal `completionDone` carried
12
+ * `stopReason: "cancelled"`. The client wrapper rejects the
13
+ * promise-aggregates (`final` / `text` / `toolCalls` / `stats`) with
14
+ * `InferenceCancelledError` carrying the partial state when this is
15
+ * set; the `events` stream itself still ends normally.
16
+ */
17
+ cancelled: boolean;
10
18
  };
11
19
  export declare function aggregateEvents(events: CompletionEvent[]): AggregatedEvents;
12
20
  export declare function buildFinalFromEvents(events: CompletionEvent[], handlers: ToolHandlerMap): {
13
21
  final: CompletionFinal;
14
22
  error: CompletionError | undefined;
23
+ cancelled: boolean;
15
24
  };
16
25
  //# sourceMappingURL=aggregate-events.d.ts.map
@@ -6,6 +6,7 @@ export function aggregateEvents(events) {
6
6
  let stats;
7
7
  let rawFullText;
8
8
  let error;
9
+ let cancelled = false;
9
10
  const toolCalls = [];
10
11
  for (const event of events) {
11
12
  if (event.type === "contentDelta") {
@@ -24,15 +25,29 @@ export function aggregateEvents(events) {
24
25
  if ("raw" in event && event.raw) {
25
26
  rawFullText = event.raw.fullText;
26
27
  }
28
+ // Error wins over cancelled if a wire event ever carries both
29
+ // signals: a mid-stream addon failure makes the partial state
30
+ // unsafe to expose, regardless of why the loop exited.
27
31
  if (event.stopReason === "error" && "error" in event) {
28
32
  error = event.error;
29
33
  }
34
+ else if (event.stopReason === "cancelled") {
35
+ cancelled = true;
36
+ }
30
37
  }
31
38
  }
32
- return { contentText, thinkingText, stats, toolCalls, rawFullText, error };
39
+ return {
40
+ contentText,
41
+ thinkingText,
42
+ stats,
43
+ toolCalls,
44
+ rawFullText,
45
+ error,
46
+ cancelled,
47
+ };
33
48
  }
34
49
  export function buildFinalFromEvents(events, handlers) {
35
- const { contentText, thinkingText, stats, toolCalls, rawFullText, error } = aggregateEvents(events);
50
+ const { contentText, thinkingText, stats, toolCalls, rawFullText, error, cancelled, } = aggregateEvents(events);
36
51
  const attachedToolCalls = attachHandlersToToolCalls(toolCalls, handlers);
37
52
  const fullText = rawFullText ?? contentText;
38
53
  const cacheableAssistantContent = attachedToolCalls.length === 0
@@ -48,5 +63,5 @@ export function buildFinalFromEvents(events, handlers) {
48
63
  cacheableAssistantContent,
49
64
  }),
50
65
  };
51
- return { final, error };
66
+ return { final, error, cancelled };
52
67
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Attach metadata to a Promise so the metadata is reachable
3
+ * synchronously while the promise's normal async surface keeps working.
4
+ *
5
+ * The decorated-promise pattern lets a long-running client-API call
6
+ * (`loadModel(...)`, `downloadAsset(...)`) return a value that is both:
7
+ * - a `Promise<T>` you can `await` for the resolved result; and
8
+ * - a record carrying call metadata (`requestId`) you can read
9
+ * synchronously to target the in-flight call with
10
+ * `cancel({ requestId })` before it resolves.
11
+ *
12
+ * Implementation notes:
13
+ * - `Object.assign` attaches enumerable own properties without
14
+ * touching the prototype chain, so `await`, `.then`, `.catch`,
15
+ * `.finally`, and async-await unwrapping continue to work exactly
16
+ * as for a plain `Promise<T>`.
17
+ * - The intersection type `Promise<T> & M` is sound because the
18
+ * resolved-value type `T` does not intersect with `M`'s key set in
19
+ * practice (callers pick metadata keys that don't collide with
20
+ * `Promise` members like `then`/`catch`/`finally`). Picking such a
21
+ * key would shadow the Promise method and break the unwrap chain;
22
+ * don't.
23
+ * - We deliberately avoid extending `Promise.prototype` or calling
24
+ * `Object.setPrototypeOf`. Either would silently affect every
25
+ * promise in the worker; the plain-object approach is intentional
26
+ * and the helper exists to keep call sites consistent.
27
+ *
28
+ * @example
29
+ * const op = decoratePromise(innerPromise, { requestId: "abc" });
30
+ * op.requestId; // "abc" (synchronous)
31
+ * await op; // resolves to T (legacy contract preserved)
32
+ */
33
+ export declare function decoratePromise<T, M extends Record<string, unknown>>(promise: Promise<T>, metadata: M): Promise<T> & M;
34
+ //# sourceMappingURL=decorate-promise.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Attach metadata to a Promise so the metadata is reachable
3
+ * synchronously while the promise's normal async surface keeps working.
4
+ *
5
+ * The decorated-promise pattern lets a long-running client-API call
6
+ * (`loadModel(...)`, `downloadAsset(...)`) return a value that is both:
7
+ * - a `Promise<T>` you can `await` for the resolved result; and
8
+ * - a record carrying call metadata (`requestId`) you can read
9
+ * synchronously to target the in-flight call with
10
+ * `cancel({ requestId })` before it resolves.
11
+ *
12
+ * Implementation notes:
13
+ * - `Object.assign` attaches enumerable own properties without
14
+ * touching the prototype chain, so `await`, `.then`, `.catch`,
15
+ * `.finally`, and async-await unwrapping continue to work exactly
16
+ * as for a plain `Promise<T>`.
17
+ * - The intersection type `Promise<T> & M` is sound because the
18
+ * resolved-value type `T` does not intersect with `M`'s key set in
19
+ * practice (callers pick metadata keys that don't collide with
20
+ * `Promise` members like `then`/`catch`/`finally`). Picking such a
21
+ * key would shadow the Promise method and break the unwrap chain;
22
+ * don't.
23
+ * - We deliberately avoid extending `Promise.prototype` or calling
24
+ * `Object.setPrototypeOf`. Either would silently affect every
25
+ * promise in the worker; the plain-object approach is intentional
26
+ * and the helper exists to keep call sites consistent.
27
+ *
28
+ * @example
29
+ * const op = decoratePromise(innerPromise, { requestId: "abc" });
30
+ * op.requestId; // "abc" (synchronous)
31
+ * await op; // resolves to T (legacy contract preserved)
32
+ */
33
+ export function decoratePromise(promise, metadata) {
34
+ return Object.assign(promise, metadata);
35
+ }
@@ -68,6 +68,24 @@ export declare class WorkerFileNotFoundError extends QvacErrorBase {
68
68
  export declare class PearWorkerEntryRequiredError extends QvacErrorBase {
69
69
  constructor(workerEntry: string, cause?: unknown);
70
70
  }
71
+ export declare class WorkerPluginsNotRegisteredError extends QvacErrorBase {
72
+ constructor(cause?: unknown);
73
+ }
74
+ export declare class BundleVerificationFailedError extends QvacErrorBase {
75
+ constructor(bundlePath: string, cause?: unknown);
76
+ }
77
+ export declare class BarePackNotInstalledError extends QvacErrorBase {
78
+ constructor(cause?: unknown);
79
+ }
80
+ export declare class BarePackError extends QvacErrorBase {
81
+ constructor(exitCode: number, entryPath: string, outputPath: string, cause?: unknown);
82
+ }
83
+ export declare class InvalidPluginSpecifierError extends QvacErrorBase {
84
+ constructor(specifiers: string[], cause?: unknown);
85
+ }
86
+ export declare class BareImportsMapNotFoundError extends QvacErrorBase {
87
+ constructor(sdkName: string, expectedPath: string, cause?: unknown);
88
+ }
71
89
  export declare class ConfigFileNotFoundError extends QvacErrorBase {
72
90
  constructor(searchPaths: string, cause?: unknown);
73
91
  }
@@ -121,6 +121,37 @@ export class PearWorkerEntryRequiredError extends QvacErrorBase {
121
121
  super(createErrorOptions(SDK_CLIENT_ERROR_CODES.PEAR_WORKER_ENTRY_REQUIRED, [workerEntry], cause));
122
122
  }
123
123
  }
124
+ export class WorkerPluginsNotRegisteredError extends QvacErrorBase {
125
+ constructor(cause) {
126
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_PLUGINS_NOT_REGISTERED, [], cause));
127
+ }
128
+ }
129
+ export class BundleVerificationFailedError extends QvacErrorBase {
130
+ constructor(bundlePath, cause) {
131
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BUNDLE_VERIFICATION_FAILED, [bundlePath], cause));
132
+ }
133
+ }
134
+ export class BarePackNotInstalledError extends QvacErrorBase {
135
+ constructor(cause) {
136
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_PACK_NOT_INSTALLED, undefined, cause));
137
+ }
138
+ }
139
+ export class BarePackError extends QvacErrorBase {
140
+ constructor(exitCode, entryPath, outputPath, cause) {
141
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_PACK_ERROR, [exitCode, entryPath, outputPath], cause));
142
+ }
143
+ }
144
+ export class InvalidPluginSpecifierError extends QvacErrorBase {
145
+ constructor(specifiers, cause) {
146
+ const list = specifiers.map((s) => ` - ${s}`).join("\n");
147
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.INVALID_PLUGIN_SPECIFIER, [list], cause));
148
+ }
149
+ }
150
+ export class BareImportsMapNotFoundError extends QvacErrorBase {
151
+ constructor(sdkName, expectedPath, cause) {
152
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_IMPORTS_MAP_NOT_FOUND, [sdkName, expectedPath], cause));
153
+ }
154
+ }
124
155
  export class ConfigFileNotFoundError extends QvacErrorBase {
125
156
  constructor(searchPaths, cause) {
126
157
  super(createErrorOptions(SDK_CLIENT_ERROR_CODES.CONFIG_FILE_NOT_FOUND, [searchPaths], cause));
@@ -1,4 +1,21 @@
1
1
  import { QvacErrorBase } from "@qvac/error";
2
+ import type { CompletionStats, ToolCallWithCall } from "../schemas/index";
3
+ /**
4
+ * Partial completion payload attached to `InferenceCancelledError` when a
5
+ * cancel hits mid-stream. Mirrors the named fields on `CompletionFinal`
6
+ * so callers who want the partial output can read `.partial.text`,
7
+ * `.partial.toolCalls`, `.partial.stats` directly without reaching for
8
+ * a `Partial<CompletionFinal>` import.
9
+ *
10
+ * Fields are all optional: a same-tick cancel-before-begin races every
11
+ * event; a cancel after the first content chunk carries `text` but no
12
+ * `stats`; a cancel after a tool-call frame carries both.
13
+ */
14
+ export interface InferenceCancelledPartial {
15
+ text?: string;
16
+ toolCalls?: ToolCallWithCall[];
17
+ stats?: CompletionStats;
18
+ }
2
19
  export declare class ModelAlreadyRegisteredError extends QvacErrorBase {
3
20
  constructor(modelId: string, cause?: unknown);
4
21
  }
@@ -35,8 +52,11 @@ export declare class TtsArtifactsRequiredError extends QvacErrorBase {
35
52
  export declare class TtsReferenceAudioRequiredError extends QvacErrorBase {
36
53
  constructor(cause?: unknown);
37
54
  }
38
- export declare class ParakeetArtifactsRequiredError extends QvacErrorBase {
39
- constructor(details?: string, cause?: unknown);
55
+ export declare class LegacyParakeetModelDeprecatedError extends QvacErrorBase {
56
+ constructor(legacyFields: readonly string[], cause?: unknown);
57
+ }
58
+ export declare class LegacyTtsModelDeprecatedError extends QvacErrorBase {
59
+ constructor(legacyFields: readonly string[], cause?: unknown);
40
60
  }
41
61
  export declare class ModelUnloadFailedError extends QvacErrorBase {
42
62
  constructor(modelId?: string, cause?: unknown);
@@ -59,12 +79,105 @@ export declare class TranslationFailedError extends QvacErrorBase {
59
79
  export declare class CompletionFailedError extends QvacErrorBase {
60
80
  constructor(details?: string, cause?: unknown);
61
81
  }
82
+ /**
83
+ * Thrown when the prompt exceeds the loaded model's configured context
84
+ * window — distinct from a generic `CompletionFailedError` so consumers
85
+ * can drive UX (truncate, summarize, or surface a "increase ctx_size /
86
+ * start a new thread" CTA) instead of treating it as an opaque failure.
87
+ *
88
+ * Carries the addon-reported prompt size and the model's context window
89
+ * when the addon's error message includes them (the C++ overflow paths
90
+ * in `TextLlmContext.cpp` and `MtmdLlmContext.cpp` format both numbers
91
+ * into the message; the bare `processPromptImpl: context overflow`
92
+ * fallback in `LlamaModel.cpp` carries neither — both fields are
93
+ * therefore optional). `modelId` is supplied by the server-side handler
94
+ * that wraps the addon error.
95
+ *
96
+ * Round-trips the RPC boundary via the typed-error reconstructor in
97
+ * `client/rpc/rpc-error.ts`, so `err instanceof ContextOverflowError`
98
+ * works on the consumer side.
99
+ */
100
+ export declare class ContextOverflowError extends QvacErrorBase {
101
+ readonly promptTokens?: number;
102
+ readonly ctxSize?: number;
103
+ readonly modelId?: string;
104
+ constructor(promptTokens?: number, ctxSize?: number, modelId?: string, cause?: unknown);
105
+ toErrorResponseFields(): Record<string, unknown>;
106
+ }
62
107
  export declare class AttachmentNotFoundError extends QvacErrorBase {
63
108
  constructor(path: string, cause?: unknown);
64
109
  }
65
110
  export declare class CancelFailedError extends QvacErrorBase {
66
111
  constructor(details?: string, cause?: unknown);
67
112
  }
113
+ export declare class RequestIdConflictError extends QvacErrorBase {
114
+ readonly requestId: string;
115
+ constructor(requestId: string, cause?: unknown);
116
+ /**
117
+ * Surface typed fields on the RPC error envelope so the client-side
118
+ * reconstructor in `client/rpc/rpc-error.ts` can rebuild this exact
119
+ * class on the consumer side. Without this, `err instanceof
120
+ * RequestIdConflictError` would always be `false` after the error
121
+ * crosses the worker boundary.
122
+ */
123
+ toErrorResponseFields(): Record<string, unknown>;
124
+ }
125
+ export declare class RequestNotFoundError extends QvacErrorBase {
126
+ readonly requestId: string;
127
+ constructor(requestId: string, cause?: unknown);
128
+ toErrorResponseFields(): Record<string, unknown>;
129
+ }
130
+ /**
131
+ * Thrown by `RequestRegistry.begin(...)` when a registered concurrency
132
+ * policy rejects the request (e.g. `oneAtATimePerModel` for the
133
+ * `completion` kind). Distinct from `RequestIdConflictError`, which
134
+ * only fires on UUID collisions.
135
+ */
136
+ export declare class RequestRejectedByPolicyError extends QvacErrorBase {
137
+ readonly requestId: string;
138
+ readonly kind: string;
139
+ readonly modelId: string;
140
+ readonly reason: string;
141
+ constructor(requestId: string, kind: string, modelId: string, reason: string, cause?: unknown);
142
+ toErrorResponseFields(): Record<string, unknown>;
143
+ }
144
+ /**
145
+ * Thrown when a long-running inference request was cancelled before
146
+ * completion. The `events` stream on `CompletionRun` ends normally with
147
+ * `stopReason: "cancelled"` on the last `completionDone`, but the
148
+ * promise-aggregates on the same run (`final` / `text` / `toolCalls` /
149
+ * `stats`) reject with this error so callers can't accidentally treat a
150
+ * cancelled run as a successful one.
151
+ *
152
+ * Carries:
153
+ * - `requestId` — correlates with `run.requestId` so callers know which
154
+ * in-flight request was cancelled when they fan out multiple cancels.
155
+ * - `partial` — whatever the aggregator accumulated up to the cancel
156
+ * point. Optional fields so consumers can opt into "show partial":
157
+ *
158
+ * try { await run.text } catch (err) {
159
+ * if (err instanceof InferenceCancelledError) {
160
+ * renderPartial(err.partial.text);
161
+ * }
162
+ * }
163
+ *
164
+ * The error is constructed client-side in
165
+ * `client/api/completion-stream.ts` when the wire stream ends with
166
+ * `stopReason: "cancelled"` — the partial payload comes from the
167
+ * client's own event aggregator. The class lives in `errors-server.ts`
168
+ * (and is re-exported from the package root) because the *semantic*
169
+ * origin of the cancel is server-side, and other handlers
170
+ * (embeddings, transcribe, …) will reuse the same class once their
171
+ * cancel surface lands.
172
+ */
173
+ export declare class InferenceCancelledError extends QvacErrorBase {
174
+ readonly requestId: string;
175
+ readonly partial: InferenceCancelledPartial;
176
+ constructor(requestId: string, partial?: InferenceCancelledPartial, cause?: unknown);
177
+ }
178
+ export declare class AsyncDisposeUnavailableError extends QvacErrorBase {
179
+ constructor(cause?: unknown);
180
+ }
68
181
  export declare class TextToSpeechFailedError extends QvacErrorBase {
69
182
  constructor(details?: string, cause?: unknown);
70
183
  }
@@ -63,9 +63,14 @@ export class TtsReferenceAudioRequiredError extends QvacErrorBase {
63
63
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.TTS_REFERENCE_AUDIO_REQUIRED, undefined, cause));
64
64
  }
65
65
  }
66
- export class ParakeetArtifactsRequiredError extends QvacErrorBase {
67
- constructor(details, cause) {
68
- super(createErrorOptions(SDK_SERVER_ERROR_CODES.PARAKEET_ARTIFACTS_REQUIRED, details ? [details] : undefined, cause));
66
+ export class LegacyParakeetModelDeprecatedError extends QvacErrorBase {
67
+ constructor(legacyFields, cause) {
68
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.LEGACY_PARAKEET_MODEL_DEPRECATED, [legacyFields.join(", ")], cause));
69
+ }
70
+ }
71
+ export class LegacyTtsModelDeprecatedError extends QvacErrorBase {
72
+ constructor(legacyFields, cause) {
73
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.LEGACY_TTS_MODEL_DEPRECATED, [legacyFields.join(", ")], cause));
69
74
  }
70
75
  }
71
76
  // ============== Model Unloading Errors ==============
@@ -105,6 +110,49 @@ export class CompletionFailedError extends QvacErrorBase {
105
110
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.COMPLETION_FAILED, details ? [details] : undefined, cause));
106
111
  }
107
112
  }
113
+ /**
114
+ * Thrown when the prompt exceeds the loaded model's configured context
115
+ * window — distinct from a generic `CompletionFailedError` so consumers
116
+ * can drive UX (truncate, summarize, or surface a "increase ctx_size /
117
+ * start a new thread" CTA) instead of treating it as an opaque failure.
118
+ *
119
+ * Carries the addon-reported prompt size and the model's context window
120
+ * when the addon's error message includes them (the C++ overflow paths
121
+ * in `TextLlmContext.cpp` and `MtmdLlmContext.cpp` format both numbers
122
+ * into the message; the bare `processPromptImpl: context overflow`
123
+ * fallback in `LlamaModel.cpp` carries neither — both fields are
124
+ * therefore optional). `modelId` is supplied by the server-side handler
125
+ * that wraps the addon error.
126
+ *
127
+ * Round-trips the RPC boundary via the typed-error reconstructor in
128
+ * `client/rpc/rpc-error.ts`, so `err instanceof ContextOverflowError`
129
+ * works on the consumer side.
130
+ */
131
+ export class ContextOverflowError extends QvacErrorBase {
132
+ promptTokens;
133
+ ctxSize;
134
+ modelId;
135
+ constructor(promptTokens, ctxSize, modelId, cause) {
136
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.CONTEXT_OVERFLOW, [
137
+ promptTokens !== undefined ? String(promptTokens) : "",
138
+ ctxSize !== undefined ? String(ctxSize) : "",
139
+ modelId ?? "",
140
+ ], cause));
141
+ if (promptTokens !== undefined)
142
+ this.promptTokens = promptTokens;
143
+ if (ctxSize !== undefined)
144
+ this.ctxSize = ctxSize;
145
+ if (modelId !== undefined)
146
+ this.modelId = modelId;
147
+ }
148
+ toErrorResponseFields() {
149
+ return {
150
+ ...(this.promptTokens !== undefined && { promptTokens: this.promptTokens }),
151
+ ...(this.ctxSize !== undefined && { ctxSize: this.ctxSize }),
152
+ ...(this.modelId !== undefined && { modelId: this.modelId }),
153
+ };
154
+ }
155
+ }
108
156
  export class AttachmentNotFoundError extends QvacErrorBase {
109
157
  constructor(path, cause) {
110
158
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.ATTACHMENT_NOT_FOUND, [path], cause));
@@ -115,6 +163,103 @@ export class CancelFailedError extends QvacErrorBase {
115
163
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.CANCEL_FAILED, details ? [details] : undefined, cause));
116
164
  }
117
165
  }
166
+ export class RequestIdConflictError extends QvacErrorBase {
167
+ requestId;
168
+ constructor(requestId, cause) {
169
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_ID_CONFLICT, [requestId], cause));
170
+ this.requestId = requestId;
171
+ }
172
+ /**
173
+ * Surface typed fields on the RPC error envelope so the client-side
174
+ * reconstructor in `client/rpc/rpc-error.ts` can rebuild this exact
175
+ * class on the consumer side. Without this, `err instanceof
176
+ * RequestIdConflictError` would always be `false` after the error
177
+ * crosses the worker boundary.
178
+ */
179
+ toErrorResponseFields() {
180
+ return { requestId: this.requestId };
181
+ }
182
+ }
183
+ export class RequestNotFoundError extends QvacErrorBase {
184
+ requestId;
185
+ constructor(requestId, cause) {
186
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_NOT_FOUND, [requestId], cause));
187
+ this.requestId = requestId;
188
+ }
189
+ toErrorResponseFields() {
190
+ return { requestId: this.requestId };
191
+ }
192
+ }
193
+ /**
194
+ * Thrown by `RequestRegistry.begin(...)` when a registered concurrency
195
+ * policy rejects the request (e.g. `oneAtATimePerModel` for the
196
+ * `completion` kind). Distinct from `RequestIdConflictError`, which
197
+ * only fires on UUID collisions.
198
+ */
199
+ export class RequestRejectedByPolicyError extends QvacErrorBase {
200
+ requestId;
201
+ kind;
202
+ modelId;
203
+ reason;
204
+ constructor(requestId, kind, modelId, reason, cause) {
205
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.REQUEST_REJECTED_BY_POLICY, [requestId, kind, modelId, reason], cause));
206
+ this.requestId = requestId;
207
+ this.kind = kind;
208
+ this.modelId = modelId;
209
+ this.reason = reason;
210
+ }
211
+ toErrorResponseFields() {
212
+ return {
213
+ requestId: this.requestId,
214
+ kind: this.kind,
215
+ modelId: this.modelId,
216
+ reason: this.reason,
217
+ };
218
+ }
219
+ }
220
+ /**
221
+ * Thrown when a long-running inference request was cancelled before
222
+ * completion. The `events` stream on `CompletionRun` ends normally with
223
+ * `stopReason: "cancelled"` on the last `completionDone`, but the
224
+ * promise-aggregates on the same run (`final` / `text` / `toolCalls` /
225
+ * `stats`) reject with this error so callers can't accidentally treat a
226
+ * cancelled run as a successful one.
227
+ *
228
+ * Carries:
229
+ * - `requestId` — correlates with `run.requestId` so callers know which
230
+ * in-flight request was cancelled when they fan out multiple cancels.
231
+ * - `partial` — whatever the aggregator accumulated up to the cancel
232
+ * point. Optional fields so consumers can opt into "show partial":
233
+ *
234
+ * try { await run.text } catch (err) {
235
+ * if (err instanceof InferenceCancelledError) {
236
+ * renderPartial(err.partial.text);
237
+ * }
238
+ * }
239
+ *
240
+ * The error is constructed client-side in
241
+ * `client/api/completion-stream.ts` when the wire stream ends with
242
+ * `stopReason: "cancelled"` — the partial payload comes from the
243
+ * client's own event aggregator. The class lives in `errors-server.ts`
244
+ * (and is re-exported from the package root) because the *semantic*
245
+ * origin of the cancel is server-side, and other handlers
246
+ * (embeddings, transcribe, …) will reuse the same class once their
247
+ * cancel surface lands.
248
+ */
249
+ export class InferenceCancelledError extends QvacErrorBase {
250
+ requestId;
251
+ partial;
252
+ constructor(requestId, partial = {}, cause) {
253
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.INFERENCE_CANCELLED, [requestId], cause));
254
+ this.requestId = requestId;
255
+ this.partial = partial;
256
+ }
257
+ }
258
+ export class AsyncDisposeUnavailableError extends QvacErrorBase {
259
+ constructor(cause) {
260
+ super(createErrorOptions(SDK_SERVER_ERROR_CODES.ASYNC_DISPOSE_UNAVAILABLE, [], cause));
261
+ }
262
+ }
118
263
  export class TextToSpeechFailedError extends QvacErrorBase {
119
264
  constructor(details, cause) {
120
265
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.TEXT_TO_SPEECH_FAILED, details ? [details] : undefined, cause));