@llumiverse/drivers 1.2.0 → 1.4.0-dev.20260629.090753Z

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 (403) hide show
  1. package/lib/{types/adobe → adobe}/firefly.d.ts +2 -1
  2. package/lib/adobe/firefly.d.ts.map +1 -0
  3. package/lib/adobe/firefly.js +120 -0
  4. package/lib/adobe/firefly.js.map +1 -0
  5. package/lib/anthropic/index.d.ts +23 -0
  6. package/lib/anthropic/index.d.ts.map +1 -0
  7. package/lib/anthropic/index.js +68 -0
  8. package/lib/anthropic/index.js.map +1 -0
  9. package/lib/{types/azure → azure}/azure_foundry.d.ts +9 -7
  10. package/lib/azure/azure_foundry.d.ts.map +1 -0
  11. package/lib/{esm/azure → azure}/azure_foundry.js +138 -124
  12. package/lib/azure/azure_foundry.js.map +1 -0
  13. package/lib/{types/bedrock → bedrock}/converse.d.ts +2 -2
  14. package/lib/bedrock/converse.d.ts.map +1 -0
  15. package/lib/{esm/bedrock → bedrock}/converse.js +86 -79
  16. package/lib/bedrock/converse.js.map +1 -0
  17. package/lib/bedrock/embeddings.d.ts +4 -0
  18. package/lib/bedrock/embeddings.d.ts.map +1 -0
  19. package/lib/bedrock/embeddings.js +359 -0
  20. package/lib/bedrock/embeddings.js.map +1 -0
  21. package/lib/{types/bedrock → bedrock}/index.d.ts +33 -9
  22. package/lib/bedrock/index.d.ts.map +1 -0
  23. package/lib/{esm/bedrock → bedrock}/index.js +599 -324
  24. package/lib/bedrock/index.js.map +1 -0
  25. package/lib/{types/bedrock → bedrock}/nova-image-payload.d.ts +5 -5
  26. package/lib/bedrock/nova-image-payload.d.ts.map +1 -0
  27. package/lib/{esm/bedrock → bedrock}/nova-image-payload.js +31 -36
  28. package/lib/bedrock/nova-image-payload.js.map +1 -0
  29. package/lib/{types/bedrock → bedrock}/payloads.d.ts +1 -1
  30. package/lib/bedrock/payloads.d.ts.map +1 -0
  31. package/lib/{cjs/bedrock → bedrock}/payloads.js.map +1 -1
  32. package/lib/{types/bedrock → bedrock}/s3.d.ts +3 -2
  33. package/lib/bedrock/s3.d.ts.map +1 -0
  34. package/lib/{esm/bedrock → bedrock}/s3.js +27 -23
  35. package/lib/bedrock/s3.js.map +1 -0
  36. package/lib/{types/bedrock → bedrock}/twelvelabs.d.ts +8 -9
  37. package/lib/bedrock/twelvelabs.d.ts.map +1 -0
  38. package/lib/{esm/bedrock → bedrock}/twelvelabs.js +17 -21
  39. package/lib/bedrock/twelvelabs.js.map +1 -0
  40. package/lib/{types/groq → groq}/index.d.ts +6 -4
  41. package/lib/groq/index.d.ts.map +1 -0
  42. package/lib/{esm/groq → groq}/index.js +72 -39
  43. package/lib/groq/index.js.map +1 -0
  44. package/lib/{types/huggingface_ie.d.ts → huggingface_ie.d.ts} +4 -3
  45. package/lib/huggingface_ie.d.ts.map +1 -0
  46. package/lib/{esm/huggingface_ie.js → huggingface_ie.js} +32 -31
  47. package/lib/huggingface_ie.js.map +1 -0
  48. package/lib/index.d.ts +16 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +16 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/{types/mistral → mistral}/index.d.ts +6 -5
  53. package/lib/mistral/index.d.ts.map +1 -0
  54. package/lib/{esm/mistral → mistral}/index.js +66 -38
  55. package/lib/mistral/index.js.map +1 -0
  56. package/lib/{types/mistral → mistral}/types.d.ts +1 -0
  57. package/lib/mistral/types.d.ts.map +1 -0
  58. package/lib/mistral/types.js.map +1 -0
  59. package/lib/{types/openai → openai}/azure_openai.d.ts +5 -4
  60. package/lib/openai/azure_openai.d.ts.map +1 -0
  61. package/lib/{esm/openai → openai}/azure_openai.js +17 -14
  62. package/lib/openai/azure_openai.js.map +1 -0
  63. package/lib/openai/drivers.d.ts +4 -0
  64. package/lib/openai/drivers.d.ts.map +1 -0
  65. package/lib/openai/drivers.js +9 -0
  66. package/lib/openai/drivers.js.map +1 -0
  67. package/lib/{types/openai → openai}/index.d.ts +17 -5
  68. package/lib/openai/index.d.ts.map +1 -0
  69. package/lib/{esm/openai → openai}/index.js +254 -148
  70. package/lib/openai/index.js.map +1 -0
  71. package/lib/{types/openai → openai}/openai.d.ts +3 -3
  72. package/lib/openai/openai.d.ts.map +1 -0
  73. package/lib/openai/openai.js +15 -0
  74. package/lib/openai/openai.js.map +1 -0
  75. package/lib/{types/openai → openai}/openai_compatible.d.ts +3 -3
  76. package/lib/openai/openai_compatible.d.ts.map +1 -0
  77. package/lib/{esm/openai → openai}/openai_compatible.js +14 -11
  78. package/lib/openai/openai_compatible.js.map +1 -0
  79. package/lib/{types/openai → openai}/openai_format.d.ts +3 -2
  80. package/lib/openai/openai_format.d.ts.map +1 -0
  81. package/lib/{esm/openai → openai}/openai_format.js +66 -24
  82. package/lib/openai/openai_format.js.map +1 -0
  83. package/lib/{types/replicate.d.ts → replicate.d.ts} +3 -2
  84. package/lib/replicate.d.ts.map +1 -0
  85. package/lib/{esm/replicate.js → replicate.js} +59 -49
  86. package/lib/replicate.js.map +1 -0
  87. package/lib/shared/claude-messages.d.ts +99 -0
  88. package/lib/shared/claude-messages.d.ts.map +1 -0
  89. package/lib/shared/claude-messages.js +869 -0
  90. package/lib/shared/claude-messages.js.map +1 -0
  91. package/lib/{types/shared → shared}/claude-thinking.d.ts +1 -1
  92. package/lib/shared/claude-thinking.d.ts.map +1 -0
  93. package/lib/{esm/shared → shared}/claude-thinking.js +5 -7
  94. package/lib/shared/claude-thinking.js.map +1 -0
  95. package/lib/shared/debug-prompt.d.ts +5 -0
  96. package/lib/shared/debug-prompt.d.ts.map +1 -0
  97. package/lib/shared/debug-prompt.js +25 -0
  98. package/lib/shared/debug-prompt.js.map +1 -0
  99. package/lib/{types/test-driver → test-driver}/TestErrorCompletionStream.d.ts +1 -1
  100. package/lib/test-driver/TestErrorCompletionStream.d.ts.map +1 -0
  101. package/lib/test-driver/TestErrorCompletionStream.js +16 -0
  102. package/lib/test-driver/TestErrorCompletionStream.js.map +1 -0
  103. package/lib/{types/test-driver → test-driver}/TestValidationErrorCompletionStream.d.ts +1 -1
  104. package/lib/test-driver/TestValidationErrorCompletionStream.d.ts.map +1 -0
  105. package/lib/{esm/test-driver → test-driver}/TestValidationErrorCompletionStream.js +4 -4
  106. package/lib/test-driver/TestValidationErrorCompletionStream.js.map +1 -0
  107. package/lib/{types/test-driver → test-driver}/index.d.ts +3 -3
  108. package/lib/test-driver/index.d.ts.map +1 -0
  109. package/lib/{esm/test-driver → test-driver}/index.js +20 -20
  110. package/lib/test-driver/index.js.map +1 -0
  111. package/lib/{types/test-driver → test-driver}/utils.d.ts +1 -1
  112. package/lib/test-driver/utils.d.ts.map +1 -0
  113. package/lib/{esm/test-driver → test-driver}/utils.js +4 -4
  114. package/lib/test-driver/utils.js.map +1 -0
  115. package/lib/togetherai/index.d.ts +15 -0
  116. package/lib/togetherai/index.d.ts.map +1 -0
  117. package/lib/togetherai/index.js +54 -0
  118. package/lib/togetherai/index.js.map +1 -0
  119. package/lib/{types/togetherai → togetherai}/interfaces.d.ts +1 -1
  120. package/lib/togetherai/interfaces.d.ts.map +1 -0
  121. package/lib/{cjs/watsonx → togetherai}/interfaces.js.map +1 -1
  122. package/lib/vertexai/debug.d.ts +2 -0
  123. package/lib/vertexai/debug.d.ts.map +1 -0
  124. package/lib/{esm/vertexai → vertexai}/debug.js +1 -1
  125. package/lib/vertexai/debug.js.map +1 -0
  126. package/lib/vertexai/embeddings/embed-legacy-multimodal.d.ts +9 -0
  127. package/lib/vertexai/embeddings/embed-legacy-multimodal.d.ts.map +1 -0
  128. package/lib/vertexai/embeddings/embed-legacy-multimodal.js +141 -0
  129. package/lib/vertexai/embeddings/embed-legacy-multimodal.js.map +1 -0
  130. package/lib/vertexai/embeddings/embed.d.ts +13 -0
  131. package/lib/vertexai/embeddings/embed.d.ts.map +1 -0
  132. package/lib/vertexai/embeddings/embed.js +162 -0
  133. package/lib/vertexai/embeddings/embed.js.map +1 -0
  134. package/lib/vertexai/embeddings/source-utils.d.ts +9 -0
  135. package/lib/vertexai/embeddings/source-utils.d.ts.map +1 -0
  136. package/lib/vertexai/embeddings/source-utils.js +18 -0
  137. package/lib/vertexai/embeddings/source-utils.js.map +1 -0
  138. package/lib/{types/vertexai → vertexai}/index.d.ts +31 -19
  139. package/lib/vertexai/index.d.ts.map +1 -0
  140. package/lib/{esm/vertexai → vertexai}/index.js +221 -159
  141. package/lib/vertexai/index.js.map +1 -0
  142. package/lib/vertexai/models/claude.d.ts +16 -0
  143. package/lib/vertexai/models/claude.d.ts.map +1 -0
  144. package/lib/vertexai/models/claude.js +65 -0
  145. package/lib/vertexai/models/claude.js.map +1 -0
  146. package/lib/{types/vertexai → vertexai}/models/gemini.d.ts +29 -5
  147. package/lib/vertexai/models/gemini.d.ts.map +1 -0
  148. package/lib/{esm/vertexai → vertexai}/models/gemini.js +255 -127
  149. package/lib/vertexai/models/gemini.js.map +1 -0
  150. package/lib/{types/vertexai → vertexai}/models/imagen.d.ts +12 -11
  151. package/lib/vertexai/models/imagen.d.ts.map +1 -0
  152. package/lib/{esm/vertexai → vertexai}/models/imagen.js +74 -47
  153. package/lib/vertexai/models/imagen.js.map +1 -0
  154. package/lib/{types/vertexai → vertexai}/models/llama.d.ts +4 -4
  155. package/lib/vertexai/models/llama.d.ts.map +1 -0
  156. package/lib/{esm/vertexai → vertexai}/models/llama.js +37 -33
  157. package/lib/vertexai/models/llama.js.map +1 -0
  158. package/lib/vertexai/models.d.ts +21 -0
  159. package/lib/vertexai/models.d.ts.map +1 -0
  160. package/lib/{esm/vertexai → vertexai}/models.js +12 -9
  161. package/lib/vertexai/models.js.map +1 -0
  162. package/lib/{types/watsonx → watsonx}/index.d.ts +4 -3
  163. package/lib/watsonx/index.d.ts.map +1 -0
  164. package/lib/{esm/watsonx → watsonx}/index.js +69 -41
  165. package/lib/watsonx/index.js.map +1 -0
  166. package/lib/watsonx/interfaces.d.ts.map +1 -0
  167. package/lib/{esm/watsonx → watsonx}/interfaces.js.map +1 -1
  168. package/lib/{types/xai → xai}/index.d.ts +4 -4
  169. package/lib/xai/index.d.ts.map +1 -0
  170. package/lib/{esm/xai → xai}/index.js +22 -18
  171. package/lib/xai/index.js.map +1 -0
  172. package/package.json +88 -36
  173. package/src/adobe/firefly.ts +60 -43
  174. package/src/anthropic/index.ts +121 -0
  175. package/src/azure/azure_foundry.ts +210 -165
  176. package/src/bedrock/converse.ts +124 -101
  177. package/src/bedrock/embeddings.test.ts +508 -0
  178. package/src/bedrock/embeddings.ts +517 -0
  179. package/src/bedrock/error-handling.test.ts +62 -14
  180. package/src/bedrock/index.ts +832 -466
  181. package/src/bedrock/nova-image-payload.ts +98 -91
  182. package/src/bedrock/payloads.ts +9 -9
  183. package/src/bedrock/s3.test.ts +39 -0
  184. package/src/bedrock/s3.ts +57 -38
  185. package/src/bedrock/streaming-tool-use.test.ts +86 -69
  186. package/src/bedrock/twelvelabs.ts +35 -32
  187. package/src/groq/index.ts +143 -60
  188. package/src/http-timeout-wiring.test.ts +263 -0
  189. package/src/huggingface_ie.ts +45 -61
  190. package/src/index.ts +15 -15
  191. package/src/mistral/index.ts +97 -48
  192. package/src/mistral/types.ts +13 -12
  193. package/src/openai/azure_openai.ts +35 -27
  194. package/src/openai/drivers.ts +9 -0
  195. package/src/openai/error-handling.test.ts +308 -113
  196. package/src/openai/index.ts +389 -254
  197. package/src/openai/openai.ts +6 -13
  198. package/src/openai/openai_compatible.ts +35 -25
  199. package/src/openai/openai_format.ts +90 -40
  200. package/src/replicate.ts +108 -86
  201. package/src/shared/claude-messages.test.ts +37 -0
  202. package/src/shared/claude-messages.ts +1085 -0
  203. package/src/shared/claude-thinking.ts +6 -12
  204. package/src/shared/debug-prompt.ts +28 -0
  205. package/src/test-driver/TestErrorCompletionStream.ts +9 -10
  206. package/src/test-driver/TestValidationErrorCompletionStream.ts +9 -10
  207. package/src/test-driver/index.ts +43 -27
  208. package/src/test-driver/utils.ts +8 -8
  209. package/src/togetherai/index.test.ts +32 -0
  210. package/src/togetherai/index.ts +64 -128
  211. package/src/togetherai/interfaces.ts +5 -5
  212. package/src/vertexai/debug.ts +3 -3
  213. package/src/vertexai/embeddings/embed-legacy-multimodal.ts +211 -0
  214. package/src/vertexai/embeddings/embed.ts +206 -0
  215. package/src/vertexai/embeddings/embeddings.test.ts +497 -0
  216. package/src/vertexai/embeddings/source-utils.test.ts +54 -0
  217. package/src/vertexai/embeddings/source-utils.ts +29 -0
  218. package/src/vertexai/index.ts +339 -253
  219. package/src/vertexai/models/claude-error-handling.test.ts +86 -39
  220. package/src/vertexai/models/claude-streaming-spacing.test.ts +82 -75
  221. package/src/vertexai/models/claude.ts +84 -1041
  222. package/src/vertexai/models/gemini-conversation-mutation.test.ts +65 -23
  223. package/src/vertexai/models/gemini-error-handling.test.ts +126 -10
  224. package/src/vertexai/models/gemini-orphaned-tool-result.test.ts +118 -0
  225. package/src/vertexai/models/gemini.ts +372 -182
  226. package/src/vertexai/models/imagen.ts +164 -100
  227. package/src/vertexai/models/llama.ts +70 -48
  228. package/src/vertexai/models.ts +36 -16
  229. package/src/watsonx/index.ts +101 -65
  230. package/src/watsonx/interfaces.ts +10 -15
  231. package/src/xai/index.ts +30 -30
  232. package/lib/cjs/adobe/firefly.js +0 -120
  233. package/lib/cjs/adobe/firefly.js.map +0 -1
  234. package/lib/cjs/azure/azure_foundry.js +0 -432
  235. package/lib/cjs/azure/azure_foundry.js.map +0 -1
  236. package/lib/cjs/bedrock/converse.js +0 -359
  237. package/lib/cjs/bedrock/converse.js.map +0 -1
  238. package/lib/cjs/bedrock/index.js +0 -1508
  239. package/lib/cjs/bedrock/index.js.map +0 -1
  240. package/lib/cjs/bedrock/nova-image-payload.js +0 -207
  241. package/lib/cjs/bedrock/nova-image-payload.js.map +0 -1
  242. package/lib/cjs/bedrock/payloads.js +0 -3
  243. package/lib/cjs/bedrock/s3.js +0 -107
  244. package/lib/cjs/bedrock/s3.js.map +0 -1
  245. package/lib/cjs/bedrock/twelvelabs.js +0 -87
  246. package/lib/cjs/bedrock/twelvelabs.js.map +0 -1
  247. package/lib/cjs/groq/index.js +0 -328
  248. package/lib/cjs/groq/index.js.map +0 -1
  249. package/lib/cjs/huggingface_ie.js +0 -201
  250. package/lib/cjs/huggingface_ie.js.map +0 -1
  251. package/lib/cjs/index.js +0 -31
  252. package/lib/cjs/index.js.map +0 -1
  253. package/lib/cjs/mistral/index.js +0 -176
  254. package/lib/cjs/mistral/index.js.map +0 -1
  255. package/lib/cjs/mistral/types.js +0 -83
  256. package/lib/cjs/mistral/types.js.map +0 -1
  257. package/lib/cjs/openai/azure_openai.js +0 -72
  258. package/lib/cjs/openai/azure_openai.js.map +0 -1
  259. package/lib/cjs/openai/index.js +0 -1129
  260. package/lib/cjs/openai/index.js.map +0 -1
  261. package/lib/cjs/openai/openai.js +0 -21
  262. package/lib/cjs/openai/openai.js.map +0 -1
  263. package/lib/cjs/openai/openai_compatible.js +0 -63
  264. package/lib/cjs/openai/openai_compatible.js.map +0 -1
  265. package/lib/cjs/openai/openai_format.js +0 -131
  266. package/lib/cjs/openai/openai_format.js.map +0 -1
  267. package/lib/cjs/package.json +0 -3
  268. package/lib/cjs/replicate.js +0 -275
  269. package/lib/cjs/replicate.js.map +0 -1
  270. package/lib/cjs/shared/claude-thinking.js +0 -60
  271. package/lib/cjs/shared/claude-thinking.js.map +0 -1
  272. package/lib/cjs/test-driver/TestErrorCompletionStream.js +0 -20
  273. package/lib/cjs/test-driver/TestErrorCompletionStream.js.map +0 -1
  274. package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js +0 -24
  275. package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js.map +0 -1
  276. package/lib/cjs/test-driver/index.js +0 -109
  277. package/lib/cjs/test-driver/index.js.map +0 -1
  278. package/lib/cjs/test-driver/utils.js +0 -30
  279. package/lib/cjs/test-driver/utils.js.map +0 -1
  280. package/lib/cjs/togetherai/index.js +0 -126
  281. package/lib/cjs/togetherai/index.js.map +0 -1
  282. package/lib/cjs/togetherai/interfaces.js +0 -3
  283. package/lib/cjs/togetherai/interfaces.js.map +0 -1
  284. package/lib/cjs/vertexai/debug.js +0 -12
  285. package/lib/cjs/vertexai/debug.js.map +0 -1
  286. package/lib/cjs/vertexai/embeddings/embeddings-image.js +0 -27
  287. package/lib/cjs/vertexai/embeddings/embeddings-image.js.map +0 -1
  288. package/lib/cjs/vertexai/embeddings/embeddings-text.js +0 -23
  289. package/lib/cjs/vertexai/embeddings/embeddings-text.js.map +0 -1
  290. package/lib/cjs/vertexai/index.js +0 -644
  291. package/lib/cjs/vertexai/index.js.map +0 -1
  292. package/lib/cjs/vertexai/models/claude.js +0 -917
  293. package/lib/cjs/vertexai/models/claude.js.map +0 -1
  294. package/lib/cjs/vertexai/models/gemini.js +0 -858
  295. package/lib/cjs/vertexai/models/gemini.js.map +0 -1
  296. package/lib/cjs/vertexai/models/imagen.js +0 -303
  297. package/lib/cjs/vertexai/models/imagen.js.map +0 -1
  298. package/lib/cjs/vertexai/models/llama.js +0 -183
  299. package/lib/cjs/vertexai/models/llama.js.map +0 -1
  300. package/lib/cjs/vertexai/models.js +0 -35
  301. package/lib/cjs/vertexai/models.js.map +0 -1
  302. package/lib/cjs/watsonx/index.js +0 -161
  303. package/lib/cjs/watsonx/index.js.map +0 -1
  304. package/lib/cjs/watsonx/interfaces.js +0 -3
  305. package/lib/cjs/xai/index.js +0 -65
  306. package/lib/cjs/xai/index.js.map +0 -1
  307. package/lib/esm/adobe/firefly.js +0 -116
  308. package/lib/esm/adobe/firefly.js.map +0 -1
  309. package/lib/esm/azure/azure_foundry.js.map +0 -1
  310. package/lib/esm/bedrock/converse.js.map +0 -1
  311. package/lib/esm/bedrock/index.js.map +0 -1
  312. package/lib/esm/bedrock/nova-image-payload.js.map +0 -1
  313. package/lib/esm/bedrock/payloads.js.map +0 -1
  314. package/lib/esm/bedrock/s3.js.map +0 -1
  315. package/lib/esm/bedrock/twelvelabs.js.map +0 -1
  316. package/lib/esm/groq/index.js.map +0 -1
  317. package/lib/esm/huggingface_ie.js.map +0 -1
  318. package/lib/esm/index.js +0 -15
  319. package/lib/esm/index.js.map +0 -1
  320. package/lib/esm/mistral/index.js.map +0 -1
  321. package/lib/esm/mistral/types.js.map +0 -1
  322. package/lib/esm/openai/azure_openai.js.map +0 -1
  323. package/lib/esm/openai/index.js.map +0 -1
  324. package/lib/esm/openai/openai.js +0 -14
  325. package/lib/esm/openai/openai.js.map +0 -1
  326. package/lib/esm/openai/openai_compatible.js.map +0 -1
  327. package/lib/esm/openai/openai_format.js.map +0 -1
  328. package/lib/esm/replicate.js.map +0 -1
  329. package/lib/esm/shared/claude-thinking.js.map +0 -1
  330. package/lib/esm/test-driver/TestErrorCompletionStream.js +0 -16
  331. package/lib/esm/test-driver/TestErrorCompletionStream.js.map +0 -1
  332. package/lib/esm/test-driver/TestValidationErrorCompletionStream.js.map +0 -1
  333. package/lib/esm/test-driver/index.js.map +0 -1
  334. package/lib/esm/test-driver/utils.js.map +0 -1
  335. package/lib/esm/togetherai/index.js +0 -122
  336. package/lib/esm/togetherai/index.js.map +0 -1
  337. package/lib/esm/togetherai/interfaces.js.map +0 -1
  338. package/lib/esm/vertexai/debug.js.map +0 -1
  339. package/lib/esm/vertexai/embeddings/embeddings-image.js +0 -24
  340. package/lib/esm/vertexai/embeddings/embeddings-image.js.map +0 -1
  341. package/lib/esm/vertexai/embeddings/embeddings-text.js +0 -20
  342. package/lib/esm/vertexai/embeddings/embeddings-text.js.map +0 -1
  343. package/lib/esm/vertexai/index.js.map +0 -1
  344. package/lib/esm/vertexai/models/claude.js +0 -906
  345. package/lib/esm/vertexai/models/claude.js.map +0 -1
  346. package/lib/esm/vertexai/models/gemini.js.map +0 -1
  347. package/lib/esm/vertexai/models/imagen.js.map +0 -1
  348. package/lib/esm/vertexai/models/llama.js.map +0 -1
  349. package/lib/esm/vertexai/models.js.map +0 -1
  350. package/lib/esm/watsonx/index.js.map +0 -1
  351. package/lib/esm/xai/index.js.map +0 -1
  352. package/lib/types/adobe/firefly.d.ts.map +0 -1
  353. package/lib/types/azure/azure_foundry.d.ts.map +0 -1
  354. package/lib/types/bedrock/converse.d.ts.map +0 -1
  355. package/lib/types/bedrock/index.d.ts.map +0 -1
  356. package/lib/types/bedrock/nova-image-payload.d.ts.map +0 -1
  357. package/lib/types/bedrock/payloads.d.ts.map +0 -1
  358. package/lib/types/bedrock/s3.d.ts.map +0 -1
  359. package/lib/types/bedrock/twelvelabs.d.ts.map +0 -1
  360. package/lib/types/groq/index.d.ts.map +0 -1
  361. package/lib/types/huggingface_ie.d.ts.map +0 -1
  362. package/lib/types/index.d.ts +0 -15
  363. package/lib/types/index.d.ts.map +0 -1
  364. package/lib/types/mistral/index.d.ts.map +0 -1
  365. package/lib/types/mistral/types.d.ts.map +0 -1
  366. package/lib/types/openai/azure_openai.d.ts.map +0 -1
  367. package/lib/types/openai/index.d.ts.map +0 -1
  368. package/lib/types/openai/openai.d.ts.map +0 -1
  369. package/lib/types/openai/openai_compatible.d.ts.map +0 -1
  370. package/lib/types/openai/openai_format.d.ts.map +0 -1
  371. package/lib/types/replicate.d.ts.map +0 -1
  372. package/lib/types/shared/claude-thinking.d.ts.map +0 -1
  373. package/lib/types/test-driver/TestErrorCompletionStream.d.ts.map +0 -1
  374. package/lib/types/test-driver/TestValidationErrorCompletionStream.d.ts.map +0 -1
  375. package/lib/types/test-driver/index.d.ts.map +0 -1
  376. package/lib/types/test-driver/utils.d.ts.map +0 -1
  377. package/lib/types/togetherai/index.d.ts +0 -23
  378. package/lib/types/togetherai/index.d.ts.map +0 -1
  379. package/lib/types/togetherai/interfaces.d.ts.map +0 -1
  380. package/lib/types/vertexai/debug.d.ts +0 -2
  381. package/lib/types/vertexai/debug.d.ts.map +0 -1
  382. package/lib/types/vertexai/embeddings/embeddings-image.d.ts +0 -11
  383. package/lib/types/vertexai/embeddings/embeddings-image.d.ts.map +0 -1
  384. package/lib/types/vertexai/embeddings/embeddings-text.d.ts +0 -10
  385. package/lib/types/vertexai/embeddings/embeddings-text.d.ts.map +0 -1
  386. package/lib/types/vertexai/index.d.ts.map +0 -1
  387. package/lib/types/vertexai/models/claude.d.ts +0 -119
  388. package/lib/types/vertexai/models/claude.d.ts.map +0 -1
  389. package/lib/types/vertexai/models/gemini.d.ts.map +0 -1
  390. package/lib/types/vertexai/models/imagen.d.ts.map +0 -1
  391. package/lib/types/vertexai/models/llama.d.ts.map +0 -1
  392. package/lib/types/vertexai/models.d.ts +0 -20
  393. package/lib/types/vertexai/models.d.ts.map +0 -1
  394. package/lib/types/watsonx/index.d.ts.map +0 -1
  395. package/lib/types/watsonx/interfaces.d.ts.map +0 -1
  396. package/lib/types/xai/index.d.ts.map +0 -1
  397. package/src/vertexai/embeddings/embeddings-image.ts +0 -52
  398. package/src/vertexai/embeddings/embeddings-text.ts +0 -54
  399. /package/lib/{esm/bedrock → bedrock}/payloads.js +0 -0
  400. /package/lib/{esm/mistral → mistral}/types.js +0 -0
  401. /package/lib/{esm/togetherai → togetherai}/interfaces.js +0 -0
  402. /package/lib/{types/watsonx → watsonx}/interfaces.d.ts +0 -0
  403. /package/lib/{esm/watsonx → watsonx}/interfaces.js +0 -0
