@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
@@ -1,16 +1,31 @@
1
1
  import { diffusionStreamResponseSchema, } from "../../schemas/index.js";
2
2
  import { stream as streamRpc } from "../rpc/rpc-client.js";
3
- import { decodeBase64 } from "../../utils/encoding.js";
3
+ import { decodeBase64, encodeBase64 } from "../../utils/encoding.js";
4
4
  /**
5
- * Generate images using a loaded diffusion model.
5
+ * Generates images using a loaded diffusion model.
6
+ *
7
+ * @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
8
+ * @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
9
+ *
10
+ * Supports both txt2img (no `init_image`) and img2img (with `init_image`).
6
11
  *
7
12
  * @example
8
13
  * ```typescript
9
- * // Basic usage
14
+ * // txt2img
10
15
  * const { outputs, stats } = diffusion({ modelId, prompt: "a cat" });
11
16
  * const buffers = await outputs;
12
17
  * fs.writeFileSync("output.png", buffers[0]);
13
18
  *
19
+ * // img2img (SD/SDXL — SDEdit)
20
+ * const initImage = fs.readFileSync("input.png");
21
+ * const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
22
+ *
23
+ * // img2img (FLUX.2 — in-context conditioning)
24
+ * // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
25
+ * // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
26
+ * // modelConfig: { prediction: "flux2_flow" } })`).
27
+ * const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
28
+ *
14
29
  * // With progress tracking
15
30
  * const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" });
16
31
  * for await (const { step, totalSteps } of progressStream) {
@@ -20,9 +35,11 @@ import { decodeBase64 } from "../../utils/encoding.js";
20
35
  * ```
21
36
  */
