@juspay/neurolink 9.63.1 → 9.65.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 (358) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +18 -17
  3. package/dist/adapters/providerImageAdapter.js +29 -1
  4. package/dist/adapters/replicate/auth.d.ts +19 -0
  5. package/dist/adapters/replicate/auth.js +32 -0
  6. package/dist/adapters/replicate/predictionLifecycle.d.ts +46 -0
  7. package/dist/adapters/replicate/predictionLifecycle.js +283 -0
  8. package/dist/adapters/video/klingVideoHandler.d.ts +37 -0
  9. package/dist/adapters/video/klingVideoHandler.js +305 -0
  10. package/dist/adapters/video/replicateVideoHandler.d.ts +29 -0
  11. package/dist/adapters/video/replicateVideoHandler.js +157 -0
  12. package/dist/adapters/video/runwayVideoHandler.d.ts +32 -0
  13. package/dist/adapters/video/runwayVideoHandler.js +316 -0
  14. package/dist/adapters/video/vertexVideoHandler.d.ts +19 -1
  15. package/dist/adapters/video/vertexVideoHandler.js +42 -11
  16. package/dist/autoresearch/runner.js +8 -2
  17. package/dist/avatar/index.d.ts +13 -0
  18. package/dist/avatar/index.js +13 -0
  19. package/dist/avatar/providers/DIDAvatar.d.ts +49 -0
  20. package/dist/avatar/providers/DIDAvatar.js +501 -0
  21. package/dist/avatar/providers/HeyGenAvatar.d.ts +30 -0
  22. package/dist/avatar/providers/HeyGenAvatar.js +337 -0
  23. package/dist/avatar/providers/ReplicateAvatar.d.ts +36 -0
  24. package/dist/avatar/providers/ReplicateAvatar.js +267 -0
  25. package/dist/browser/neurolink.min.js +573 -554
  26. package/dist/cli/commands/mcp.js +29 -0
  27. package/dist/cli/commands/proxy.js +24 -5
  28. package/dist/cli/factories/commandFactory.d.ts +25 -1
  29. package/dist/cli/factories/commandFactory.js +341 -63
  30. package/dist/cli/loop/optionsSchema.d.ts +1 -1
  31. package/dist/cli/loop/optionsSchema.js +12 -0
  32. package/dist/constants/contextWindows.js +101 -0
  33. package/dist/constants/enums.d.ts +273 -2
  34. package/dist/constants/enums.js +290 -1
  35. package/dist/constants/videoErrors.d.ts +4 -0
  36. package/dist/constants/videoErrors.js +4 -0
  37. package/dist/core/baseProvider.d.ts +23 -3
  38. package/dist/core/baseProvider.js +217 -11
  39. package/dist/core/constants.d.ts +11 -0
  40. package/dist/core/constants.js +69 -1
  41. package/dist/core/modules/MessageBuilder.js +20 -0
  42. package/dist/core/redisConversationMemoryManager.js +6 -0
  43. package/dist/evaluation/index.d.ts +2 -0
  44. package/dist/evaluation/index.js +4 -0
  45. package/dist/factories/providerFactory.js +7 -1
  46. package/dist/factories/providerRegistry.js +203 -2
  47. package/dist/features/ppt/contentPlanner.js +42 -14
  48. package/dist/index.d.ts +9 -1
  49. package/dist/index.js +16 -1
  50. package/dist/lib/adapters/providerImageAdapter.js +29 -1
  51. package/dist/lib/adapters/replicate/auth.d.ts +19 -0
  52. package/dist/lib/adapters/replicate/auth.js +33 -0
  53. package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +46 -0
  54. package/dist/lib/adapters/replicate/predictionLifecycle.js +284 -0
  55. package/dist/lib/adapters/video/klingVideoHandler.d.ts +37 -0
  56. package/dist/lib/adapters/video/klingVideoHandler.js +306 -0
  57. package/dist/lib/adapters/video/replicateVideoHandler.d.ts +29 -0
  58. package/dist/lib/adapters/video/replicateVideoHandler.js +158 -0
  59. package/dist/lib/adapters/video/runwayVideoHandler.d.ts +32 -0
  60. package/dist/lib/adapters/video/runwayVideoHandler.js +317 -0
  61. package/dist/lib/adapters/video/vertexVideoHandler.d.ts +19 -1
  62. package/dist/lib/adapters/video/vertexVideoHandler.js +42 -11
  63. package/dist/lib/autoresearch/runner.js +8 -2
  64. package/dist/lib/avatar/index.d.ts +13 -0
  65. package/dist/lib/avatar/index.js +14 -0
  66. package/dist/lib/avatar/providers/DIDAvatar.d.ts +49 -0
  67. package/dist/lib/avatar/providers/DIDAvatar.js +502 -0
  68. package/dist/lib/avatar/providers/HeyGenAvatar.d.ts +30 -0
  69. package/dist/lib/avatar/providers/HeyGenAvatar.js +338 -0
  70. package/dist/lib/avatar/providers/ReplicateAvatar.d.ts +36 -0
  71. package/dist/lib/avatar/providers/ReplicateAvatar.js +268 -0
  72. package/dist/lib/constants/contextWindows.js +101 -0
  73. package/dist/lib/constants/enums.d.ts +273 -2
  74. package/dist/lib/constants/enums.js +290 -1
  75. package/dist/lib/constants/videoErrors.d.ts +4 -0
  76. package/dist/lib/constants/videoErrors.js +4 -0
  77. package/dist/lib/core/baseProvider.d.ts +23 -3
  78. package/dist/lib/core/baseProvider.js +217 -11
  79. package/dist/lib/core/constants.d.ts +11 -0
  80. package/dist/lib/core/constants.js +69 -1
  81. package/dist/lib/core/modules/MessageBuilder.js +20 -0
  82. package/dist/lib/core/redisConversationMemoryManager.js +6 -0
  83. package/dist/lib/evaluation/index.d.ts +2 -0
  84. package/dist/lib/evaluation/index.js +4 -0
  85. package/dist/lib/factories/providerFactory.js +7 -1
  86. package/dist/lib/factories/providerRegistry.js +203 -2
  87. package/dist/lib/features/ppt/contentPlanner.js +42 -14
  88. package/dist/lib/index.d.ts +9 -1
  89. package/dist/lib/index.js +16 -1
  90. package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
  91. package/dist/lib/memory/hippocampusInitializer.js +32 -2
  92. package/dist/lib/middleware/builtin/lifecycle.js +52 -51
  93. package/dist/lib/music/index.d.ts +13 -0
  94. package/dist/lib/music/index.js +14 -0
  95. package/dist/lib/music/providers/BeatovenMusic.d.ts +31 -0
  96. package/dist/lib/music/providers/BeatovenMusic.js +334 -0
  97. package/dist/lib/music/providers/ElevenLabsMusic.d.ts +30 -0
  98. package/dist/lib/music/providers/ElevenLabsMusic.js +169 -0
  99. package/dist/lib/music/providers/LyriaMusic.d.ts +29 -0
  100. package/dist/lib/music/providers/LyriaMusic.js +173 -0
  101. package/dist/lib/music/providers/ReplicateMusic.d.ts +31 -0
  102. package/dist/lib/music/providers/ReplicateMusic.js +262 -0
  103. package/dist/lib/neurolink.d.ts +30 -0
  104. package/dist/lib/neurolink.js +342 -49
  105. package/dist/lib/providers/amazonBedrock.d.ts +10 -0
  106. package/dist/lib/providers/amazonBedrock.js +94 -39
  107. package/dist/lib/providers/anthropic.js +55 -7
  108. package/dist/lib/providers/anthropicBaseProvider.js +1 -1
  109. package/dist/lib/providers/azureOpenai.js +66 -17
  110. package/dist/lib/providers/cloudflare.d.ts +35 -0
  111. package/dist/lib/providers/cloudflare.js +174 -0
  112. package/dist/lib/providers/cohere.d.ts +52 -0
  113. package/dist/lib/providers/cohere.js +253 -0
  114. package/dist/lib/providers/deepseek.js +72 -17
  115. package/dist/lib/providers/fireworks.d.ts +33 -0
  116. package/dist/lib/providers/fireworks.js +164 -0
  117. package/dist/lib/providers/googleAiStudio.d.ts +11 -3
  118. package/dist/lib/providers/googleAiStudio.js +336 -344
  119. package/dist/lib/providers/googleNativeGemini3.d.ts +107 -2
  120. package/dist/lib/providers/googleNativeGemini3.js +381 -25
  121. package/dist/lib/providers/googleVertex.d.ts +116 -129
  122. package/dist/lib/providers/googleVertex.js +3002 -1988
  123. package/dist/lib/providers/groq.d.ts +33 -0
  124. package/dist/lib/providers/groq.js +181 -0
  125. package/dist/lib/providers/huggingFace.js +9 -8
  126. package/dist/lib/providers/ideogram.d.ts +34 -0
  127. package/dist/lib/providers/ideogram.js +184 -0
  128. package/dist/lib/providers/index.d.ts +13 -0
  129. package/dist/lib/providers/index.js +13 -0
  130. package/dist/lib/providers/jina.d.ts +59 -0
  131. package/dist/lib/providers/jina.js +218 -0
  132. package/dist/lib/providers/llamaCpp.js +14 -46
  133. package/dist/lib/providers/lmStudio.js +14 -47
  134. package/dist/lib/providers/mistral.js +7 -7
  135. package/dist/lib/providers/nvidiaNim.js +160 -19
  136. package/dist/lib/providers/ollama.js +7 -7
  137. package/dist/lib/providers/openAI.d.ts +22 -1
  138. package/dist/lib/providers/openAI.js +181 -0
  139. package/dist/lib/providers/openRouter.js +38 -22
  140. package/dist/lib/providers/openaiCompatible.js +9 -8
  141. package/dist/lib/providers/perplexity.d.ts +33 -0
  142. package/dist/lib/providers/perplexity.js +179 -0
  143. package/dist/lib/providers/recraft.d.ts +34 -0
  144. package/dist/lib/providers/recraft.js +197 -0
  145. package/dist/lib/providers/replicate.d.ts +75 -0
  146. package/dist/lib/providers/replicate.js +403 -0
  147. package/dist/lib/providers/stability.d.ts +37 -0
  148. package/dist/lib/providers/stability.js +191 -0
  149. package/dist/lib/providers/togetherAi.d.ts +33 -0
  150. package/dist/lib/providers/togetherAi.js +176 -0
  151. package/dist/lib/providers/voyage.d.ts +47 -0
  152. package/dist/lib/providers/voyage.js +177 -0
  153. package/dist/lib/providers/xai.d.ts +33 -0
  154. package/dist/lib/providers/xai.js +172 -0
  155. package/dist/lib/telemetry/index.d.ts +1 -1
  156. package/dist/lib/telemetry/index.js +1 -1
  157. package/dist/lib/telemetry/tracers.d.ts +19 -0
  158. package/dist/lib/telemetry/tracers.js +19 -0
  159. package/dist/lib/telemetry/withSpan.d.ts +35 -0
  160. package/dist/lib/telemetry/withSpan.js +103 -0
  161. package/dist/lib/types/aliases.d.ts +14 -0
  162. package/dist/lib/types/avatar.d.ts +143 -0
  163. package/dist/lib/types/avatar.js +20 -0
  164. package/dist/lib/types/cli.d.ts +6 -0
  165. package/dist/lib/types/common.d.ts +0 -3
  166. package/dist/lib/types/conversation.d.ts +10 -3
  167. package/dist/lib/types/generate.d.ts +76 -5
  168. package/dist/lib/types/index.d.ts +6 -0
  169. package/dist/lib/types/index.js +8 -0
  170. package/dist/lib/types/memory.d.ts +96 -0
  171. package/dist/lib/types/memory.js +23 -0
  172. package/dist/lib/types/middleware.d.ts +27 -0
  173. package/dist/lib/types/multimodal.d.ts +35 -2
  174. package/dist/lib/types/music.d.ts +165 -0
  175. package/dist/lib/types/music.js +21 -0
  176. package/dist/lib/types/providers.d.ts +284 -3
  177. package/dist/lib/types/replicate.d.ts +67 -0
  178. package/dist/lib/types/replicate.js +10 -0
  179. package/dist/lib/types/safeFetch.d.ts +15 -0
  180. package/dist/lib/types/safeFetch.js +7 -0
  181. package/dist/lib/types/stream.d.ts +8 -1
  182. package/dist/lib/types/tools.d.ts +13 -0
  183. package/dist/lib/types/video.d.ts +89 -0
  184. package/dist/lib/types/video.js +15 -0
  185. package/dist/lib/utils/avatarProcessor.d.ts +68 -0
  186. package/dist/lib/utils/avatarProcessor.js +172 -0
  187. package/dist/lib/utils/cloneOptions.d.ts +36 -0
  188. package/dist/lib/utils/cloneOptions.js +62 -0
  189. package/dist/lib/utils/lifecycleCallbacks.d.ts +56 -0
  190. package/dist/lib/utils/lifecycleCallbacks.js +100 -0
  191. package/dist/lib/utils/lifecycleTimeout.d.ts +25 -0
  192. package/dist/lib/utils/lifecycleTimeout.js +39 -0
  193. package/dist/lib/utils/logSanitize.d.ts +49 -0
  194. package/dist/lib/utils/logSanitize.js +170 -0
  195. package/dist/lib/utils/loggingFetch.d.ts +29 -0
  196. package/dist/lib/utils/loggingFetch.js +60 -0
  197. package/dist/lib/utils/messageBuilder.d.ts +10 -0
  198. package/dist/lib/utils/messageBuilder.js +83 -30
  199. package/dist/lib/utils/modelChoices.js +236 -3
  200. package/dist/lib/utils/modelDetection.d.ts +11 -0
  201. package/dist/lib/utils/modelDetection.js +27 -0
  202. package/dist/lib/utils/musicProcessor.d.ts +67 -0
  203. package/dist/lib/utils/musicProcessor.js +189 -0
  204. package/dist/lib/utils/optionsConversion.js +3 -2
  205. package/dist/lib/utils/parameterValidation.js +14 -4
  206. package/dist/lib/utils/pricing.js +193 -0
  207. package/dist/lib/utils/providerConfig.d.ts +55 -0
  208. package/dist/lib/utils/providerConfig.js +224 -0
  209. package/dist/lib/utils/providerHealth.js +7 -7
  210. package/dist/lib/utils/safeFetch.d.ts +26 -0
  211. package/dist/lib/utils/safeFetch.js +83 -0
  212. package/dist/lib/utils/schemaConversion.d.ts +1 -1
  213. package/dist/lib/utils/schemaConversion.js +59 -4
  214. package/dist/lib/utils/sizeGuard.d.ts +34 -0
  215. package/dist/lib/utils/sizeGuard.js +45 -0
  216. package/dist/lib/utils/ssrfGuard.d.ts +52 -0
  217. package/dist/lib/utils/ssrfGuard.js +411 -0
  218. package/dist/lib/utils/tokenLimits.js +23 -32
  219. package/dist/lib/utils/videoProcessor.d.ts +60 -0
  220. package/dist/lib/utils/videoProcessor.js +201 -0
  221. package/dist/lib/voice/providers/FishAudioTTS.d.ts +27 -0
  222. package/dist/lib/voice/providers/FishAudioTTS.js +183 -0
  223. package/dist/lib/workflow/core/ensembleExecutor.js +26 -9
  224. package/dist/memory/hippocampusInitializer.d.ts +2 -2
  225. package/dist/memory/hippocampusInitializer.js +32 -2
  226. package/dist/middleware/builtin/lifecycle.js +52 -51
  227. package/dist/music/index.d.ts +13 -0
  228. package/dist/music/index.js +13 -0
  229. package/dist/music/providers/BeatovenMusic.d.ts +31 -0
  230. package/dist/music/providers/BeatovenMusic.js +333 -0
  231. package/dist/music/providers/ElevenLabsMusic.d.ts +30 -0
  232. package/dist/music/providers/ElevenLabsMusic.js +168 -0
  233. package/dist/music/providers/LyriaMusic.d.ts +29 -0
  234. package/dist/music/providers/LyriaMusic.js +172 -0
  235. package/dist/music/providers/ReplicateMusic.d.ts +31 -0
  236. package/dist/music/providers/ReplicateMusic.js +261 -0
  237. package/dist/neurolink.d.ts +30 -0
  238. package/dist/neurolink.js +342 -49
  239. package/dist/providers/amazonBedrock.d.ts +10 -0
  240. package/dist/providers/amazonBedrock.js +94 -39
  241. package/dist/providers/anthropic.js +55 -7
  242. package/dist/providers/anthropicBaseProvider.js +1 -1
  243. package/dist/providers/azureOpenai.js +66 -17
  244. package/dist/providers/cloudflare.d.ts +35 -0
  245. package/dist/providers/cloudflare.js +173 -0
  246. package/dist/providers/cohere.d.ts +52 -0
  247. package/dist/providers/cohere.js +252 -0
  248. package/dist/providers/deepseek.js +72 -17
  249. package/dist/providers/fireworks.d.ts +33 -0
  250. package/dist/providers/fireworks.js +163 -0
  251. package/dist/providers/googleAiStudio.d.ts +11 -3
  252. package/dist/providers/googleAiStudio.js +335 -344
  253. package/dist/providers/googleNativeGemini3.d.ts +107 -2
  254. package/dist/providers/googleNativeGemini3.js +381 -25
  255. package/dist/providers/googleVertex.d.ts +116 -129
  256. package/dist/providers/googleVertex.js +3000 -1987
  257. package/dist/providers/groq.d.ts +33 -0
  258. package/dist/providers/groq.js +180 -0
  259. package/dist/providers/huggingFace.js +9 -8
  260. package/dist/providers/ideogram.d.ts +34 -0
  261. package/dist/providers/ideogram.js +183 -0
  262. package/dist/providers/index.d.ts +13 -0
  263. package/dist/providers/index.js +13 -0
  264. package/dist/providers/jina.d.ts +59 -0
  265. package/dist/providers/jina.js +217 -0
  266. package/dist/providers/llamaCpp.js +14 -46
  267. package/dist/providers/lmStudio.js +14 -47
  268. package/dist/providers/mistral.js +7 -7
  269. package/dist/providers/nvidiaNim.js +160 -19
  270. package/dist/providers/ollama.js +7 -7
  271. package/dist/providers/openAI.d.ts +22 -1
  272. package/dist/providers/openAI.js +181 -0
  273. package/dist/providers/openRouter.js +38 -22
  274. package/dist/providers/openaiCompatible.js +9 -8
  275. package/dist/providers/perplexity.d.ts +33 -0
  276. package/dist/providers/perplexity.js +178 -0
  277. package/dist/providers/recraft.d.ts +34 -0
  278. package/dist/providers/recraft.js +196 -0
  279. package/dist/providers/replicate.d.ts +75 -0
  280. package/dist/providers/replicate.js +402 -0
  281. package/dist/providers/stability.d.ts +37 -0
  282. package/dist/providers/stability.js +190 -0
  283. package/dist/providers/togetherAi.d.ts +33 -0
  284. package/dist/providers/togetherAi.js +175 -0
  285. package/dist/providers/voyage.d.ts +47 -0
  286. package/dist/providers/voyage.js +176 -0
  287. package/dist/providers/xai.d.ts +33 -0
  288. package/dist/providers/xai.js +171 -0
  289. package/dist/telemetry/index.d.ts +1 -1
  290. package/dist/telemetry/index.js +1 -1
  291. package/dist/telemetry/tracers.d.ts +19 -0
  292. package/dist/telemetry/tracers.js +19 -0
  293. package/dist/telemetry/withSpan.d.ts +35 -0
  294. package/dist/telemetry/withSpan.js +103 -0
  295. package/dist/types/aliases.d.ts +14 -0
  296. package/dist/types/avatar.d.ts +143 -0
  297. package/dist/types/avatar.js +19 -0
  298. package/dist/types/cli.d.ts +6 -0
  299. package/dist/types/common.d.ts +0 -3
  300. package/dist/types/conversation.d.ts +10 -3
  301. package/dist/types/generate.d.ts +76 -5
  302. package/dist/types/index.d.ts +6 -0
  303. package/dist/types/index.js +8 -0
  304. package/dist/types/memory.d.ts +96 -0
  305. package/dist/types/memory.js +22 -0
  306. package/dist/types/middleware.d.ts +27 -0
  307. package/dist/types/multimodal.d.ts +35 -2
  308. package/dist/types/music.d.ts +165 -0
  309. package/dist/types/music.js +20 -0
  310. package/dist/types/providers.d.ts +284 -3
  311. package/dist/types/replicate.d.ts +67 -0
  312. package/dist/types/replicate.js +9 -0
  313. package/dist/types/safeFetch.d.ts +15 -0
  314. package/dist/types/safeFetch.js +6 -0
  315. package/dist/types/stream.d.ts +8 -1
  316. package/dist/types/tools.d.ts +13 -0
  317. package/dist/types/video.d.ts +89 -0
  318. package/dist/types/video.js +14 -0
  319. package/dist/utils/avatarProcessor.d.ts +68 -0
  320. package/dist/utils/avatarProcessor.js +171 -0
  321. package/dist/utils/cloneOptions.d.ts +36 -0
  322. package/dist/utils/cloneOptions.js +61 -0
  323. package/dist/utils/lifecycleCallbacks.d.ts +56 -0
  324. package/dist/utils/lifecycleCallbacks.js +99 -0
  325. package/dist/utils/lifecycleTimeout.d.ts +25 -0
  326. package/dist/utils/lifecycleTimeout.js +38 -0
  327. package/dist/utils/logSanitize.d.ts +49 -0
  328. package/dist/utils/logSanitize.js +169 -0
  329. package/dist/utils/loggingFetch.d.ts +29 -0
  330. package/dist/utils/loggingFetch.js +59 -0
  331. package/dist/utils/messageBuilder.d.ts +10 -0
  332. package/dist/utils/messageBuilder.js +83 -30
  333. package/dist/utils/modelChoices.js +236 -3
  334. package/dist/utils/modelDetection.d.ts +11 -0
  335. package/dist/utils/modelDetection.js +27 -0
  336. package/dist/utils/musicProcessor.d.ts +67 -0
  337. package/dist/utils/musicProcessor.js +188 -0
  338. package/dist/utils/optionsConversion.js +3 -2
  339. package/dist/utils/parameterValidation.js +14 -4
  340. package/dist/utils/pricing.js +193 -0
  341. package/dist/utils/providerConfig.d.ts +55 -0
  342. package/dist/utils/providerConfig.js +224 -0
  343. package/dist/utils/providerHealth.js +7 -7
  344. package/dist/utils/safeFetch.d.ts +26 -0
  345. package/dist/utils/safeFetch.js +82 -0
  346. package/dist/utils/schemaConversion.d.ts +1 -1
  347. package/dist/utils/schemaConversion.js +59 -4
  348. package/dist/utils/sizeGuard.d.ts +34 -0
  349. package/dist/utils/sizeGuard.js +44 -0
  350. package/dist/utils/ssrfGuard.d.ts +52 -0
  351. package/dist/utils/ssrfGuard.js +410 -0
  352. package/dist/utils/tokenLimits.js +23 -32
  353. package/dist/utils/videoProcessor.d.ts +60 -0
  354. package/dist/utils/videoProcessor.js +200 -0
  355. package/dist/voice/providers/FishAudioTTS.d.ts +27 -0
  356. package/dist/voice/providers/FishAudioTTS.js +182 -0
  357. package/dist/workflow/core/ensembleExecutor.js +26 -9
  358. package/package.json +42 -8
