@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
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ export declare const vlaConfigSchema: z.ZodObject<{
3
+ backend: z.ZodOptional<z.ZodEnum<{
4
+ cpu: "cpu";
5
+ auto: "auto";
6
+ }>>;
7
+ verbosity: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$strip>;
9
+ export type VlaConfig = z.input<typeof vlaConfigSchema>;
10
+ export declare const vlaHparamsSchema: z.ZodObject<{
11
+ chunkSize: z.ZodNumber;
12
+ actionDim: z.ZodNumber;
13
+ maxActionDim: z.ZodNumber;
14
+ maxStateDim: z.ZodNumber;
15
+ tokenizerMaxLength: z.ZodNumber;
16
+ visionImageSize: z.ZodNumber;
17
+ }, z.core.$strip>;
18
+ export type VlaHparams = z.infer<typeof vlaHparamsSchema>;
19
+ export declare const vlaStatsSchema: z.ZodObject<{
20
+ vision_ms: z.ZodOptional<z.ZodNumber>;
21
+ smollm2_compute_ms: z.ZodOptional<z.ZodNumber>;
22
+ smollm2_total_ms: z.ZodOptional<z.ZodNumber>;
23
+ ode_ms: z.ZodOptional<z.ZodNumber>;
24
+ total_ms: z.ZodOptional<z.ZodNumber>;
25
+ backendDevice: z.ZodOptional<z.ZodNumber>;
26
+ }, z.core.$strip>;
27
+ export type VlaStats = z.infer<typeof vlaStatsSchema>;
28
+ export declare const vlaRunRequestSchema: z.ZodObject<{
29
+ type: z.ZodLiteral<"vlaRun">;
30
+ modelId: z.ZodString;
31
+ images: z.ZodArray<z.ZodString>;
32
+ imgWidth: z.ZodNumber;
33
+ imgHeight: z.ZodNumber;
34
+ state: z.ZodString;
35
+ tokens: z.ZodString;
36
+ mask: z.ZodString;
37
+ noise: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export type VlaRunRequest = z.input<typeof vlaRunRequestSchema>;
40
+ export declare const vlaRunResponseSchema: z.ZodObject<{
41
+ actions: z.ZodString;
42
+ actionDim: z.ZodNumber;
43
+ chunkSize: z.ZodNumber;
44
+ stats: z.ZodOptional<z.ZodObject<{
45
+ vision_ms: z.ZodOptional<z.ZodNumber>;
46
+ smollm2_compute_ms: z.ZodOptional<z.ZodNumber>;
47
+ smollm2_total_ms: z.ZodOptional<z.ZodNumber>;
48
+ ode_ms: z.ZodOptional<z.ZodNumber>;
49
+ total_ms: z.ZodOptional<z.ZodNumber>;
50
+ backendDevice: z.ZodOptional<z.ZodNumber>;
51
+ }, z.core.$strip>>;
52
+ }, z.core.$strip>;
53
+ export type VlaRunResponse = z.infer<typeof vlaRunResponseSchema>;
54
+ export declare const vlaHparamsRequestSchema: z.ZodObject<{
55
+ type: z.ZodLiteral<"vlaHparams">;
56
+ modelId: z.ZodString;
57
+ }, z.core.$strip>;
58
+ export type VlaHparamsRequest = z.input<typeof vlaHparamsRequestSchema>;
59
+ export declare const vlaHparamsResponseSchema: z.ZodObject<{
60
+ hparams: z.ZodObject<{
61
+ chunkSize: z.ZodNumber;
62
+ actionDim: z.ZodNumber;
63
+ maxActionDim: z.ZodNumber;
64
+ maxStateDim: z.ZodNumber;
65
+ tokenizerMaxLength: z.ZodNumber;
66
+ visionImageSize: z.ZodNumber;
67
+ }, z.core.$strip>;
68
+ backendName: z.ZodNullable<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ export type VlaHparamsResponse = z.infer<typeof vlaHparamsResponseSchema>;
71
+ export interface VlaClientRunParams {
72
+ modelId: string;
73
+ images: Float32Array[];
74
+ imgWidth: number;
75
+ imgHeight: number;
76
+ state: Float32Array;
77
+ tokens: Int32Array;
78
+ mask: Uint8Array;
79
+ noise?: Float32Array;
80
+ }
81
+ export interface VlaClientRunResult {
82
+ actions: Float32Array;
83
+ actionDim: number;
84
+ chunkSize: number;
85
+ stats?: VlaStats;
86
+ }
87
+ //# sourceMappingURL=vla.d.ts.map
@@ -0,0 +1,108 @@
1
+ import { z } from "zod";
2
+ const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
3
+ // ============================================
4
+ // Load-time config
5
+ // ============================================
6
+ export const vlaConfigSchema = z.object({
7
+ backend: z
8
+ .enum(["auto", "cpu"])
9
+ .optional()
10
+ .describe("Backend selection passed to `VlaModel.load({ backend })`. " +
11
+ "`'auto'` (default) prefers an accepted GPU (Vulkan / Metal / OpenCL) and falls back to CPU. " +
12
+ "`'cpu'` forces CPU regardless of available accelerators."),
13
+ verbosity: z
14
+ .number()
15
+ .int()
16
+ .optional()
17
+ .describe("Native log verbosity forwarded to the addon (0=ERROR, 1=WARN, 2=INFO, 3=DEBUG)."),
18
+ });
19
+ // ============================================
20
+ // Hparams (returned by the addon after load)
21
+ // ============================================
22
+ export const vlaHparamsSchema = z.object({
23
+ chunkSize: z.number().int().nonnegative(),
24
+ actionDim: z.number().int().nonnegative(),
25
+ maxActionDim: z.number().int().nonnegative(),
26
+ maxStateDim: z.number().int().nonnegative(),
27
+ tokenizerMaxLength: z.number().int().nonnegative(),
28
+ visionImageSize: z.number().int().nonnegative(),
29
+ });
30
+ // ============================================
31
+ // Stats
32
+ // ============================================
33
+ export const vlaStatsSchema = z.object({
34
+ vision_ms: z.number().optional(),
35
+ smollm2_compute_ms: z.number().optional(),
36
+ smollm2_total_ms: z.number().optional(),
37
+ ode_ms: z.number().optional(),
38
+ total_ms: z.number().optional(),
39
+ backendDevice: z
40
+ .number()
41
+ .optional()
42
+ .describe("0 = CPU backend, 1 = GPU backend (Vulkan / Metal / OpenCL)."),
43
+ });
44
+ // ============================================
45
+ // Run request / response (wire format)
46
+ //
47
+ // Typed arrays travel as base64-encoded ArrayBuffers because JSON-RPC can't
48
+ // carry them natively. The client API helpers (`vla()` in client/api/vla.ts)
49
+ // keep the consumer-facing `Float32Array | Int32Array | Uint8Array` shape
50
+ // and handle the encoding internally.
51
+ // ============================================
52
+ export const vlaRunRequestSchema = z.object({
53
+ type: z.literal("vlaRun"),
54
+ modelId: z.string(),
55
+ images: z
56
+ .array(z.string().min(1).regex(BASE64_PATTERN))
57
+ .min(1)
58
+ .describe("Base64-encoded preprocessed images. Each entry is the underlying " +
59
+ "ArrayBuffer of a `Float32Array` produced by `vlaPreprocessImage(...)`. " +
60
+ "Length per image must equal `3 * imgWidth * imgHeight`."),
61
+ imgWidth: z.number().int().positive(),
62
+ imgHeight: z.number().int().positive(),
63
+ state: z
64
+ .string()
65
+ .min(1)
66
+ .regex(BASE64_PATTERN)
67
+ .describe("Base64-encoded `Float32Array` of length `hparams.maxStateDim`. " +
68
+ "Use `vlaPadState(state, hparams.maxStateDim)` to zero-pad."),
69
+ tokens: z
70
+ .string()
71
+ .min(1)
72
+ .regex(BASE64_PATTERN)
73
+ .describe("Base64-encoded `Int32Array` of length `hparams.tokenizerMaxLength`."),
74
+ mask: z
75
+ .string()
76
+ .min(1)
77
+ .regex(BASE64_PATTERN)
78
+ .describe("Base64-encoded `Uint8Array` of length `hparams.tokenizerMaxLength`."),
79
+ noise: z
80
+ .string()
81
+ .min(1)
82
+ .regex(BASE64_PATTERN)
83
+ .optional()
84
+ .describe("Optional base64-encoded `Float32Array` of length " +
85
+ "`hparams.chunkSize * hparams.maxActionDim`. When omitted the addon " +
86
+ "samples its own prior."),
87
+ });
88
+ export const vlaRunResponseSchema = z.object({
89
+ actions: z
90
+ .string()
91
+ .min(1)
92
+ .regex(BASE64_PATTERN)
93
+ .describe("Base64-encoded `Float32Array` of length `hparams.chunkSize * hparams.actionDim`."),
94
+ actionDim: z.number().int().positive(),
95
+ chunkSize: z.number().int().positive(),
96
+ stats: vlaStatsSchema.optional(),
97
+ });
98
+ // ============================================
99
+ // Hparams request / response (plugin handler)
100
+ // ============================================
101
+ export const vlaHparamsRequestSchema = z.object({
102
+ type: z.literal("vlaHparams"),
103
+ modelId: z.string(),
104
+ });
105
+ export const vlaHparamsResponseSchema = z.object({
106
+ hparams: vlaHparamsSchema,
107
+ backendName: z.string().nullable(),
108
+ });
@@ -1,13 +1,32 @@
1
- import { readdirSync } from "fs";
1
+ import { readFileSync, readdirSync } from "fs";
2
2
  import { join, dirname } from "path";
3
3
  import { spawnSync } from "child_process";
4
4
  import { fileURLToPath } from "url";
5
5
  const __dirname = dirname(fileURLToPath(import.meta.url));
6
6
  const testDir = join(__dirname, "..", "test", "unit");
7
- const testFiles = readdirSync(testDir).filter((f) => f.endsWith(".test.ts"));
7
+ function collectTestFiles(dir) {
8
+ const files = [];
9
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
10
+ const fullPath = join(dir, entry.name);
11
+ if (entry.isDirectory()) {
12
+ files.push(...collectTestFiles(fullPath));
13
+ }
14
+ else if (entry.isFile() && entry.name.endsWith(".test.ts")) {
15
+ files.push(fullPath);
16
+ }
17
+ }
18
+ return files;
19
+ }
20
+ const testFiles = collectTestFiles(testDir);
8
21
  let hasFailure = false;
22
+ function usesNodeTestRunner(filePath) {
23
+ const source = readFileSync(filePath, "utf8");
24
+ return (source.includes("from 'node:test'") ||
25
+ source.includes('from "node:test"'));
26
+ }
9
27
  for (const file of testFiles) {
10
- const result = spawnSync("bun", ["run", join(testDir, file)], {
28
+ const args = usesNodeTestRunner(file) ? ["test", file] : ["run", file];
29
+ const result = spawnSync("bun", args, {
11
30
  stdio: "inherit",
12
31
  });
13
32
  if (result.status !== 0) {
@@ -1,3 +1,29 @@
1
1
  import { type CancelInferenceBaseParams } from "../../../schemas/index";
2
- export declare function cancel(params: CancelInferenceBaseParams): Promise<void>;
2
+ import type { RequestKind } from "../runtime/index";
3
+ /**
4
+ * Broad cancel: abort every in-flight request matching `modelId` (and
5
+ * optionally a `kind`). Maps onto `RequestRegistry.cancel({ modelId })`
6
+ * — the registry walks active contexts and aborts each one's signal,
7
+ * which each handler has wired to its own addon-level / async unwind
8
+ * via the registry's `await using ctx = registry.begin(...)` block.
9
+ *
10
+ * Kept as a stable surface alongside the new `cancel({ requestId })`
11
+ * path: the caller may not have a `requestId` to hand (model unload,
12
+ * app shutdown, admin sweeps), and the escape hatch is cheap because
13
+ * the registry already does the matching.
14
+ *
15
+ * Returns the number of contexts whose abort was triggered by *this*
16
+ * call (already-cancelled contexts are skipped so callers can rely on
17
+ * the count to log "n requests cancelled" once). Used by the RPC
18
+ * cancel handler to populate `CancelResponse.cancelled` and by
19
+ * internal server-side callers that want to know whether anything
20
+ * landed.
21
+ *
22
+ * The legacy pre-registry addon-cancel fallback was removed in 0.11.0
23
+ * once every handler had been migrated onto the registry; the function
24
+ * now does exactly one thing — a registry walk.
25
+ */
26
+ export declare function cancel(params: CancelInferenceBaseParams, opts?: {
27
+ kind?: RequestKind;
28
+ }): number;
3
29
  //# sourceMappingURL=cancel.d.ts.map
@@ -1,20 +1,46 @@
1
1
  import { getModel } from "../registry/model-registry.js";
2
2
  import { cancelInferenceBaseSchema, } from "../../../schemas/index.js";
3
3
  import { ModelNotLoadedError } from "../../../utils/errors-server.js";
4
- import { noteCancelRequested } from "../plugins/llamacpp-completion/ops/kv-cache-state.js";
5
- export async function cancel(params) {
4
+ import { getRequestRegistry } from "../runtime/index.js";
5
+ import { getServerLogger } from "../../../logging/index.js";
6
+ const logger = getServerLogger();
7
+ /**
8
+ * Broad cancel: abort every in-flight request matching `modelId` (and
9
+ * optionally a `kind`). Maps onto `RequestRegistry.cancel({ modelId })`
10
+ * — the registry walks active contexts and aborts each one's signal,
11
+ * which each handler has wired to its own addon-level / async unwind
12
+ * via the registry's `await using ctx = registry.begin(...)` block.
13
+ *
14
+ * Kept as a stable surface alongside the new `cancel({ requestId })`
15
+ * path: the caller may not have a `requestId` to hand (model unload,
16
+ * app shutdown, admin sweeps), and the escape hatch is cheap because
17
+ * the registry already does the matching.
18
+ *
19
+ * Returns the number of contexts whose abort was triggered by *this*
20
+ * call (already-cancelled contexts are skipped so callers can rely on
21
+ * the count to log "n requests cancelled" once). Used by the RPC
22
+ * cancel handler to populate `CancelResponse.cancelled` and by
23
+ * internal server-side callers that want to know whether anything
24
+ * landed.
25
+ *
26
+ * The legacy pre-registry addon-cancel fallback was removed in 0.11.0
27
+ * once every handler had been migrated onto the registry; the function
28
+ * now does exactly one thing — a registry walk.
29
+ */
30
+ export function cancel(params, opts) {
6
31
  const { modelId } = cancelInferenceBaseSchema.parse(params);
7
32
  const model = getModel(modelId);
8
33
  if (!model) {
9
34
  throw new ModelNotLoadedError(modelId);
10
35
  }
11
- // Must be recorded *before* `addon.cancel()` so the in-flight
12
- // `completion()` for this model sees the bumped counter when it
13
- // snapshots after `processModelResponse` returns. This is the signal
14
- // that tells `completion()` not to record a `savedCount` for the
15
- // kv-cache on a cancelled turn.
16
- noteCancelRequested(modelId);
17
- if (model.addon && model.addon.cancel) {
18
- await model.addon.cancel();
36
+ const registry = getRequestRegistry();
37
+ const target = opts?.kind ? { modelId, kind: opts.kind } : { modelId };
38
+ const cancelled = registry.cancel(target);
39
+ if (cancelled === 0) {
40
+ // Callers (workbench "Stop" button, app shutdown sweeps) often
41
+ // fire-and-forget; log so operators can see when a broad cancel
42
+ // landed against a registry with nothing in flight on this model.
43
+ logger.debug(`[cancel] no in-flight request matched modelId=${modelId}${opts?.kind ? ` kind=${opts.kind}` : ""}`);
19
44
  }
45
+ return cancelled;
20
46
  }
@@ -6,11 +6,11 @@ export interface EmbedResult {
6
6
  export declare function embed(params: {
7
7
  modelId: string;
8
8
  text: string;
9
- }): Promise<EmbedResult>;
9
+ }, requestId?: string): Promise<EmbedResult>;
10
10
  export declare function embed(params: {
11
11
  modelId: string;
12
12
  text: string[];
13
- }): Promise<EmbedResult>;
14
- export declare function embed(params: EmbedParams): Promise<EmbedResult>;
13
+ }, requestId?: string): Promise<EmbedResult>;
14
+ export declare function embed(params: EmbedParams, requestId?: string): Promise<EmbedResult>;
15
15
  export declare function normalizeVector(vector: Float32Array): number[];
16
16
  //# sourceMappingURL=embed.d.ts.map
@@ -1,40 +1,156 @@
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
1
53
  import { getModel } from "../registry/model-registry.js";
2
54
  import { embedParamsSchema } from "../../../schemas/index.js";
3
55
  import { buildUnaryResult } from "../../../profiling/model-execution.js";
4
- import { EmbedNoEmbeddingsError, EmbedFailedError, } from "../../../utils/errors-server.js";
56
+ import { EmbedNoEmbeddingsError, EmbedFailedError, InferenceCancelledError, } from "../../../utils/errors-server.js";
5
57
  import { nowMs } from "../../../profiling/index.js";
6
- export async function embed(params) {
7
- const { modelId, text } = embedParamsSchema.parse(params);
8
- const model = getModel(modelId);
9
- const modelStart = nowMs();
10
- const response = (await model.run(text));
11
- const rawEmbeddings = await response.await();
12
- const modelExecutionMs = nowMs() - modelStart;
13
- const stats = {
14
- ...(response.stats?.total_time_ms !== undefined && { totalTime: response.stats.total_time_ms }),
15
- ...(response.stats?.tokens_per_second !== undefined && { tokensPerSecond: response.stats.tokens_per_second }),
16
- ...(response.stats?.total_tokens !== undefined && { totalTokens: response.stats.total_tokens }),
17
- ...(response.stats?.backendDevice !== undefined && { backendDevice: response.stats.backendDevice }),
18
- };
19
- const embeddingsArray = rawEmbeddings[0];
20
- if (Array.isArray(text)) {
21
- if (!embeddingsArray || embeddingsArray.length === 0) {
22
- throw new EmbedNoEmbeddingsError();
58
+ import { getRequestRegistry, withRequestContext, } from "../runtime/index.js";
59
+ import { generateServerRequestId } from "../runtime/request-id.js";
60
+ import { getServerLogger } from "../../../logging/index.js";
61
+ export async function embed(params, requestId) {
62
+ const env_1 = { stack: [], error: void 0, hasError: false };
63
+ try {
64
+ const { modelId, text } = embedParamsSchema.parse(params);
65
+ // Open a request-scoped lifecycle. The registry routes
66
+ // `cancel({ requestId })` and broad `cancel({ modelId, kind: "embeddings" })`
67
+ // straight to this context's signal. Falls back to a server-generated
68
+ // id if the client didn't send one (older releases).
69
+ const ctx = __addDisposableResource(env_1, getRequestRegistry().begin({
70
+ requestId: requestId ?? generateServerRequestId(),
71
+ kind: "embeddings",
72
+ modelId,
73
+ }), true);
74
+ // `requestLogger` is intentionally referenced once so the
75
+ // request-scoped logger is built at handler entry per the canonical
76
+ // shape, even when this op has no per-step emits beyond the
77
+ // registry's own lifecycle lines. Future addon-level warns inside
78
+ // this body should route through `requestLogger`.
79
+ const requestLogger = withRequestContext(getServerLogger(), ctx);
80
+ const model = getModel(modelId);
81
+ // Hard-cancel wiring: llamacpp-embedding declares
82
+ // `cancel: { scope: "model", hard: true }`. The signal listener
83
+ // forwards an abort to the addon so C++ work stops as soon as the
84
+ // user cancels — mirrors the canonical handler shape documented in
85
+ // `request-lifecycle-primitives.mdc`. The post-await
86
+ // `signal.aborted` checks below are the soft-cancel safety net for
87
+ // the case where the abort fires between `model.run(...)` returning
88
+ // and `response.await()` resolving (both can take seconds on large
89
+ // batches).
90
+ const onAbort = () => {
91
+ const addon = model.addon;
92
+ if (addon?.cancel) {
93
+ addon.cancel.call(addon).catch((err) => {
94
+ requestLogger.warn(`[cancel] addon.cancel() rejected during abort for modelId=${modelId}: ${err instanceof Error ? err.message : String(err)}`);
95
+ });
96
+ }
97
+ };
98
+ ctx.signal.addEventListener("abort", onAbort, { once: true });
99
+ // `{ once: true }` does not fire if the signal is already aborted at
100
+ // register time. The registry may abort synchronously when a
101
+ // cancel-before-begin race resolves or the parent signal was pre-
102
+ // aborted — re-use `onAbort` so the listener body is the single
103
+ // source of truth for "what cancel does."
104
+ if (ctx.signal.aborted)
105
+ onAbort();
106
+ ctx.scope.defer(() => {
107
+ ctx.signal.removeEventListener("abort", onAbort);
108
+ });
109
+ const modelStart = nowMs();
110
+ const response = (await model.run(text));
111
+ if (ctx.signal.aborted) {
112
+ throw new InferenceCancelledError(ctx.requestId);
113
+ }
114
+ const rawEmbeddings = await response.await();
115
+ if (ctx.signal.aborted) {
116
+ throw new InferenceCancelledError(ctx.requestId);
117
+ }
118
+ const modelExecutionMs = nowMs() - modelStart;
119
+ const stats = {
120
+ ...(response.stats?.total_time_ms !== undefined && { totalTime: response.stats.total_time_ms }),
121
+ ...(response.stats?.tokens_per_second !== undefined && { tokensPerSecond: response.stats.tokens_per_second }),
122
+ ...(response.stats?.total_tokens !== undefined && { totalTokens: response.stats.total_tokens }),
123
+ ...(response.stats?.backendDevice !== undefined && { backendDevice: response.stats.backendDevice }),
124
+ };
125
+ const embeddingsArray = rawEmbeddings[0];
126
+ if (Array.isArray(text)) {
127
+ if (!embeddingsArray || embeddingsArray.length === 0) {
128
+ throw new EmbedNoEmbeddingsError();
129
+ }
130
+ const embedding = embeddingsArray.map((embeddingVector) => {
131
+ if (!embeddingVector || embeddingVector.length === 0) {
132
+ throw new EmbedNoEmbeddingsError();
133
+ }
134
+ return normalizeVector(embeddingVector);
135
+ });
136
+ return buildUnaryResult({ embedding }, modelExecutionMs, stats);
23
137
  }
24
- const embedding = embeddingsArray.map((embeddingVector) => {
138
+ else {
139
+ const embeddingVector = embeddingsArray?.[0];
25
140
  if (!embeddingVector || embeddingVector.length === 0) {
26
141
  throw new EmbedNoEmbeddingsError();
27
142
  }
28
- return normalizeVector(embeddingVector);
29
- });
30
- return buildUnaryResult({ embedding }, modelExecutionMs, stats);
31
- }
32
- else {
33
- const embeddingVector = embeddingsArray?.[0];
34
- if (!embeddingVector || embeddingVector.length === 0) {
35
- throw new EmbedNoEmbeddingsError();
143
+ return buildUnaryResult({ embedding: normalizeVector(embeddingVector) }, modelExecutionMs, stats);
36
144
  }
37
- return buildUnaryResult({ embedding: normalizeVector(embeddingVector) }, modelExecutionMs, stats);
145
+ }
146
+ catch (e_1) {
147
+ env_1.error = e_1;
148
+ env_1.hasError = true;
149
+ }
150
+ finally {
151
+ const result_1 = __disposeResources(env_1);
152
+ if (result_1)
153
+ await result_1;
38
154
  }
39
155
  }
40
156
  export function normalizeVector(vector) {
@@ -1,10 +1,4 @@
1
1
  import { type CacheMessage } from "../../utils/index";
2
- export declare function markCacheInitialized(modelId: string, configHash: string, cacheKey: string): void;
3
- export declare function isCacheInitialized(modelId: string, configHash: string, cacheKey: string): boolean;
4
- export declare function clearCacheRegistry(scope?: {
5
- cacheKey?: string | undefined;
6
- modelId?: string | undefined;
7
- }): void;
8
2
  export declare function extractSystemPrompt(messages: CacheMessage[]): string | null;
9
3
  export declare function generateConfigHash(systemPrompt: string | null, tools?: unknown): string;
10
4
  export declare function generateCacheKey(messages: CacheMessage[]): string;
@@ -18,7 +12,6 @@ export declare function getCurrentCacheInfo(modelId: string, configHash: string,
18
12
  cachePath: string;
19
13
  }>;
20
14
  export declare function renameCacheFile(oldPath: string, newPath: string): Promise<boolean>;
21
- export declare function customCacheExists(modelId: string, configHash: string, cacheKey: string): Promise<boolean>;
22
15
  export declare function deleteCache(options: {
23
16
  all: true;
24
17
  } | {
@@ -4,37 +4,10 @@ import path from "bare-path";
4
4
  import { getAutoCacheLookupHistory, getKVCacheDir, validateAndJoinPath, } from "../../utils/index.js";
5
5
  import { getServerLogger } from "../../../logging/index.js";
6
6
  const logger = getServerLogger();
7
- // In-memory registry tracks caches initialized this session (addon defers disk writes)
8
- const initializedCaches = new Set();
9
- function getCacheRegistryKey(modelId, configHash, cacheKey) {
10
- return `${modelId}:${configHash}:${cacheKey}`;
11
- }
12
- export function markCacheInitialized(modelId, configHash, cacheKey) {
13
- initializedCaches.add(getCacheRegistryKey(modelId, configHash, cacheKey));
14
- }
15
- export function isCacheInitialized(modelId, configHash, cacheKey) {
16
- return initializedCaches.has(getCacheRegistryKey(modelId, configHash, cacheKey));
17
- }
18
- export function clearCacheRegistry(scope) {
19
- if (!scope || (scope.cacheKey === undefined && scope.modelId === undefined)) {
20
- initializedCaches.clear();
21
- return;
22
- }
23
- // key format: "modelId:configHash:cacheKey"
24
- for (const key of initializedCaches) {
25
- const firstSep = key.indexOf(":");
26
- const secondSep = key.indexOf(":", firstSep + 1);
27
- if (firstSep === -1 || secondSep === -1)
28
- continue;
29
- const modelId = key.slice(0, firstSep);
30
- const cacheKey = key.slice(secondSep + 1);
31
- if (scope.cacheKey !== undefined && cacheKey !== scope.cacheKey)
32
- continue;
33
- if (scope.modelId !== undefined && modelId !== scope.modelId)
34
- continue;
35
- initializedCaches.delete(key);
36
- }
37
- }
7
+ // In-memory KV-cache state lives in `KvCacheSession` (the single
8
+ // mutation point for all three KV-cache bookkeeping layers). This
9
+ // module keeps only the pure path / hash utilities that don't touch
10
+ // in-memory state.
38
11
  export function extractSystemPrompt(messages) {
39
12
  const systemMessage = messages.find((msg) => msg.role === "system");
40
13
  return systemMessage ? systemMessage.content : null;
@@ -107,22 +80,10 @@ export async function renameCacheFile(oldPath, newPath) {
107
80
  return false;
108
81
  }
109
82
  }
110
- export async function customCacheExists(modelId, configHash, cacheKey) {
111
- // Check in-memory registry first (addon defers disk writes)
112
- if (isCacheInitialized(modelId, configHash, cacheKey)) {
113
- return true;
114
- }
115
- // Then check file system (for caches from previous runs)
116
- const cachePath = await getCacheFilePath(modelId, configHash, cacheKey);
117
- try {
118
- await fsPromises.access(cachePath);
119
- markCacheInitialized(modelId, configHash, cacheKey);
120
- return true;
121
- }
122
- catch {
123
- return false;
124
- }
125
- }
83
+ // Cache-existence probing (in-memory registry first, fall back to
84
+ // `fs.access`) lives in `KvCacheSession.beginTurn(...)`. Keeping the
85
+ // in-memory `initializedCaches` set private to the session module
86
+ // avoids drift between the two layers.
126
87
  export async function deleteCache(options) {
127
88
  const cacheDir = getKVCacheDir();
128
89
  if ("all" in options) {
@@ -1,4 +1,4 @@
1
- import { type TranscribeParams, type TranscribeSegment, type TranscribeStats } from "../../../schemas/index";
1
+ import { type TranscribeParams, type TranscribeSegment, type TranscribeStats, type TranscribeStreamEvent, type ParakeetStreamingRunConfig } from "../../../schemas/index";
2
2
  import { assertMetadataSupported, toTranscribeSegment, type WhisperAddonSegment } from "../utils/transcribe-metadata";
3
3
  export { assertMetadataSupported, toTranscribeSegment, type WhisperAddonSegment, };
4
4
  type TranscribeReturn = {
@@ -7,8 +7,14 @@ type TranscribeReturn = {
7
7
  };
8
8
  export declare function transcribe(params: TranscribeParams & {
9
9
  metadata: true;
10
- }): AsyncGenerator<TranscribeSegment, TranscribeReturn, void>;
11
- export declare function transcribe(params: TranscribeParams): AsyncGenerator<string, TranscribeReturn, void>;
12
- export declare function transcribeStream(modelId: string, audioInputStream: AsyncIterable<Buffer>, prompt: string | undefined, metadata: true): AsyncGenerator<TranscribeSegment, void, void>;
13
- export declare function transcribeStream(modelId: string, audioInputStream: AsyncIterable<Buffer>, prompt?: string, metadata?: boolean): AsyncGenerator<string, void, void>;
10
+ }, requestId?: string): AsyncGenerator<TranscribeSegment, TranscribeReturn, void>;
11
+ export declare function transcribe(params: TranscribeParams, requestId?: string): AsyncGenerator<string, TranscribeReturn, void>;
12
+ export interface TranscribeStreamOpts {
13
+ emitVadEvents?: boolean;
14
+ endOfTurnSilenceMs?: number;
15
+ vadRunIntervalMs?: number;
16
+ parakeetStreamingConfig?: ParakeetStreamingRunConfig;
17
+ }
18
+ export declare function transcribeStream(modelId: string, audioInputStream: AsyncIterable<Buffer>, prompt: string | undefined, metadata: true, opts?: TranscribeStreamOpts, requestId?: string): AsyncGenerator<TranscribeSegment | TranscribeStreamEvent, void, void>;
19
+ export declare function transcribeStream(modelId: string, audioInputStream: AsyncIterable<Buffer>, prompt?: string, metadata?: boolean, opts?: TranscribeStreamOpts, requestId?: string): AsyncGenerator<string | TranscribeStreamEvent, void, void>;
14
20
  //# sourceMappingURL=transcribe.d.ts.map