22
37
  export function diffusion(params) {
38
+ const { init_image, ...rest } = params;
23
39
  const request = {
40
+ ...rest,
41
+ ...(init_image !== undefined && { init_image: encodeBase64(init_image) }),
24
42
  type: "diffusionStream",
25
- ...params,
26
43
  };
27
44
  let statsResolver = () => { };
28
45
  let statsRejecter = () => { };
@@ -2,10 +2,12 @@ import { type EmbedStats, type RPCOptions } from "../../schemas/index";
2
2
  /**
3
3
  * Generates embeddings for a single text using a specified model.
4
4
  *
5
+ * @overloadLabel "Single text"
5
6
  * @param params - The parameters for the embedding
6
7
  * @param params.modelId - The identifier of the embedding model to use
7
8
  * @param params.text - The input text to embed
8
9
  * @param options - Optional RPC options including per-call profiling
10
+ * @returns A promise resolving to an object with `embedding` (a single `number[]` vector) and optional `stats` performance data.
9
11
  * @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
10
12
  */
11
13
  export declare function embed(params: {
@@ -18,10 +20,12 @@ export declare function embed(params: {
18
20
  /**
19
21
  * Generates embeddings for multiple texts using a specified model.
20
22
  *
23
+ * @overloadLabel "Multiple texts"
21
24
  * @param params - The parameters for the embedding
22
25
  * @param params.modelId - The identifier of the embedding model to use
23
26
  * @param params.text - The input texts to embed
24
27
  * @param options - Optional RPC options including per-call profiling
28
+ * @returns A promise resolving to an object with `embedding` (one `number[]` vector per input text, i.e. `number[][]`) and optional `stats` performance data.
25
29
  * @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
26
30
  */
27
31
  export declare function embed(params: {
@@ -63,7 +63,28 @@ type FinetuneReplyParams = FinetuneStopParams | FinetuneGetStateParams;
63
63
  * console.log(pauseResult.status);
64
64
  * ```
65
65
  */
66
+ /**
67
+ * Run / start / resume a finetune job. Returns a handle with a streaming
68
+ * `progressStream` and a terminal `result` promise.
69
+ *
70
+ * @overloadLabel "Run / start / resume"
71
+ * @param params - The finetuning run parameters (see the function-level
72
+ * docs for the full breakdown of `params.options`).
73
+ * @param rpcOptions - Optional RPC transport options.
74
+ * @returns A `FinetuneHandle` with `progressStream` (yields per-step loss
75
+ * metrics) and `result` (resolves once the run terminates).
76
+ */
66
77
  export declare function finetune(params: FinetuneRunParams, rpcOptions?: RPCOptions): FinetuneHandle;
78
+ /**
79
+ * Stop / pause / cancel an in-flight finetune, or query its current state.
80
+ *
81
+ * @overloadLabel "Stop / getState / pause / cancel"
82
+ * @param params - Finetune control parameters; `params.operation` selects
83
+ * `pause`, `cancel`, or `getState`.
84
+ * @param rpcOptions - Optional RPC transport options.
85
+ * @returns A promise that resolves to the current `FinetuneResult`
86
+ * (status + last-known progress).
87
+ */
67
88
  export declare function finetune(params: FinetuneReplyParams, rpcOptions?: RPCOptions): Promise<FinetuneResult>;
68
89
  export {};
69
90
  //# sourceMappingURL=finetune.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { type GetLoadedModelInfoParams, type LoadedModelInfo } from "../../schemas/index";
2
+ import { type RPCOptions } from "../../schemas/common";
3
+ /**
4
+ * Returns introspection info for a loaded `modelId` (local or delegated).
5
+ *
6
+ * For local models, `info.modelType` and `info.handlers` are authoritative.
7
+ * Use them to preflight an SDK call before sending the actual RPC, e.g.
8
+ * confirm that a model supports `transcribeStream` before calling `transcribe()`.
9
+ *
10
+ * For delegated models, only `modelId`, `isDelegated: true`, `providerInfo`,
11
+ * and `handlers: []` are populated. Preflight against a delegated model is
12
+ * best-effort and falls through to the provider's error response.
13
+ *
14
+ * Throws `ModelNotFoundError` if no entry exists for `modelId`.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const info = await getLoadedModelInfo({ modelId });
19
+ * if (info.isDelegated || info.handlers.includes("completionStream")) {
20
+ * // safe to call completion(); delegated path defers to provider
21
+ * }
22
+ * ```
23
+ */
24
+ export declare function getLoadedModelInfo(params: GetLoadedModelInfoParams, rpcOptions?: RPCOptions): Promise<LoadedModelInfo>;
25
+ //# sourceMappingURL=get-loaded-model-info.d.ts.map
@@ -0,0 +1,36 @@
1
+ import {} from "../../schemas/index.js";
2
+ import {} from "../../schemas/common.js";
3
+ import { send } from "../rpc/rpc-client.js";
4
+ import { InvalidResponseError } from "../../utils/errors-client.js";
5
+ /**
6
+ * Returns introspection info for a loaded `modelId` (local or delegated).
7
+ *
8
+ * For local models, `info.modelType` and `info.handlers` are authoritative.
9
+ * Use them to preflight an SDK call before sending the actual RPC, e.g.
10
+ * confirm that a model supports `transcribeStream` before calling `transcribe()`.
11
+ *
12
+ * For delegated models, only `modelId`, `isDelegated: true`, `providerInfo`,
13
+ * and `handlers: []` are populated. Preflight against a delegated model is
14
+ * best-effort and falls through to the provider's error response.
15
+ *
16
+ * Throws `ModelNotFoundError` if no entry exists for `modelId`.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const info = await getLoadedModelInfo({ modelId });
21
+ * if (info.isDelegated || info.handlers.includes("completionStream")) {
22
+ * // safe to call completion(); delegated path defers to provider
23
+ * }
24
+ * ```
25
+ */
26
+ export async function getLoadedModelInfo(params, rpcOptions) {
27
+ const request = {
28
+ type: "getLoadedModelInfo",
29
+ modelId: params.modelId,
30
+ };
31
+ const response = await send(request, rpcOptions);
32
+ if (response.type !== "getLoadedModelInfo") {
33
+ throw new InvalidResponseError("getLoadedModelInfo");
34
+ }
35
+ return response.info;
36
+ }
@@ -1,10 +1,18 @@
1
1
  import { type GetModelInfoParams } from "../../schemas/index";
2
+ /**
3
+ * Returns status information for a catalog model, including cache state and loaded instances.
4
+ *
5
+ * @param params - Query parameters.
6
+ * @param params.name - The model's registry name (as found in the SDK's built-in catalog) to look up.
7
+ * @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
8
+ * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
9
+ */
2
10
  export declare function getModelInfo(params: GetModelInfoParams): Promise<{
3
11
  name: string;
4
12
  modelId: string;
5
13
  expectedSize: number;
6
14
  sha256Checksum: string;
7
- addon: "llm" | "whisper" | "embeddings" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | "other";
15
+ addon: "embeddings" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | "other";
8
16
  isCached: boolean;
9
17
  isLoaded: boolean;
10
18
  cacheFiles: {
@@ -1,6 +1,14 @@
1
1
  import {} from "../../schemas/index.js";
2
2
  import { send } from "../rpc/rpc-client.js";
3
3
  import { InvalidResponseError } from "../../utils/errors-client.js";
4
+ /**
5
+ * Returns status information for a catalog model, including cache state and loaded instances.
6
+ *
7
+ * @param params - Query parameters.
8
+ * @param params.name - The model's registry name (as found in the SDK's built-in catalog) to look up.
9
+ * @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
10
+ * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
11
+ */
4
12
  export async function getModelInfo(params) {
5
13
  const request = {
6
14
  type: "getModelInfo",
@@ -5,7 +5,7 @@ import type { DelegateBase } from "../../schemas/delegate";
5
5
  * Can also be used to check if the local SDK worker is responsive.
6
6
  *
7
7
  * @param params - Delegation target to check
8
- * @param params.delegate - The provider to check (topic + publicKey + optional timeout)
8
+ * @param params.delegate - The provider to check (providerPublicKey + optional timeout)
9
9
  * @returns A promise that resolves to a heartbeat response if the provider is reachable.
10
10
  * @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
11
11
  *
@@ -13,7 +13,7 @@ import type { DelegateBase } from "../../schemas/delegate";
13
13
  * // Check if a delegated provider is online
14
14
  * try {
15
15
  * await heartbeat({
16
- * delegate: { topic: "topicHex", providerPublicKey: "peerHex", timeout: 3000 },
16
+ * delegate: { providerPublicKey: "peerHex", timeout: 3000 },
17
17
  * });
18
18
  * console.log("Provider is online");
19
19
  * } catch {
@@ -6,7 +6,7 @@ import { InvalidResponseError } from "../../utils/errors-client.js";
6
6
  * Can also be used to check if the local SDK worker is responsive.
7
7
  *
8
8
  * @param params - Delegation target to check
9
- * @param params.delegate - The provider to check (topic + publicKey + optional timeout)
9
+ * @param params.delegate - The provider to check (providerPublicKey + optional timeout)
10
10
  * @returns A promise that resolves to a heartbeat response if the provider is reachable.
11
11
  * @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
12
12
  *
@@ -14,7 +14,7 @@ import { InvalidResponseError } from "../../utils/errors-client.js";
14
14
  * // Check if a delegated provider is online
15
15
  * try {
16
16
  * await heartbeat({
17
- * delegate: { topic: "topicHex", providerPublicKey: "peerHex", timeout: 3000 },
17
+ * delegate: { providerPublicKey: "peerHex", timeout: 3000 },
18
18
  * });
19
19
  * console.log("Provider is online");
20
20
  * } catch {
@@ -13,12 +13,14 @@ export { cancel } from "./cancel";
13
13
  export { startQVACProvider } from "./provide";
14
14
  export { stopQVACProvider } from "./stop-provider";
15
15
  export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag";
16
- export { textToSpeech } from "./text-to-speech";
16
+ export { textToSpeech, textToSpeechStream } from "./text-to-speech";
17
17
  export { getModelInfo } from "./get-model-info";
18
+ export { getLoadedModelInfo } from "./get-loaded-model-info";
18
19
  export { ocr } from "./ocr";
19
20
  export { invokePlugin, invokePluginStream } from "./invoke-plugin";
20
21
  export { diffusion, type DiffusionProgressTick } from "./diffusion";
21
22
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./registry";
22
23
  export { suspend } from "./suspend";
23
24
  export { resume } from "./resume";
25
+ export { state } from "./state";
24
26
  //# sourceMappingURL=index.d.ts.map
@@ -13,11 +13,13 @@ export { cancel } from "./cancel.js";
13
13
  export { startQVACProvider } from "./provide.js";
14
14
  export { stopQVACProvider } from "./stop-provider.js";
15
15
  export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag.js";
16
- export { textToSpeech } from "./text-to-speech.js";
16
+ export { textToSpeech, textToSpeechStream } from "./text-to-speech.js";
17
17
  export { getModelInfo } from "./get-model-info.js";
18
+ export { getLoadedModelInfo } from "./get-loaded-model-info.js";
18
19
  export { ocr } from "./ocr.js";
19
20
  export { invokePlugin, invokePluginStream } from "./invoke-plugin.js";
20
21
  export { diffusion } from "./diffusion.js";
21
22
  export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./registry.js";
22
23
  export { suspend } from "./suspend.js";
23
24
  export { resume } from "./resume.js";
25
+ export { state } from "./state.js";
@@ -6,10 +6,26 @@ export interface InvokePluginOptions<TParams = unknown> {
6
6
  }
7
7
  /**
8
8
  * Invoke a non-streaming plugin handler.
9
+ *
10
+ * @param options - Invocation payload.
11
+ * @param options.modelId - The identifier of the model instance that owns the plugin.
12
+ * @param options.handler - Name of the plugin handler to invoke.
13
+ * @param options.params - Handler-specific parameters, passed through to the plugin.
14
+ * @param rpcOptions - Optional RPC options (timeout, profiling, force new connection, etc.).
15
+ * @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
16
+ * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
9
17
  */
10
18
  export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse>;
11
19
  /**
12
20
  * Invoke a streaming plugin handler.
21
+ *
22
+ * @param options - Invocation payload.
23
+ * @param options.modelId - The identifier of the model instance that owns the plugin.
24
+ * @param options.handler - Name of the plugin stream handler to invoke.
25
+ * @param options.params - Handler-specific parameters, passed through to the plugin.
26
+ * @param rpcOptions - Optional RPC options (timeout, profiling, force new connection, etc.).
27
+ * @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
28
+ * @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
13
29
  */
14
30
  export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse>;
15
31
  //# sourceMappingURL=invoke-plugin.d.ts.map
@@ -2,6 +2,14 @@ import { send, stream } from "../rpc/rpc-client.js";
2
2
  import { InvalidResponseError } from "../../utils/errors-client.js";
3
3
  /**
4
4
  * Invoke a non-streaming plugin handler.
5
+ *
6
+ * @param options - Invocation payload.
7
+ * @param options.modelId - The identifier of the model instance that owns the plugin.
8
+ * @param options.handler - Name of the plugin handler to invoke.
9
+ * @param options.params - Handler-specific parameters, passed through to the plugin.
10
+ * @param rpcOptions - Optional RPC options (timeout, profiling, force new connection, etc.).
11
+ * @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
12
+ * @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
5
13
  */
6
14
  export async function invokePlugin(options, rpcOptions) {
7
15
  const request = {
@@ -18,6 +26,14 @@ export async function invokePlugin(options, rpcOptions) {
18
26
  }
19
27
  /**
20
28
  * Invoke a streaming plugin handler.
29
+ *
30
+ * @param options - Invocation payload.
31
+ * @param options.modelId - The identifier of the model instance that owns the plugin.
32
+ * @param options.handler - Name of the plugin stream handler to invoke.
33
+ * @param options.params - Handler-specific parameters, passed through to the plugin.
34
+ * @param rpcOptions - Optional RPC options (timeout, profiling, force new connection, etc.).
35
+ * @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
36
+ * @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
21
37
  */
22
38
  export async function* invokePluginStream(options, rpcOptions) {
23
39
  const request = {
@@ -1,4 +1,23 @@
1
- import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from "../../schemas/index";
1
+ import { type LoadModelOptions, type LoadCustomPluginModelOptions, type LoadModelDescriptorParam, type ReloadConfigOptions, type RPCOptions, type ModelDescriptor } from "../../schemas/index";
2
+ /**
3
+ * Loads a model from a descriptor; `modelType` is inferred from `modelSrc`.
4
+ * `modelConfig` narrows per-engine when `modelSrc.engine` is a literal,
5
+ * otherwise falls back to a permissive shape.
6
+ *
7
+ * @overloadLabel "From descriptor"
8
+ * @param options - Descriptor-based load options. `modelSrc` is a
9
+ * `ModelDescriptor` (e.g. one of the `LLAMA_3_2_1B_INST_Q4_0`-style
10
+ * constants); `modelType` is inferred from it.
11
+ * @param rpcOptions - Optional RPC options including per-call profiling.
12
+ * @returns Promise that resolves to the loaded model ID.
13
+ * @throws {ModelTypeRequiredError} When `modelType` cannot be inferred from `modelSrc` at runtime.
14
+ * @example
15
+ * ```typescript
16
+ * await loadModel({ modelSrc: LLAMA_3_2_1B_INST_Q4_0, modelConfig: { ctx_size: 2048 } });
17
+ * await loadModel({ modelSrc: WHISPER_TINY });
18
+ * ```
19
+ */
20
+ export declare function loadModel<S extends ModelDescriptor>(options: LoadModelDescriptorParam<S>, rpcOptions?: RPCOptions): Promise<string>;
2
21
  /**
3
22
  * Loads a machine learning model from a local path, remote URL, or Hyperdrive key.
4
23
  *
@@ -8,6 +27,7 @@ import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from
8
27
  * When `onProgress` is provided, the function uses streaming to provide real-time download progress.
9
28
  * Otherwise, it uses a simple request-response pattern for faster execution.
10
29
  *
30
+ * @overloadLabel "Load new model"
11
31
  * @param options - An object that defines all configuration parameters required for loading the model, including:
12
32
  * - modelSrc: The location from which the model weights are fetched (local path, remote URL, or Hyperdrive URL)
13
33
  * - modelType: The type of model ("llm", "whisper", "embeddings", "nmt", or "tts")
@@ -28,7 +48,7 @@ import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from
28
48
  * const localModelId = await loadModel({
29
49
  * modelSrc: "/home/user/models/llama-7b.gguf",
30
50
  * modelType: "llm",
31
- * modelConfig: { contextSize: 2048 }
51
+ * modelConfig: { ctx_size: 2048 }
32
52
  * });
33
53
  *
34
54
  * // Local file path - relative path
@@ -41,7 +61,7 @@ import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from
41
61
  * const hyperdriveId = await loadModel({
42
62
  * modelSrc: "pear://<hyperdrive-key>/llama-7b.gguf",
43
63
  * modelType: "llm",
44
- * modelConfig: { contextSize: 2048 }
64
+ * modelConfig: { ctx_size: 2048 }
45
65
  * });
46
66
  *
47
67
  * // Remote HTTP/HTTPS URL with progress tracking
@@ -91,9 +111,22 @@ import { type LoadModelOptions, type ReloadConfigOptions, type RPCOptions } from
91
111
  * ```
92
112
  */
93
113
  export declare function loadModel(options: LoadModelOptions, rpcOptions?: RPCOptions): Promise<string>;
114
+ /**
115
+ * Loads a custom plugin model (any non-built-in `modelType` string).
116
+ * `modelConfig` is plugin-defined; the SDK does not narrow it.
117
+ *
118
+ * @overloadLabel "Custom plugin"
119
+ * @param options - Custom plugin load options. `modelType` can be any
120
+ * string registered by a plugin; `modelConfig` is forwarded to the
121
+ * plugin's `loadModel` handler unchanged.
122
+ * @param rpcOptions - Optional RPC options including per-call profiling.
123
+ * @returns Promise that resolves to the loaded model ID.
124
+ */
125
+ export declare function loadModel<T extends string>(options: LoadCustomPluginModelOptions<T>, rpcOptions?: RPCOptions): Promise<string>;
94
126
  /**
95
127
  * Hot-reloads configuration on an already loaded model.
96
128
  *
129
+ * @overloadLabel "Hot-reload config"
97
130
  * @param options - Configuration for reloading config on an existing model:
98
131
  * - modelId: The ID of an existing loaded model
99
132
  * - modelType: The type of model (must match the loaded model)
@@ -1,21 +1,42 @@
1
1
  import { send, stream } from "../rpc/rpc-client.js";
2
2
  import { startLoggingStreamForModel } from "../logging-stream-registry.js";
3
- import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, isModelTypeAlias, normalizeModelType, } from "../../schemas/index.js";
4
- import { ModelLoadFailedError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
3
+ import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, isModelTypeAlias, normalizeModelType, inferModelTypeFromModelSrc, } from "../../schemas/index.js";
4
+ import { ModelLoadFailedError, ModelTypeRequiredError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
5
+ import { assertModelSrcMatchesModelType } from "../../utils/load-model-validation.js";
5
6
  import { getClientLogger } from "../../logging/index.js";
6
7
  const logger = getClientLogger();
7
8
  export async function loadModel(options, rpcOptions) {
8
9
  const isReloadConfig = "modelId" in options && !("modelSrc" in options);
9
- // Warn about deprecated alias usage
10
- if (!isReloadConfig && isModelTypeAlias(options.modelType)) {
11
- const canonical = normalizeModelType(options.modelType);
12
- logger.warn(`Model type "${options.modelType}" is an alias and will be deprecated. Use "${canonical}" instead.`);
10
+ // Infer `modelType` from `modelSrc` when omitted; the schema still validates
11
+ // the resolved options below.
12
+ let resolvedOptions = options;
13
+ if (!isReloadConfig) {
14
+ let modelType = resolvedOptions["modelType"];
15
+ if (typeof modelType === "string") {
16
+ assertModelSrcMatchesModelType(resolvedOptions["modelSrc"], modelType);
17
+ }
18
+ else if (modelType === undefined) {
19
+ const inferred = inferModelTypeFromModelSrc(resolvedOptions["modelSrc"]);
20
+ if (!inferred) {
21
+ throw new ModelTypeRequiredError();
22
+ }
23
+ resolvedOptions = { ...resolvedOptions, modelType: inferred };
24
+ modelType = inferred;
25
+ }
26
+ if (typeof modelType === "string" && isModelTypeAlias(modelType)) {
27
+ const canonical = normalizeModelType(modelType);
28
+ logger.warn(`Model type "${modelType}" is an alias and will be deprecated. Use "${canonical}" instead.`);
29
+ }
13
30
  }
14
31
  const request = isReloadConfig
15
- ? reloadConfigOptionsToRequestSchema.parse(options)
16
- : loadModelOptionsToRequestSchema.parse(options);
17
- const modelLogger = isReloadConfig ? undefined : options.logger;
18
- const onProgress = isReloadConfig ? undefined : options.onProgress;
32
+ ? reloadConfigOptionsToRequestSchema.parse(resolvedOptions)
33
+ : loadModelOptionsToRequestSchema.parse(resolvedOptions);
34
+ const modelLogger = isReloadConfig
35
+ ? undefined
36
+ : resolvedOptions["logger"];
37
+ const onProgress = isReloadConfig
38
+ ? undefined
39
+ : resolvedOptions["onProgress"];
19
40
  if (onProgress) {
20
41
  // Use streaming for progress updates
21
42
  for await (const response of stream(request, rpcOptions)) {
@@ -1,15 +1,21 @@
1
1
  import { type ProvideParams } from "../../schemas/index";
2
2
  /**
3
3
  * Starts a provider service that offers QVAC capabilities to remote peers.
4
- * The provider's keypair can be controlled via the seed option or QVAC_HYPERSWARM_SEED environment variable.
5
4
  *
6
- * @param options - Options object with required topic, optional seed, and optional firewall config
7
- * @param options.topic - Topic hex string for peer discovery
8
- * @param options.firewall - Optional firewall configuration to allow/deny specific public keys
5
+ * Consumers connect directly to the provider via its public key using
6
+ * `dht.connect(publicKey)`, so no topic or discovery configuration is needed.
7
+ * The provider's keypair (and therefore its public key) can be controlled via
8
+ * the `QVAC_HYPERSWARM_SEED` environment variable.
9
+ *
10
+ * Idempotent: calling more than once while a provider is already running
11
+ * returns the same public key without re-listening on the DHT.
12
+ *
13
+ * @param params - Options object with optional firewall config
14
+ * @param params.firewall - Optional firewall configuration to allow/deny specific public keys
9
15
  * @returns A promise that resolves to the provide response containing success status and public key
10
16
  * @throws {QvacErrorBase} When the response type is not "provide" or the request fails
11
17
  */
12
- export declare function startQVACProvider(params: ProvideParams): Promise<{
18
+ export declare function startQVACProvider(params?: ProvideParams): Promise<{
13
19
  type: "provide";
14
20
  success: boolean;
15
21
  error?: string | undefined;
@@ -3,18 +3,23 @@ import { send } from "../rpc/rpc-client.js";
3
3
  import { InvalidResponseError, ProviderStartFailedError, } from "../../utils/errors-client.js";
4
4
  /**
5
5
  * Starts a provider service that offers QVAC capabilities to remote peers.
6
- * The provider's keypair can be controlled via the seed option or QVAC_HYPERSWARM_SEED environment variable.
7
6
  *
8
- * @param options - Options object with required topic, optional seed, and optional firewall config
9
- * @param options.topic - Topic hex string for peer discovery
10
- * @param options.firewall - Optional firewall configuration to allow/deny specific public keys
7
+ * Consumers connect directly to the provider via its public key using
8
+ * `dht.connect(publicKey)`, so no topic or discovery configuration is needed.
9
+ * The provider's keypair (and therefore its public key) can be controlled via
10
+ * the `QVAC_HYPERSWARM_SEED` environment variable.
11
+ *
12
+ * Idempotent: calling more than once while a provider is already running
13
+ * returns the same public key without re-listening on the DHT.
14
+ *
15
+ * @param params - Options object with optional firewall config
16
+ * @param params.firewall - Optional firewall configuration to allow/deny specific public keys
11
17
  * @returns A promise that resolves to the provide response containing success status and public key
12
18
  * @throws {QvacErrorBase} When the response type is not "provide" or the request fails
13
19
  */
14
- export async function startQVACProvider(params) {
20
+ export async function startQVACProvider(params = {}) {
15
21
  const request = {
16
22
  type: "provide",
17
- topic: params.topic,
18
23
  firewall: params.firewall,
19
24
  };
20
25
  const response = await send(request);
@@ -6,6 +6,7 @@ import type { RagChunkParams, RagDoc, RagIngestParams, RagSaveEmbeddingsParams,
6
6
  * @param params - The parameters for chunking
7
7
  * @param params.documents - Documents to chunk (string or array)
8
8
  * @param params.chunkOpts - Chunking options (chunkSize, chunkOverlap, chunkStrategy)
9
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
9
10
  * @returns Array of chunk results with id and content
10
11
  * @throws {RAGChunkFailedError} When the operation fails
11
12
  *
@@ -37,6 +38,7 @@ export declare function ragChunk(params: RagChunkParams, options?: RPCOptions):
37
38
  * @param params.workspace - Workspace for isolated storage (default: "default"). Created if it doesn't exist.
38
39
  * @param params.onProgress - Progress callback (stage, current, total)
39
40
  * @param params.progressInterval - Minimum interval between progress updates in ms
41
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
40
42
  * @returns Processing results and dropped indices
41
43
  * @throws {RAGSaveFailedError} When the operation fails
42
44
  * @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
@@ -76,6 +78,7 @@ export declare function ragIngest(params: RagIngestParams, options?: RPCOptions)
76
78
  * @param params.workspace - Workspace for isolated storage (default: "default"). Created if it doesn't exist.
77
79
  * @param params.onProgress - Progress callback (stage, current, total)
78
80
  * @param params.progressInterval - Minimum interval between progress updates in ms
81
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
79
82
  * @returns Array of save results
80
83
  * @throws {RAGSaveFailedError} When the operation fails
81
84
  * @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
@@ -109,6 +112,7 @@ export declare function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, optio
109
112
  * @param params.topK - Number of top results to retrieve (default: 5)
110
113
  * @param params.n - Number of centroids to use for IVF index search (default: 3)
111
114
  * @param params.workspace - Workspace to search in (default: "default").
115
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
112
116
  * @returns Array of search results with id, content, and score. Empty array if workspace doesn't exist.
113
117
  * @throws {RAGSearchFailedError} When the operation fails
114
118
  *
@@ -131,6 +135,7 @@ export declare function ragSearch(params: RagSearchParams, options?: RPCOptions)
131
135
  * @param params - The parameters for deleting embeddings
132
136
  * @param params.ids - Array of document IDs to delete
133
137
  * @param params.workspace - Workspace to delete from (default: "default")
138
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
134
139
  * @throws {RAGDeleteFailedError} When the operation fails or workspace doesn't exist
135
140
  *
136
141
  * @example
@@ -155,6 +160,7 @@ export declare function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams, o
155
160
  * @param params - The parameters for reindexing
156
161
  * @param params.workspace - Workspace to reindex (default: "default"). Must already exist.
157
162
  * @param params.onProgress - Progress callback (stage, current, total)
163
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
158
164
  * @returns Reindex result with `reindexed` boolean and optional `details`
159
165
  * @throws {RAGSaveFailedError} When the operation fails or workspace doesn't exist
160
166
  * @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
@@ -188,6 +194,7 @@ export declare function ragReindex(params: RagReindexParams, options?: RPCOption
188
194
  * the workspace is currently loaded in memory and holding active resources
189
195
  * (Corestore, HyperDB adapter, and possibly a RAG instance).
190
196
  *
197
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
191
198
  * @returns Array of workspace info with name and open status
192
199
  * @throws {RAGListWorkspacesFailedError} When the operation fails
193
200
  *
@@ -208,6 +215,7 @@ export declare function ragListWorkspaces(options?: RPCOptions): Promise<RagWork
208
215
  * @param params - The parameters for closing
209
216
  * @param params.workspace - Name of the workspace to close (default: "default")
210
217
  * @param params.deleteOnClose - If true, deletes the workspace data from disk after closing (default: false)
218
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
211
219
  * @throws {RAGCloseWorkspaceFailedError} When the operation fails
212
220
  *
213
221
  * @example
@@ -226,6 +234,7 @@ export declare function ragCloseWorkspace(params?: RagCloseWorkspaceParams, opti
226
234
  *
227
235
  * @param params - The parameters for deletion
228
236
  * @param params.workspace - Name of the workspace to delete
237
+ * @param options - Optional RPC options (timeout, profiling, force new connection, etc.).
229
238
  * @throws {RAGDeleteFailedError} When the workspace doesn't exist or is currently loaded
230
239
  *
231
240
  * @example