@@ -5,7 +5,10 @@ import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
5
5
  import { MiddlewareFactory } from "../middleware/factory.js";
6
6
  import { ATTR, tracers } from "../telemetry/index.js";
7
7
  import { isAbortError } from "../utils/errorHandling.js";
8
+ import { hasLifecycleErrorFired, markLifecycleErrorFired, } from "../utils/lifecycleCallbacks.js";
9
+ import { resolveLifecycleTimeoutMs } from "../utils/lifecycleTimeout.js";
8
10
  import { logger } from "../utils/logger.js";
11
+ import { withTimeoutFn } from "../utils/async/withTimeout.js";
9
12
  import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
10
13
  import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
11
14
  import { getKeyCount, getKeysAsString } from "../utils/transformationUtils.js";
@@ -133,7 +136,14 @@ export class BaseProvider {
133
136
  provider: this.providerName,
134
137
  model: this.modelName,
135
138
  });
136
- return await this.executeFakeStreaming(options, analysisSchema);
139
+ // Note: executeFakeStreaming() owns its own catch that fires the
140
+ // consumer-supplied onError before re-throwing through
141
+ // handleProviderError(), so we do not need to wrap again here —
142
+ // doing so would route the error through handleProviderError()
143
+ // twice (and risk a double-fire onError without the shared
144
+ // lifecycle-fired WeakSet mark).
145
+ const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
146
+ return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
137
147
  }
