@qvac/sdk 0.9.1 → 0.10.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 (335) hide show
  1. package/NOTICE +15 -68
  2. package/dist/client/api/cancel.d.ts +1 -1
  3. package/dist/client/api/cancel.js +1 -1
  4. package/dist/client/api/completion-stream.d.ts +51 -12
  5. package/dist/client/api/completion-stream.js +129 -56
  6. package/dist/client/api/delete-cache.d.ts +1 -0
  7. package/dist/client/api/delete-cache.js +1 -0
  8. package/dist/client/api/diffusion.d.ts +17 -2
  9. package/dist/client/api/diffusion.js +21 -4
  10. package/dist/client/api/embed.d.ts +4 -0
  11. package/dist/client/api/finetune.d.ts +21 -0
  12. package/dist/client/api/get-loaded-model-info.d.ts +25 -0
  13. package/dist/client/api/get-loaded-model-info.js +36 -0
  14. package/dist/client/api/get-model-info.d.ts +9 -1
  15. package/dist/client/api/get-model-info.js +8 -0
  16. package/dist/client/api/heartbeat.d.ts +2 -2
  17. package/dist/client/api/heartbeat.js +2 -2
  18. package/dist/client/api/index.d.ts +3 -1
  19. package/dist/client/api/index.js +3 -1
  20. package/dist/client/api/invoke-plugin.d.ts +16 -0
  21. package/dist/client/api/invoke-plugin.js +16 -0
  22. package/dist/client/api/load-model.d.ts +36 -3
  23. package/dist/client/api/load-model.js +31 -10
  24. package/dist/client/api/provide.d.ts +11 -5
  25. package/dist/client/api/provide.js +11 -6
  26. package/dist/client/api/rag.d.ts +9 -0
  27. package/dist/client/api/rag.js +9 -0
  28. package/dist/client/api/registry.d.ts +26 -0
  29. package/dist/client/api/registry.js +26 -0
  30. package/dist/client/api/resume.d.ts +20 -4
  31. package/dist/client/api/resume.js +20 -4
  32. package/dist/client/api/state.d.ts +23 -0
  33. package/dist/client/api/state.js +29 -0
  34. package/dist/client/api/stop-provider.d.ts +11 -5
  35. package/dist/client/api/stop-provider.js +11 -5
  36. package/dist/client/api/suspend.d.ts +21 -3
  37. package/dist/client/api/suspend.js +21 -3
  38. package/dist/client/api/text-to-speech.d.ts +64 -6
  39. package/dist/client/api/text-to-speech.js +423 -47
  40. package/dist/client/api/transcribe.d.ts +29 -4
  41. package/dist/client/api/transcribe.js +86 -28
  42. package/dist/client/api/translate.d.ts +1 -0
  43. package/dist/client/api/translate.js +1 -0
  44. package/dist/client/rpc/bare-client.js +22 -1
  45. package/dist/client/rpc/expo-rpc-client.d.ts +1 -1
  46. package/dist/client/rpc/expo-rpc-client.js +96 -4
  47. package/dist/client/rpc/node-rpc-client.js +36 -0
  48. package/dist/examples/audio/mic-input.d.ts +9 -0
  49. package/dist/examples/audio/mic-input.js +111 -0
  50. package/dist/examples/completion-events.d.ts +18 -0
  51. package/dist/examples/completion-events.js +79 -0
  52. package/dist/examples/delegated-inference/composite.js +12 -18
  53. package/dist/examples/delegated-inference/consumer-profiled.js +4 -11
  54. package/dist/examples/delegated-inference/consumer.js +8 -13
  55. package/dist/examples/delegated-inference/provider.js +11 -16
  56. package/dist/examples/diffusion-flux2-klein-img2img.d.ts +2 -0
  57. package/dist/examples/diffusion-flux2-klein-img2img.js +60 -0
  58. package/dist/examples/diffusion-flux2-klein.js +1 -0
  59. package/dist/examples/diffusion-img2img.d.ts +2 -0
  60. package/dist/examples/diffusion-img2img.js +49 -0
  61. package/dist/examples/diffusion-txt2img.js +2 -1
  62. package/dist/examples/kv-cache-example.js +11 -12
  63. package/dist/examples/llamacpp-cache.d.ts +2 -0
  64. package/dist/examples/llamacpp-cache.js +107 -0
  65. package/dist/examples/llamacpp-dynamic-tools.d.ts +2 -0
  66. package/dist/examples/llamacpp-dynamic-tools.js +144 -0
  67. package/dist/examples/llamacpp-native-tools.js +2 -8
  68. package/dist/examples/llamacpp-structured-output.d.ts +2 -0
  69. package/dist/examples/llamacpp-structured-output.js +106 -0
  70. package/dist/examples/llamacpp-tools-pythonic.d.ts +2 -0
  71. package/dist/examples/llamacpp-tools-pythonic.js +69 -0
  72. package/dist/examples/plugins.js +4 -4
  73. package/dist/examples/suspend-resume.js +21 -4
  74. package/dist/examples/transcription/parakeet-microphone-record.js +6 -33
  75. package/dist/examples/transcription/whispercpp-filesystem-streaming.js +7 -5
  76. package/dist/examples/transcription/whispercpp-filesystem.js +12 -3
  77. package/dist/examples/transcription/whispercpp-microphone-record.js +6 -29
  78. package/dist/examples/translation/translation-stream.js +5 -5
  79. package/dist/examples/tts/llm-to-tts-streaming.d.ts +16 -0
  80. package/dist/examples/tts/llm-to-tts-streaming.js +143 -0
  81. package/dist/examples/tts/supertonic-multilingual.js +3 -3
  82. package/dist/examples/tts/supertonic.js +3 -3
  83. package/dist/examples/tts/utils.d.ts +11 -1
  84. package/dist/examples/tts/utils.js +70 -17
  85. package/dist/examples/voice-assistant/voice-assistant.d.ts +2 -0
  86. package/dist/examples/voice-assistant/voice-assistant.js +207 -0
  87. package/dist/expo/plugins/withMobileBundle.js +1 -1
  88. package/dist/index.d.ts +2 -2
  89. package/dist/index.js +2 -2
  90. package/dist/logging/logger.d.ts +11 -0
  91. package/dist/logging/logger.js +11 -0
  92. package/dist/logging/types.d.ts +18 -0
  93. package/dist/models/registry/models.d.ts +6620 -6185
  94. package/dist/models/registry/models.js +6296 -5318
  95. package/dist/models/update-models/codegen.js +84 -23
  96. package/dist/models/update-models/companions.d.ts +18 -0
  97. package/dist/models/update-models/companions.js +175 -0
  98. package/dist/models/update-models/naming.js +0 -25
  99. package/dist/models/update-models/registry.js +4 -2
  100. package/dist/models/update-models/types.d.ts +37 -9
  101. package/dist/profiling/index.d.ts +49 -0
  102. package/dist/profiling/index.js +49 -0
  103. package/dist/schemas/cancel.d.ts +6 -2
  104. package/dist/schemas/cancel.js +14 -7
  105. package/dist/schemas/common.d.ts +361 -279
  106. package/dist/schemas/common.js +26 -5
  107. package/dist/schemas/completion-event.d.ts +225 -0
  108. package/dist/schemas/completion-event.js +79 -0
  109. package/dist/schemas/completion-stream.d.ts +122 -31
  110. package/dist/schemas/completion-stream.js +137 -36
  111. package/dist/schemas/delegate.d.ts +0 -2
  112. package/dist/schemas/delegate.js +25 -6
  113. package/dist/schemas/download-asset.d.ts +5 -5
  114. package/dist/schemas/embed.js +21 -9
  115. package/dist/schemas/engine-addon-map.d.ts +11 -1
  116. package/dist/schemas/engine-addon-map.js +2 -2
  117. package/dist/schemas/finetune.d.ts +16 -16
  118. package/dist/schemas/finetune.js +8 -8
  119. package/dist/schemas/get-loaded-model-info.d.ts +52 -0
  120. package/dist/schemas/get-loaded-model-info.js +44 -0
  121. package/dist/schemas/get-model-info.d.ts +2 -2
  122. package/dist/schemas/get-model-info.js +103 -32
  123. package/dist/schemas/heartbeat.d.ts +0 -1
  124. package/dist/schemas/index.d.ts +4 -1
  125. package/dist/schemas/index.js +4 -1
  126. package/dist/schemas/llamacpp-config.d.ts +14 -4
  127. package/dist/schemas/llamacpp-config.js +5 -0
  128. package/dist/schemas/load-model.d.ts +3233 -1260
  129. package/dist/schemas/load-model.js +23 -16
  130. package/dist/schemas/model-src-utils.d.ts +7 -6
  131. package/dist/schemas/model-src-utils.js +27 -1
  132. package/dist/schemas/model-types.d.ts +4 -4
  133. package/dist/schemas/ocr.d.ts +1 -1
  134. package/dist/schemas/plugin.d.ts +27 -3
  135. package/dist/schemas/plugin.js +27 -2
  136. package/dist/schemas/profiling.js +11 -3
  137. package/dist/schemas/provide.d.ts +1 -3
  138. package/dist/schemas/provide.js +0 -3
  139. package/dist/schemas/rag.d.ts +4 -4
  140. package/dist/schemas/registry.d.ts +10 -10
  141. package/dist/schemas/registry.js +36 -14
  142. package/dist/schemas/reload-config.d.ts +73 -7
  143. package/dist/schemas/sdcpp-config.d.ts +16 -8
  144. package/dist/schemas/sdcpp-config.js +118 -25
  145. package/dist/schemas/sdk-config.d.ts +116 -90
  146. package/dist/schemas/sdk-config.js +16 -0
  147. package/dist/schemas/sdk-errors-client.d.ts +3 -0
  148. package/dist/schemas/sdk-errors-client.js +16 -1
  149. package/dist/schemas/sdk-errors-server.d.ts +3 -0
  150. package/dist/schemas/sdk-errors-server.js +23 -0
  151. package/dist/schemas/state.d.ts +23 -0
  152. package/dist/schemas/state.js +14 -0
  153. package/dist/schemas/stop-provide.d.ts +0 -5
  154. package/dist/schemas/stop-provide.js +2 -6
  155. package/dist/schemas/text-to-speech.d.ts +93 -27
  156. package/dist/schemas/text-to-speech.js +27 -0
  157. package/dist/schemas/tools.d.ts +16 -0
  158. package/dist/schemas/tools.js +15 -0
  159. package/dist/schemas/transcription-config.d.ts +8 -8
  160. package/dist/schemas/transcription.d.ts +33 -0
  161. package/dist/schemas/transcription.js +9 -0
  162. package/dist/schemas/translate.js +59 -19
  163. package/dist/schemas/translation-config.d.ts +157 -133
  164. package/dist/schemas/translation-config.js +34 -11
  165. package/dist/server/bare/delegate-rpc-client.d.ts +1 -1
  166. package/dist/server/bare/delegate-rpc-client.js +131 -122
  167. package/dist/server/bare/hyperswarm.d.ts +2 -2
  168. package/dist/server/bare/hyperswarm.js +12 -7
  169. package/dist/server/bare/ops/cancel.js +7 -0
  170. package/dist/server/bare/ops/kv-cache-utils.d.ts +7 -10
  171. package/dist/server/bare/ops/kv-cache-utils.js +31 -40
  172. package/dist/server/bare/ops/load-model.js +0 -1
  173. package/dist/server/bare/ops/transcribe.d.ts +11 -4
  174. package/dist/server/bare/ops/transcribe.js +25 -4
  175. package/dist/server/bare/ops/translate.js +42 -4
  176. package/dist/server/bare/ops/unload-model.js +21 -19
  177. package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +1 -2
  178. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +13 -8
  179. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +257 -85
  180. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +101 -0
  181. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +135 -0
  182. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +83 -26
  183. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +57 -32
  184. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -16
  185. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +69 -44
  186. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +113 -94
  187. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +1 -1
  188. package/dist/server/bare/plugins/onnx-ocr/plugin.js +1 -2
  189. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.d.ts +7 -0
  190. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.js +116 -0
  191. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +2 -3
  192. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +71 -9
  193. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +41 -13
  194. package/dist/server/bare/plugins/onnx-tts/plugin.js +48 -3
  195. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +15 -7
  196. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +5 -6
  197. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +6 -0
  198. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +8 -5
  199. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +13 -13
  200. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +17 -1
  201. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +40 -17
  202. package/dist/server/bare/registry/config-registry.js +14 -3
  203. package/dist/server/bare/registry/model-registry.d.ts +8 -10
  204. package/dist/server/bare/registry/model-registry.js +17 -12
  205. package/dist/server/bare/registry/registry-client.js +79 -19
  206. package/dist/server/bare/runtime-lifecycle.d.ts +2 -1
  207. package/dist/server/bare/runtime-lifecycle.js +13 -2
  208. package/dist/server/bare/types/addon-responses.d.ts +8 -3
  209. package/dist/server/bare/utils/transcribe-metadata.d.ts +21 -0
  210. package/dist/server/bare/utils/transcribe-metadata.js +28 -0
  211. package/dist/server/bare/utils/tts-stats.d.ts +22 -0
  212. package/dist/server/bare/utils/tts-stats.js +10 -0
  213. package/dist/server/rpc/create-server.d.ts +4 -1
  214. package/dist/server/rpc/create-server.js +5 -1
  215. package/dist/server/rpc/delegate-transport.js +36 -29
  216. package/dist/server/rpc/handle-request.js +28 -3
  217. package/dist/server/rpc/handler-registry.js +7 -1
  218. package/dist/server/rpc/handler-utils.d.ts +5 -0
  219. package/dist/server/rpc/handler-utils.js +22 -0
  220. package/dist/server/rpc/handlers/cancel-delegated.js +3 -5
  221. package/dist/server/rpc/handlers/cancelHandler.js +4 -5
  222. package/dist/server/rpc/handlers/completion-stream-delegated.js +14 -5
  223. package/dist/server/rpc/handlers/delete-cache.js +8 -3
  224. package/dist/server/rpc/handlers/download-asset.js +3 -24
  225. package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +3 -0
  226. package/dist/server/rpc/handlers/get-loaded-model-info.js +39 -0
  227. package/dist/server/rpc/handlers/get-model-info.js +93 -84
  228. package/dist/server/rpc/handlers/heartbeat-delegated.js +2 -2
  229. package/dist/server/rpc/handlers/index.d.ts +6 -0
  230. package/dist/server/rpc/handlers/index.js +6 -0
  231. package/dist/server/rpc/handlers/load-model/download-manager.d.ts +35 -9
  232. package/dist/server/rpc/handlers/load-model/download-manager.js +142 -38
  233. package/dist/server/rpc/handlers/load-model/download-stats.d.ts +5 -4
  234. package/dist/server/rpc/handlers/load-model/download-stats.js +49 -8
  235. package/dist/server/rpc/handlers/load-model/handler.js +31 -50
  236. package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
  237. package/dist/server/rpc/handlers/load-model/http.js +97 -142
  238. package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
  239. package/dist/server/rpc/handlers/load-model/hyperdrive.js +55 -74
  240. package/dist/server/rpc/handlers/load-model/index.d.ts +0 -1
  241. package/dist/server/rpc/handlers/load-model/index.js +0 -1
  242. package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +27 -0
  243. package/dist/server/rpc/handlers/load-model/registry-client-options.js +19 -0
  244. package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +22 -0
  245. package/dist/server/rpc/handlers/load-model/registry-companion-set.js +208 -0
  246. package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +24 -0
  247. package/dist/server/rpc/handlers/load-model/registry-download-utils.js +114 -0
  248. package/dist/server/rpc/handlers/load-model/registry.d.ts +2 -20
  249. package/dist/server/rpc/handlers/load-model/registry.js +109 -381
  250. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +15 -0
  251. package/dist/server/rpc/handlers/load-model/resolve-session.js +61 -0
  252. package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -3
  253. package/dist/server/rpc/handlers/load-model/resolve.js +14 -23
  254. package/dist/server/rpc/handlers/load-model/types.d.ts +11 -4
  255. package/dist/server/rpc/handlers/load-model/types.js +28 -1
  256. package/dist/server/rpc/handlers/load-model-delegated.js +2 -4
  257. package/dist/server/rpc/handlers/plugin-dispatch.js +9 -5
  258. package/dist/server/rpc/handlers/plugin-invoke.js +1 -1
  259. package/dist/server/rpc/handlers/provideHandler/connection.js +13 -2
  260. package/dist/server/rpc/handlers/provideHandler/handler.js +42 -29
  261. package/dist/server/rpc/handlers/state.d.ts +3 -0
  262. package/dist/server/rpc/handlers/state.js +7 -0
  263. package/dist/server/rpc/handlers/stopProvideHandler.d.ts +2 -2
  264. package/dist/server/rpc/handlers/stopProvideHandler.js +12 -7
  265. package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +3 -0
  266. package/dist/server/rpc/handlers/text-to-speech-stream.js +4 -0
  267. package/dist/server/rpc/handlers/unload-model-delegated.js +3 -3
  268. package/dist/server/rpc/profiling/operation-metrics.js +20 -0
  269. package/dist/server/rpc/rpc-utils.js +1 -1
  270. package/dist/server/rpc/transport-selector.d.ts +3 -0
  271. package/dist/server/rpc/transport-selector.js +18 -0
  272. package/dist/server/utils/cache/auto-history.d.ts +4 -0
  273. package/dist/server/utils/cache/auto-history.js +22 -0
  274. package/dist/server/utils/{cache.d.ts → cache/paths.d.ts} +22 -5
  275. package/dist/server/utils/{cache.js → cache/paths.js} +36 -20
  276. package/dist/server/utils/cache/types.d.ts +8 -0
  277. package/dist/server/utils/cache/types.js +1 -0
  278. package/dist/server/utils/checksum.d.ts +2 -2
  279. package/dist/server/utils/checksum.js +1 -1
  280. package/dist/server/utils/clear-storage.d.ts +5 -0
  281. package/dist/server/utils/clear-storage.js +17 -0
  282. package/dist/server/utils/completion-normalizer.d.ts +17 -0
  283. package/dist/server/utils/completion-normalizer.js +301 -0
  284. package/dist/server/utils/expand-gguf-shards.d.ts +3 -0
  285. package/dist/server/utils/expand-gguf-shards.js +22 -0
  286. package/dist/server/utils/formatting.js +1 -1
  287. package/dist/server/utils/index.d.ts +4 -2
  288. package/dist/server/utils/index.js +4 -2
  289. package/dist/server/utils/qvac-paths.d.ts +2 -0
  290. package/dist/server/utils/qvac-paths.js +5 -0
  291. package/dist/server/utils/response-format.d.ts +3 -0
  292. package/dist/server/utils/response-format.js +20 -0
  293. package/dist/server/utils/tool-integration.d.ts +15 -4
  294. package/dist/server/utils/tool-integration.js +21 -41
  295. package/dist/server/utils/tools/dialect.d.ts +8 -0
  296. package/dist/server/utils/tools/dialect.js +12 -0
  297. package/dist/server/utils/tools/index.d.ts +3 -0
  298. package/dist/server/utils/tools/index.js +2 -0
  299. package/dist/server/utils/tools/parser.d.ts +6 -0
  300. package/dist/server/utils/tools/parser.js +40 -0
  301. package/dist/server/utils/tools/parsers/hermes.d.ts +4 -0
  302. package/dist/server/utils/tools/parsers/hermes.js +100 -0
  303. package/dist/server/utils/tools/parsers/json.d.ts +6 -0
  304. package/dist/server/utils/tools/parsers/json.js +115 -0
  305. package/dist/server/utils/tools/parsers/pythonic.d.ts +4 -0
  306. package/dist/server/utils/tools/parsers/pythonic.js +267 -0
  307. package/dist/server/utils/tools/shared.d.ts +18 -0
  308. package/dist/server/utils/tools/shared.js +54 -0
  309. package/dist/server/utils/worker-lock.d.ts +3 -0
  310. package/dist/server/utils/worker-lock.js +67 -0
  311. package/dist/server/worker-core.d.ts +16 -1
  312. package/dist/server/worker-core.js +114 -14
  313. package/dist/utils/aggregate-events.d.ts +16 -0
  314. package/dist/utils/aggregate-events.js +52 -0
  315. package/dist/utils/cache-normalize.d.ts +10 -0
  316. package/dist/utils/cache-normalize.js +23 -0
  317. package/dist/utils/encoding.d.ts +8 -0
  318. package/dist/utils/encoding.js +13 -0
  319. package/dist/utils/errors-client.d.ts +12 -0
  320. package/dist/utils/errors-client.js +20 -0
  321. package/dist/utils/errors-server.d.ts +14 -0
  322. package/dist/utils/errors-server.js +31 -0
  323. package/dist/utils/load-model-validation.d.ts +7 -0
  324. package/dist/utils/load-model-validation.js +18 -0
  325. package/expo/plugins/patches/android-link.mjs +1 -1
  326. package/expo/plugins/patches/ios-link.mjs +1 -1
  327. package/package.json +15 -19
  328. package/dist/examples/translation/translation-opus.d.ts +0 -2
  329. package/dist/examples/translation/translation-opus.js +0 -33
  330. package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
  331. package/dist/server/bare/utils/loader-adapter.js +0 -9
  332. package/dist/server/utils/model-path.d.ts +0 -5
  333. package/dist/server/utils/model-path.js +0 -7
  334. package/dist/server/utils/tool-parser.d.ts +0 -7
  335. package/dist/server/utils/tool-parser.js +0 -248
