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