138
148
  }
139
149
  // CRITICAL: Image generation models don't support real streaming
@@ -151,8 +161,11 @@ export class BaseProvider {
151
161
  model: this.modelName,
152
162
  reason: "Image generation requires fake streaming to yield image output",
153
163
  });
154
- // Skip real streaming, go directly to fake streaming
155
- return await this.executeFakeStreaming(options, analysisSchema);
164
+ // Skip real streaming, go directly to fake streaming.
165
+ // executeFakeStreaming() owns its own catch + lifecycle fire, so
166
+ // wrapping again here would double-route through handleProviderError().
167
+ const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
168
+ return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
156
169
  }
157
170
  // Central tool merge: Pre-merge base tools (MCP/built-in) with user-provided
158
171
  // tools (e.g. RAG tools) into options.tools. This way, every provider's
@@ -177,8 +190,14 @@ export class BaseProvider {
177
190
  provider: this.providerName,
178
191
  timestamp: Date.now(),
179
192
  });
180
- // If real streaming succeeds, return it (with tools support via Vercel AI SDK)
181
- return realStreamResult;
193
+ // Wire lifecycle callbacks (onChunk/onFinish/onError) on the user-
194
+ // facing StreamResult.stream. The AI-SDK lifecycle middleware only
195
+ // sees AI-SDK-internal chunks via streamText/wrapLanguageModel, so
196
+ // providers with custom HTTP streaming (Ollama, llama.cpp's /api,
197
+ // anything that doesn't go through streamText) bypass it. Wrapping
198
+ // here makes the callbacks fire for every provider, regardless of
199
+ // streaming implementation.
200
+ return this.wrapStreamWithLifecycleCallbacks(realStreamResult, options);
182
201
  }