@@ -62,6 +62,7 @@ export declare const diffusionPlugin: {
62
62
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
63
63
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
64
64
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
65
+ embeddings: "embeddings";
65
66
  "llamacpp-completion": "llamacpp-completion";
66
67
  "whispercpp-transcription": "whispercpp-transcription";
67
68
  "llamacpp-embedding": "llamacpp-embedding";
@@ -72,7 +73,6 @@ export declare const diffusionPlugin: {
72
73
  "sdcpp-generation": "sdcpp-generation";
73
74
  llm: "llm";
74
75
  whisper: "whisper";
75
- embeddings: "embeddings";
76
76
  nmt: "nmt";
77
77
  parakeet: "parakeet";
78
78
  tts: "tts";
@@ -92,6 +92,7 @@ export declare const diffusionPlugin: {
92
92
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
93
93
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
94
94
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
95
+ embeddings: "embeddings";
95
96
  "llamacpp-completion": "llamacpp-completion";
96
97
  "whispercpp-transcription": "whispercpp-transcription";
97
98
  "llamacpp-embedding": "llamacpp-embedding";
@@ -102,7 +103,6 @@ export declare const diffusionPlugin: {
102
103
  "sdcpp-generation": "sdcpp-generation";
103
104
  llm: "llm";
104
105
  whisper: "whisper";
105
- embeddings: "embeddings";
106
106
  nmt: "nmt";
107
107
  parakeet: "parakeet";
108
108
  tts: "tts";
@@ -122,6 +122,7 @@ export declare const diffusionPlugin: {
122
122
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
123
123
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
124
124
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
125
+ embeddings: "embeddings";
125
126
  "llamacpp-completion": "llamacpp-completion";
126
127
  "whispercpp-transcription": "whispercpp-transcription";
127
128
  "llamacpp-embedding": "llamacpp-embedding";
@@ -132,7 +133,6 @@ export declare const diffusionPlugin: {
132
133
  "sdcpp-generation": "sdcpp-generation";
133
134
  llm: "llm";
134
135
  whisper: "whisper";
135
- embeddings: "embeddings";
136
136
  nmt: "nmt";
137
137
  parakeet: "parakeet";
138
138
  tts: "tts";
@@ -152,6 +152,7 @@ export declare const diffusionPlugin: {
152
152
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
153
153
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
154
154
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
155
+ embeddings: "embeddings";
155
156
  "llamacpp-completion": "llamacpp-completion";
156
157
  "whispercpp-transcription": "whispercpp-transcription";
157
158
  "llamacpp-embedding": "llamacpp-embedding";
@@ -162,7 +163,6 @@ export declare const diffusionPlugin: {
162
163
  "sdcpp-generation": "sdcpp-generation";
163
164
  llm: "llm";
164
165
  whisper: "whisper";
165
- embeddings: "embeddings";
166
166
  nmt: "nmt";
167
167
  parakeet: "parakeet";
168
168
  tts: "tts";
@@ -182,6 +182,7 @@ export declare const diffusionPlugin: {
182
182
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
183
183
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
184
184
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
185
+ embeddings: "embeddings";
185
186
  "llamacpp-completion": "llamacpp-completion";
186
187
  "whispercpp-transcription": "whispercpp-transcription";
187
188
  "llamacpp-embedding": "llamacpp-embedding";
@@ -192,7 +193,6 @@ export declare const diffusionPlugin: {
192
193
  "sdcpp-generation": "sdcpp-generation";
193
194
  llm: "llm";
194
195
  whisper: "whisper";
195
- embeddings: "embeddings";
196
196
  nmt: "nmt";
197
197
  parakeet: "parakeet";
198
198
  tts: "tts";
@@ -212,6 +212,7 @@ export declare const diffusionPlugin: {
212
212
  height: import("zod").ZodOptional<import("zod").ZodNumber>;
213
213
  steps: import("zod").ZodOptional<import("zod").ZodNumber>;
214
214
  cfg_scale: import("zod").ZodOptional<import("zod").ZodNumber>;
215
+ img_cfg_scale: import("zod").ZodDefault<import("zod").ZodNumber>;
215
216
  guidance: import("zod").ZodOptional<import("zod").ZodNumber>;
216
217
  sampling_method: import("zod").ZodOptional<import("zod").ZodEnum<{
217
218
  euler: "euler";
@@ -246,6 +247,8 @@ export declare const diffusionPlugin: {
246
247
  batch_count: import("zod").ZodOptional<import("zod").ZodNumber>;
247
248
  vae_tiling: import("zod").ZodOptional<import("zod").ZodBoolean>;
248
249
  cache_preset: import("zod").ZodOptional<import("zod").ZodString>;
250
+ init_image: import("zod").ZodOptional<import("zod").ZodString>;
251
+ strength: import("zod").ZodOptional<import("zod").ZodNumber>;
249
252
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
250
253
  type: import("zod").ZodLiteral<"diffusionStream">;
251
254
  step: import("zod").ZodOptional<import("zod").ZodNumber>;
@@ -2,7 +2,6 @@ import ImgStableDiffusion, {} from "@qvac/diffusion-cpp";
2
2
  import addonLogging from "@qvac/diffusion-cpp/addonLogging.js";
3
3
  import { definePlugin, defineHandler, sdcppConfigSchema, diffusionRequestSchema, diffusionStreamResponseSchema, ModelType, ADDON_DIFFUSION, } from "../../../../schemas/index.js";
4
4
  import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
5
- import { parseModelPath } from "../../../utils/index.js";
6
5
  import { diffusion } from "./ops/diffusion.js";
7
6
  export const diffusionPlugin = definePlugin({
8
7
  modelType: ModelType.sdcppGeneration,
@@ -38,22 +37,23 @@ export const diffusionPlugin = definePlugin({
38
37
  createModel(params) {
39
38
  const { modelId, modelPath, modelConfig, artifacts } = params;
40
39
  const config = (modelConfig ?? {});
41
- const { dirPath, basePath } = parseModelPath(modelPath);
42
40
  const logger = createStreamLogger(modelId, ModelType.sdcppGeneration);
43
41
  registerAddonLogger(modelId, ModelType.sdcppGeneration, logger);
44
- const addonArgs = {
45
- diskPath: dirPath,
46
- modelName: basePath,
42
+ const files = {
43
+ model: modelPath,
44
+ ...(artifacts?.["clipLModelPath"] && { clipL: artifacts["clipLModelPath"] }),
45
+ ...(artifacts?.["clipGModelPath"] && { clipG: artifacts["clipGModelPath"] }),
46
+ ...(artifacts?.["t5XxlModelPath"] && { t5Xxl: artifacts["t5XxlModelPath"] }),
47
+ ...(artifacts?.["llmModelPath"] && { llm: artifacts["llmModelPath"] }),
48
+ ...(artifacts?.["vaeModelPath"] && { vae: artifacts["vaeModelPath"] }),
49
+ };
50
+ const model = new ImgStableDiffusion({
51
+ files,
52
+ config: config,
47
53
  logger,
48
54
  opts: { stats: true },
49
- ...(artifacts?.["clipLModelPath"] && { clipLModel: artifacts["clipLModelPath"] }),
50
- ...(artifacts?.["clipGModelPath"] && { clipGModel: artifacts["clipGModelPath"] }),
51
- ...(artifacts?.["t5XxlModelPath"] && { t5XxlModel: artifacts["t5XxlModelPath"] }),
52
- ...(artifacts?.["llmModelPath"] && { llmModel: artifacts["llmModelPath"] }),
53
- ...(artifacts?.["vaeModelPath"] && { vaeModel: artifacts["vaeModelPath"] }),
54
- };
55
- const model = new ImgStableDiffusion(addonArgs, config);
56
- return { model, loader: undefined };
55
+ });
56
+ return { model };
57
57
  },
58
58
  handlers: {
59
59
  diffusionStream: defineHandler({
@@ -75,6 +75,7 @@ export declare const whisperPlugin: {
75
75
  expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
76
76
  sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
77
77
  addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
78
+ embeddings: "embeddings";
78
79
  "llamacpp-completion": "llamacpp-completion";
79
80
  "whispercpp-transcription": "whispercpp-transcription";
80
81
  "llamacpp-embedding": "llamacpp-embedding";
@@ -85,7 +86,6 @@ export declare const whisperPlugin: {
85
86
  "sdcpp-generation": "sdcpp-generation";
86
87
  llm: "llm";
87
88
  whisper: "whisper";
88
- embeddings: "embeddings";
89
89
  nmt: "nmt";
90
90
  parakeet: "parakeet";
91
91
  tts: "tts";
@@ -216,6 +216,7 @@ export declare const whisperPlugin: {
216
216
  transcribe: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
217
217
  modelId: import("zod").ZodString;
218
218
  prompt: import("zod").ZodOptional<import("zod").ZodString>;
219
+ metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
219
220
  audioChunk: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
220
221
  type: import("zod").ZodLiteral<"base64">;
221
222
  value: import("zod").ZodString;
@@ -240,11 +241,19 @@ export declare const whisperPlugin: {
240
241
  melSpecTime: import("zod").ZodOptional<import("zod").ZodNumber>;
241
242
  }, import("zod/v4/core").$strip>>;
242
243
  error: import("zod").ZodOptional<import("zod").ZodString>;
244
+ segment: import("zod").ZodOptional<import("zod").ZodObject<{
245
+ text: import("zod").ZodString;
246
+ startMs: import("zod").ZodNumber;
247
+ endMs: import("zod").ZodNumber;
248
+ append: import("zod").ZodBoolean;
249
+ id: import("zod").ZodNumber;
250
+ }, import("zod/v4/core").$strip>>;
243
251
  type: import("zod").ZodLiteral<"transcribe">;
244
252
  }, import("zod/v4/core").$strip>>;
245
253
  transcribeStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
246
254
  modelId: import("zod").ZodString;
247
255
  prompt: import("zod").ZodOptional<import("zod").ZodString>;
256
+ metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
248
257
  type: import("zod").ZodLiteral<"transcribeStream">;
249
258
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
250
259
  text: import("zod").ZodOptional<import("zod").ZodString>;
@@ -262,6 +271,13 @@ export declare const whisperPlugin: {
262
271
  melSpecTime: import("zod").ZodOptional<import("zod").ZodNumber>;
263
272
  }, import("zod/v4/core").$strip>>;
264
273
  error: import("zod").ZodOptional<import("zod").ZodString>;
274
+ segment: import("zod").ZodOptional<import("zod").ZodObject<{
275
+ text: import("zod").ZodString;
276
+ startMs: import("zod").ZodNumber;
277
+ endMs: import("zod").ZodNumber;
278
+ append: import("zod").ZodBoolean;
279
+ id: import("zod").ZodNumber;
280
+ }, import("zod/v4/core").$strip>>;
265
281
  type: import("zod").ZodLiteral<"transcribeStream">;
266
282
  }, import("zod/v4/core").$strip>>;
267
283
  };
@@ -24,7 +24,7 @@ function createWhisperModel(modelId, modelPath, whisperConfig, vadModelPath) {
24
24
  ...(miscConfig && { miscConfig }),
25
25
  };
26
26
  const model = new TranscriptionWhispercpp(args, config);
27
- return { model, loader: null };
27
+ return { model };
28
28
  }
29
29
  export const whisperPlugin = definePlugin({
30
30
  modelType: ModelType.whispercppTranscription,
@@ -44,8 +44,8 @@ export const whisperPlugin = definePlugin({
44
44
  },
45
45
  createModel(params) {
46
46
  const whisperConfig = (params.modelConfig ?? {});
47
- const { model, loader } = createWhisperModel(params.modelId, params.modelPath, whisperConfig, params.artifacts?.["vadModelPath"]);
48
- return { model, loader };
47
+ const { model } = createWhisperModel(params.modelId, params.modelPath, whisperConfig, params.artifacts?.["vadModelPath"]);
48
+ return { model };
49
49
  },
50
50
  handlers: {
51
51
  transcribe: defineHandler({
@@ -53,18 +53,31 @@ export const whisperPlugin = definePlugin({
53
53
  responseSchema: transcribeResponseSchema,
54
54
  streaming: true,
55
55
  handler: async function* (request) {
56
- const stream = transcribe({
57
- modelId: request.modelId,
58
- audioChunk: request.audioChunk,
59
- prompt: request.prompt,
60
- });
56
+ const metadata = request.metadata === true;
57
+ const stream = metadata
58
+ ? transcribe({
59
+ modelId: request.modelId,
60
+ audioChunk: request.audioChunk,
61
+ prompt: request.prompt,
62
+ metadata: true,
63
+ })
64
+ : transcribe({
65
+ modelId: request.modelId,
66
+ audioChunk: request.audioChunk,
67
+ prompt: request.prompt,
68
+ });
61
69
  try {
62
70
  let result = await stream.next();
63
71
  while (!result.done) {
64
- yield {
65
- type: "transcribe",
66
- text: result.value,
67
- };
72
+ yield metadata
73
+ ? {
74
+ type: "transcribe",
75
+ segment: result.value,
76
+ }
77
+ : {
78
+ type: "transcribe",
79
+ text: result.value,
80
+ };
68
81
  result = await stream.next();
69
82
  }
70
83
  const { modelExecutionMs, stats } = result.value;
@@ -86,11 +99,21 @@ export const whisperPlugin = definePlugin({
86
99
  streaming: true,
87
100
  duplex: true,
88
101
  handler: async function* (request, inputStream) {
89
- for await (const text of transcribeStream(request.modelId, inputStream, request.prompt)) {
90
- yield {
91
- type: "transcribeStream",
92
- text,
93
- };
102
+ if (request.metadata === true) {
103
+ for await (const segment of transcribeStream(request.modelId, inputStream, request.prompt, true)) {
104
+ yield {
105
+ type: "transcribeStream",
106
+ segment,
107
+ };
108
+ }
109
+ }
110
+ else {
111
+ for await (const text of transcribeStream(request.modelId, inputStream, request.prompt)) {
112
+ yield {
113
+ type: "transcribeStream",
114
+ text,
115
+ };
116
+ }
94
117
  }
95
118
  yield {
96
119
  type: "transcribeStream",
@@ -1,6 +1,6 @@
1
1
  import fs from "bare-fs";
2
2
  import path from "bare-path";
3
- import { getEnv } from "../../env.js";
3
+ import { getQvacPath } from "../../utils/qvac-paths.js";
4
4
  import { CacheDirNotAbsoluteError, CacheDirNotWritableError, ConfigAlreadySetError, } from "../../../utils/errors-server.js";
5
5
  import { getServerLogger, setGlobalConsoleOutput, setGlobalLogLevel, } from "../../../logging/index.js";
6
6
  const logger = getServerLogger();
@@ -10,6 +10,8 @@ const configRegistry = {
10
10
  loggerLevel: undefined,
11
11
  loggerConsoleOutput: undefined,
12
12
  httpDownloadConcurrency: undefined,
13
+ registryDownloadMaxRetries: undefined,
14
+ registryStreamTimeoutMs: undefined,
13
15
  deviceDefaults: undefined,
14
16
  };
15
17
  let configIsSet = false;
@@ -63,6 +65,16 @@ export function setSDKConfig(config) {
63
65
  configRegistry.httpDownloadConcurrency = config.httpDownloadConcurrency;
64
66
  logger.info(`HTTP download concurrency set to: ${config.httpDownloadConcurrency}`);
65
67
  }
68
+ if (config.registryDownloadMaxRetries !== undefined &&
69
+ config.registryDownloadMaxRetries !== null) {
70
+ configRegistry.registryDownloadMaxRetries = config.registryDownloadMaxRetries;
71
+ logger.info(`✅ Registry download max retries set to: ${config.registryDownloadMaxRetries}`);
72
+ }
73
+ if (config.registryStreamTimeoutMs !== undefined &&
74
+ config.registryStreamTimeoutMs !== null) {
75
+ configRegistry.registryStreamTimeoutMs = config.registryStreamTimeoutMs;
76
+ logger.info(`✅ Registry stream timeout set to: ${config.registryStreamTimeoutMs}ms`);
77
+ }
66
78
  if (config.deviceDefaults !== undefined && config.deviceDefaults !== null) {
67
79
  configRegistry.deviceDefaults = config.deviceDefaults;
68
80
  logger.info(`✅ Device defaults configured: ${config.deviceDefaults.length} pattern(s)`);
@@ -74,8 +86,7 @@ export function getSDKConfig() {
74
86
  return { ...configRegistry };
75
87
  }
76
88
  function getDefaultCacheDir() {
77
- const homeDir = getEnv().HOME_DIR;
78
- return path.join(homeDir, ".qvac", "models");
89
+ return getQvacPath("models");
79
90
  }
80
91
  export function getConfiguredCacheDir() {
81
92
  return configRegistry.cacheDirectory || getDefaultCacheDir();
@@ -1,4 +1,3 @@
1
- import type FilesystemDL from "@qvac/dl-filesystem";
2
1
  import type { CanonicalModelType } from "../../../schemas/index";
3
2
  import type BaseInference from "@qvac/infer-base";
4
3
  interface AddonInterface {
@@ -9,7 +8,6 @@ export type AnyModel = Omit<BaseInference, "addon"> & {
9
8
  addon?: AddonInterface;
10
9
  };
11
10
  interface DelegateOptions {
12
- topic: string;
13
11
  providerPublicKey: string;
14
12
  timeout?: number | undefined;
15
13
  healthCheckTimeout?: number | undefined;
@@ -21,23 +19,23 @@ interface LocalOptions {
21
19
  config: unknown;
22
20
  modelType: CanonicalModelType;
23
21
  name?: string | undefined;
24
- loader?: FilesystemDL;
25
22
  }
26
- export interface ModelEntry {
23
+ export type ModelEntry = {
27
24
  id: string;
28
- isDelegated: boolean;
29
- local?: LocalOptions;
30
- delegated?: DelegateOptions;
31
- }
25
+ isDelegated: true;
26
+ delegated: DelegateOptions;
27
+ } | {
28
+ id: string;
29
+ isDelegated: false;
30
+ local: LocalOptions;
31
+ };
32
32
  export declare function registerModel(id: string, options: {
33
33
  model: AnyModel;
34
34
  path: string;
35
35
  config: unknown;
36
36
  modelType: CanonicalModelType;
37
- loader?: FilesystemDL;
38
37
  name?: string | undefined;
39
38
  } | {
40
- topic: string;
41
39
  providerPublicKey: string;
42
40
  timeout?: number;
43
41
  healthCheckTimeout?: number;
@@ -7,20 +7,19 @@ export function registerModel(id, options) {
7
7
  if (modelRegistry.has(id)) {
8
8
  throw new ModelAlreadyRegisteredError(id);
9
9
  }
10
- const isDelegated = "topic" in options && "providerPublicKey" in options;
10
+ const isDelegated = "providerPublicKey" in options;
11
11
  if (isDelegated) {
12
- const { topic, providerPublicKey, timeout, healthCheckTimeout } = options;
12
+ const { providerPublicKey, timeout, healthCheckTimeout } = options;
13
13
  modelRegistry.set(id, {
14
14
  id,
15
15
  isDelegated: true,
16
16
  delegated: {
17
- topic,
18
17
  providerPublicKey,
19
18
  timeout,
20
19
  healthCheckTimeout,
21
20
  },
22
21
  });
23
- logger.info(`Delegated model registered: ${id} -> topic: ${topic}, provider: ${providerPublicKey}, timeout: ${timeout}ms`);
22
+ logger.info(`Delegated model registered: ${id} -> provider: ${providerPublicKey}, timeout: ${timeout}ms`);
24
23
  }
25
24
  else {
26
25
  modelRegistry.set(id, {
@@ -32,7 +31,6 @@ export function registerModel(id, options) {
32
31
  loadedAt: new Date(),
33
32
  config: options.config,
34
33
  modelType: options.modelType,
35
- ...(options.loader && { loader: options.loader }),
36
34
  name: options.name,
37
35
  },
38
36
  });
@@ -48,7 +46,7 @@ export function getModel(id) {
48
46
  if (!entry) {
49
47
  throw new ModelNotFoundError(id);
50
48
  }
51
- if (!entry.local) {
49
+ if (entry.isDelegated) {
52
50
  throw new ModelIsDelegatedError(id);
53
51
  }
54
52
  return entry.local.model;
@@ -70,7 +68,7 @@ export function getAllModelIds() {
70
68
  }
71
69
  export function getModelInfo(id) {
72
70
  const entry = modelRegistry.get(id);
73
- if (!entry || !entry.local) {
71
+ if (!entry || entry.isDelegated) {
74
72
  return null;
75
73
  }
76
74
  const result = {
@@ -86,7 +84,7 @@ export function getModelInfo(id) {
86
84
  }
87
85
  export function getModelConfig(id) {
88
86
  const entry = modelRegistry.get(id);
89
- if (!entry || !entry.local) {
87
+ if (!entry || entry.isDelegated) {
90
88
  throw new ModelNotFoundError(id);
91
89
  }
92
90
  return entry.local.config;
@@ -96,7 +94,7 @@ export function updateModelConfig(id, config) {
96
94
  if (!entry) {
97
95
  throw new ModelNotFoundError(id);
98
96
  }
99
- if (!entry.local) {
97
+ if (entry.isDelegated) {
100
98
  throw new ModelIsDelegatedError(id);
101
99
  }
102
100
  entry.local.config = config;
@@ -115,9 +113,16 @@ export async function unloadAllModels() {
115
113
  const modelIds = getAllModelIds();
116
114
  for (const modelId of modelIds) {
117
115
  const entry = modelRegistry.get(modelId);
118
- if (entry?.local?.model && entry.local.model.unload) {
119
- await entry.local.model.unload();
120
- logger.debug(`Model unloaded: ${modelId}`);
116
+ try {
117
+ if (entry && !entry.isDelegated) {
118
+ if (entry.local.model.unload) {
119
+ await entry.local.model.unload();
120
+ }
121
+ logger.debug(`Model unloaded: ${modelId}`);
122
+ }
123
+ }
124
+ catch (error) {
125
+ logger.error(`Error unloading model ${modelId}:`, error instanceof Error ? error.message : String(error));
121
126
  }
122
127
  modelRegistry.delete(modelId);
123
128
  }
@@ -1,35 +1,95 @@
1
1
  import { QVACRegistryClient } from "@qvac/registry-client";
2
- import { getCacheDir } from "../../utils/cache.js";
2
+ import { getCacheDir } from "../../utils/cache/paths.js";
3
3
  import { registerSwarm, unregisterSwarm, registerCorestore, unregisterCorestore, } from "../runtime-lifecycle.js";
4
4
  import { getServerLogger } from "../../../logging/index.js";
5
5
  import { DEFAULT_REGISTRY_CORE_KEY } from "../../../constants/index.js";
6
6
  const logger = getServerLogger();
7
+ // fd-lock retry budget for the registry corestore.
8
+ //
9
+ // We pass `corestoreOpts: { wait: false }` (tryLock semantics) and provide a
10
+ // JS-bounded retry budget here instead of letting Hypercore's underlying
11
+ // fd-lock issue a blocking flock(LOCK_EX) on a libuv worker thread. The
12
+ // blocking variant cannot be cancelled from JS, so if another SDK process
13
+ // holds the lock indefinitely it leaves a pending native handle that
14
+ // prevents process.exit() from terminating the worker — see QVAC-18197.
15
+ //
16
+ // With tryLock + bounded retries we get the same "tolerate transient locks
17
+ // during another SDK's startup/shutdown" property #1480 wanted, but every
18
+ // retry step is a fresh non-blocking syscall that surfaces failure to JS,
19
+ // so shutdown always remains cancellable.
20
+ const MAX_RETRIES = 8;
21
+ const BASE_DELAY_MS = 250;
22
+ const MAX_TOTAL_WAIT_MS = 10_000;
7
23
  let registryClient = null;
24
+ let inflightInit = null;
25
+ function isFdLockError(error) {
26
+ if (error instanceof Error) {
27
+ return error.message.includes("File descriptor could not be locked");
28
+ }
29
+ return false;
30
+ }
31
+ async function delay(ms) {
32
+ return new Promise((resolve) => setTimeout(resolve, ms));
33
+ }
34
+ async function initRegistryClient() {
35
+ let lastError;
36
+ const deadline = Date.now() + MAX_TOTAL_WAIT_MS;
37
+ for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
38
+ try {
39
+ const client = new QVACRegistryClient({
40
+ registryCoreKey: DEFAULT_REGISTRY_CORE_KEY,
41
+ storage: getCacheDir(`registry-corestore/${DEFAULT_REGISTRY_CORE_KEY}`),
42
+ corestoreOpts: { wait: false },
43
+ });
44
+ await client.ready();
45
+ registryClient = client;
46
+ if (registryClient.corestore) {
47
+ registerCorestore(registryClient.corestore, {
48
+ label: "registry-client",
49
+ createdAt: Date.now(),
50
+ });
51
+ }
52
+ if (registryClient.hyperswarm) {
53
+ registerSwarm(registryClient.hyperswarm, {
54
+ label: "registry-client",
55
+ createdAt: Date.now(),
56
+ });
57
+ }
58
+ logger.info("✅ Registry client ready");
59
+ return client;
60
+ }
61
+ catch (error) {
62
+ lastError = error;
63
+ if (isFdLockError(error) && attempt < MAX_RETRIES) {
64
+ const remaining = deadline - Date.now();
65
+ if (remaining <= 0) {
66
+ logger.warn(`Registry client fd-lock failed after ${MAX_TOTAL_WAIT_MS}ms wait budget exhausted (attempt ${attempt}/${MAX_RETRIES})`);
67
+ throw error;
68
+ }
69
+ const backoff = Math.min(BASE_DELAY_MS * Math.pow(2, attempt - 1), remaining);
70
+ logger.warn(`Registry client fd-lock failed (attempt ${attempt}/${MAX_RETRIES}), retrying in ${backoff}ms...`);
71
+ await delay(backoff);
72
+ continue;
73
+ }
74
+ throw error;
75
+ }
76
+ }
77
+ throw lastError;
78
+ }
8
79
  export async function getRegistryClient() {
9
80
  if (registryClient) {
10
81
  logger.debug("Registry client reused");
11
82
  return registryClient;
12
83
  }
84
+ if (inflightInit) {
85
+ logger.debug("Registry client init already in progress, waiting...");
86
+ return inflightInit;
87
+ }
13
88
  logger.info("🔗 Creating new registry client...");
14
- registryClient = new QVACRegistryClient({
15
- registryCoreKey: DEFAULT_REGISTRY_CORE_KEY,
16
- storage: getCacheDir(`registry-corestore/${DEFAULT_REGISTRY_CORE_KEY}`),
89
+ inflightInit = initRegistryClient().finally(() => {
90
+ inflightInit = null;
17
91
  });
18
- await registryClient.ready();
19
- if (registryClient.corestore) {
20
- registerCorestore(registryClient.corestore, {
21
- label: "registry-client",
22
- createdAt: Date.now(),
23
- });
24
- }
25
- if (registryClient.hyperswarm) {
26
- registerSwarm(registryClient.hyperswarm, {
27
- label: "registry-client",
28
- createdAt: Date.now(),
29
- });
30
- }
31
- logger.info("✅ Registry client ready");
32
- return registryClient;
92
+ return inflightInit;
33
93
  }
34
94
  export async function closeRegistryClient() {
35
95
  if (!registryClient)
@@ -1,3 +1,4 @@
1
+ import type { LifecycleState, Request } from "../../schemas/index";
1
2
  export interface SuspendableSwarm {
2
3
  readonly suspended: boolean;
3
4
  suspend(): Promise<void>;
@@ -7,7 +8,6 @@ export interface SuspendableStore {
7
8
  suspend(): Promise<void>;
8
9
  resume(): Promise<void>;
9
10
  }
10
- type LifecycleState = "active" | "suspending" | "suspended" | "resuming";
11
11
  interface ResourceMeta {
12
12
  label: string;
13
13
  createdAt: number;
@@ -17,6 +17,7 @@ export declare function unregisterSwarm(swarm: SuspendableSwarm): void;
17
17
  export declare function registerCorestore(store: SuspendableStore, meta: ResourceMeta): void;
18
18
  export declare function unregisterCorestore(store: SuspendableStore): void;
19
19
  export declare function getLifecycleState(): LifecycleState;
20
+ export declare function assertLifecycleAllowed(request: Request): void;
20
21
  export declare function getRegisteredResourceCounts(): {
21
22
  swarms: number;
22
23
  stores: number;
@@ -1,5 +1,11 @@
1
1
  import { getServerLogger } from "../../logging/index.js";
2
+ import { LifecycleOperationBlockedError } from "../../utils/errors-server.js";
2
3
  const logger = getServerLogger();
4
+ const LIFECYCLE_ALLOWED_TYPES = new Set([
5
+ "suspend",
6
+ "resume",
7
+ "state",
8
+ ]);
3
9
  const swarms = new Map();
4
10
  const stores = new Map();
5
11
  let state = "active";
@@ -29,6 +35,11 @@ export function unregisterCorestore(store) {
29
35
  export function getLifecycleState() {
30
36
  return state;
31
37
  }
38
+ export function assertLifecycleAllowed(request) {
39
+ if (state === "active" || LIFECYCLE_ALLOWED_TYPES.has(request.type))
40
+ return;
41
+ throw new LifecycleOperationBlockedError(request.type, state);
42
+ }
32
43
  export function getRegisteredResourceCounts() {
33
44
  return { swarms: swarms.size, stores: stores.size };
34
45
  }
@@ -121,8 +132,8 @@ export async function resumeRuntime() {
121
132
  logger.info("▶️ Runtime resumed");
122
133
  })
123
134
  .catch((error) => {
124
- state = "active";
125
- logger.error("▶️ Runtime resume partially failed, state committed for recovery");
135
+ state = "suspended";
136
+ logger.error("▶️ Runtime resume partially failed, staying suspended for retry");
126
137
  throw error;
127
138
  })
128
139
  .finally(() => {
@@ -53,10 +53,15 @@ export interface TranscribeStats {
53
53
  decoderMs?: number;
54
54
  melSpecMs?: number;
55
55
  }
56
+ export interface TranscribeAddonSegment {
57
+ text: string;
58
+ start?: number;
59
+ end?: number;
60
+ toAppend?: boolean;
61
+ id?: number;
62
+ }
56
63
  export interface TranscribeResponse {
57
64
  stats?: TranscribeStats;
58
- iterate(): AsyncIterable<Array<{
59
- text: string;
60
- }>>;
65
+ iterate(): AsyncIterable<Array<TranscribeAddonSegment>>;
61
66
  }
62
67
  //# sourceMappingURL=addon-responses.d.ts.map