@@ -1,36 +1,40 @@
1
- import type { ClientOptions as AnthropicVertexClientOptions } from "@anthropic-ai/vertex-sdk";
2
- import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";
3
- import { PredictionServiceClient, v1beta1 } from "@google-cloud/aiplatform";
4
- import { Content, GoogleGenAI, Model } from "@google/genai";
1
+ import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
2
+ import { type Content, GoogleGenAI, type Model } from '@google/genai';
3
+ import { PredictionServiceClient, v1beta1 } from '@google-cloud/aiplatform';
5
4
  import {
6
- AIModel,
7
- AbstractDriver,
8
- Completion,
9
- CompletionChunkObject,
10
- CompletionResult,
11
- DriverOptions,
12
- EmbeddingsOptions,
13
- EmbeddingsResult,
14
- ExecutionOptions,
15
- LlumiverseError,
16
- LlumiverseErrorContext,
17
- ModelSearchPayload,
18
- PromptSegment,
5
+ type AIModel,
6
+ type Completion,
7
+ type CompletionChunkObject,
8
+ type CompletionResult,
9
+ type DriverOptions,
10
+ type EmbeddingsOptions,
11
+ type EmbeddingsResult,
12
+ type ExecutionOptions,
19
13
  getConversationMeta,
20
14
  getModelCapabilities,
15
+ type HttpTimeoutOptions,
21
16
  incrementConversationTurn,
17
+ type LlumiverseError,
18
+ type LlumiverseErrorContext,
19
+ type ModelSearchPayload,
22
20
  modelModalitiesToArray,
21
+ type PromptSegment,
23
22
  stripBase64ImagesFromConversation,
24
23
  stripHeartbeatsFromConversation,
24
+ type ToolUse,
25
25
  truncateLargeTextInConversation,
26
- } from "@llumiverse/core";
27
- import { FetchClient } from "@vertesia/api-fetch-client";
28
- import { AuthClient, GoogleAuth, GoogleAuthOptions } from "google-auth-library";
29
- import { getEmbeddingsForImages } from "./embeddings/embeddings-image.js";
30
- import { TextEmbeddingsOptions, getEmbeddingsForText } from "./embeddings/embeddings-text.js";
31
- import { getModelDefinition } from "./models.js";
32
- import { ANTHROPIC_REGIONS, NON_GLOBAL_ANTHROPIC_MODELS } from "./models/claude.js";
33
- import { ImagenModelDefinition, ImagenPrompt } from "./models/imagen.js";
26
+ } from '@llumiverse/core';
27
+ import { AbstractDriver } from '@llumiverse/core/driver';
28
+ import { mergeDriverHttpTimeoutOptions, resolveDriverHttpTimeouts } from '@llumiverse/core/http-agent';
29
+ import { type FETCH_FN, FetchClient } from '@vertesia/api-fetch-client';
30
+ import { type AuthClient, GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';
31
+ import { type ClaudePrompt, formatClaudeDebugPrompt } from '../shared/claude-messages.js';
32
+ import { generateVertexAiEmbeddings } from './embeddings/embed.js';
33
+ import { ANTHROPIC_REGIONS, NON_GLOBAL_ANTHROPIC_MODELS } from './models/claude.js';
34
+ import { formatGeminiDebugPrompt } from './models/gemini.js';
35
+ import { formatImagenDebugPrompt, ImagenModelDefinition, type ImagenPrompt } from './models/imagen.js';
36
+ import type { LLamaPrompt } from './models/llama.js';
37
+ import { getModelDefinition, trimModelName } from './models.js';
34
38
 
35
39
  export interface VertexAIDriverOptions extends DriverOptions {
36
40
  project: string;
@@ -42,17 +46,32 @@ export interface GenerateContentPrompt {
42
46
  contents: Content[];
43
47
  system?: Content;
44
48
  }
49
+ type ClaudeStreamingPrompt = { messages: unknown[]; system?: unknown[] };
50
+ type ConversationWrapper = { messages?: unknown[]; system?: unknown[] };
51
+
52
+ function isClaudePrompt(prompt: VertexAIPrompt): prompt is ClaudePrompt {
53
+ return (
54
+ 'messages' in prompt &&
55
+ ('system' in prompt || prompt.messages.some((message) => Array.isArray(message.content)))
56
+ );
57
+ }
58
+
59
+ function isClaudeStreamingPrompt(prompt: unknown): prompt is ClaudeStreamingPrompt {
60
+ return (
61
+ prompt !== null &&
62
+ typeof prompt === 'object' &&
63
+ 'messages' in prompt &&
64
+ Array.isArray((prompt as ConversationWrapper).messages)
65
+ );
66
+ }
45
67
 
46
68
  //General Prompt type for VertexAI
47
- export type VertexAIPrompt = ImagenPrompt | GenerateContentPrompt;
69
+ export type VertexAIPrompt = ImagenPrompt | GenerateContentPrompt | ClaudePrompt | LLamaPrompt;
48
70
 
49
- export function trimModelName(model: string) {
50
- const i = model.lastIndexOf("@");
51
- return i > -1 ? model.substring(0, i) : model;
52
- }
71
+ export { trimModelName };
53
72
 
54
73
  export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, VertexAIPrompt> {
55
- static PROVIDER = "vertexai";
74
+ static PROVIDER = 'vertexai';
56
75
  provider = VertexAIDriver.PROVIDER;
57
76
 
58
77
  aiplatform: v1beta1.ModelServiceClient | undefined;
@@ -61,11 +80,12 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
61
80
  googleGenAI: GoogleGenAI | undefined;
62
81
  googleGenAIRegion: string | undefined;
63
82
  googleGenAIFlex: boolean | undefined;
64
- llamaClient: FetchClient & { region?: string } | undefined;
83
+ llamaClient: (FetchClient & { region?: string }) | undefined;
65
84
  modelGarden: v1beta1.ModelGardenServiceClient | undefined;
66
85
  imagenClient: PredictionServiceClient | undefined;
86
+ predictionClient: PredictionServiceClient | undefined;
67
87
 
68
- googleAuth: GoogleAuth<any>;
88
+ googleAuth: GoogleAuth<AuthClient>;
69
89
  private authClientPromise: Promise<AuthClient> | undefined;
70
90
 
71
91
  constructor(options: VertexAIDriverOptions) {
@@ -73,18 +93,32 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
73
93
 
74
94
  this.aiplatform = undefined;
75
95
  this.anthropicClient = undefined;
76
- this.fetchClient = undefined
96
+ this.fetchClient = undefined;
77
97
  this.googleGenAI = undefined;
78
98
  this.googleGenAIRegion = undefined;
79
99
  this.googleGenAIFlex = undefined;
80
100
  this.modelGarden = undefined;
81
101
  this.llamaClient = undefined;
82
102
  this.imagenClient = undefined;
103
+ this.predictionClient = undefined;
83
104
 
84
- this.googleAuth = new GoogleAuth(options.googleAuthOptions) as GoogleAuth<any>;
105
+ this.googleAuth = new GoogleAuth(options.googleAuthOptions);
85
106
  this.authClientPromise = undefined;
86
107
  }
87
108
 
109
+ /**
110
+ * Cleanup Google Cloud clients when the driver is evicted from the cache.
111
+ * `super.destroy()` releases the HTTP agent socket pool created by
112
+ * {@link AbstractDriver.getHttpAgent} / {@link AbstractDriver.getDriverFetch}.
113
+ */
114
+ destroy(): void {
115
+ this.aiplatform?.close();
116
+ this.modelGarden?.close();
117
+ this.imagenClient?.close();
118
+ this.predictionClient?.close();
119
+ super.destroy();
120
+ }
121
+
88
122
  private async getAuthClient(): Promise<AuthClient> {
89
123
  if (!this.authClientPromise) {
90
124
  this.authClientPromise = this.googleAuth.getClient();
@@ -92,10 +126,46 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
92
126
  return this.authClientPromise;
93
127
  }
94
128
 
95
- public getGoogleGenAIClient(region: string = this.options.region, flex: boolean = false): GoogleGenAI {
96
- if (this.googleGenAI &&
97
- this.googleGenAIRegion === region &&
98
- this.googleGenAIFlex === flex) {
129
+ private getSdkRequestTimeoutMs(httpTimeout?: HttpTimeoutOptions): number {
130
+ const timeouts = resolveDriverHttpTimeouts(
131
+ mergeDriverHttpTimeoutOptions(this.options.httpTimeout, httpTimeout),
132
+ );
133
+ return Math.max(timeouts.headersTimeout, timeouts.bodyTimeout);
134
+ }
135
+
136
+ private getGoogleGenAIHttpOptions(flex: boolean, httpTimeout?: HttpTimeoutOptions) {
137
+ return {
138
+ timeout: this.getSdkRequestTimeoutMs(httpTimeout),
139
+ ...(flex
140
+ ? {
141
+ headers: {
142
+ 'X-Vertex-AI-LLM-Request-Type': 'shared',
143
+ 'X-Vertex-AI-LLM-Shared-Request-Type': 'flex',
144
+ },
145
+ }
146
+ : {}),
147
+ };
148
+ }
149
+
150
+ private getAnthropicVertexClientOptions(region: string, authClient: AuthClient, httpTimeout?: HttpTimeoutOptions) {
151
+ return {
152
+ timeout: this.getSdkRequestTimeoutMs(httpTimeout),
153
+ region,
154
+ projectId: this.options.project,
155
+ authClient: authClient,
156
+ fetch: this.getDriverFetch(),
157
+ };
158
+ }
159
+
160
+ public getGoogleGenAIClient(
161
+ region: string = this.options.region,
162
+ flex: boolean = false,
163
+ httpTimeout?: HttpTimeoutOptions,
164
+ ): GoogleGenAI {
165
+ if (httpTimeout) {
166
+ return this.buildGoogleGenAIClient(region, flex, httpTimeout);
167
+ }
168
+ if (this.googleGenAI && this.googleGenAIRegion === region && this.googleGenAIFlex === flex) {
99
169
  // Return existing client if region and flex settings match
100
170
  return this.googleGenAI;
101
171
  }
@@ -105,31 +175,25 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
105
175
  return this.googleGenAI;
106
176
  }
107
177
 
108
- private buildGoogleGenAIClient(region: string, flex: boolean): GoogleGenAI {
178
+ private buildGoogleGenAIClient(region: string, flex: boolean, httpTimeout?: HttpTimeoutOptions): GoogleGenAI {
109
179
  return new GoogleGenAI({
110
180
  project: this.options.project,
111
181
  location: region,
112
182
  vertexai: true,
113
183
  googleAuthOptions: this.options.googleAuthOptions || {
114
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
184
+ scopes: ['https://www.googleapis.com/auth/cloud-platform'],
115
185
  },
116
- ...(flex ? {
117
- httpOptions: {
118
- headers: {
119
- "X-Vertex-AI-LLM-Request-Type": "shared",
120
- "X-Vertex-AI-LLM-Shared-Request-Type": "flex",
121
- }
122
- }
123
- } : {}),
186
+ httpOptions: this.getGoogleGenAIHttpOptions(flex, httpTimeout),
124
187
  });
125
188
  }
126
189
 
127
- public getFetchClient(): FetchClient {
190
+ public getFetchClient(region: string = this.options.region): FetchClient {
128
191
  //Lazy initialization
129
192
  if (!this.fetchClient) {
130
193
  this.fetchClient = createFetchClient({
131
- region: this.options.region,
194
+ region: region,
132
195
  project: this.options.project,
196
+ fetchImpl: this.getDriverFetch(),
133
197
  }).withAuthCallback(async () => {
134
198
  const token = await this.googleAuth.getAccessToken();
135
199
  return `Bearer ${token}`;
@@ -138,24 +202,28 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
138
202
  return this.fetchClient;
139
203
  }
140
204
 
141
- public getLLamaClient(region: string = "us-central1"): FetchClient {
205
+ public getLLamaClient(region: string = 'us-central1'): FetchClient {
142
206
  //Lazy initialization
143
- if (!this.llamaClient || this.llamaClient["region"] !== region) {
207
+ if (!this.llamaClient || this.llamaClient.region !== region) {
144
208
  this.llamaClient = createFetchClient({
145
209
  region: region,
146
210
  project: this.options.project,
147
- apiVersion: "v1beta1",
211
+ apiVersion: 'v1beta1',
212
+ fetchImpl: this.getDriverFetch(),
148
213
  }).withAuthCallback(async () => {
149
214
  const token = await this.googleAuth.getAccessToken();
150
215
  return `Bearer ${token}`;
151
216
  });
152
217
  // Store the region for potential client reuse
153
- this.llamaClient["region"] = region;
218
+ this.llamaClient.region = region;
154
219
  }
155
220
  return this.llamaClient;
156
221
  }
157
222
 
158
- public async getAnthropicClient(region: string = this.options.region): Promise<AnthropicVertex> {
223
+ public async getAnthropicClient(
224
+ region: string = this.options.region,
225
+ httpTimeout?: HttpTimeoutOptions,
226
+ ): Promise<AnthropicVertex> {
159
227
  // Extract region prefix and map if it exists in ANTHROPIC_REGIONS, otherwise use as-is
160
228
  const getRegionPrefix = (r: string) => r.split('-')[0];
161
229
  const regionPrefix = getRegionPrefix(region);
@@ -168,23 +236,13 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
168
236
  const authClient = await this.getAuthClient();
169
237
 
170
238
  // If mapped region is different from default mapped region, create one-off client
171
- if (mappedRegion !== defaultMappedRegion) {
172
- return new AnthropicVertex({
173
- timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
174
- region: mappedRegion,
175
- projectId: this.options.project,
176
- authClient: authClient as unknown as AnthropicVertexClientOptions["authClient"],
177
- });
239
+ if (httpTimeout || mappedRegion !== defaultMappedRegion) {
240
+ return new AnthropicVertex(this.getAnthropicVertexClientOptions(mappedRegion, authClient, httpTimeout));
178
241
  }
179
242
 
180
243
  //Lazy initialization for default region
181
244
  if (!this.anthropicClient) {
182
- this.anthropicClient = new AnthropicVertex({
183
- timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
184
- region: mappedRegion,
185
- projectId: this.options.project,
186
- authClient: authClient as unknown as AnthropicVertexClientOptions["authClient"],
187
- });
245
+ this.anthropicClient = new AnthropicVertex(this.getAnthropicVertexClientOptions(mappedRegion, authClient));
188
246
  }
189
247
  return this.anthropicClient;
190
248
  }
@@ -229,10 +287,23 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
229
287
  return this.imagenClient;
230
288
  }
231
289
 
290
+ public async getPredictionServiceClient(): Promise<PredictionServiceClient> {
291
+ //Lazy initialization using the driver's configured region
292
+ if (!this.predictionClient) {
293
+ const authClient = await this.getAuthClient();
294
+ this.predictionClient = new PredictionServiceClient({
295
+ projectId: this.options.project,
296
+ apiEndpoint: `${this.options.region}-${API_BASE_PATH}`,
297
+ authClient,
298
+ });
299
+ }
300
+ return this.predictionClient;
301
+ }
302
+
232
303
  validateResult(result: Completion, options: ExecutionOptions) {
233
304
  // Optionally preprocess the result before validation
234
305
  const modelDef = getModelDefinition(options.model);
235
- if (typeof modelDef.preValidationProcessing === "function") {
306
+ if (typeof modelDef.preValidationProcessing === 'function') {
236
307
  const processed = modelDef.preValidationProcessing(result, options);
237
308
  result = processed.result;
238
309
  options = processed.options;
@@ -249,7 +320,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
249
320
  }
250
321
 
251
322
  protected isImageModel(model: string): boolean {
252
- return model.includes("imagen");
323
+ return model.includes('imagen');
253
324
  }
254
325
 
255
326
  public createPrompt(segments: PromptSegment[], options: ExecutionOptions): Promise<VertexAIPrompt> {
@@ -259,6 +330,19 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
259
330
  return getModelDefinition(options.model).createPrompt(this, segments, options);
260
331
  }
261
332
 
333
+ public formatDebugPrompt(prompt: VertexAIPrompt): VertexAIPrompt {
334
+ if (isClaudePrompt(prompt)) {
335
+ return formatClaudeDebugPrompt(prompt);
336
+ }
337
+ if ('contents' in prompt) {
338
+ return formatGeminiDebugPrompt(prompt);
339
+ }
340
+ if ('messages' in prompt) {
341
+ return prompt;
342
+ }
343
+ return formatImagenDebugPrompt(prompt);
344
+ }
345
+
262
346
  async requestTextCompletion(prompt: VertexAIPrompt, options: ExecutionOptions): Promise<Completion> {
263
347
  return getModelDefinition(options.model).requestTextCompletion(this, prompt, options);
264
348
  }
@@ -278,11 +362,11 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
278
362
  prompt: VertexAIPrompt,
279
363
  result: unknown[],
280
364
  toolUse: unknown[] | undefined,
281
- options: ExecutionOptions
365
+ options: ExecutionOptions,
282
366
  ): Content[] | unknown | undefined {
283
367
  // Handle Claude-style prompts (has 'messages' array)
284
- if ('messages' in prompt && Array.isArray((prompt as any).messages)) {
285
- return this.buildClaudeStreamingConversation(prompt as any, result, toolUse, options);
368
+ if (isClaudeStreamingPrompt(prompt)) {
369
+ return this.buildClaudeStreamingConversation(prompt, result, toolUse, options);
286
370
  }
287
371
 
288
372
  // Only handle Gemini-style prompts with contents array
@@ -294,7 +378,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
294
378
 
295
379
  // Convert accumulated results to text content for assistant message
296
380
  const textContent = completionResults
297
- .map(r => {
381
+ .map((r) => {
298
382
  switch (r.type) {
299
383
  case 'text':
300
384
  return r.value;
@@ -303,25 +387,27 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
303
387
  case 'image':
304
388
  // Skip images in conversation - they're in the result
305
389
  return '';
306
- default:
307
- return String((r as any).value || '');
390
+ default: {
391
+ const _exhaustive: never = r;
392
+ return String(_exhaustive);
393
+ }
308
394
  }
309
395
  })
310
396
  .join('');
311
397
 
312
398
  // Build parts array for assistant message
313
- const parts: any[] = [];
399
+ const parts: unknown[] = [];
314
400
  if (textContent) {
315
401
  parts.push({ text: textContent });
316
402
  }
317
403
  // Add function calls if present (Gemini format)
318
404
  if (toolUse && toolUse.length > 0) {
319
- for (const tool of toolUse as any[]) {
320
- const functionCallPart: any = {
405
+ for (const tool of toolUse as ToolUse<unknown>[]) {
406
+ const functionCallPart: Record<string, unknown> = {
321
407
  functionCall: {
322
408
  name: tool.tool_name,
323
409
  args: tool.tool_input,
324
- }
410
+ },
325
411
  };
326
412
  // Include thought_signature for Gemini thinking models (2.5+/3.0+)
327
413
  // This must be preserved in the conversation for subsequent API calls
@@ -335,16 +421,14 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
335
421
  // prompt.contents already includes the conversation history
336
422
  // (merged in requestTextCompletionStream via updateConversation),
337
423
  // so we use it directly — do NOT prepend options.conversation again.
338
- let conversation: Content[] = [
339
- ...prompt.contents,
340
- ];
424
+ let conversation: Content[] = [...prompt.contents];
341
425
 
342
426
  // Only add assistant message if there's actual content
343
427
  // (Empty text parts can cause API errors)
344
428
  if (parts.length > 0) {
345
429
  conversation.push({
346
430
  role: 'model',
347
- parts: parts
431
+ parts: parts as Content['parts'],
348
432
  });
349
433
  }
350
434
 
@@ -356,7 +440,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
356
440
  const stripOptions = {
357
441
  keepForTurns: options.stripImagesAfterTurns ?? Infinity,
358
442
  currentTurn,
359
- textMaxTokens: options.stripTextMaxTokens
443
+ textMaxTokens: options.stripTextMaxTokens,
360
444
  };
361
445
  let processedConversation = stripBase64ImagesFromConversation(conversation, stripOptions);
362
446
  processedConversation = truncateLargeTextInConversation(processedConversation, stripOptions);
@@ -371,7 +455,10 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
371
455
  const geminiPrompt = prompt as GenerateContentPrompt;
372
456
  if (geminiPrompt.system) {
373
457
  if (typeof processedConversation === 'object' && processedConversation !== null) {
374
- processedConversation = { ...processedConversation as object, _llumiverse_system: geminiPrompt.system };
458
+ processedConversation = {
459
+ ...(processedConversation as object),
460
+ _llumiverse_system: geminiPrompt.system,
461
+ };
375
462
  }
376
463
  }
377
464
 
@@ -386,13 +473,13 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
386
473
  prompt: { messages: unknown[]; system?: unknown[] },
387
474
  result: unknown[],
388
475
  toolUse: unknown[] | undefined,
389
- options: ExecutionOptions
476
+ options: ExecutionOptions,
390
477
  ): unknown {
391
478
  const completionResults = result as CompletionResult[];
392
479
 
393
480
  // Convert accumulated results to text content
394
481
  const textContent = completionResults
395
- .map(r => {
482
+ .map((r) => {
396
483
  switch (r.type) {
397
484
  case 'text':
398
485
  return r.value;
@@ -400,8 +487,10 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
400
487
  return typeof r.value === 'string' ? r.value : JSON.stringify(r.value);
401
488
  case 'image':
402
489
  return '';
403
- default:
404
- return String((r as any).value || '');
490
+ default: {
491
+ const _exhaustive: never = r;
492
+ return String(_exhaustive);
493
+ }
405
494
  }
406
495
  })
407
496
  .join('');
@@ -413,46 +502,44 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
413
502
  if (textContent) {
414
503
  content.push({
415
504
  type: 'text',
416
- text: textContent
505
+ text: textContent,
417
506
  });
418
507
  }
419
508
 
420
509
  // Add tool_use blocks in Claude format
421
510
  if (toolUse && toolUse.length > 0) {
422
- for (const tool of toolUse as any[]) {
511
+ for (const tool of toolUse as ToolUse<unknown>[]) {
423
512
  content.push({
424
513
  type: 'tool_use',
425
514
  id: tool.id,
426
515
  name: tool.tool_name,
427
- input: tool.tool_input ?? {}
516
+ input: tool.tool_input ?? {},
428
517
  });
429
518
  }
430
519
  }
431
520
 
432
521
  // Claude's requestTextCompletionStream does NOT mutate prompt.messages
433
522
  // to include history, so we must prepend options.conversation here.
434
- const existingMessages = (options.conversation as any)?.messages ?? [];
435
- const existingSystem = (options.conversation as any)?.system ?? prompt.system;
523
+ const existingConversation = options.conversation as ConversationWrapper | undefined;
524
+ const existingMessages = existingConversation?.messages ?? [];
525
+ const existingSystem = existingConversation?.system ?? prompt.system;
436
526
 
437
527
  // Build the new messages array
438
- const newMessages = [
439
- ...existingMessages,
440
- ...prompt.messages,
441
- ];
528
+ const newMessages = [...existingMessages, ...prompt.messages];
442
529
 
443
530
  // Only add assistant message if there's actual content
444
531
  // (Claude API rejects empty text content blocks)
445
532
  if (content.length > 0) {
446
533
  newMessages.push({
447
534
  role: 'assistant',
448
- content: content
535
+ content: content,
449
536
  });
450
537
  }
451
538
 
452
539
  // Build the new conversation in ClaudePrompt format
453
540
  const conversation = {
454
541
  messages: newMessages,
455
- system: existingSystem
542
+ system: existingSystem,
456
543
  };
457
544
 
458
545
  // Increment turn counter
@@ -463,7 +550,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
463
550
  const stripOptions = {
464
551
  keepForTurns: options.stripImagesAfterTurns ?? Infinity,
465
552
  currentTurn,
466
- textMaxTokens: options.stripTextMaxTokens
553
+ textMaxTokens: options.stripTextMaxTokens,
467
554
  };
468
555
  let processedConversation = stripBase64ImagesFromConversation(withTurn, stripOptions);
469
556
  processedConversation = truncateLargeTextInConversation(processedConversation, stripOptions);
@@ -475,11 +562,8 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
475
562
  return processedConversation;
476
563
  }
477
564
 
478
- async requestImageGeneration(
479
- _prompt: ImagenPrompt,
480
- _options: ExecutionOptions,
481
- ): Promise<Completion> {
482
- const splits = _options.model.split("/");
565
+ async requestImageGeneration(_prompt: ImagenPrompt, _options: ExecutionOptions): Promise<Completion> {
566
+ const splits = _options.model.split('/');
483
567
  const modelName = trimModelName(splits[splits.length - 1]);
484
568
  return new ImagenModelDefinition(modelName).requestImageGeneration(this, _prompt, _options);
485
569
  }
@@ -497,36 +581,42 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
497
581
  // Get clients
498
582
  const modelGarden = await this.getModelGardenClient();
499
583
  const aiplatform = await this.getAIPlatformClient();
500
- const globalGenAiClient = this.getGoogleGenAIClient("global");
584
+ const globalGenAiClient = this.getGoogleGenAIClient('global');
501
585
 
502
586
  let models: AIModel<string>[] = [];
503
587
 
504
588
  //Model Garden Publisher models - Pretrained models
505
- const publishers = ["google", "anthropic", "meta"];
589
+ const publishers = ['google', 'anthropic', 'meta'];
506
590
  // Meta "maas" models are LLama Models-As-A-Service. Non-maas models are not pre-deployed.
507
- const supportedModels = { google: ["gemini", "imagen"], anthropic: ["claude"], meta: ["maas"] };
591
+ const supportedModels = { google: ['gemini', 'imagen'], anthropic: ['claude'], meta: ['maas'] };
508
592
  // Additional models not in the listings, but we want to include
509
593
  // TODO: Remove once the models are available in the listing API, or no longer needed
510
594
  const additionalModels = {
511
- google: [
512
- "imagen-3.0-fast-generate-001",
513
- ],
595
+ google: ['imagen-3.0-fast-generate-001'],
514
596
  anthropic: [],
515
597
  meta: [
516
- "llama-4-maverick-17b-128e-instruct-maas",
517
- "llama-4-scout-17b-16e-instruct-maas",
518
- "llama-3.3-70b-instruct-maas",
519
- "llama-3.2-90b-vision-instruct-maas",
520
- "llama-3.1-405b-instruct-maas",
521
- "llama-3.1-70b-instruct-maas",
522
- "llama-3.1-8b-instruct-maas",
598
+ 'llama-4-maverick-17b-128e-instruct-maas',
599
+ 'llama-4-scout-17b-16e-instruct-maas',
600
+ 'llama-3.3-70b-instruct-maas',
601
+ 'llama-3.2-90b-vision-instruct-maas',
602
+ 'llama-3.1-405b-instruct-maas',
603
+ 'llama-3.1-70b-instruct-maas',
604
+ 'llama-3.1-8b-instruct-maas',
523
605
  ],
524
- }
606
+ };
525
607
 
526
608
  //Used to exclude retired models that are still in the listing API but not available for use.
527
609
  //Or models we do not support yet
528
610
  const unsupportedModelsByPublisher = {
529
- google: ["gemini-pro", "gemini-ultra", "imagen-product-recontext-preview", "embedding", "gemini-live-2.5-flash-preview-native-audio", "computer-use-preview"],
611
+ google: [
612
+ 'gemini-pro',
613
+ 'gemini-ultra',
614
+ 'imagen-product-recontext-preview',
615
+ 'embedding',
616
+ 'embed',
617
+ 'gemini-live-2.5-flash-preview-native-audio',
618
+ 'computer-use-preview',
619
+ ],
530
620
  anthropic: [],
531
621
  meta: [],
532
622
  };
@@ -538,7 +628,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
538
628
  const publisherPromises = publishers.map(async (publisher) => {
539
629
  const [response] = await modelGarden.listPublisherModels({
540
630
  parent: `publishers/${publisher}`,
541
- orderBy: "name",
631
+ orderBy: 'name',
542
632
  listAllVersions: true,
543
633
  });
544
634
  return { publisher, response };
@@ -556,124 +646,138 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
556
646
  const [response] = aiplatformResult;
557
647
  models = models.concat(
558
648
  response.map((model) => ({
559
- id: model.name?.split("/").pop() ?? "",
560
- name: model.displayName ?? "",
561
- provider: "vertexai"
562
- }))
649
+ id: model.name?.split('/').pop() ?? '',
650
+ name: model.displayName ?? '',
651
+ provider: 'vertexai',
652
+ })),
563
653
  );
564
654
 
565
655
  // Process global google models from GenAI
656
+ // Exclude embedding, retired and or unsupported models
657
+ const excludedModels = unsupportedModelsByPublisher.google;
566
658
  models = models.concat(
567
- globalGoogleResult.map((model) => {
568
- const modelCapability = getModelCapabilities(model.name ?? '', "vertexai");
569
- return {
570
- id: "locations/global/" + model.name,
571
- name: "Global " + model.name?.split('/').pop(),
572
- provider: "vertexai",
573
- owner: "google",
574
- input_modalities: modelModalitiesToArray(modelCapability.input),
575
- output_modalities: modelModalitiesToArray(modelCapability.output),
576
- tool_support: modelCapability.tool_support,
577
- };
578
- })
659
+ globalGoogleResult
660
+ .filter((model) => !excludedModels.includes(model.name ?? ''))
661
+ .map((model) => {
662
+ const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
663
+ return {
664
+ id: `locations/global/${model.name}`,
665
+ name: `Global ${model.name?.split('/').pop()}`,
666
+ provider: 'vertexai',
667
+ owner: 'google',
668
+ input_modalities: modelModalitiesToArray(modelCapability.input),
669
+ output_modalities: modelModalitiesToArray(modelCapability.output),
670
+ tool_support: modelCapability.tool_support,
671
+ };
672
+ }),
579
673
  );
580
674
 
581
675
  // Process publisher models
582
676
  for (const result of publisherResults) {
583
677
  const { publisher, response } = result;
584
678
  const modelFamily = supportedModels[publisher as keyof typeof supportedModels];
585
- const retiredModels = unsupportedModelsByPublisher[publisher as keyof typeof unsupportedModelsByPublisher];
586
-
587
- models = models.concat(response.filter((model) => {
588
- const modelName = model.name ?? "";
589
- // Exclude retired models
590
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
591
- return false;
592
- }
593
- // Check if the model belongs to the supported model families
594
- if (modelFamily.some(family => modelName.includes(family))) {
595
- return true;
596
- }
597
- return false;
598
- }).map(model => {
599
- const modelCapability = getModelCapabilities(model.name ?? '', "vertexai");
600
- return {
601
- id: model.name ?? '',
602
- name: model.name?.split('/').pop() ?? '',
603
- provider: 'vertexai',
604
- owner: publisher,
605
- input_modalities: modelModalitiesToArray(modelCapability.input),
606
- output_modalities: modelModalitiesToArray(modelCapability.output),
607
- tool_support: modelCapability.tool_support,
608
- } satisfies AIModel<string>;
609
- }));
679
+ const excludedModels = unsupportedModelsByPublisher[publisher as keyof typeof unsupportedModelsByPublisher];
680
+
681
+ models = models.concat(
682
+ response
683
+ .filter((model) => {
684
+ const modelName = model.name ?? '';
685
+ // Exclude embedding, retired and or unsupported models
686
+ if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
687
+ return false;
688
+ }
689
+ // Check if the model belongs to the supported model families
690
+ if (modelFamily.some((family) => modelName.includes(family))) {
691
+ return true;
692
+ }
693
+ return false;
694
+ })
695
+ .map((model) => {
696
+ const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
697
+ return {
698
+ id: model.name ?? '',
699
+ name: model.name?.split('/').pop() ?? '',
700
+ provider: 'vertexai',
701
+ owner: publisher,
702
+ input_modalities: modelModalitiesToArray(modelCapability.input),
703
+ output_modalities: modelModalitiesToArray(modelCapability.output),
704
+ tool_support: modelCapability.tool_support,
705
+ } satisfies AIModel<string>;
706
+ }),
707
+ );
610
708
 
611
709
  // Create global google gemini models for Gemini 2.5 and later, if missing from GenAI listing
612
710
  if (publisher === 'google') {
613
- const globalGeminiModels = response.filter((model) => {
614
- const modelName = model.name ?? "";
615
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
616
- return false;
617
- }
618
- if (modelFamily.some(family => modelName.includes(family))) {
619
- const versionMatch = modelName.match(/gemini-(\d+(?:\.\d+)?)/);
620
- if (versionMatch) {
621
- const version = parseFloat(versionMatch[1]);
622
- if (version >= 2.5) {
623
- // Check if already present
624
- const shortName = modelName.split('/').pop();
625
- const globalName = "Global " + shortName;
626
- if (models.some(m => m.name === globalName)) {
627
- return false;
711
+ const globalGeminiModels = response
712
+ .filter((model) => {
713
+ const modelName = model.name ?? '';
714
+ if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
715
+ return false;
716
+ }
717
+ if (modelFamily.some((family) => modelName.includes(family))) {
718
+ const versionMatch = modelName.match(/gemini-(\d+(?:\.\d+)?)/);
719
+ if (versionMatch) {
720
+ const version = parseFloat(versionMatch[1]);
721
+ if (version >= 2.5) {
722
+ // Check if already present
723
+ const shortName = modelName.split('/').pop();
724
+ const globalName = `Global ${shortName}`;
725
+ if (models.some((m) => m.name === globalName)) {
726
+ return false;
727
+ }
728
+ return true;
628
729
  }
629
- return true;
630
730
  }
731
+ return false;
631
732
  }
632
733
  return false;
633
- }
634
- return false;
635
- }).map(model => {
636
- const modelCapability = getModelCapabilities(model.name ?? '', "vertexai");
637
- return {
638
- id: "locations/global/" + model.name,
639
- name: "Global " + model.name?.split('/').pop(),
640
- provider: 'vertexai',
641
- owner: publisher,
642
- input_modalities: modelModalitiesToArray(modelCapability.input),
643
- output_modalities: modelModalitiesToArray(modelCapability.output),
644
- tool_support: modelCapability.tool_support,
645
- } satisfies AIModel<string>;
646
- });
734
+ })
735
+ .map((model) => {
736
+ const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
737
+ return {
738
+ id: `locations/global/${model.name}`,
739
+ name: `Global ${model.name?.split('/').pop()}`,
740
+ provider: 'vertexai',
741
+ owner: publisher,
742
+ input_modalities: modelModalitiesToArray(modelCapability.input),
743
+ output_modalities: modelModalitiesToArray(modelCapability.output),
744
+ tool_support: modelCapability.tool_support,
745
+ } satisfies AIModel<string>;
746
+ });
647
747
 
648
748
  models = models.concat(globalGeminiModels);
649
749
  }
650
750
 
651
751
  // Create global anthropic models for those not in NON_GLOBAL_ANTHROPIC_MODELS
652
752
  if (publisher === 'anthropic') {
653
- const globalAnthropicModels = response.filter((model) => {
654
- const modelName = model.name ?? "";
655
- if (retiredModels.some(retiredModel => modelName.includes(retiredModel))) {
656
- return false;
657
- }
658
- if (modelFamily.some(family => modelName.includes(family))) {
659
- if (modelName.includes("claude-3-7")) {
660
- return true;
753
+ const globalAnthropicModels = response
754
+ .filter((model) => {
755
+ const modelName = model.name ?? '';
756
+ if (excludedModels.some((retiredModel) => modelName.includes(retiredModel))) {
757
+ return false;
661
758
  }
662
- return !NON_GLOBAL_ANTHROPIC_MODELS.some(nonGlobalModel => modelName.includes(nonGlobalModel));
663
- }
664
- return false;
665
- }).map(model => {
666
- const modelCapability = getModelCapabilities(model.name ?? '', "vertexai");
667
- return {
668
- id: "locations/global/" + model.name,
669
- name: "Global " + model.name?.split('/').pop(),
670
- provider: 'vertexai',
671
- owner: publisher,
672
- input_modalities: modelModalitiesToArray(modelCapability.input),
673
- output_modalities: modelModalitiesToArray(modelCapability.output),
674
- tool_support: modelCapability.tool_support,
675
- } satisfies AIModel<string>;
676
- });
759
+ if (modelFamily.some((family) => modelName.includes(family))) {
760
+ if (modelName.includes('claude-3-7')) {
761
+ return true;
762
+ }
763
+ return !NON_GLOBAL_ANTHROPIC_MODELS.some((nonGlobalModel) =>
764
+ modelName.includes(nonGlobalModel),
765
+ );
766
+ }
767
+ return false;
768
+ })
769
+ .map((model) => {
770
+ const modelCapability = getModelCapabilities(model.name ?? '', 'vertexai');
771
+ return {
772
+ id: `locations/global/${model.name}`,
773
+ name: `Global ${model.name?.split('/').pop()}`,
774
+ provider: 'vertexai',
775
+ owner: publisher,
776
+ input_modalities: modelModalitiesToArray(modelCapability.input),
777
+ output_modalities: modelModalitiesToArray(modelCapability.output),
778
+ tool_support: modelCapability.tool_support,
779
+ } satisfies AIModel<string>;
780
+ });
677
781
 
678
782
  models = models.concat(globalAnthropicModels);
679
783
  }
@@ -681,7 +785,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
681
785
  // Add additional models that are not in the listing
682
786
  for (const additionalModel of additionalModels[publisher as keyof typeof additionalModels]) {
683
787
  const publisherModelName = `publishers/${publisher}/models/${additionalModel}`;
684
- const modelCapability = getModelCapabilities(additionalModel, "vertexai");
788
+ const modelCapability = getModelCapabilities(additionalModel, 'vertexai');
685
789
  models.push({
686
790
  id: publisherModelName,
687
791
  name: additionalModel,
@@ -695,54 +799,33 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
695
799
  }
696
800
 
697
801
  //Remove duplicates
698
- const uniqueModels = Array.from(new Set(models.map(a => a.id)))
699
- .map(id => {
700
- return models.find(a => a.id === id) ?? {} as AIModel<string>;
701
- }).sort((a, b) => a.id.localeCompare(b.id));
802
+ const uniqueModels = Array.from(new Set(models.map((a) => a.id)))
803
+ .map((id) => {
804
+ return models.find((a) => a.id === id) ?? ({} as AIModel<string>);
805
+ })
806
+ .sort((a, b) => a.id.localeCompare(b.id));
702
807
 
703
808
  return uniqueModels;
704
809
  }
705
810
 
706
811
  validateConnection(): Promise<boolean> {
707
- throw new Error("Method not implemented.");
812
+ throw new Error('Method not implemented.');
708
813
  }
709
814
 
710
815
  async generateEmbeddings(options: EmbeddingsOptions): Promise<EmbeddingsResult> {
711
- if (options.image || options.model?.includes("multimodal")) {
712
- if (options.text && options.image) {
713
- throw new Error("Text and Image simultaneous embedding not implemented. Submit separately");
714
- }
715
- return getEmbeddingsForImages(this, options);
716
- }
717
- const text_options: TextEmbeddingsOptions = {
718
- content: options.text ?? "",
719
- model: options.model,
720
- };
721
- return getEmbeddingsForText(this, text_options);
722
- }
723
-
724
- /**
725
- * Cleanup Google Cloud clients when the driver is evicted from the cache.
726
- */
727
- destroy(): void {
728
- this.aiplatform?.close();
729
- this.modelGarden?.close();
730
- this.imagenClient?.close();
816
+ return generateVertexAiEmbeddings(this, options);
731
817
  }
732
818
 
733
819
  /**
734
820
  * Format VertexAI errors by routing to model-specific error handlers.
735
821
  * Each model definition (Gemini, Claude, Llama) can provide custom error parsing
736
822
  * based on their specific SDK error structures.
737
- *
823
+ *
738
824
  * @param error - The error from the VertexAI/model SDK
739
825
  * @param context - Context about where the error occurred
740
826
  * @returns A standardized LlumiverseError
741
827
  */
742
- public formatLlumiverseError(
743
- error: unknown,
744
- context: LlumiverseErrorContext
745
- ): LlumiverseError {
828
+ public formatLlumiverseError(error: unknown, context: LlumiverseErrorContext): LlumiverseError {
746
829
  // Get the model definition for this request
747
830
  const modelDef = getModelDefinition(context.model);
748
831
 
@@ -750,7 +833,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
750
833
  if (modelDef.formatLlumiverseError) {
751
834
  try {
752
835
  return modelDef.formatLlumiverseError(this, error, context);
753
- } catch (formattingError) {
836
+ } catch {
754
837
  // If model-specific handler throws, fall through to default handling
755
838
  // This allows model handlers to explicitly opt out for certain errors
756
839
  }
@@ -762,22 +845,25 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
762
845
  }
763
846
 
764
847
  //'us-central1-aiplatform.googleapis.com',
765
- const API_BASE_PATH = "aiplatform.googleapis.com";
848
+ const API_BASE_PATH = 'aiplatform.googleapis.com';
766
849
  function createFetchClient({
767
850
  region,
768
851
  project,
769
852
  apiEndpoint,
770
- apiVersion = "v1",
853
+ apiVersion = 'v1',
854
+ fetchImpl,
771
855
  }: {
772
856
  region: string;
773
857
  project: string;
774
858
  apiEndpoint?: string;
775
859
  apiVersion?: string;
860
+ fetchImpl?: FETCH_FN;
776
861
  }) {
777
862
  const vertexBaseEndpoint = apiEndpoint ?? `${region}-${API_BASE_PATH}`;
778
863
  return new FetchClient(
779
864
  `https://${vertexBaseEndpoint}/${apiVersion}/projects/${project}/locations/${region}`,
865
+ fetchImpl,
780
866
  ).withHeaders({
781
- "Content-Type": "application/json",
867
+ 'Content-Type': 'application/json',
782
868
  });
783
869
  }