183
202
  catch (realStreamError) {
184
203
  // Don't retry on terminal/abort errors — only fall back for
@@ -195,23 +214,178 @@ export class BaseProvider {
195
214
  errMsg.includes("quota") ||
196
215
  errMsg.includes("rate limit") ||
197
216
  errMsg.includes("authentication")) {
217
+ await this.fireLifecycleErrorCallback(options, realStreamError);
198
218
  throw this.handleProviderError(realStreamError);
199
219
  }
200
220
  logger.warn(`Real streaming failed for ${this.providerName}, falling back to fake streaming:`, {
201
221
  error: errMsg,
202
222
  timestamp: Date.now(),
203
223
  });
204
- // Fallback to fake streaming only if real streaming fails AND tools are enabled
224
+ // Fallback to fake streaming only if real streaming fails AND tools
225
+ // are enabled. executeFakeStreaming() owns its own catch + lifecycle
226
+ // fire, so a fake-streaming failure here surfaces through that path
227
+ // without needing an outer wrap (which would double-route through
228
+ // handleProviderError()).
205
229
  if (!options.disableTools && this.supportsTools()) {
206
- return await this.executeFakeStreaming(options, analysisSchema);
230
+ const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
231
+ return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
207
232
  }
208
233
  else {
234
+ // If real streaming failed and no tools are enabled, fire onError
235
+ // before re-throwing so consumer-supplied callbacks see the failure.
236
+ await this.fireLifecycleErrorCallback(options, realStreamError);
209
237
  // If real streaming failed and no tools are enabled, re-throw the original error
210
238
  logger.error(`Real streaming failed for ${this.providerName}:`, realStreamError);
211
239
  throw this.handleProviderError(realStreamError);
212
240
  }
213
241
  }
214
242
  }
243
+ /**
244
+ * Wrap a StreamResult with consumer-facing lifecycle callbacks.
245
+ *
246
+ * `options.onChunk`, `options.onFinish`, `options.onError` are translated
247
+ * by NeuroLink.applyStreamLifecycleMiddleware() into
248
+ * `options.middleware.middlewareConfig.lifecycle.config`. The AI SDK's
249
+ * lifecycle middleware only sees these via the wrapped LanguageModel —
250
+ * which is bypassed by providers that stream via raw HTTP fetch (Ollama
251
+ * over /api/chat, custom OpenAI-compatible servers, etc). Wrapping the
252
+ * user-facing stream here ensures the callbacks fire regardless of the
253
+ * underlying transport.
254
+ */
255
+ wrapStreamWithLifecycleCallbacks(result, options) {
256
+ const lifecycle = options
257
+ ?.middleware?.middlewareConfig?.lifecycle?.config;
258
+ if (!lifecycle?.onChunk && !lifecycle?.onFinish && !lifecycle?.onError) {
259
+ return result;
260
+ }
261
+ const { onChunk, onFinish, onError } = lifecycle;
262
+ const startTime = Date.now();
263
+ const originalStream = result.stream;
264
+ // Lifecycle callbacks are awaited with a bounded deadline so callers
265
+ // observe ordering guarantees (onChunk/onFinish/onError have all
266
+ // settled by the time `for await` returns / throws). The previous
267
+ // fire-and-forget pattern left async work running past stream close,
268
+ // creating races during cleanup. The deadline is configurable via
269
+ // `lifecycle.timeoutMs` (per-call) or `NEUROLINK_LIFECYCLE_TIMEOUT_MS`
270
+ // (env / CLI surface) — see `resolveLifecycleTimeoutMs`.
271
+ const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
272
+ const safeFire = async (fn, label) => {
273
+ try {
274
+ await withTimeoutFn(async () => {
275
+ const ret = fn();
276
+ if (ret && typeof ret.then === "function") {
277
+ await ret;
278
+ }
279
+ }, timeoutMs, `[lifecycle] ${label} callback exceeded ${timeoutMs}ms`);
280
+ }
281
+ catch (e) {
282
+ logger.warn(`[lifecycle] ${label} callback error:`, e);
283
+ }
284
+ };
285
+ const wrappedStream = (async function* () {
286
+ let accumulated = "";
287
+ let seq = 0;
288
+ try {
289
+ for await (const chunk of originalStream) {
290
+ const textPart = chunk &&
291
+ typeof chunk === "object" &&
292
+ "content" in chunk &&
293
+ typeof chunk.content === "string"
294
+ ? chunk.content
295
+ : "";
296
+ // Only fire onChunk for actual text deltas. Non-text chunks
297
+ // (image, tts_audio) would otherwise produce empty text-delta
298
+ // events that consumers must filter out themselves.
299
+ if (onChunk && textPart) {
300
+ const currentSeq = seq++;
301
+ await safeFire(() => onChunk({
302
+ type: "text-delta",
303
+ textDelta: textPart,
304
+ sequenceNumber: currentSeq,
305
+ }), "onChunk");
306
+ }
307
+ if (textPart) {
308
+ accumulated += textPart;
309
+ }
310
+ yield chunk;
311
+ }
312
+ if (onFinish) {
313
+ await safeFire(() => onFinish({
314
+ text: accumulated,
315
+ duration: Date.now() - startTime,
316
+ }), "onFinish");
317
+ }
318
+ }
319
+ catch (error) {
320
+ const err = error instanceof Error ? error : new Error(String(error));
321
+ if (onError && !hasLifecycleErrorFired(err)) {
322
+ // Mark before firing so a higher layer that also routes through
323
+ // fireLifecycleErrorCallback (or its own lifecycle wrapper) with
324
+ // the same error instance won't double-fire onError. Mirrors the
325
+ // pattern in fireLifecycleErrorCallback below.
326
+ markLifecycleErrorFired(err);
327
+ await safeFire(() => onError({
328
+ error: err,
329
+ duration: Date.now() - startTime,
330
+ recoverable: false,
331
+ }), "onError");
332
+ }
333
+ throw err;
334
+ }
335
+ })();
336
+ return { ...result, stream: wrappedStream };
337
+ }
338
+ /**
339
+ * Fire the consumer-supplied onError callback before throwing. Used in
340
+ * error branches inside stream() that re-throw without emitting any
341
+ * stream chunks (which would otherwise hide the failure from a caller
342
+ * that supplied `onError`).
343
+ */
344
+ async fireLifecycleErrorCallback(options, error) {
345
+ const err = error instanceof Error ? error : new Error(String(error));
346
+ // The AI-SDK lifecycle middleware stamps errors it has already
347
+ // surfaced (Symbol.for("neurolink.onErrorFired"); see
348
+ // utils/lifecycleCallbacks.ts). Skip here so consumers don't receive
349
+ // duplicate onError events for the same failure.
350
+ if (hasLifecycleErrorFired(err)) {
351
+ return;
352
+ }
353
+ const lifecycle = options
354
+ ?.middleware?.middlewareConfig?.lifecycle?.config;
355
+ const onError = lifecycle?.onError;
356
+ if (!onError) {
357
+ return;
358
+ }
359
+ // Set the marker before invoking so a sync re-entry (or a concurrent
360
+ // dispatch path) can't double-fire onError for the same error object.
361
+ markLifecycleErrorFired(err);
362
+ // Fire the consumer's onError with a bounded deadline AND await its
363
+ // completion — callers can now `await fireLifecycleErrorCallback(...)`
364
+ // to guarantee the consumer's async onError settles before the
365
+ // surrounding stream() / executeFakeStreaming() rethrows. Deadline is
366
+ // configurable via `lifecycle.timeoutMs` or the
367
+ // `NEUROLINK_LIFECYCLE_TIMEOUT_MS` env var.
368
+ const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
369
+ try {
370
+ await withTimeoutFn(async () => {
371
+ // Capturing `onError` into a const above means TypeScript sees the
372
+ // narrowing past the early-return, so no non-null assertion needed
373
+ // here — and the callback identity is stable across the timeout
374
+ // boundary even if the caller mutates `lifecycle.onError` mid-call.
375
+ const ret = onError({
376
+ error: err,
377
+ duration: 0,
378
+ recoverable: false,
379
+ });
380
+ if (ret && typeof ret.then === "function") {
381
+ await ret;
382
+ }
383
+ }, timeoutMs, `[lifecycle] onError callback exceeded ${timeoutMs}ms`);
384
+ }
385
+ catch (e) {
386
+ logger.warn("[lifecycle] onError callback error:", e);
387
+ }
388
+ }
215
389
  /**
216
390
  * Execute fake streaming - extracted method for reusability
217
391
  */
@@ -347,6 +521,14 @@ export class BaseProvider {
347
521
  }
348
522
  catch (error) {
349
523
  logger.error(`Fake streaming fallback failed for ${this.providerName}:`, error);
524
+ // Fire the consumer-supplied onError BEFORE re-throwing through
525
+ // handleProviderError() so callers using onChunk/onFinish/onError
526
+ // get notified even when fake-streaming setup (message build, image
527
+ // adapter, etc.) fails synchronously. Awaited so the consumer's
528
+ // async onError fully settles before we rethrow. The shared
529
+ // lifecycle-fired WeakSet mark prevents double-fire if a wrapper
530
+ // layer also handles this.
531
+ await this.fireLifecycleErrorCallback(options, error);
350
532
  throw this.handleProviderError(error);
351
533
  }
352
534
  }
@@ -694,7 +876,15 @@ export class BaseProvider {
694
876
  }, options, startTime);
695
877
  }
696
878
  async executeStandardGenerateFlow(options, startTime, model, messages, tools) {
697
- const timeoutController = createTimeoutController(options.timeout, this.providerName, "generate");
879
+ // Apply a defensive default timeout (3 min) when the caller didn't pass
880
+ // one. Without this guard, AI SDK's generateText() will wait forever on
881
+ // an upstream that accepts the connection but never produces a response
882
+ // (observed against the litellm gateway when a request triggers the
883
+ // team-access denial path — connection stays open, no response is sent,
884
+ // and the matrix test hangs the entire suite). Callers can still pass
885
+ // a larger value (e.g. video generation passes 10 min).
886
+ const effectiveTimeout = options.timeout ?? 180_000;
887
+ const timeoutController = createTimeoutController(effectiveTimeout, this.providerName, "generate");
698
888
  const composedSignal = composeAbortSignals(options.abortSignal, timeoutController?.controller.signal);
699
889
  const composedOptions = composedSignal
700
890
  ? { ...options, abortSignal: composedSignal }
@@ -802,6 +992,11 @@ export class BaseProvider {
802
992
  analytics: result.analytics,
803
993
  evaluation: result.evaluation,
804
994
  audio: result.audio,
995
+ // Forward reasoning fields populated by GenerationHandler from AI-SDK
996
+ // reasoning parts (DeepSeek `reasoning_content`, Anthropic thinking,
997
+ // Gemini thought parts, OpenAI o1).
998
+ reasoning: result.reasoning,
999
+ reasoningTokens: result.reasoningTokens,
805
1000
  };
806
1001
  }
807
1002
  /**
@@ -828,8 +1023,9 @@ export class BaseProvider {
828
1023
  textLength: text.length,
829
1024
  });
830
1025
  throw new Error(`Embedding generation is not supported by the ${this.providerName} provider. ` +
831
- `Supported providers: openai, vertex/google, bedrock. ` +
1026
+ `Supported providers: openai, vertex/google, bedrock, cohere, voyage, jina. ` +
832
1027
  `Use an embedding model like text-embedding-3-small (OpenAI), text-embedding-004 (Vertex), ` +
1028
+ `embed-english-v3.0 (Cohere), voyage-3 (Voyage), jina-embeddings-v3 (Jina), ` +
833
1029
  `or amazon.titan-embed-text-v2:0 (Bedrock).`);
834
1030
  }
835
1031
  /**
@@ -849,9 +1045,10 @@ export class BaseProvider {
849
1045
  count: texts.length,
850
1046
  });
851
1047
  throw new Error(`Batch embedding generation is not supported by the ${this.providerName} provider. ` +
852
- `Supported providers: openai, googleAiStudio, vertex/google, bedrock. ` +
1048
+ `Supported providers: openai, googleAiStudio, vertex/google, bedrock, cohere, voyage, jina. ` +
853
1049
  `Use an embedding model like text-embedding-3-small (OpenAI), gemini-embedding-001 (Google AI), ` +
854
- `text-embedding-004 (Vertex), or amazon.titan-embed-text-v2:0 (Bedrock).`);
1050
+ `text-embedding-004 (Vertex), embed-english-v3.0 (Cohere), voyage-3 (Voyage), ` +
1051
+ `jina-embeddings-v3 (Jina), or amazon.titan-embed-text-v2:0 (Bedrock).`);
855
1052
  }
856
1053
  /**
857
1054
  * Get the default embedding model for this provider
@@ -1005,6 +1202,15 @@ export class BaseProvider {
1005
1202
  : new DOMException("The operation was aborted", "AbortError");
1006
1203
  }
1007
1204
  const formatted = this.formatProviderError(error);
1205
+ // Preserve the lifecycle-fired mark across formatting:
1206
+ // fireLifecycleErrorCallback() marks the ORIGINAL error in the shared
1207
+ // WeakSet, but formatProviderError() typically returns a new Error
1208
+ // instance. Re-mark the formatted error so a higher layer (e.g.
1209
+ // NeuroLink.stream()'s top-level catch + applyStreamLifecycleMiddleware)
1210
+ // doesn't fire onError a second time for the same failure.
1211
+ if (hasLifecycleErrorFired(error)) {
1212
+ markLifecycleErrorFired(formatted);
1213
+ }
1008
1214
  // P3 fix: Classify error and set error.type on the active OTel span
1009
1215
  try {
1010
1216
  const activeSpan = trace.getSpan(context.active());
@@ -3,6 +3,17 @@
3
3
  * Single source of truth for all default values
4
4
  */
5
5
  export declare const IMAGE_GENERATION_MODELS: string[];
6
+ /**
7
+ * Boundary-aware test for whether `modelName` represents an image-generation
8
+ * model.
9
+ *
10
+ * Matches when the model name **equals** an entry in
11
+ * {@link IMAGE_GENERATION_MODELS} or contains the entry as a prefix followed
12
+ * by a separator (`-`, `_`, `:`, `/`, `.`) or end-of-string. This avoids
13
+ * accidental matches such as a custom fine-tune named `"my-V_1"` matching
14
+ * `"V_1"` via plain substring inclusion.
15
+ */
16
+ export declare function isImageGenerationModel(modelName: string | undefined): boolean;
6
17
  export declare const PDF_IMAGE_GENERATION_MODELS: string[];
7
18
  export declare const GLOBAL_LOCATION_MODELS: string[];
8
19
  export declare const DEFAULT_MAX_TOKENS: undefined;
@@ -3,12 +3,80 @@
3
3
  * Single source of truth for all default values
4
4
  */
5
5
  // Image Generation Model Identifiers
6
- // Used to detect if a model is an image generation model (not text generation)
6
+ // Used to detect if a model is an image generation model (not text generation).
7
+ // `isImageGenerationModel(name)` (below) does boundary-aware matching:
8
+ // the modelName must equal an entry OR contain an entry followed by a
9
+ // non-alphanumeric character (`-`, `_`, `:`, `/`, `.`, end-of-string).
10
+ // This prevents short identifiers like `"V_1"` or `"gpt-image-1"` from
11
+ // accidentally matching unrelated model names that happen to embed them.
7
12
  export const IMAGE_GENERATION_MODELS = [
13
+ // Gemini image models (Vertex AI, Google AI Studio)
8
14
  "gemini-3-pro-image-preview",
9
15
  "gemini-2.5-flash-image",
10
16
  "gemini-3.1-flash-image-preview",
17
+ // Stability AI (direct provider — image-only)
18
+ "stable-image-ultra",
19
+ "stable-image-core",
20
+ "sd3.5-large",
21
+ "sd3.5-large-turbo",
22
+ "sd3.5-medium",
23
+ // Ideogram (direct provider — image-only). API uses model-version
24
+ // identifiers like "V_1", "V_1_TURBO", "V_2", "V_2_TURBO", "V_2A",
25
+ // "V_2A_TURBO", "V_3". Keep prefixes that won't collide with generic
26
+ // text-model names.
27
+ "V_1",
28
+ "V_1_TURBO",
29
+ "V_2",
30
+ "V_2_TURBO",
31
+ "V_2A",
32
+ "V_2A_TURBO",
33
+ "V_3",
34
+ // Recraft (direct provider — image-only)
35
+ "recraftv3",
36
+ "recraftv2",
37
+ // OpenAI image models (DALL-E + GPT-Image). Substring match keeps
38
+ // version variants like "dall-e-3" / "dall-e-2" routed correctly.
39
+ "gpt-image-1",
40
+ "dall-e-3",
41
+ "dall-e-2",
42
+ // Replicate-hosted image models (matched on model slug prefix).
43
+ // Replicate model slugs are passed through as-is via the LLM
44
+ // provider; image-gen models trigger the image-gen path.
45
+ "black-forest-labs/flux",
46
+ "stability-ai/sdxl",
47
+ "stability-ai/stable-diffusion",
11
48
  ];
49
+ /**
50
+ * Boundary-aware test for whether `modelName` represents an image-generation
51
+ * model.
52
+ *
53
+ * Matches when the model name **equals** an entry in
54
+ * {@link IMAGE_GENERATION_MODELS} or contains the entry as a prefix followed
55
+ * by a separator (`-`, `_`, `:`, `/`, `.`) or end-of-string. This avoids
56
+ * accidental matches such as a custom fine-tune named `"my-V_1"` matching
57
+ * `"V_1"` via plain substring inclusion.
58
+ */
59
+ export function isImageGenerationModel(modelName) {
60
+ if (!modelName) {
61
+ return false;
62
+ }
63
+ for (const entry of IMAGE_GENERATION_MODELS) {
64
+ if (modelName === entry) {
65
+ return true;
66
+ }
67
+ const idx = modelName.indexOf(entry);
68
+ if (idx === -1) {
69
+ continue;
70
+ }
71
+ const before = idx === 0 ? "" : modelName[idx - 1];
72
+ const after = modelName[idx + entry.length] ?? "";
73
+ const isBoundary = (ch) => ch === "" || /[-_:./@]/.test(ch);
74
+ if (isBoundary(before) && isBoundary(after)) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ }
12
80
  // PDF Image Generation Models
13
81
  // Models that support generating images from PDFs
14
82
  export const PDF_IMAGE_GENERATION_MODELS = [
@@ -106,6 +106,16 @@ export class MessageBuilder {
106
106
  fileRegistry: options.fileRegistry,
107
107
  };
108
108
  messages = await buildMultimodalMessagesArray(multimodalOptions, this.providerName, this.modelName);
109
+ // Propagate any systemPrompt augmentation (e.g. inline-file
110
+ // handling guidance from processUnifiedFilesArray) back to the
111
+ // caller's options. Providers like GoogleVertex's native
112
+ // @google/genai stream path read `options.systemPrompt` directly
113
+ // — without this propagation the augmentation lives only on the
114
+ // local `multimodalOptions` clone and never reaches the model.
115
+ if (multimodalOptions.systemPrompt &&
116
+ multimodalOptions.systemPrompt !== options.systemPrompt) {
117
+ options.systemPrompt = multimodalOptions.systemPrompt;
118
+ }
109
119
  }
110
120
  else {
111
121
  if (process.env.NEUROLINK_DEBUG === "true") {
@@ -214,6 +224,16 @@ export class MessageBuilder {
214
224
  fileRegistry: options.fileRegistry,
215
225
  };
216
226
  messages = await buildMultimodalMessagesArray(multimodalOptions, this.providerName, this.modelName);
227
+ // Propagate any systemPrompt augmentation (e.g. inline-file
228
+ // handling guidance from processUnifiedFilesArray) back to the
229
+ // caller's options. Providers like GoogleVertex's native
230
+ // @google/genai stream path read `options.systemPrompt` directly
231
+ // — without this propagation the augmentation lives only on the
232
+ // local `multimodalOptions` clone and never reaches the model.
233
+ if (multimodalOptions.systemPrompt &&
234
+ multimodalOptions.systemPrompt !== options.systemPrompt) {
235
+ options.systemPrompt = multimodalOptions.systemPrompt;
236
+ }
217
237
  }
218
238
  else {
219
239
  if (process.env.NEUROLINK_DEBUG === "true") {
@@ -951,6 +951,12 @@ User message: "${userMessage}"`;
951
951
  provider: this.config.summarizationProvider || "vertex",
952
952
  model: this.config.summarizationModel || "gemini-2.5-flash",
953
953
  disableTools: true, // Title generation doesn't need tools — saves ~600 tokens of tool descriptions
954
+ // A 20-25 letter title is well under 64 tokens; capping prevents
955
+ // Vertex 400 INVALID_ARGUMENT — Gemini 2.5 Flash on the native
956
+ // @google/genai SDK rejects requests with no maxOutputTokens cap
957
+ // when the prompt is short, which silently broke every
958
+ // `conversationMemory.enabled + context` test path.
959
+ maxTokens: 64,
954
960
  });
955
961
  // Clean up the generated title
956
962
  let title = result.content?.trim() || "New Conversation";
@@ -12,6 +12,8 @@ export { BatchEvaluator } from "./BatchEvaluator.js";
12
12
  export { EvaluationAggregator } from "./EvaluationAggregator.js";
13
13
  export { EvaluatorFactory, getEvaluatorFactory } from "./EvaluatorFactory.js";
14
14
  export { EvaluatorRegistry, getEvaluatorRegistry, } from "./EvaluatorRegistry.js";
15
+ export { RAGASEvaluator } from "./ragasEvaluator.js";
16
+ export { RetryManager } from "./retryManager.js";
15
17
  /**
16
18
  * A centralized class for performing response evaluations. It supports different
17
19
  * evaluation strategies, with RAGAS-style model-based evaluation as the default.
@@ -19,6 +19,10 @@ export { BatchEvaluator } from "./BatchEvaluator.js";
19
19
  export { EvaluationAggregator } from "./EvaluationAggregator.js";
20
20
  export { EvaluatorFactory, getEvaluatorFactory } from "./EvaluatorFactory.js";
21
21
  export { EvaluatorRegistry, getEvaluatorRegistry, } from "./EvaluatorRegistry.js";
22
+ // Re-export internal RAGAS classes so callers (and the evaluation test
23
+ // suite) can instantiate them directly from the public surface.
24
+ export { RAGASEvaluator } from "./ragasEvaluator.js";
25
+ export { RetryManager } from "./retryManager.js";
22
26
  /**
23
27
  * A centralized class for performing response evaluations. It supports different
24
28
  * evaluation strategies, with RAGAS-style model-based evaluation as the default.
@@ -60,11 +60,17 @@ export class ProviderFactory {
60
60
  }
61
61
  // Map registered provider names to NeurolinkCredentials keys.
62
62
  // Most names match (openai, anthropic, vertex, bedrock, etc.)
63
- // but some differ (google-ai googleAiStudio, openai-compatible openaiCompatible).
63
+ // but every kebab-case provider whose canonical credentials key is
64
+ // camelCase MUST be mapped here — otherwise per-call credential
65
+ // overrides silently get dropped (the factory looks up
66
+ // credentials["lm-studio"] which is undefined while the user wrote
67
+ // credentials.lmStudio).
64
68
  const credentialKeyMap = {
65
69
  "google-ai": "googleAiStudio",
66
70
  "openai-compatible": "openaiCompatible",
67
71
  huggingface: "huggingFace",
72
+ "lm-studio": "lmStudio",
73
+ "nvidia-nim": "nvidiaNim",
68
74
  };
69
75
  const credKey = credentialKeyMap[normalizedName] ?? normalizedName;
70
76
  // Extract provider-scoped credential slice (e.g. credentials.openai for OpenAI)