promptfoo 0.125.0 → 0.125.1

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 (869) hide show
  1. package/README.md +3 -3
  2. package/dist/src/accounts-BOxNYxVN.js +229 -0
  3. package/dist/src/accounts-BezXLdAW.cjs +276 -0
  4. package/dist/src/accounts-CPISMNlh.js +227 -0
  5. package/dist/src/accounts-vJBPs89d.js +222 -0
  6. package/dist/src/agentWorkspace-Bom7SpF2.js +592 -0
  7. package/dist/src/agentWorkspace-CEomAcws.cjs +619 -0
  8. package/dist/src/agentWorkspace-DPtMLrlI.js +593 -0
  9. package/dist/src/agentWorkspace-DkAeEYLz.js +592 -0
  10. package/dist/src/agentic-utils-121v7mJo.js +197 -0
  11. package/dist/src/agentic-utils-CBWD_rcd.cjs +237 -0
  12. package/dist/src/agentic-utils-D8wyQwPG.js +198 -0
  13. package/dist/src/agentic-utils-EP1QkQCs.js +197 -0
  14. package/dist/src/agents-Br3ah8iA.js +778 -0
  15. package/dist/src/agents-C5wj_UTv.js +777 -0
  16. package/dist/src/agents-C9Efp4mC.js +266 -0
  17. package/dist/src/agents-CQYwaVCO.js +267 -0
  18. package/dist/src/agents-CjCd4Vo8.js +777 -0
  19. package/dist/src/agents-DRWiCHYz.js +266 -0
  20. package/dist/src/agents-F2rhx0iL.cjs +266 -0
  21. package/dist/src/agents-RTYyy69h.cjs +777 -0
  22. package/dist/src/agents-api-CY72O86e.js +711 -0
  23. package/dist/src/agents-api-CsSsC21b.js +710 -0
  24. package/dist/src/agents-api-DN-ibDc8.js +710 -0
  25. package/dist/src/agents-api-cNDsCCv1.cjs +710 -0
  26. package/dist/src/ai.studio-Bj6Dyi6o.js +2 -0
  27. package/dist/src/ai.studio-C-e0LzyW.js +369 -0
  28. package/dist/src/ai.studio-CR8M6Aqf.cjs +391 -0
  29. package/dist/src/ai.studio-YKk7F0tv.js +374 -0
  30. package/dist/src/aimlapi-BGunsuTu.js +30 -0
  31. package/dist/src/aimlapi-BkzcfBsL.js +29 -0
  32. package/dist/src/aimlapi-DXFcEdP8.js +28 -0
  33. package/dist/src/aimlapi-r-8iCcAw.cjs +29 -0
  34. package/dist/src/anthropicMessages-7-YNRgQR.js +114 -0
  35. package/dist/src/anthropicMessages-C8m9Whrd.cjs +114 -0
  36. package/dist/src/anthropicMessages-DS1vXD0f.js +115 -0
  37. package/dist/src/anthropicMessages-DmvGkz-0.js +114 -0
  38. package/dist/src/app/assets/index-CrdXWTXm.js +392 -0
  39. package/dist/src/app/browser-inventory.json +4 -4
  40. package/dist/src/app/index.html +1 -1
  41. package/dist/src/audio-BLgFgyw-.cjs +104 -0
  42. package/dist/src/audio-C2sibT7Q.js +104 -0
  43. package/dist/src/audio-DXEXb03H.js +104 -0
  44. package/dist/src/audio-TkvojpwO.js +105 -0
  45. package/dist/src/authoritativeMarkupInjection-BAT9B-Wj.js +79 -0
  46. package/dist/src/authoritativeMarkupInjection-B_yHETKT.js +78 -0
  47. package/dist/src/authoritativeMarkupInjection-BfjecQ3Q.cjs +78 -0
  48. package/dist/src/authoritativeMarkupInjection-D-hDKrhD.js +78 -0
  49. package/dist/src/aws-B_9unI_-.js +1149 -0
  50. package/dist/src/aws-D0FY3qkc.js +2433 -0
  51. package/dist/src/aws-Dh1-a90n.js +2433 -0
  52. package/dist/src/aws-qskKGczY.cjs +2454 -0
  53. package/dist/src/base-CaWlBkVz.js +462 -0
  54. package/dist/src/base-CcViNwVs.js +255 -0
  55. package/dist/src/base-CsVbPJkU.cjs +467 -0
  56. package/dist/src/base-DNK9py25.js +255 -0
  57. package/dist/src/base-DlH5tjEZ.js +463 -0
  58. package/dist/src/base-DyLOZ_iX.js +256 -0
  59. package/dist/src/base-RRYXfG7l.cjs +305 -0
  60. package/dist/src/base-oXVgvtVn.js +462 -0
  61. package/dist/src/bedrock-BP17ZXbR.cjs +2 -0
  62. package/dist/src/bedrock-CsjM1dOt.js +1300 -0
  63. package/dist/src/bedrock-CzPwj8GO.js +1 -0
  64. package/dist/src/bedrock-eGXZw8oh.js +1 -0
  65. package/dist/src/bedrock-tSWjmXdj.js +2 -0
  66. package/dist/src/bestOfN-BQ93nUKV.js +160 -0
  67. package/dist/src/bestOfN-ByGGwlcb.cjs +161 -0
  68. package/dist/src/bestOfN-CbP7csHr.js +159 -0
  69. package/dist/src/bestOfN-xn6i2Xs2.js +159 -0
  70. package/dist/src/cache-CHq9hPz9.js +2 -0
  71. package/dist/src/cache-D-9eZN3I.js +754 -0
  72. package/dist/src/cache-DSm6t1MZ.js +741 -0
  73. package/dist/src/cache-DeF5zIEN.js +782 -0
  74. package/dist/src/cache-iG87oYan.cjs +856 -0
  75. package/dist/src/cerebras-CTtM4yMH.js +98 -0
  76. package/dist/src/cerebras-CogcJ3ce.cjs +97 -0
  77. package/dist/src/cerebras-DmkRypTh.js +97 -0
  78. package/dist/src/cerebras-GUp0B8JY.js +97 -0
  79. package/dist/src/chat-B4ihd3fw.js +226 -0
  80. package/dist/src/chat-B9cAQ_rS.js +227 -0
  81. package/dist/src/chat-BU7EB4R-.cjs +76 -0
  82. package/dist/src/chat-C8yxJ2-s.cjs +226 -0
  83. package/dist/src/chat-ClTFM3qq.js +934 -0
  84. package/dist/src/chat-Cnq0Is68.js +123 -0
  85. package/dist/src/chat-CwrurR57.cjs +987 -0
  86. package/dist/src/chat-D0lsojPv.js +124 -0
  87. package/dist/src/chat-D7_8yFIx.js +76 -0
  88. package/dist/src/chat-DCoETlLG.js +226 -0
  89. package/dist/src/chat-DHE7xaTR.js +76 -0
  90. package/dist/src/chat-DmhT6rz2.cjs +123 -0
  91. package/dist/src/chat-DvfMe8KI.js +123 -0
  92. package/dist/src/chat-DwP5kVnl.js +935 -0
  93. package/dist/src/chat-MB7U-QE2.js +77 -0
  94. package/dist/src/chat-zCWuBKAj.js +934 -0
  95. package/dist/src/claude-agent-sdk-23bIVI75.js +999 -0
  96. package/dist/src/claude-agent-sdk-BACpnIJi.cjs +1005 -0
  97. package/dist/src/claude-agent-sdk-BlYlmcEr.js +999 -0
  98. package/dist/src/claude-agent-sdk-Cr-jqJZl.js +1000 -0
  99. package/dist/src/client-BktbiPx9.cjs +357 -0
  100. package/dist/src/client-CjztEBmW.js +351 -0
  101. package/dist/src/client-mRs2UvH9.js +351 -0
  102. package/dist/src/client-uCz0ydjC.js +352 -0
  103. package/dist/src/cloud-BtYF555L.js +2 -0
  104. package/dist/src/cloud-CVSUEmAy.js +287 -0
  105. package/dist/src/cloud-D7Ifb-Fl.js +599 -0
  106. package/dist/src/cloud-DB5oK5NX.cjs +666 -0
  107. package/dist/src/cloud-ecu989Em.js +657 -0
  108. package/dist/src/cloud-ramjGURF.js +599 -0
  109. package/dist/src/cloudflare-ai-BfDkIjO8.js +133 -0
  110. package/dist/src/cloudflare-ai-D9HaXz1M.js +134 -0
  111. package/dist/src/cloudflare-ai-HrD5WUK8.js +132 -0
  112. package/dist/src/cloudflare-ai-Qdj8aKP2.cjs +133 -0
  113. package/dist/src/cloudflare-gateway-C81uKETQ.js +276 -0
  114. package/dist/src/cloudflare-gateway-CX5Z9X0k.js +276 -0
  115. package/dist/src/cloudflare-gateway-DW-og8gb.js +277 -0
  116. package/dist/src/cloudflare-gateway-iRyXo9n2.cjs +276 -0
  117. package/dist/src/codex-app-server-BFIrSgdy.js +2155 -0
  118. package/dist/src/codex-app-server-By1eDVD4.js +2 -0
  119. package/dist/src/codex-app-server-DKsF4qmY.js +2156 -0
  120. package/dist/src/codex-app-server-n7n4uZzC.cjs +2162 -0
  121. package/dist/src/codex-app-server-xAoELVxu.js +2155 -0
  122. package/dist/src/codex-sdk-C2ZLxa6r.js +1552 -0
  123. package/dist/src/codex-sdk-CzG02tQt.cjs +1588 -0
  124. package/dist/src/codex-sdk-DNxAOhiV.js +2 -0
  125. package/dist/src/codex-sdk-DT3aQezK.js +1557 -0
  126. package/dist/src/codex-sdk-pw9DpcJP.js +1557 -0
  127. package/dist/src/codex-security-B0bLmXJF.js +406 -0
  128. package/dist/src/codex-security-BhYs-3iY.js +406 -0
  129. package/dist/src/codex-security-DQcOfxYW.js +407 -0
  130. package/dist/src/codex-security-DsCWr6GZ.cjs +411 -0
  131. package/dist/src/cometapi-B16asPLX.cjs +55 -0
  132. package/dist/src/cometapi-MgTbZA_H.js +53 -0
  133. package/dist/src/cometapi-i33vKzPV.js +55 -0
  134. package/dist/src/cometapi-wK2UWK0X.js +56 -0
  135. package/dist/src/compatible-COj8ZCy9.js +24 -0
  136. package/dist/src/compatible-CRSsIUGb.cjs +24 -0
  137. package/dist/src/compatible-Dy1vCcNF.js +25 -0
  138. package/dist/src/compatible-aUItQrpk.js +24 -0
  139. package/dist/src/completion-Bn7COFMk.js +119 -0
  140. package/dist/src/completion-Bub2N48b.js +118 -0
  141. package/dist/src/completion-Cf2G9OlM.cjs +123 -0
  142. package/dist/src/conversationScoring-BiTYJ9MD.js +374 -0
  143. package/dist/src/conversationScoring-CKL47uIu.js +373 -0
  144. package/dist/src/conversationScoring-DCvQKp6k.cjs +398 -0
  145. package/dist/src/conversationScoring-DLNJtDZI.js +373 -0
  146. package/dist/src/crescendo-5iLk9WiJ.cjs +734 -0
  147. package/dist/src/crescendo-B5ylG7kW.js +733 -0
  148. package/dist/src/crescendo-BD7k6TIx.js +730 -0
  149. package/dist/src/crescendo-DqO2Ch0P.js +732 -0
  150. package/dist/src/custom-8rv_aG2K.js +617 -0
  151. package/dist/src/custom-BOtrIHFN.js +619 -0
  152. package/dist/src/custom-BvN8seCs.cjs +620 -0
  153. package/dist/src/custom-Cld9v_Y4.js +618 -0
  154. package/dist/src/dataUrl-BdHUey2l.cjs +3187 -0
  155. package/dist/src/dataUrl-DBMifX6C.js +3133 -0
  156. package/dist/src/dataUrl-DUSr-ZvI.js +2868 -0
  157. package/dist/src/decisions-CLazADTw.js +516 -0
  158. package/dist/src/decisions-D5X93awq.js +515 -0
  159. package/dist/src/decisions-DmaeArEn.js +515 -0
  160. package/dist/src/decisions-DyQJyHJz.cjs +514 -0
  161. package/dist/src/docker-C9NYQFeu.js +94 -0
  162. package/dist/src/docker-CGq3mMol.cjs +94 -0
  163. package/dist/src/docker-DOm7nmpl.js +95 -0
  164. package/dist/src/docker-skFN-Kfo.js +93 -0
  165. package/dist/src/embedding-0UbzkTk9.js +82 -0
  166. package/dist/src/embedding-DTrSDt7k.cjs +86 -0
  167. package/dist/src/embedding-j2ORNl5H.js +81 -0
  168. package/dist/src/envoy-BvS8XTQO.js +60 -0
  169. package/dist/src/envoy-Cn6Hzw0e.js +60 -0
  170. package/dist/src/envoy-DC3KWcUY.cjs +60 -0
  171. package/dist/src/envoy-DetHjo5B.js +61 -0
  172. package/dist/src/eval-Cer9dPe9.js +1920 -0
  173. package/dist/src/eval-CytYmI2Z.js +2 -0
  174. package/dist/src/evalResult-DzOq5wt9.js +1300 -0
  175. package/dist/src/evaluator-BxCmvGtv.js +10578 -0
  176. package/dist/src/evaluator-Ct7YDELm.js +2 -0
  177. package/dist/src/evaluatorHelpers-B_AwIrsl.js +600 -0
  178. package/dist/src/evaluatorHelpers-D1Tpc7gd.js +601 -0
  179. package/dist/src/evaluatorHelpers-DRR3rLq0.cjs +622 -0
  180. package/dist/src/fetch-B5KxZuKu.js +1559 -0
  181. package/dist/src/fetch-BG_Jl7ty.js +1556 -0
  182. package/dist/src/fetch-BKlgUg08.cjs +1853 -0
  183. package/dist/src/fetch-C9Fsja0R.js +2 -0
  184. package/dist/src/fetch-CM7P8KWA.cjs +14 -0
  185. package/dist/src/fetch-D0FkIB3G.js +9 -0
  186. package/dist/src/fetch-RXHsZF-J.js +1280 -0
  187. package/dist/src/fetch-rSECy8jR.js +10 -0
  188. package/dist/src/functionCallbackUtils-BB9tmf6a.cjs +262 -0
  189. package/dist/src/functionCallbackUtils-BXk2iY01.js +246 -0
  190. package/dist/src/functionCallbackUtils-B_cYp7P5.js +245 -0
  191. package/dist/src/functionCallbackUtils-BfXnPo0o.js +245 -0
  192. package/dist/src/gemini-image-BXLMADDz.js +471 -0
  193. package/dist/src/gemini-image-BYUZyEUx.js +472 -0
  194. package/dist/src/gemini-image-DSt1QubZ.cjs +471 -0
  195. package/dist/src/gemini-image-DdNDMiZ_.js +471 -0
  196. package/dist/src/goat-9b-uU_k6.js +514 -0
  197. package/dist/src/goat-BCJuiDd0.js +515 -0
  198. package/dist/src/goat-CmAHbemm.js +512 -0
  199. package/dist/src/goat-DdOTdyoS.cjs +515 -0
  200. package/dist/src/goblin-Bp5C5lyb.js +22 -0
  201. package/dist/src/goblin-Dmr7GItI.js +23 -0
  202. package/dist/src/goblin-DpM8wxlf.cjs +22 -0
  203. package/dist/src/goblin-cJyH6Pq-.js +22 -0
  204. package/dist/src/google-B6eaPAbE.js +142 -0
  205. package/dist/src/google-D-FStdN6.cjs +142 -0
  206. package/dist/src/google-DAC7BsCW.js +142 -0
  207. package/dist/src/google-Id18H0Va.js +143 -0
  208. package/dist/src/graders-BjNQWkaB.js +2 -0
  209. package/dist/src/graders-CqdIp_vl.js +15470 -0
  210. package/dist/src/hydra-6Ouh74DE.js +610 -0
  211. package/dist/src/hydra-BHjhZnLB.cjs +612 -0
  212. package/dist/src/hydra-BL6k2REV.js +2 -0
  213. package/dist/src/hydra-BWUc0o67.js +613 -0
  214. package/dist/src/hydra-CUkEOLKw.js +612 -0
  215. package/dist/src/image-B6hG_xhb.js +481 -0
  216. package/dist/src/image-BFaq7Krd.cjs +209 -0
  217. package/dist/src/image-Bql5C0N9.cjs +504 -0
  218. package/dist/src/image-BtZfI2pT.js +163 -0
  219. package/dist/src/image-CIM4oN7Z.cjs +163 -0
  220. package/dist/src/image-CbAl7Jpu.js +209 -0
  221. package/dist/src/image-CiYm_yFw.js +209 -0
  222. package/dist/src/image-DCMNvBiV.js +163 -0
  223. package/dist/src/image-DL7pIuUZ.js +210 -0
  224. package/dist/src/image-ey0kxF8o.js +164 -0
  225. package/dist/src/image-smgIk3rE.js +482 -0
  226. package/dist/src/index.cjs +27 -27
  227. package/dist/src/index.d.cts +8 -8
  228. package/dist/src/index.js +27 -27
  229. package/dist/src/indirectWebPwn-B_-UpWY5.js +285 -0
  230. package/dist/src/indirectWebPwn-Cz3SLiEq.js +434 -0
  231. package/dist/src/indirectWebPwn-D2s8zGiM.cjs +463 -0
  232. package/dist/src/indirectWebPwn-DXbj2wGu.cjs +285 -0
  233. package/dist/src/indirectWebPwn-D_4H44E6.js +285 -0
  234. package/dist/src/indirectWebPwn-L044SrpV.js +434 -0
  235. package/dist/src/indirectWebPwn-cnmvdavH.js +435 -0
  236. package/dist/src/indirectWebPwn-zUBzsqTt.js +286 -0
  237. package/dist/src/interactions-Bu3oVQ-j.js +850 -0
  238. package/dist/src/interactions-CND010Lh.cjs +850 -0
  239. package/dist/src/interactions-DAx7tqUz.js +851 -0
  240. package/dist/src/interactions-DPkIumeh.js +850 -0
  241. package/dist/src/iterative-BO4JRnpG.js +545 -0
  242. package/dist/src/iterative-CAK-k9rz.js +548 -0
  243. package/dist/src/iterative-CDgHc0xO.cjs +549 -0
  244. package/dist/src/iterative-CXJlHLl9.js +547 -0
  245. package/dist/src/iterativeImage-BEdGKSmh.cjs +419 -0
  246. package/dist/src/iterativeImage-BfL0QZw5.js +417 -0
  247. package/dist/src/iterativeImage-C9KhnibC.js +417 -0
  248. package/dist/src/iterativeImage-btjkOfWG.js +418 -0
  249. package/dist/src/iterativeMeta-B5Bdw6QA.js +437 -0
  250. package/dist/src/iterativeMeta-C3mI4gpT.js +440 -0
  251. package/dist/src/iterativeMeta-Co2BKyqS.cjs +439 -0
  252. package/dist/src/iterativeMeta-DD8ihRWD.js +439 -0
  253. package/dist/src/iterativeTree-AMi4GV2O.js +878 -0
  254. package/dist/src/iterativeTree-C8FJOEje.cjs +879 -0
  255. package/dist/src/iterativeTree-CvrY1f2Z.js +877 -0
  256. package/dist/src/iterativeTree-bPtESmaD.js +876 -0
  257. package/dist/src/knowledgeBase-Cf5871e3.js +163 -0
  258. package/dist/src/knowledgeBase-D2PQhqLH.js +164 -0
  259. package/dist/src/knowledgeBase-DpoMw1IH.cjs +163 -0
  260. package/dist/src/knowledgeBase-npGFl763.js +163 -0
  261. package/dist/src/litellm-BBB5DQdt.cjs +146 -0
  262. package/dist/src/litellm-Bo43ow7r.js +145 -0
  263. package/dist/src/litellm-CaU8CMLS.js +146 -0
  264. package/dist/src/litellm-wY7Unh8o.js +147 -0
  265. package/dist/src/live-5g2w-M-E.js +891 -0
  266. package/dist/src/live-BfaXsDyD.cjs +891 -0
  267. package/dist/src/live-C1xewnGD.js +2 -0
  268. package/dist/src/live-DaF7nYy5.js +892 -0
  269. package/dist/src/live-lp3urLUw.js +891 -0
  270. package/dist/src/luma-ray-B7zvKGVG.js +309 -0
  271. package/dist/src/luma-ray-DCf5fnrz.cjs +309 -0
  272. package/dist/src/luma-ray-DepBcn6z.js +309 -0
  273. package/dist/src/luma-ray-XQC4M1pt.js +310 -0
  274. package/dist/src/main.js +26 -26
  275. package/dist/src/mantleChat-7xm95vSV.js +154 -0
  276. package/dist/src/mantleChat-CXhAs5RD.js +155 -0
  277. package/dist/src/mantleChat-CcE-zjfj.cjs +154 -0
  278. package/dist/src/mantleChat-Cpefl7Zm.js +154 -0
  279. package/dist/src/mcp-B0V0ikdM.js +84 -0
  280. package/dist/src/mcp-CV2k2gwj.js +85 -0
  281. package/dist/src/memoryPoisoning-BC5FQQWZ.js +111 -0
  282. package/dist/src/memoryPoisoning-BDwrtZKX.js +111 -0
  283. package/dist/src/memoryPoisoning-BFemS_FF.js +112 -0
  284. package/dist/src/memoryPoisoning-DRs2rbVV.cjs +111 -0
  285. package/dist/src/messages-Bc5oZoAJ.js +1128 -0
  286. package/dist/src/messages-BkaH8fRW.js +1127 -0
  287. package/dist/src/messages-CoHlziS5.js +1127 -0
  288. package/dist/src/messages-Cv_m6kYs.cjs +1161 -0
  289. package/dist/src/mischievousUser-BcyFxrqJ.js +51 -0
  290. package/dist/src/mischievousUser-BlhOQSd2.js +52 -0
  291. package/dist/src/mischievousUser-BuQiKE8D.js +51 -0
  292. package/dist/src/mischievousUser-ChIOk6cT.cjs +51 -0
  293. package/dist/src/modelslab-BXIWBTgX.js +171 -0
  294. package/dist/src/modelslab-ChVsUiaJ.js +170 -0
  295. package/dist/src/modelslab-DZ6BFlDv.js +170 -0
  296. package/dist/src/modelslab-DhRr-vyo.cjs +170 -0
  297. package/dist/src/nova-reel-BL8DrN4_.js +272 -0
  298. package/dist/src/nova-reel-BiOMUm5q.cjs +272 -0
  299. package/dist/src/nova-reel-CTsya1hV.js +273 -0
  300. package/dist/src/nova-reel-kgBY4Svd.js +272 -0
  301. package/dist/src/nova-sonic-CaSSA3Jq.cjs +374 -0
  302. package/dist/src/nova-sonic-DLpmoGsR.js +375 -0
  303. package/dist/src/nova-sonic-DwWc4SoN.js +374 -0
  304. package/dist/src/nova-sonic-qnReTaXm.js +374 -0
  305. package/dist/src/novita-B5mAt3Ui.js +114 -0
  306. package/dist/src/novita-D57vCjDD.js +116 -0
  307. package/dist/src/novita-ITRtG8IJ.js +115 -0
  308. package/dist/src/novita-Rh3T13YO.cjs +115 -0
  309. package/dist/src/nscale-8V7iZ_pI.js +210 -0
  310. package/dist/src/nscale-BQnMv4pH.cjs +209 -0
  311. package/dist/src/nscale-BWZXHZVF.js +209 -0
  312. package/dist/src/nscale-BqrHiUqU.js +207 -0
  313. package/dist/src/openaiResponses-BMtGTu8R.js +317 -0
  314. package/dist/src/openaiResponses-CvcI_viE.js +318 -0
  315. package/dist/src/openaiResponses-DYPZEMX1.cjs +318 -0
  316. package/dist/src/openaiResponses-DZTg1-kb.js +319 -0
  317. package/dist/src/openclaw-BeKuig4g.js +1338 -0
  318. package/dist/src/openclaw-COkdQ83y.js +1337 -0
  319. package/dist/src/openclaw-CSoX_HQ5.cjs +1344 -0
  320. package/dist/src/openclaw-DJlhPGCb.js +1336 -0
  321. package/dist/src/opencode-sdk-BEJftEs6.cjs +1018 -0
  322. package/dist/src/opencode-sdk-DMvBB3V7.js +1013 -0
  323. package/dist/src/opencode-sdk-Df7hMjLO.js +1012 -0
  324. package/dist/src/opencode-sdk-bQp5Xf3W.js +1012 -0
  325. package/dist/src/openinterpreter-B3GgVZjK.js +431 -0
  326. package/dist/src/openinterpreter-BiGcU-HN.cjs +435 -0
  327. package/dist/src/openinterpreter-Buj2l3Eh.js +432 -0
  328. package/dist/src/openinterpreter-C3_Cg5b_.js +431 -0
  329. package/dist/src/pricing-0Pampf0q.cjs +999 -0
  330. package/dist/src/pricing-B8VdhEhY.js +976 -0
  331. package/dist/src/pricing-CtLA-rKA.js +976 -0
  332. package/dist/src/promptfoo-4OkHtH9P.cjs +341 -0
  333. package/dist/src/promptfoo-Bhpm7sH6.js +286 -0
  334. package/dist/src/promptfoo-BqV8ogVA.js +285 -0
  335. package/dist/src/promptfoo-S1Q9OHk_.js +286 -0
  336. package/dist/src/providers-B5zs1ZRv.js +24437 -0
  337. package/dist/src/providers-Cd6CJh6m.js +2 -0
  338. package/dist/src/providers-CpJlgHET.js +24039 -0
  339. package/dist/src/providers-CzvLvK6G.cjs +24180 -0
  340. package/dist/src/quiverai-1E_IvLHn.js +325 -0
  341. package/dist/src/quiverai-BXH004Vv.js +325 -0
  342. package/dist/src/quiverai-Ccya2z8Y.cjs +325 -0
  343. package/dist/src/quiverai-Cez57oe-.js +326 -0
  344. package/dist/src/registry-3zX_M9Ik.js +131 -0
  345. package/dist/src/registry-AuCrKTvS.js +132 -0
  346. package/dist/src/registry-CxXWKtQG.js +131 -0
  347. package/dist/src/registry-DG3o66JQ.cjs +131 -0
  348. package/dist/src/remoteGeneration-CAtvamG6.js +370 -0
  349. package/dist/src/remoteGeneration-CF225pDl.cjs +482 -0
  350. package/dist/src/remoteGeneration-DtnqocnL.js +370 -0
  351. package/dist/src/remoteGeneration-g3KvW-sP.js +371 -0
  352. package/dist/src/responses-BMbaUXQI.js +1098 -0
  353. package/dist/src/responses-B_TOSof-.js +1099 -0
  354. package/dist/src/responses-v-yANwTA.cjs +1109 -0
  355. package/dist/src/runtimeTransform-BBZv-oUZ.js +156 -0
  356. package/dist/src/runtimeTransform-DT2v5ovW.js +156 -0
  357. package/dist/src/runtimeTransform-GXXEIXdS.cjs +161 -0
  358. package/dist/src/runtimeTransform-JTwBQc-P.js +157 -0
  359. package/dist/src/sagemaker-B8D0L4rj.cjs +716 -0
  360. package/dist/src/sagemaker-CR2_AGdB.js +713 -0
  361. package/dist/src/sagemaker-Cd9qSQUV.js +714 -0
  362. package/dist/src/sagemaker-mKlltN4p.js +713 -0
  363. package/dist/src/scanner-PG_8lh8r.js +1971 -0
  364. package/dist/src/server/index.js +55 -55
  365. package/dist/src/server-Bmh7sd9F.js +155 -0
  366. package/dist/src/server-C7b8z6aC.js +63 -0
  367. package/dist/src/server-CAcovgtL.js +2 -0
  368. package/dist/src/server-CuuMfKlh.cjs +74 -0
  369. package/dist/src/server-DMPCj9jy.js +189 -0
  370. package/dist/src/session-BksXvRH_.cjs +69 -0
  371. package/dist/src/session-DOxUjqGQ.js +63 -0
  372. package/dist/src/session-Dujsc-b9.js +62 -0
  373. package/dist/src/session-VjtIxREd.js +62 -0
  374. package/dist/src/shared-Bkyz_7e5.cjs +2185 -0
  375. package/dist/src/shared-DDJg8ycC.js +1929 -0
  376. package/dist/src/shared-Dh3yfRBd.js +1927 -0
  377. package/dist/src/shared-tfPT8Tna.js +1928 -0
  378. package/dist/src/simulatedUser-6JdkyL3k.cjs +252 -0
  379. package/dist/src/simulatedUser-CFr2mr3M.js +248 -0
  380. package/dist/src/simulatedUser-DjwwUqx-.js +247 -0
  381. package/dist/src/slack-C_gIYiUs.js +144 -0
  382. package/dist/src/slack-DhNbz9CM.cjs +144 -0
  383. package/dist/src/slack-Dm2iI1zu.js +145 -0
  384. package/dist/src/strategies-BIY-bNul.js +2248 -0
  385. package/dist/src/strategies-C1KQQj9G.cjs +2420 -0
  386. package/dist/src/strategies-DM_3mReG.js +2385 -0
  387. package/dist/src/telemetry-BhMTibZO.js +2 -0
  388. package/dist/src/telemetry-C04d25BM.cjs +216 -0
  389. package/dist/src/telemetry-CIqy4fSC.js +201 -0
  390. package/dist/src/telemetry-CXozp_6C.js +205 -0
  391. package/dist/src/telemetry-g7PkBxmY.js +205 -0
  392. package/dist/src/togetherai-BvCim68-.js +50 -0
  393. package/dist/src/togetherai-CWyDCA9m.cjs +49 -0
  394. package/dist/src/togetherai-CeSE31vK.js +49 -0
  395. package/dist/src/togetherai-_2W0URf8.js +48 -0
  396. package/dist/src/traceContext-Brw3Oe41.js +1016 -0
  397. package/dist/src/traceContext-DpAYv27G.js +1015 -0
  398. package/dist/src/traceContext-KSqhzZI2.cjs +1032 -0
  399. package/dist/src/transcription-BySopazW.js +175 -0
  400. package/dist/src/transcription-DO4UPkRI.cjs +178 -0
  401. package/dist/src/transcription-RJGBa-pC.js +176 -0
  402. package/dist/src/transcription-fZenF3G5.js +175 -0
  403. package/dist/src/transform-BzhRc5z2.js +125 -0
  404. package/dist/src/transform-CPQu05u6.cjs +154 -0
  405. package/dist/src/transform-DAED8imp.js +126 -0
  406. package/dist/src/transform-DIOIQDmM.js +125 -0
  407. package/dist/src/typesafe-ByE0Kxfg.js +253 -0
  408. package/dist/src/typesafe-CFqGFY34.js +253 -0
  409. package/dist/src/typesafe-DCWIw-CP.cjs +253 -0
  410. package/dist/src/typesafe-DyHFV5Qk.js +254 -0
  411. package/dist/src/util-BHkj9joz.js +2049 -0
  412. package/dist/src/util-CICwIpmu.cjs +934 -0
  413. package/dist/src/util-CePiY2xZ.js +286 -0
  414. package/dist/src/util-CgT3uf4p.js +743 -0
  415. package/dist/src/util-Cj9drvOY.js +1770 -0
  416. package/dist/src/util-ClJRjlQA.cjs +357 -0
  417. package/dist/src/util-Cxf8VF2M.js +395 -0
  418. package/dist/src/util-D7RdV7rS.js +395 -0
  419. package/dist/src/util-DMNFhk47.js +351 -0
  420. package/dist/src/util-DNzh3M0z.js +396 -0
  421. package/dist/src/util-Df7rfMGb.cjs +2305 -0
  422. package/dist/src/util-Kf0KnG_6.js +2051 -0
  423. package/dist/src/util-LEbeiYw_.js +743 -0
  424. package/dist/src/util-WH8CgVs4.js +352 -0
  425. package/dist/src/util-cx6Xw8Lw.cjs +478 -0
  426. package/dist/src/util-qzBqirBH.js +2050 -0
  427. package/dist/src/vertex-CBAMfRz3.js +854 -0
  428. package/dist/src/vertex-CMP2IpN9.js +2 -0
  429. package/dist/src/vertex-CZ5YOotT.js +848 -0
  430. package/dist/src/vertex-DNsh1F1M.cjs +871 -0
  431. package/dist/src/vertexLive-BTXYj3-F.js +55 -0
  432. package/dist/src/vertexLive-Ba_LAqEF.cjs +55 -0
  433. package/dist/src/vertexLive-DM4sFaaj.js +56 -0
  434. package/dist/src/vertexLive-JqZOw7HC.js +55 -0
  435. package/dist/src/video-BY7Q2Gii.cjs +706 -0
  436. package/dist/src/video-CYElP-CK.js +703 -0
  437. package/dist/src/video-C_AdEDH0.js +702 -0
  438. package/dist/src/video-DGvjQ_4j.js +702 -0
  439. package/package.json +1 -1
  440. package/dist/src/accounts-Dpb43yde.cjs +0 -276
  441. package/dist/src/accounts-GKrO1olH.js +0 -229
  442. package/dist/src/accounts-e4FGOsji.js +0 -227
  443. package/dist/src/accounts-sUiEJfkB.js +0 -222
  444. package/dist/src/agentWorkspace-B8A_wuMR.cjs +0 -619
  445. package/dist/src/agentWorkspace-DSPIscXR.js +0 -593
  446. package/dist/src/agentWorkspace-DxUqd-XK.js +0 -592
  447. package/dist/src/agentWorkspace-n0uOJXhD.js +0 -592
  448. package/dist/src/agentic-utils-9bCj4twQ.js +0 -197
  449. package/dist/src/agentic-utils-CyCLuLoj.js +0 -197
  450. package/dist/src/agentic-utils-D23qtOlx.cjs +0 -237
  451. package/dist/src/agentic-utils-DuBMMNCw.js +0 -198
  452. package/dist/src/agents-6hDRNoYD.js +0 -777
  453. package/dist/src/agents-B8w2o7Sc.cjs +0 -777
  454. package/dist/src/agents-Ck0NXl7v.js +0 -777
  455. package/dist/src/agents-CwT3B1qB.js +0 -778
  456. package/dist/src/agents-DOLjfOEq.js +0 -266
  457. package/dist/src/agents-OcF9hq--.js +0 -267
  458. package/dist/src/agents-api-CnZZt8bn.cjs +0 -710
  459. package/dist/src/agents-api-D04u3bmL.js +0 -711
  460. package/dist/src/agents-api-DWw0_Vio.js +0 -710
  461. package/dist/src/agents-api-IWHEwp8i.js +0 -710
  462. package/dist/src/agents-mHt2Mh9O.cjs +0 -266
  463. package/dist/src/agents-sICccZCA.js +0 -266
  464. package/dist/src/ai.studio-Ci4rypDT.js +0 -2
  465. package/dist/src/ai.studio-KkQ6KaHa.js +0 -369
  466. package/dist/src/ai.studio-gSXK2cGI.js +0 -374
  467. package/dist/src/ai.studio-nQF_B4DH.cjs +0 -391
  468. package/dist/src/aimlapi-BeSk5BDV.js +0 -30
  469. package/dist/src/aimlapi-CzNUhdKu.cjs +0 -29
  470. package/dist/src/aimlapi-DCkazDPI.js +0 -29
  471. package/dist/src/aimlapi-WeH5B6K1.js +0 -28
  472. package/dist/src/anthropicMessages-AcNWTpYO.js +0 -115
  473. package/dist/src/anthropicMessages-BUtvzbpL.js +0 -114
  474. package/dist/src/anthropicMessages-DTWhZDCd.js +0 -114
  475. package/dist/src/anthropicMessages-lGVnSgyx.cjs +0 -114
  476. package/dist/src/app/assets/index-CyEI5aDN.js +0 -392
  477. package/dist/src/audio-BE_Duiu1.js +0 -104
  478. package/dist/src/audio-CiUd00k2.cjs +0 -104
  479. package/dist/src/audio-Dop6omna.js +0 -105
  480. package/dist/src/audio-EZNTInr_.js +0 -104
  481. package/dist/src/authoritativeMarkupInjection-BUqH6hNk.js +0 -78
  482. package/dist/src/authoritativeMarkupInjection-BmbJdJO0.cjs +0 -78
  483. package/dist/src/authoritativeMarkupInjection-Cpz12Y3w.js +0 -78
  484. package/dist/src/authoritativeMarkupInjection-W4XfcH91.js +0 -79
  485. package/dist/src/aws-B2Jqbnet.js +0 -2433
  486. package/dist/src/aws-DHtuUIzQ.js +0 -1149
  487. package/dist/src/aws-DLqXP6wY.js +0 -2433
  488. package/dist/src/aws-DfduhmwL.cjs +0 -2454
  489. package/dist/src/base-B9L2Xvpc.js +0 -255
  490. package/dist/src/base-BTZnIsuH.cjs +0 -305
  491. package/dist/src/base-BhaWNQPJ.js +0 -462
  492. package/dist/src/base-Br-G_Xou.js +0 -256
  493. package/dist/src/base-Bzo8hiUS.cjs +0 -467
  494. package/dist/src/base-C82fd2jq.js +0 -463
  495. package/dist/src/base-CRdQwC1W.js +0 -462
  496. package/dist/src/base-CjGwZNOQ.js +0 -255
  497. package/dist/src/bedrock-BdMru_ro.js +0 -1300
  498. package/dist/src/bedrock-CBUmfLX1.cjs +0 -2
  499. package/dist/src/bedrock-DBDxBaF9.js +0 -2
  500. package/dist/src/bedrock-DDrECM21.js +0 -1
  501. package/dist/src/bedrock-DVwkgvRS.js +0 -1
  502. package/dist/src/bestOfN-AKF5beq4.js +0 -159
  503. package/dist/src/bestOfN-C1UIVGJV.js +0 -160
  504. package/dist/src/bestOfN-DlkETbXy.cjs +0 -161
  505. package/dist/src/bestOfN-XIfEgU-g.js +0 -159
  506. package/dist/src/cache-BZaVoKaA.js +0 -2
  507. package/dist/src/cache-CEYhFUsH.js +0 -741
  508. package/dist/src/cache-Cbw1zH6q.js +0 -782
  509. package/dist/src/cache-CdaZNb75.js +0 -754
  510. package/dist/src/cache-DpuIzPxh.cjs +0 -856
  511. package/dist/src/cerebras-Bpn6FPkJ.js +0 -97
  512. package/dist/src/cerebras-CqJ0BRCJ.cjs +0 -97
  513. package/dist/src/cerebras-D4ILa_TY.js +0 -97
  514. package/dist/src/cerebras-DR8uc7ee.js +0 -98
  515. package/dist/src/chat-B7PZfaYp.cjs +0 -987
  516. package/dist/src/chat-BVuSjdEb.js +0 -227
  517. package/dist/src/chat-BsaZRjXN.js +0 -76
  518. package/dist/src/chat-C5liqe3Y.js +0 -226
  519. package/dist/src/chat-C9hyHf5B.js +0 -124
  520. package/dist/src/chat-CFLalAck.js +0 -226
  521. package/dist/src/chat-CN8JGrHu.js +0 -76
  522. package/dist/src/chat-CaHBBpCb.js +0 -123
  523. package/dist/src/chat-CcbLSghx.js +0 -123
  524. package/dist/src/chat-CoSN6sr2.js +0 -934
  525. package/dist/src/chat-CsJRFX8a.cjs +0 -226
  526. package/dist/src/chat-DFoZLvO_.js +0 -934
  527. package/dist/src/chat-DiLQvL7r.js +0 -77
  528. package/dist/src/chat-F6qVSDk3.cjs +0 -123
  529. package/dist/src/chat-Oq4FaJgI.cjs +0 -76
  530. package/dist/src/chat-knMfQUKz.js +0 -935
  531. package/dist/src/claude-agent-sdk-CJkOLpnI.js +0 -999
  532. package/dist/src/claude-agent-sdk-Ckn76PRD.js +0 -999
  533. package/dist/src/claude-agent-sdk-DX0gTr11.cjs +0 -1005
  534. package/dist/src/claude-agent-sdk-LMeikxoR.js +0 -1000
  535. package/dist/src/client-BFf1r6Z8.js +0 -352
  536. package/dist/src/client-CdXyDdDi.js +0 -351
  537. package/dist/src/client-DV8XMu7i.js +0 -351
  538. package/dist/src/client-iEXtOBKW.cjs +0 -357
  539. package/dist/src/cloud-B02qcpjf.js +0 -2
  540. package/dist/src/cloud-BlHP-g1v.cjs +0 -666
  541. package/dist/src/cloud-C9BI4isF.js +0 -287
  542. package/dist/src/cloud-CTTLNdvj.js +0 -657
  543. package/dist/src/cloud-D5X5yQ_d.js +0 -599
  544. package/dist/src/cloud-QxPkpsHA.js +0 -599
  545. package/dist/src/cloudflare-ai-DRTRT1fc.js +0 -132
  546. package/dist/src/cloudflare-ai-DgaXapAV.cjs +0 -133
  547. package/dist/src/cloudflare-ai-DkuJXijS.js +0 -134
  548. package/dist/src/cloudflare-ai-wy9QCHku.js +0 -133
  549. package/dist/src/cloudflare-gateway-9cAN8g29.cjs +0 -276
  550. package/dist/src/cloudflare-gateway-BVFMD292.js +0 -277
  551. package/dist/src/cloudflare-gateway-BuUI4p6I.js +0 -276
  552. package/dist/src/cloudflare-gateway-TlYHizbW.js +0 -276
  553. package/dist/src/codex-app-server-BPz_feug.cjs +0 -2162
  554. package/dist/src/codex-app-server-C9noXM9C.js +0 -2155
  555. package/dist/src/codex-app-server-CEmD-Y5U.js +0 -2
  556. package/dist/src/codex-app-server-DZolc18r.js +0 -2156
  557. package/dist/src/codex-app-server-Dd0A37nO.js +0 -2155
  558. package/dist/src/codex-sdk-BbxjBvBk.cjs +0 -1588
  559. package/dist/src/codex-sdk-BpXeIs-_.js +0 -1557
  560. package/dist/src/codex-sdk-BtQp5X0f.js +0 -1552
  561. package/dist/src/codex-sdk-CH0v9Bk1.js +0 -2
  562. package/dist/src/codex-sdk-CgrN7JB8.js +0 -1557
  563. package/dist/src/codex-security-B5fENNUr.js +0 -406
  564. package/dist/src/codex-security-C6uuJx-y.cjs +0 -411
  565. package/dist/src/codex-security-CifWtZR_.js +0 -407
  566. package/dist/src/codex-security-Kg2bOEKy.js +0 -406
  567. package/dist/src/cometapi-BFpIDLIx.js +0 -55
  568. package/dist/src/cometapi-C6O2PIrN.js +0 -56
  569. package/dist/src/cometapi-D5Yupc6F.js +0 -53
  570. package/dist/src/cometapi-DzgIwJzJ.cjs +0 -55
  571. package/dist/src/compatible-0jhmVfOp.js +0 -25
  572. package/dist/src/compatible-DdtwWdJi.cjs +0 -24
  573. package/dist/src/compatible-Di4nR3sU.js +0 -24
  574. package/dist/src/compatible-iJKLWdnf.js +0 -24
  575. package/dist/src/completion-B0_hVUDG.js +0 -119
  576. package/dist/src/completion-BdI6v0-Q.cjs +0 -123
  577. package/dist/src/completion-CWcJscwv.js +0 -118
  578. package/dist/src/conversationScoring-99EOPJRa.js +0 -373
  579. package/dist/src/conversationScoring-BIq4J0Cq.js +0 -374
  580. package/dist/src/conversationScoring-DARyeATr.cjs +0 -398
  581. package/dist/src/conversationScoring-DS48t4Hb.js +0 -373
  582. package/dist/src/crescendo-CebvXIu4.js +0 -730
  583. package/dist/src/crescendo-CxrLS0oo.js +0 -732
  584. package/dist/src/crescendo-DZQXBSkj.js +0 -733
  585. package/dist/src/crescendo-wjEx68uD.cjs +0 -734
  586. package/dist/src/custom-BiQ-aUNw.cjs +0 -620
  587. package/dist/src/custom-ByyB5Z93.js +0 -619
  588. package/dist/src/custom-C5jOevNb.js +0 -617
  589. package/dist/src/custom-CCrsCz8o.js +0 -618
  590. package/dist/src/dataUrl-C9J7wz9H.js +0 -3133
  591. package/dist/src/dataUrl-CGsBT7UZ.cjs +0 -3187
  592. package/dist/src/dataUrl-CzKvvWNO.js +0 -2868
  593. package/dist/src/decisions-BTusXCUx.cjs +0 -514
  594. package/dist/src/decisions-BYtL9edD.js +0 -515
  595. package/dist/src/decisions-jYix_gCF.js +0 -515
  596. package/dist/src/decisions-nxxfHRAN.js +0 -516
  597. package/dist/src/docker-DDIv4zkg.js +0 -93
  598. package/dist/src/docker-DVLp_5OG.js +0 -94
  599. package/dist/src/docker-INm9w0SY.cjs +0 -94
  600. package/dist/src/docker-sGuoCul_.js +0 -95
  601. package/dist/src/embedding-CAhqLLrR.js +0 -82
  602. package/dist/src/embedding-D94GAsti.cjs +0 -86
  603. package/dist/src/embedding-zb4MAzQy.js +0 -81
  604. package/dist/src/envoy-BMPszwEa.cjs +0 -60
  605. package/dist/src/envoy-Bp-s39_8.js +0 -60
  606. package/dist/src/envoy-BswDt-Ou.js +0 -61
  607. package/dist/src/envoy-rVbYcV80.js +0 -60
  608. package/dist/src/eval-B1-XfrC7.js +0 -2
  609. package/dist/src/eval-pC4qCvLw.js +0 -1920
  610. package/dist/src/evalResult-CzjCb5bd.js +0 -1300
  611. package/dist/src/evaluator-CNq2K7J_.js +0 -10578
  612. package/dist/src/evaluator-LtfxdxEu.js +0 -2
  613. package/dist/src/evaluatorHelpers-C5J0NYpQ.js +0 -601
  614. package/dist/src/evaluatorHelpers-DcdCglCs.cjs +0 -622
  615. package/dist/src/evaluatorHelpers-Rvb88W6B.js +0 -600
  616. package/dist/src/fetch-5HtnNhHg.js +0 -1556
  617. package/dist/src/fetch-BCwjoIFd.js +0 -1559
  618. package/dist/src/fetch-BhfUnKen.js +0 -1280
  619. package/dist/src/fetch-C08w4vVl.js +0 -9
  620. package/dist/src/fetch-DBxy8Tlb.cjs +0 -14
  621. package/dist/src/fetch-DYte6oQX.cjs +0 -1853
  622. package/dist/src/fetch-ElpfcAVG.js +0 -10
  623. package/dist/src/fetch-lM1OIaSt.js +0 -2
  624. package/dist/src/functionCallbackUtils-BCAdWfHO.js +0 -246
  625. package/dist/src/functionCallbackUtils-BYq9qOhG.js +0 -245
  626. package/dist/src/functionCallbackUtils-ByWkmVud.cjs +0 -262
  627. package/dist/src/functionCallbackUtils-D_C_JaFd.js +0 -245
  628. package/dist/src/gemini-image-CAlwaJhZ.js +0 -471
  629. package/dist/src/gemini-image-DJoVoOnZ.cjs +0 -471
  630. package/dist/src/gemini-image-Waio-9Xx.js +0 -472
  631. package/dist/src/gemini-image-vbY6Ftbf.js +0 -471
  632. package/dist/src/goat-BWbtyY9c.js +0 -512
  633. package/dist/src/goat-CXzzeCOQ.cjs +0 -515
  634. package/dist/src/goat-CfgvzSgZ.js +0 -514
  635. package/dist/src/goat-DLeoIHBp.js +0 -515
  636. package/dist/src/goblin-CmfCfwqk.cjs +0 -22
  637. package/dist/src/goblin-CtcaORRH.js +0 -22
  638. package/dist/src/goblin-DF6DDhM-.js +0 -22
  639. package/dist/src/goblin-Nai0xxBV.js +0 -23
  640. package/dist/src/google-ClpkLtKL.cjs +0 -142
  641. package/dist/src/google-CrFgKu9k.js +0 -143
  642. package/dist/src/google-Dj_EIBqS.js +0 -142
  643. package/dist/src/google-e4-vARv6.js +0 -142
  644. package/dist/src/graders-BN1IIa71.js +0 -15470
  645. package/dist/src/graders-C5sCfSP5.js +0 -2
  646. package/dist/src/hydra-B7RfXVBK.js +0 -2
  647. package/dist/src/hydra-C1cFN-Jg.js +0 -613
  648. package/dist/src/hydra-CK6Uc1ia.js +0 -612
  649. package/dist/src/hydra-Dg65rAP_.js +0 -610
  650. package/dist/src/hydra-Fqx8l_Xu.cjs +0 -612
  651. package/dist/src/image-BdlUDAtp.js +0 -163
  652. package/dist/src/image-C-KwEhwt.cjs +0 -163
  653. package/dist/src/image-C76fp6NK.cjs +0 -209
  654. package/dist/src/image-D75ehv3D.js +0 -482
  655. package/dist/src/image-DKtc5v5W.js +0 -209
  656. package/dist/src/image-DT_xOkJY.js +0 -163
  657. package/dist/src/image-DVpdllEE.js +0 -209
  658. package/dist/src/image-DXZ8AzMf.js +0 -481
  659. package/dist/src/image-DZl_1mvy.js +0 -164
  660. package/dist/src/image-DcTD7Ak0.cjs +0 -504
  661. package/dist/src/image-ndxEvBKB.js +0 -210
  662. package/dist/src/indirectWebPwn-70WA5x_q.js +0 -435
  663. package/dist/src/indirectWebPwn-BRVyd3qV.cjs +0 -463
  664. package/dist/src/indirectWebPwn-BsJVsu0q.js +0 -285
  665. package/dist/src/indirectWebPwn-Cw6yJu0i.js +0 -285
  666. package/dist/src/indirectWebPwn-D-PhJzo4.js +0 -286
  667. package/dist/src/indirectWebPwn-DRPHt2I8.js +0 -434
  668. package/dist/src/indirectWebPwn-DXtfFhd9.cjs +0 -285
  669. package/dist/src/indirectWebPwn-DvpNouzc.js +0 -434
  670. package/dist/src/interactions-5ixfW7Cl.js +0 -850
  671. package/dist/src/interactions-BOUzfmg1.cjs +0 -850
  672. package/dist/src/interactions-CSSXcGNc.js +0 -851
  673. package/dist/src/interactions-WB_sgkN0.js +0 -850
  674. package/dist/src/iterative-BShRNqjC.cjs +0 -549
  675. package/dist/src/iterative-BcW_ELtB.js +0 -548
  676. package/dist/src/iterative-BpHbHz8B.js +0 -547
  677. package/dist/src/iterative-YcchP12d.js +0 -545
  678. package/dist/src/iterativeImage-BMFE5Hl7.cjs +0 -419
  679. package/dist/src/iterativeImage-CkSaYLMY.js +0 -417
  680. package/dist/src/iterativeImage-DAEUlQX_.js +0 -418
  681. package/dist/src/iterativeImage-DeUSkEnj.js +0 -417
  682. package/dist/src/iterativeMeta-DbdaKdEO.cjs +0 -439
  683. package/dist/src/iterativeMeta-DcF9JWEK.js +0 -437
  684. package/dist/src/iterativeMeta-DkfPqWIC.js +0 -439
  685. package/dist/src/iterativeMeta-DkrpnVSs.js +0 -440
  686. package/dist/src/iterativeTree-CEMY1FhE.cjs +0 -879
  687. package/dist/src/iterativeTree-Cv5W4tX9.js +0 -877
  688. package/dist/src/iterativeTree-DGvomd3M.js +0 -876
  689. package/dist/src/iterativeTree-KbtC2Mkz.js +0 -878
  690. package/dist/src/knowledgeBase-AYRXn4wO.js +0 -163
  691. package/dist/src/knowledgeBase-BNqQfx01.js +0 -163
  692. package/dist/src/knowledgeBase-C0IaCCVs.js +0 -164
  693. package/dist/src/knowledgeBase-C2uj6wK4.cjs +0 -163
  694. package/dist/src/litellm-CN1ScAwZ.js +0 -147
  695. package/dist/src/litellm-CTjwiKSa.js +0 -146
  696. package/dist/src/litellm-Cd4Nj5ue.js +0 -145
  697. package/dist/src/litellm-DMqLpEBg.cjs +0 -146
  698. package/dist/src/live-Bt50-InO.cjs +0 -891
  699. package/dist/src/live-Bu2ujadG.js +0 -2
  700. package/dist/src/live-C3M52i3p.js +0 -891
  701. package/dist/src/live-CRfHMO3B.js +0 -892
  702. package/dist/src/live-iCIpO14m.js +0 -891
  703. package/dist/src/luma-ray-B8eHC4c8.cjs +0 -309
  704. package/dist/src/luma-ray-BIvkPw0s.js +0 -309
  705. package/dist/src/luma-ray-ChsiBxMA.js +0 -309
  706. package/dist/src/luma-ray-DAvKrInz.js +0 -310
  707. package/dist/src/mantleChat-5YeEXAZI.js +0 -154
  708. package/dist/src/mantleChat-D--mW3hl.js +0 -154
  709. package/dist/src/mantleChat-DHP3siNg.cjs +0 -154
  710. package/dist/src/mantleChat-wBfAX46o.js +0 -155
  711. package/dist/src/mcp-49jlEcTQ.js +0 -85
  712. package/dist/src/mcp-__PIz81I.js +0 -84
  713. package/dist/src/memoryPoisoning-Chxge74M.js +0 -111
  714. package/dist/src/memoryPoisoning-QH6NCUVE.js +0 -112
  715. package/dist/src/memoryPoisoning-tCxZt8Nz.js +0 -111
  716. package/dist/src/memoryPoisoning-ymrRItRR.cjs +0 -111
  717. package/dist/src/messages-BE_eZ7NA.js +0 -1127
  718. package/dist/src/messages-Bo638ShI.js +0 -1127
  719. package/dist/src/messages-BzR0-NQ1.js +0 -1128
  720. package/dist/src/messages-Cbg5Pfd0.cjs +0 -1161
  721. package/dist/src/mischievousUser-BtED2Z5Z.cjs +0 -51
  722. package/dist/src/mischievousUser-KqSOjrDJ.js +0 -51
  723. package/dist/src/mischievousUser-YMD41YNZ.js +0 -51
  724. package/dist/src/mischievousUser-zBxlNdCu.js +0 -52
  725. package/dist/src/modelslab-B8gZxtfE.js +0 -171
  726. package/dist/src/modelslab-C7bmVpTB.js +0 -170
  727. package/dist/src/modelslab-CCeQCTZg.js +0 -170
  728. package/dist/src/modelslab-CvBJGv7y.cjs +0 -170
  729. package/dist/src/nova-reel-BOEWsEKA.cjs +0 -272
  730. package/dist/src/nova-reel-BtyBXq5M.js +0 -273
  731. package/dist/src/nova-reel-C1eF3-EE.js +0 -272
  732. package/dist/src/nova-reel-YhgrxEKT.js +0 -272
  733. package/dist/src/nova-sonic-BaERP20w.js +0 -374
  734. package/dist/src/nova-sonic-CxgM3O-P.cjs +0 -374
  735. package/dist/src/nova-sonic-DJS22fC3.js +0 -375
  736. package/dist/src/nova-sonic-DwvwHyRX.js +0 -374
  737. package/dist/src/novita-D1l2tG0O.js +0 -116
  738. package/dist/src/novita-D84VM3v0.cjs +0 -115
  739. package/dist/src/novita-DGInvwfR.js +0 -115
  740. package/dist/src/novita-vXHkXhTg.js +0 -114
  741. package/dist/src/nscale-CU0Ldr00.js +0 -209
  742. package/dist/src/nscale-ClfKlQeM.cjs +0 -209
  743. package/dist/src/nscale-DxaVnF0x.js +0 -210
  744. package/dist/src/nscale-_poVxIrO.js +0 -207
  745. package/dist/src/openaiResponses-CJGsneNj.js +0 -317
  746. package/dist/src/openaiResponses-CKSl5Sdg.js +0 -319
  747. package/dist/src/openaiResponses-DC8rzFUc.js +0 -318
  748. package/dist/src/openaiResponses-rMHIA3dV.cjs +0 -318
  749. package/dist/src/openclaw-CCbvsNFW.cjs +0 -1344
  750. package/dist/src/openclaw-CZw1lCDZ.js +0 -1336
  751. package/dist/src/openclaw-ChFLgC-a.js +0 -1338
  752. package/dist/src/openclaw-DrPMoRrH.js +0 -1337
  753. package/dist/src/opencode-sdk-2EfIDhFp.cjs +0 -1018
  754. package/dist/src/opencode-sdk-CHw3F845.js +0 -1013
  755. package/dist/src/opencode-sdk-D0EGGxvy.js +0 -1012
  756. package/dist/src/opencode-sdk-jSS7NI2Q.js +0 -1012
  757. package/dist/src/openinterpreter-CY622xHC.js +0 -431
  758. package/dist/src/openinterpreter-DATyhuhP.js +0 -432
  759. package/dist/src/openinterpreter-DDUMyIf1.js +0 -431
  760. package/dist/src/openinterpreter-s5Tz6Lid.cjs +0 -435
  761. package/dist/src/pricing-C498twd2.js +0 -976
  762. package/dist/src/pricing-DBd_bMIh.cjs +0 -999
  763. package/dist/src/pricing-ISrMCskv.js +0 -976
  764. package/dist/src/promptfoo-6p0WG2ih.js +0 -286
  765. package/dist/src/promptfoo-BQRfgNs_.js +0 -285
  766. package/dist/src/promptfoo-Bqo88z20.cjs +0 -341
  767. package/dist/src/promptfoo-Cq5AVI3I.js +0 -286
  768. package/dist/src/providers-ATbeMX5E.cjs +0 -24180
  769. package/dist/src/providers-B7F1FiNI.js +0 -2
  770. package/dist/src/providers-DazIw8mI.js +0 -24039
  771. package/dist/src/providers-QvGlNAD0.js +0 -24437
  772. package/dist/src/quiverai-BPlNcLkV.cjs +0 -325
  773. package/dist/src/quiverai-By99-YmJ.js +0 -325
  774. package/dist/src/quiverai-CmmByDqo.js +0 -325
  775. package/dist/src/quiverai-HZkoJJqw.js +0 -326
  776. package/dist/src/registry-BLTnTfjT.cjs +0 -131
  777. package/dist/src/registry-BMC-COHT.js +0 -132
  778. package/dist/src/registry-C8UZtmBp.js +0 -131
  779. package/dist/src/registry-CfwEUYXG.js +0 -131
  780. package/dist/src/remoteGeneration-Bgg6kC5V.js +0 -370
  781. package/dist/src/remoteGeneration-CKJFE960.cjs +0 -482
  782. package/dist/src/remoteGeneration-DaxwJDKv.js +0 -370
  783. package/dist/src/remoteGeneration-vHMGVKr1.js +0 -371
  784. package/dist/src/responses-BvnyIHrq.js +0 -1099
  785. package/dist/src/responses-CERAgvf-.js +0 -1098
  786. package/dist/src/responses-CwgjeuOg.cjs +0 -1109
  787. package/dist/src/runtimeTransform-3RF9Avyg.cjs +0 -161
  788. package/dist/src/runtimeTransform-C51Z5j4H.js +0 -156
  789. package/dist/src/runtimeTransform-CKE_Iyv8.js +0 -157
  790. package/dist/src/runtimeTransform-Cs11xJpj.js +0 -156
  791. package/dist/src/sagemaker-BJ4dOCxE.js +0 -713
  792. package/dist/src/sagemaker-Bt3JUAWq.js +0 -714
  793. package/dist/src/sagemaker-QVKyLgLF.cjs +0 -716
  794. package/dist/src/sagemaker-l3IB8iTs.js +0 -713
  795. package/dist/src/scanner-DGjIiTZ1.js +0 -1971
  796. package/dist/src/server-BNaLZH6u.js +0 -63
  797. package/dist/src/server-CBMuQul3.js +0 -189
  798. package/dist/src/server-CMKKIzKv.cjs +0 -74
  799. package/dist/src/server-CN2IS9Cs.js +0 -155
  800. package/dist/src/server-ua4cqbjC.js +0 -2
  801. package/dist/src/session-CQIjq_HZ.cjs +0 -69
  802. package/dist/src/session-FTlg8sEu.js +0 -62
  803. package/dist/src/session-GBQXtPWp.js +0 -63
  804. package/dist/src/session-_0-rTdwY.js +0 -62
  805. package/dist/src/shared-BtuO-OAM.js +0 -1927
  806. package/dist/src/shared-Ci78wTZX.js +0 -1928
  807. package/dist/src/shared-Dd3rimdM.js +0 -1929
  808. package/dist/src/shared-KAjFxRre.cjs +0 -2185
  809. package/dist/src/simulatedUser--OjW6xCx.js +0 -247
  810. package/dist/src/simulatedUser-D0-slRye.cjs +0 -252
  811. package/dist/src/simulatedUser-D1Kh_cwA.js +0 -248
  812. package/dist/src/slack-BX0FUevO.js +0 -144
  813. package/dist/src/slack-CcwXFiJE.cjs +0 -144
  814. package/dist/src/slack-CnfqKfXp.js +0 -145
  815. package/dist/src/strategies-2ntcK4tN.js +0 -2248
  816. package/dist/src/strategies-DZIW7Zcs.js +0 -2385
  817. package/dist/src/strategies-YRDF2j-N.cjs +0 -2420
  818. package/dist/src/telemetry-CL8CVA4p.js +0 -205
  819. package/dist/src/telemetry-Cix90qqz.js +0 -201
  820. package/dist/src/telemetry-CkmlqTjV.js +0 -205
  821. package/dist/src/telemetry-DQH7l5bb.js +0 -2
  822. package/dist/src/telemetry-DUCXc1-r.cjs +0 -216
  823. package/dist/src/togetherai-3yUt5Ck7.js +0 -49
  824. package/dist/src/togetherai-BJUByLwt.cjs +0 -49
  825. package/dist/src/togetherai-Bh6KZkmd.js +0 -50
  826. package/dist/src/togetherai-DDl9yk3b.js +0 -48
  827. package/dist/src/traceContext-BiJVppjT.cjs +0 -1032
  828. package/dist/src/traceContext-CKKluULP.js +0 -1016
  829. package/dist/src/traceContext-D3Sk8fO-.js +0 -1015
  830. package/dist/src/transcription-BoVQKIVz.js +0 -175
  831. package/dist/src/transcription-Bs5u8780.js +0 -175
  832. package/dist/src/transcription-Dl654d1p.cjs +0 -178
  833. package/dist/src/transcription-VEvhM1Fu.js +0 -176
  834. package/dist/src/transform-BAbkGpvl.js +0 -125
  835. package/dist/src/transform-C_j4hUH8.js +0 -126
  836. package/dist/src/transform-Da86hs4M.cjs +0 -154
  837. package/dist/src/transform-_i1raQNo.js +0 -125
  838. package/dist/src/typesafe-CKXBeh82.cjs +0 -253
  839. package/dist/src/typesafe-D3VaGeNm.js +0 -253
  840. package/dist/src/typesafe-DYM-SFNH.js +0 -253
  841. package/dist/src/typesafe-LXmSbw8F.js +0 -254
  842. package/dist/src/util-41rb0XHX.js +0 -743
  843. package/dist/src/util-B0WlHYFM.js +0 -2049
  844. package/dist/src/util-BD1R_PsR.js +0 -1770
  845. package/dist/src/util-BLbM_ItC.js +0 -395
  846. package/dist/src/util-C72P0iIa.js +0 -352
  847. package/dist/src/util-C7MpGlJ6.cjs +0 -2305
  848. package/dist/src/util-CCtqagKc.js +0 -286
  849. package/dist/src/util-CM2Ec_uY.js +0 -2051
  850. package/dist/src/util-CSSAWO8v.js +0 -351
  851. package/dist/src/util-CkQc-fx3.cjs +0 -934
  852. package/dist/src/util-DcOlFTFa.cjs +0 -478
  853. package/dist/src/util-DluGTGVB.js +0 -395
  854. package/dist/src/util-PfQ60chz.js +0 -743
  855. package/dist/src/util-f14-CPij.js +0 -396
  856. package/dist/src/util-l9pXX3Eu.cjs +0 -357
  857. package/dist/src/util-o_BnlYqS.js +0 -2050
  858. package/dist/src/vertex-B_-gQgzc.js +0 -2
  859. package/dist/src/vertex-CU4gqoYa.js +0 -854
  860. package/dist/src/vertex-DZ42UHb3.js +0 -848
  861. package/dist/src/vertex-DsYQJA0T.cjs +0 -871
  862. package/dist/src/vertexLive-BvIaHKGB.js +0 -55
  863. package/dist/src/vertexLive-CTULqNx7.js +0 -56
  864. package/dist/src/vertexLive-DjJ_YQBe.cjs +0 -55
  865. package/dist/src/vertexLive-STUGcteB.js +0 -55
  866. package/dist/src/video-CAQGmtEV.js +0 -703
  867. package/dist/src/video-_FSTWlwX.js +0 -702
  868. package/dist/src/video-aBPJPWdt.js +0 -702
  869. package/dist/src/video-gDjkWv5m.cjs +0 -706
@@ -1,2051 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Q as getEnvString, Z as getEnvOverrides, c as logger, nt as getProviderEnvString, ut as getExplicitProviderEnv, z as getAjv } from "./logger-pCNnmVuz.js";
3
- import { _ as transformToolChoice, f as parseChatPrompt, n as calculateCost, r as clampCachedTokens, v as transformTools } from "./shared-DS_sDrmK.js";
4
- import { i as isJavascriptFile } from "./fileExtensions-pf0fAeS_.js";
5
- import { _ as parseFileUrl, a as maybeLoadFromExternalFile, c as maybeLoadToolsFromExternalFile, t as getLoadedFileMimeType } from "./file-DnhgJopr.js";
6
- import { n as renderVarsInObject, o as getNunjucksEngine } from "./render-DdqOpT1Z.js";
7
- import "./util-BD1R_PsR.js";
8
- import { t as resolveProviderEnv } from "./env-BJ9OfjdV.js";
9
- import { n as InvalidToolCallError, t as InvalidToolSchemaError } from "./toolSchemaError-kjNPzS21.js";
10
- import { n as isDataUrl, r as parseDataUrl, t as extractBase64FromDataUrl } from "./dataUrl-CJlC_-p_.js";
11
- import { z as z$1 } from "zod";
12
- import path from "path";
13
- import crypto from "crypto";
14
- import Clone from "rfdc";
15
- //#region src/providers/google/auth.ts
16
- /**
17
- * Centralized authentication manager for Google AI providers.
18
- *
19
- * This module handles authentication for both Google AI Studio and Vertex AI,
20
- * with support for API keys, OAuth/ADC, and service account credentials.
21
- *
22
- * Environment variable priority is aligned with the Python SDK:
23
- * 1. config.apiKey (explicit)
24
- * 2. VERTEX_API_KEY (Vertex mode only)
25
- * 3. GOOGLE_API_KEY (primary - Python SDK alignment)
26
- * 4. GEMINI_API_KEY (secondary)
27
- */
28
- const EXPECTED_GCP_METADATA_LOOKUP_WARNING_PREFIX = "received unexpected error = ";
29
- let activeGcpMetadataLookupWarningSuppressions = 0;
30
- let restoreEmitWarning;
31
- async function suppressExpectedGcpMetadataLookupWarning(action) {
32
- if (activeGcpMetadataLookupWarningSuppressions === 0) {
33
- const originalEmitWarning = process.emitWarning;
34
- const wrappedEmitWarning = ((warning, ...args) => {
35
- const message = warning instanceof Error ? warning.message : warning;
36
- if ((warning instanceof Error ? warning.name : args[0]) === "MetadataLookupWarning" && typeof message === "string" && message.startsWith(EXPECTED_GCP_METADATA_LOOKUP_WARNING_PREFIX)) return;
37
- Reflect.apply(originalEmitWarning, process, [warning, ...args]);
38
- });
39
- process.emitWarning = wrappedEmitWarning;
40
- restoreEmitWarning = () => {
41
- if (process.emitWarning === wrappedEmitWarning) process.emitWarning = originalEmitWarning;
42
- };
43
- }
44
- activeGcpMetadataLookupWarningSuppressions += 1;
45
- try {
46
- return await action();
47
- } finally {
48
- activeGcpMetadataLookupWarningSuppressions -= 1;
49
- if (activeGcpMetadataLookupWarningSuppressions === 0) {
50
- restoreEmitWarning?.();
51
- restoreEmitWarning = void 0;
52
- }
53
- }
54
- }
55
- /**
56
- * Centralized authentication manager for Google AI providers.
57
- *
58
- * Handles:
59
- * - API key resolution with proper priority
60
- * - OAuth client creation for Vertex AI
61
- * - Service account credential loading
62
- * - Conflict detection and warnings
63
- */
64
- var GoogleAuthManager = class {
65
- static cachedHasDefaultCredentials;
66
- static pendingHasDefaultCredentials;
67
- /**
68
- * Get API key with proper priority order.
69
- *
70
- * Environment scope takes priority; aliases are checked in this order within each scope.
71
- * Priority (aligned with Python SDK):
72
- * 1. config.apiKey (explicit)
73
- * 2. VERTEX_API_KEY (Vertex mode only)
74
- * 3. GOOGLE_API_KEY (primary - Python SDK alignment)
75
- * 4. GEMINI_API_KEY (secondary)
76
- * 5. PALM_API_KEY (legacy)
77
- *
78
- * @param config - Provider configuration
79
- * @param env - Environment overrides
80
- * @param isVertexMode - Whether in Vertex AI mode
81
- * @returns The resolved API key and its source
82
- */
83
- static getApiKey(config, env, isVertexMode = false) {
84
- if (config.apiKey) return {
85
- apiKey: config.apiKey,
86
- source: "config"
87
- };
88
- const keys = isVertexMode ? ["VERTEX_API_KEY", "GOOGLE_API_KEY"] : [
89
- "GOOGLE_API_KEY",
90
- "GEMINI_API_KEY",
91
- "PALM_API_KEY"
92
- ];
93
- const masked = /* @__PURE__ */ new Set();
94
- for (const layer of [
95
- getExplicitProviderEnv(env),
96
- getEnvOverrides("provider"),
97
- env,
98
- getEnvOverrides(),
99
- getEnvOverrides("file"),
100
- Object.fromEntries(keys.map((key) => [key, getEnvString(key)]))
101
- ]) for (const source of keys) {
102
- const apiKey = layer?.[source];
103
- if (masked.has(source) || apiKey === void 0) continue;
104
- masked.add(source);
105
- if (!apiKey) continue;
106
- if (source === "VERTEX_API_KEY") logger.warn("[Google] VERTEX_API_KEY is not a standard SDK env var. Use GOOGLE_API_KEY instead.");
107
- else if (source === "PALM_API_KEY") logger.warn("[Google] PALM_API_KEY is deprecated. Use GOOGLE_API_KEY instead.");
108
- else if (source === "GEMINI_API_KEY") logger.debug("[Google] GEMINI_API_KEY is not a standard SDK env var. Consider using GOOGLE_API_KEY.");
109
- else if (!isVertexMode && layer?.GEMINI_API_KEY) logger.debug("[Google] Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.");
110
- return {
111
- apiKey,
112
- source
113
- };
114
- }
115
- return {
116
- apiKey: void 0,
117
- source: "none"
118
- };
119
- }
120
- /**
121
- * Validate authentication configuration and emit warnings or throw errors for issues.
122
- *
123
- * @param config - Authentication configuration
124
- * @param env - Environment overrides
125
- * @throws Error if strictMutualExclusivity is true and mutual exclusivity violation detected
126
- */
127
- static validateAndWarn(config, env) {
128
- const { apiKey, credentials, projectId, region, vertexai, strictMutualExclusivity } = config;
129
- const isStrict = strictMutualExclusivity === true;
130
- const useVertexEnv = getProviderEnvString(env, "GOOGLE_GENAI_USE_VERTEXAI") ?? getEnvString("GOOGLE_GENAI_USE_VERTEXAI");
131
- const cloudProject = env?.GOOGLE_CLOUD_PROJECT ?? getEnvString("GOOGLE_CLOUD_PROJECT");
132
- const hasProjectEnvironment = Boolean(resolveProviderEnv(env, [
133
- "VERTEX_PROJECT_ID",
134
- "GOOGLE_PROJECT_ID",
135
- "GOOGLE_CLOUD_PROJECT"
136
- ])?.value);
137
- if ((projectId || region) && apiKey) {
138
- const message = "[Google] Project/location and API key are mutually exclusive in the client initializer. Use either apiKey for express mode OR projectId/region for OAuth mode, not both.";
139
- if (isStrict) throw new Error(message);
140
- else logger.warn(message);
141
- }
142
- if (useVertexEnv && vertexai === false) logger.warn("[Google] GOOGLE_GENAI_USE_VERTEXAI is set but vertexai: false was specified in config. Config takes precedence.");
143
- if (cloudProject && projectId && cloudProject !== projectId) logger.warn("[Google] Both GOOGLE_CLOUD_PROJECT and config.projectId are set with different values. Using config.projectId.");
144
- if (apiKey && credentials) logger.debug("[Google] Both apiKey and credentials are set. Using API key (express mode). Set expressMode: false to use OAuth/ADC instead.");
145
- if (vertexai && !apiKey && !projectId && !hasProjectEnvironment && !credentials) {
146
- if (!Boolean(env?.GOOGLE_APPLICATION_CREDENTIALS ?? getEnvString("GOOGLE_APPLICATION_CREDENTIALS"))) logger.debug("[Google] Vertex AI mode enabled but no projectId, credentials, or ADC detected. Authentication may fail.");
147
- }
148
- }
149
- /**
150
- * Determine if Vertex AI mode should be used.
151
- *
152
- * Priority:
153
- * 1. Explicit vertexai config flag
154
- * 2. GOOGLE_GENAI_USE_VERTEXAI env var (Python SDK compatibility)
155
- * 3. Auto-detect from projectId/credentials presence
156
- * 4. Default: false (Google AI Studio)
157
- *
158
- * @param config - Provider configuration
159
- * @param env - Environment overrides
160
- * @returns Whether to use Vertex AI mode
161
- */
162
- static determineVertexMode(config, env) {
163
- if (config.vertexai !== void 0) return config.vertexai;
164
- const useVertexEnv = getProviderEnvString(env, "GOOGLE_GENAI_USE_VERTEXAI") ?? getEnvString("GOOGLE_GENAI_USE_VERTEXAI");
165
- if (useVertexEnv === "true" || useVertexEnv === "1") {
166
- logger.debug("[Google] Vertex AI mode enabled via GOOGLE_GENAI_USE_VERTEXAI");
167
- return true;
168
- }
169
- if (useVertexEnv === "false" || useVertexEnv === "0") return false;
170
- const hasProjectId = Boolean(config.projectId || resolveProviderEnv(env, [
171
- "VERTEX_PROJECT_ID",
172
- "GOOGLE_PROJECT_ID",
173
- "GOOGLE_CLOUD_PROJECT"
174
- ])?.value);
175
- const hasCredentials = Boolean(config.credentials);
176
- if (hasProjectId || hasCredentials) {
177
- logger.debug("[Google] Auto-detected Vertex AI mode from projectId/credentials. Set vertexai: true/false explicitly to suppress this message.");
178
- return true;
179
- }
180
- return false;
181
- }
182
- /**
183
- * Load credentials from file or return as-is.
184
- *
185
- * Supports:
186
- * - file:// prefix to load from external file
187
- * - Raw JSON string
188
- * - Pre-parsed object (from config loading pipeline)
189
- *
190
- * @param credentials - Credentials string, file path, or pre-parsed object
191
- * @returns Processed credentials JSON string
192
- */
193
- static loadCredentials(credentials) {
194
- if (!credentials) return;
195
- if (typeof credentials === "object") return JSON.stringify(credentials);
196
- if (credentials.startsWith("file://")) try {
197
- const loaded = maybeLoadFromExternalFile(credentials);
198
- if (typeof loaded === "object") return JSON.stringify(loaded);
199
- return loaded;
200
- } catch (error) {
201
- throw new Error(`Failed to load credentials from file: ${error}`);
202
- }
203
- return credentials;
204
- }
205
- /**
206
- * Get or create a Google OAuth client.
207
- *
208
- * Supports googleAuthOptions passthrough for advanced configuration
209
- * like custom scopes, keyFilename, universeDomain, etc.
210
- *
211
- * @param options - OAuth client options (can also pass string for backward compatibility)
212
- * @returns OAuth client and detected project ID
213
- */
214
- static async getOAuthClient(options = {}) {
215
- const { credentials, googleAuthOptions, scopes, keyFilename } = typeof options === "string" ? { credentials: options } : options;
216
- const resolvedScopes = scopes ?? googleAuthOptions?.scopes ?? "https://www.googleapis.com/auth/cloud-platform";
217
- const authOptions = {
218
- ...googleAuthOptions,
219
- scopes: resolvedScopes
220
- };
221
- if (keyFilename && !authOptions.keyFilename) authOptions.keyFilename = keyFilename;
222
- let GoogleAuthClass;
223
- try {
224
- GoogleAuthClass = (await import("google-auth-library")).GoogleAuth;
225
- } catch {
226
- throw new Error("The google-auth-library package is required for Vertex AI. Please install it: npm install google-auth-library");
227
- }
228
- const auth = new GoogleAuthClass(authOptions);
229
- const processedCredentials = this.loadCredentials(credentials);
230
- let client;
231
- if (processedCredentials) {
232
- let parsedCredentials;
233
- try {
234
- parsedCredentials = JSON.parse(processedCredentials);
235
- } catch (parseError) {
236
- const errorMsg = parseError instanceof Error ? parseError.message : String(parseError);
237
- throw new Error(`[Google] Invalid credentials JSON format: ${errorMsg}`);
238
- }
239
- try {
240
- client = await auth.fromJSON(parsedCredentials);
241
- } catch (error) {
242
- const errorMsg = error instanceof Error ? error.message : String(error);
243
- logger.error(`[Google] Could not load credentials: ${errorMsg}`);
244
- throw new Error(`[Google] Could not load credentials: ${errorMsg}`);
245
- }
246
- } else client = await auth.getClient();
247
- let projectId;
248
- try {
249
- projectId = await auth.getProjectId();
250
- } catch {
251
- projectId = void 0;
252
- }
253
- return {
254
- client,
255
- projectId
256
- };
257
- }
258
- /**
259
- * Resolve project ID from multiple sources.
260
- *
261
- * Priority:
262
- * 1. config.projectId
263
- * 2. Provider-scoped VERTEX_PROJECT_ID / GOOGLE_PROJECT_ID / GOOGLE_CLOUD_PROJECT
264
- * 3. Process-wide VERTEX_PROJECT_ID / GOOGLE_PROJECT_ID / GOOGLE_CLOUD_PROJECT
265
- * 4. Auto-detected from OAuth credentials
266
- *
267
- * @param config - Provider configuration
268
- * @param env - Environment overrides
269
- * @returns Resolved project ID
270
- */
271
- static async resolveProjectId(config, env) {
272
- const project = resolveProviderEnv(env, [
273
- "VERTEX_PROJECT_ID",
274
- "GOOGLE_PROJECT_ID",
275
- "GOOGLE_CLOUD_PROJECT"
276
- ]);
277
- if (project && project.name !== "GOOGLE_CLOUD_PROJECT" && !config.projectId) logger.debug(`[Google] ${project.name} is not a standard SDK env var. Consider using GOOGLE_CLOUD_PROJECT.`);
278
- const configuredProjectId = config.projectId || project?.value;
279
- if (configuredProjectId) return configuredProjectId;
280
- const { projectId: authProjectId } = await this.getOAuthClient({
281
- credentials: config.credentials,
282
- googleAuthOptions: config.googleAuthOptions,
283
- keyFilename: config.keyFilename,
284
- scopes: config.scopes
285
- });
286
- return authProjectId || "";
287
- }
288
- /**
289
- * Resolve region from multiple sources.
290
- *
291
- * Priority:
292
- * 1. config.region
293
- * 2. Provider-scoped VERTEX_REGION / GOOGLE_CLOUD_LOCATION overrides
294
- * 3. Process-wide VERTEX_REGION / GOOGLE_CLOUD_LOCATION env vars
295
- * 4. Model-specific fallback region
296
- * 5. Default: 'global' for Vertex AI without API key (SDK aligned), 'us-central1' otherwise
297
- *
298
- * @param config - Provider configuration
299
- * @param env - Environment overrides
300
- * @param hasApiKey - Whether an API key is configured (affects default region)
301
- * @param modelDefaultRegion - Model-specific fallback region
302
- * @returns Resolved region
303
- */
304
- static resolveRegion(config, env, hasApiKey, modelDefaultRegion) {
305
- const region = resolveProviderEnv(env, ["VERTEX_REGION", "GOOGLE_CLOUD_LOCATION"]);
306
- if (region?.name === "VERTEX_REGION" && !config.region) logger.debug("[Google] VERTEX_REGION is not a standard SDK env var. Consider using GOOGLE_CLOUD_LOCATION.");
307
- const configuredRegion = config.region || region?.value;
308
- if (configuredRegion) return configuredRegion;
309
- if (modelDefaultRegion) return modelDefaultRegion;
310
- if (hasApiKey === false) return "global";
311
- return "us-central1";
312
- }
313
- /**
314
- * Check if Application Default Credentials are available.
315
- *
316
- * @returns True if ADC is available
317
- */
318
- static async hasDefaultCredentials() {
319
- if (this.cachedHasDefaultCredentials !== void 0) return this.cachedHasDefaultCredentials;
320
- if (!this.pendingHasDefaultCredentials) {
321
- const probe = (async () => {
322
- try {
323
- await suppressExpectedGcpMetadataLookupWarning(() => this.getOAuthClient());
324
- return true;
325
- } catch {
326
- return false;
327
- }
328
- })();
329
- this.pendingHasDefaultCredentials = probe;
330
- probe.then((result) => {
331
- if (this.pendingHasDefaultCredentials === probe) this.cachedHasDefaultCredentials = result;
332
- return result;
333
- }).finally(() => {
334
- if (this.pendingHasDefaultCredentials === probe) this.pendingHasDefaultCredentials = void 0;
335
- });
336
- }
337
- return this.pendingHasDefaultCredentials;
338
- }
339
- /**
340
- * Clear internal auth detection caches (useful for testing).
341
- */
342
- static clearCache() {
343
- this.cachedHasDefaultCredentials = void 0;
344
- this.pendingHasDefaultCredentials = void 0;
345
- }
346
- };
347
- const loadCredentials = GoogleAuthManager.loadCredentials.bind(GoogleAuthManager);
348
- const getGoogleClient = GoogleAuthManager.getOAuthClient.bind(GoogleAuthManager);
349
- const resolveProjectId = GoogleAuthManager.resolveProjectId.bind(GoogleAuthManager);
350
- const getGoogleApiKey = GoogleAuthManager.getApiKey.bind(GoogleAuthManager);
351
- const determineGoogleVertexMode = GoogleAuthManager.determineVertexMode.bind(GoogleAuthManager);
352
- const hasGoogleDefaultCredentials = GoogleAuthManager.hasDefaultCredentials.bind(GoogleAuthManager);
353
- GoogleAuthManager.clearCache.bind(GoogleAuthManager);
354
- //#endregion
355
- //#region src/providers/google/shared.ts
356
- const VERTEX_GLOBAL_DEFAULT_MODELS = /* @__PURE__ */ new Set([
357
- "gemini-3.8-flash-tts",
358
- "gemini-3.8-flash-lite-tts",
359
- "gemini-3.8-flash",
360
- "gemini-3.8-flash-cyber",
361
- "gemini-3.7-flash",
362
- "gemini-3.6-flash",
363
- "gemini-3.5-flash",
364
- "gemini-flash-latest",
365
- "gemini-3.5-flash-lite",
366
- "gemini-3.1-pro-preview",
367
- "gemini-3.1-pro-preview-customtools",
368
- "gemini-3.1-flash-lite",
369
- "gemini-flash-lite-latest",
370
- "gemini-3-flash-preview"
371
- ]);
372
- const VERTEX_US_EAST5_DEFAULT_MODELS = /* @__PURE__ */ new Set(["llama-4-maverick-17b-128e-instruct-maas", "llama-4-scout-17b-16e-instruct-maas"]);
373
- function getVertexModelDefaultRegion(modelName) {
374
- if (VERTEX_GLOBAL_DEFAULT_MODELS.has(modelName)) return "global";
375
- if (VERTEX_US_EAST5_DEFAULT_MODELS.has(modelName)) return "us-east5";
376
- }
377
- const GEMINI_FLASH_MODELS = [
378
- {
379
- id: "gemini-3.8-flash",
380
- name: "Gemini 3.8 Flash"
381
- },
382
- {
383
- id: "gemini-3.7-flash",
384
- name: "Gemini 3.7 Flash"
385
- },
386
- {
387
- id: "gemini-3.6-flash",
388
- name: "Gemini 3.6 Flash"
389
- },
390
- {
391
- id: "gemini-3.5-flash-lite",
392
- name: "Gemini 3.5 Flash-Lite"
393
- }
394
- ];
395
- function getVertexApiHostForRegion(region) {
396
- if (region === "global") return "aiplatform.googleapis.com";
397
- if (region === "us" || region === "eu") return `aiplatform.${region}.rep.googleapis.com`;
398
- return `${region}-aiplatform.googleapis.com`;
399
- }
400
- const GEMINI_3_PRO_COST = {
401
- input: 2 / 1e6,
402
- output: 12 / 1e6,
403
- cacheRead: .2 / 1e6
404
- };
405
- const GEMINI_3_PRO_TIERED_COST = {
406
- threshold: 2e5,
407
- above: {
408
- input: 4 / 1e6,
409
- output: 18 / 1e6,
410
- cacheRead: .4 / 1e6
411
- }
412
- };
413
- const GEMINI_2_5_PRO_COST = {
414
- input: 1.25 / 1e6,
415
- output: 10 / 1e6,
416
- cacheRead: .125 / 1e6
417
- };
418
- const GEMINI_2_5_PRO_TIERED_COST = {
419
- threshold: 2e5,
420
- above: {
421
- input: 2.5 / 1e6,
422
- output: 15 / 1e6,
423
- cacheRead: .25 / 1e6
424
- }
425
- };
426
- const GEMINI_FLASH_INTRODUCTORY_PRICING = {
427
- expiresAt: Date.UTC(2027, 0, 1),
428
- multiplier: .5
429
- };
430
- const GEMINI_3_5_FLASH_LITE_COST = {
431
- input: .3 / 1e6,
432
- output: 2.5 / 1e6,
433
- cacheRead: .03 / 1e6,
434
- priorityMultiplier: 1.8,
435
- flexMultiplier: .5
436
- };
437
- /**
438
- * Google AI Studio model pricing used for current requests and saved-evaluation cost scoring.
439
- * Prices are per token (from Google AI pricing page, converted from per-million).
440
- *
441
- * Selected retired IDs remain here so historical results can still be scored. Membership in this
442
- * table does not imply that Google still serves the endpoint.
443
- *
444
- * Note: Vertex AI may have different pricing for some models.
445
- * @see https://ai.google.dev/gemini-api/docs/pricing
446
- * @see https://cloud.google.com/vertex-ai/generative-ai/pricing
447
- */
448
- const GOOGLE_MODELS = [
449
- {
450
- id: "gemini-3.8-flash-cyber",
451
- vertexCost: {
452
- input: 1.5 / 1e6,
453
- output: 7.5 / 1e6,
454
- cacheRead: .15 / 1e6,
455
- priorityMultiplier: 1.8,
456
- flexMultiplier: .5
457
- },
458
- vertexRegionalPremium: 1.1
459
- },
460
- ...[
461
- "gemini-3.8-flash",
462
- "gemini-3.7-flash",
463
- "gemini-3.6-flash",
464
- "gemini-flash-latest"
465
- ].map((id) => ({
466
- id,
467
- cost: {
468
- input: 1.5 / 1e6,
469
- output: 7.5 / 1e6,
470
- cacheRead: .15 / 1e6,
471
- priorityMultiplier: 1.8,
472
- flexMultiplier: .5
473
- },
474
- introductoryPricing: GEMINI_FLASH_INTRODUCTORY_PRICING,
475
- vertexRegionalPremium: 1.1
476
- })),
477
- ...[{
478
- id: "gemini-3.8-flash-tts",
479
- audioOutput: 18 / 1e6
480
- }, {
481
- id: "gemini-3.8-flash-lite-tts",
482
- audioOutput: 12 / 1e6
483
- }].map(({ id, audioOutput }) => ({
484
- id,
485
- cost: {
486
- input: 1 / 1e6,
487
- output: audioOutput,
488
- audioOutput,
489
- priorityMultiplier: 1.8,
490
- flexMultiplier: .5
491
- },
492
- vertexCost: {
493
- input: 1 / 1e6,
494
- output: audioOutput,
495
- audioOutput
496
- },
497
- introductoryPricing: GEMINI_FLASH_INTRODUCTORY_PRICING
498
- })),
499
- {
500
- id: "gemini-3.5-flash",
501
- cost: {
502
- input: 1.5 / 1e6,
503
- output: 9 / 1e6,
504
- cacheRead: .15 / 1e6,
505
- audioInput: 1.5 / 1e6,
506
- priorityMultiplier: 1.8,
507
- flexMultiplier: .5,
508
- flexCacheRead: .08 / 1e6
509
- },
510
- vertexCost: {
511
- input: 1.5 / 1e6,
512
- output: 9 / 1e6,
513
- cacheRead: .15 / 1e6,
514
- audioInput: 1.5 / 1e6,
515
- priorityMultiplier: 1.8,
516
- flexMultiplier: .5,
517
- flexCacheRead: .075 / 1e6
518
- },
519
- vertexRegionalCost: {
520
- input: 1.65 / 1e6,
521
- output: 9.9 / 1e6,
522
- cacheRead: .165 / 1e6,
523
- audioInput: 1.65 / 1e6,
524
- priorityMultiplier: 1.8,
525
- flexMultiplier: .5,
526
- flexCacheRead: .0825 / 1e6
527
- },
528
- vertexRegionalPremium: 1.1
529
- },
530
- ...["gemini-3.5-flash-lite", "gemini-flash-lite-latest"].map((id) => ({
531
- id,
532
- cost: {
533
- ...GEMINI_3_5_FLASH_LITE_COST,
534
- priorityCacheRead: .05 / 1e6,
535
- flexCacheRead: .02 / 1e6
536
- },
537
- vertexCost: GEMINI_3_5_FLASH_LITE_COST,
538
- vertexRegionalPremium: 1.1
539
- })),
540
- ...modelsWithCost([
541
- "gemini-omni-flash-preview",
542
- "gemini-omni-1.1-flash",
543
- "gemini-omni-1.1-flash-preview"
544
- ], {
545
- input: 1.5 / 1e6,
546
- output: 9 / 1e6,
547
- audioInput: 1.5 / 1e6,
548
- videoOutput: 17.5 / 1e6
549
- }),
550
- ...modelsWithCost(["gemini-3.5-live-translate-preview"], {
551
- input: 3.5 / 1e6,
552
- output: 21 / 1e6,
553
- audioInput: 3.5 / 1e6,
554
- audioOutput: 21 / 1e6
555
- }),
556
- ...[
557
- "gemini-3.1-pro-preview",
558
- "gemini-3.1-pro-preview-customtools",
559
- "gemini-pro-latest"
560
- ].map((id) => ({
561
- id,
562
- cost: {
563
- ...GEMINI_3_PRO_COST,
564
- priorityMultiplier: 1.8,
565
- flexMultiplier: .5,
566
- flexCacheRead: GEMINI_3_PRO_COST.cacheRead
567
- },
568
- tieredCost: {
569
- ...GEMINI_3_PRO_TIERED_COST,
570
- above: {
571
- ...GEMINI_3_PRO_TIERED_COST.above,
572
- priorityMultiplier: 1.8,
573
- flexMultiplier: .5,
574
- flexCacheRead: GEMINI_3_PRO_TIERED_COST.above.cacheRead
575
- }
576
- }
577
- })),
578
- ...["gemini-3.1-flash-lite", "gemini-3.1-flash-lite-preview"].map((id) => ({
579
- id,
580
- cost: {
581
- input: .25 / 1e6,
582
- output: 1.5 / 1e6,
583
- cacheRead: .025 / 1e6,
584
- cacheReadAudio: .05 / 1e6,
585
- audioInput: .5 / 1e6,
586
- ...id === "gemini-3.1-flash-lite-preview" ? {} : {
587
- priorityMultiplier: 1.8,
588
- priorityAudioInput: .9 / 1e6,
589
- flexMultiplier: .5,
590
- flexAudioInput: .25 / 1e6
591
- }
592
- },
593
- ...id === "gemini-3.1-flash-lite-preview" ? {} : { vertexRegionalPremium: 1.1 }
594
- })),
595
- ...modelsWithCost([
596
- "gemini-3.8-live",
597
- "gemini-3.8-live-extended-thinking",
598
- "gemini-3.1-flash-live-preview"
599
- ], {
600
- input: .75 / 1e6,
601
- output: 4.5 / 1e6,
602
- audioInput: 3 / 1e6,
603
- audioOutput: 12 / 1e6,
604
- imageInput: 1 / 1e6,
605
- videoInputPerSecond: 33333333333333335e-21
606
- }),
607
- ...modelsWithCost(["gemini-live-2.5-flash-native-audio"], {
608
- input: .5 / 1e6,
609
- output: 2 / 1e6,
610
- audioInput: 3 / 1e6,
611
- audioOutput: 12 / 1e6,
612
- imageInput: 3 / 1e6
613
- }),
614
- ...modelsWithCost(["gemini-3.1-flash-tts-preview"], {
615
- input: 1 / 1e6,
616
- output: 20 / 1e6,
617
- audioOutput: 20 / 1e6
618
- }),
619
- ...modelsWithCost(["gemini-live-2.5-flash-preview-native-audio-09-2025"], {
620
- input: .3 / 1e6,
621
- output: 2 / 1e6,
622
- cacheRead: .075 / 1e6,
623
- audioInput: 3 / 1e6,
624
- audioOutput: 12 / 1e6
625
- }),
626
- ...modelsWithCost(["gemini-2.5-flash-native-audio-latest", "gemini-2.5-flash-native-audio-preview-12-2025"], {
627
- input: .5 / 1e6,
628
- output: 2 / 1e6,
629
- audioInput: 3 / 1e6,
630
- audioOutput: 12 / 1e6
631
- }),
632
- ...modelsWithCost(["gemini-2.5-flash-native-audio-preview-09-2025"], {
633
- input: .3 / 1e6,
634
- output: 2.5 / 1e6,
635
- audioInput: 1 / 1e6
636
- }),
637
- ...modelsWithCost(["gemini-3-flash-preview"], {
638
- input: .5 / 1e6,
639
- output: 3 / 1e6,
640
- cacheRead: .05 / 1e6,
641
- cacheReadAudio: .1 / 1e6,
642
- audioInput: 1 / 1e6,
643
- priorityMultiplier: 1.8,
644
- flexMultiplier: .5,
645
- flexCacheRead: .05 / 1e6,
646
- flexCacheReadAudio: .1 / 1e6
647
- }),
648
- {
649
- id: "gemini-3-pro-preview",
650
- cost: {
651
- ...GEMINI_3_PRO_COST,
652
- priorityMultiplier: 1.8
653
- },
654
- tieredCost: {
655
- ...GEMINI_3_PRO_TIERED_COST,
656
- above: {
657
- ...GEMINI_3_PRO_TIERED_COST.above,
658
- priorityMultiplier: 1.8
659
- }
660
- }
661
- },
662
- ...["gemini-2.5-pro", "gemini-2.5-computer-use-preview-10-2025"].map((id) => ({
663
- id,
664
- cost: id === "gemini-2.5-computer-use-preview-10-2025" ? {
665
- input: 1.25 / 1e6,
666
- output: 10 / 1e6
667
- } : GEMINI_2_5_PRO_COST,
668
- tieredCost: id === "gemini-2.5-computer-use-preview-10-2025" ? {
669
- threshold: 2e5,
670
- above: {
671
- input: 2.5 / 1e6,
672
- output: 15 / 1e6
673
- }
674
- } : GEMINI_2_5_PRO_TIERED_COST
675
- })),
676
- ...modelsWithCost(["gemini-2.5-pro-preview-tts"], {
677
- input: 1 / 1e6,
678
- output: 20 / 1e6,
679
- audioOutput: 20 / 1e6
680
- }),
681
- ...modelsWithCost(["gemini-2.5-flash-preview-tts"], {
682
- input: .5 / 1e6,
683
- output: 10 / 1e6,
684
- audioOutput: 10 / 1e6
685
- }),
686
- ...modelsWithCost(["gemini-2.5-flash", "gemini-2.5-flash-preview-04-17"], {
687
- input: .3 / 1e6,
688
- output: 2.5 / 1e6,
689
- cacheRead: .03 / 1e6,
690
- cacheReadAudio: .1 / 1e6,
691
- audioInput: 1 / 1e6
692
- }),
693
- ...modelsWithCost(["gemini-2.5-flash-lite"], {
694
- input: .1 / 1e6,
695
- output: .4 / 1e6,
696
- cacheRead: .01 / 1e6,
697
- cacheReadAudio: .03 / 1e6,
698
- audioInput: .3 / 1e6
699
- }),
700
- ...["gemini-2.0-flash", "gemini-2.0-flash-001"].map((id) => ({
701
- id,
702
- cost: {
703
- input: .1 / 1e6,
704
- output: .4 / 1e6,
705
- cacheRead: .025 / 1e6,
706
- cacheReadAudio: .175 / 1e6,
707
- audioInput: .7 / 1e6
708
- },
709
- vertexCost: {
710
- input: .15 / 1e6,
711
- output: .6 / 1e6,
712
- cacheRead: .0375 / 1e6,
713
- audioInput: 1 / 1e6
714
- }
715
- })),
716
- ...modelsWithCost(["gemini-2.0-flash-lite", "gemini-2.0-flash-lite-001"], {
717
- input: .075 / 1e6,
718
- output: .3 / 1e6,
719
- cacheRead: .01875 / 1e6,
720
- audioInput: .075 / 1e6
721
- }),
722
- {
723
- id: "gemini-1.5-pro",
724
- cost: {
725
- input: 1.25 / 1e6,
726
- output: 5 / 1e6
727
- },
728
- tieredCost: {
729
- threshold: 128e3,
730
- above: {
731
- input: 2.5 / 1e6,
732
- output: 10 / 1e6
733
- }
734
- }
735
- },
736
- ...[
737
- "gemini-1.5-pro-001",
738
- "gemini-1.5-pro-002",
739
- "gemini-1.5-pro-latest"
740
- ].map((id) => ({
741
- id,
742
- cost: {
743
- input: 1.25 / 1e6,
744
- output: 5 / 1e6
745
- },
746
- tieredCost: {
747
- threshold: 128e3,
748
- above: {
749
- input: 2.5 / 1e6,
750
- output: 10 / 1e6
751
- }
752
- }
753
- })),
754
- ...["gemini-1.5-pro-preview-0409", "gemini-1.5-pro-preview-0514"].map((id) => ({
755
- id,
756
- cost: {
757
- input: 1.25 / 1e6,
758
- output: 5 / 1e6
759
- },
760
- tieredCost: {
761
- threshold: 128e3,
762
- above: {
763
- input: 2.5 / 1e6,
764
- output: 10 / 1e6
765
- }
766
- }
767
- })),
768
- ...[
769
- "gemini-1.5-flash",
770
- "gemini-1.5-flash-001",
771
- "gemini-1.5-flash-002",
772
- "gemini-1.5-flash-latest",
773
- "gemini-1.5-flash-preview-0514"
774
- ].map((id) => ({
775
- id,
776
- cost: {
777
- input: .075 / 1e6,
778
- output: .3 / 1e6
779
- },
780
- tieredCost: {
781
- threshold: 128e3,
782
- above: {
783
- input: .15 / 1e6,
784
- output: .6 / 1e6
785
- }
786
- }
787
- })),
788
- ...[
789
- "gemini-1.5-flash-8b",
790
- "gemini-1.5-flash-8b-001",
791
- "gemini-1.5-flash-8b-latest"
792
- ].map((id) => ({
793
- id,
794
- cost: {
795
- input: .0375 / 1e6,
796
- output: .15 / 1e6
797
- },
798
- tieredCost: {
799
- threshold: 128e3,
800
- above: {
801
- input: .075 / 1e6,
802
- output: .3 / 1e6
803
- }
804
- }
805
- })),
806
- ...modelsWithCost([
807
- "gemini-1.0-pro",
808
- "gemini-1.0-pro-001",
809
- "gemini-1.0-pro-002",
810
- "gemini-1.0-pro-vision",
811
- "gemini-1.0-pro-vision-001"
812
- ], {
813
- input: .5 / 1e6,
814
- output: 1.5 / 1e6
815
- }),
816
- ...modelsWithCost(["gemini-pro"], {
817
- input: .5 / 1e6,
818
- output: 1.5 / 1e6
819
- }),
820
- ...modelsWithCost(["gemini-pro-vision"], {
821
- input: .5 / 1e6,
822
- output: 1.5 / 1e6
823
- }),
824
- ...modelsWithCost(["gemini-robotics-er-1.6-preview"], {
825
- input: 1 / 1e6,
826
- output: 5 / 1e6,
827
- audioInput: 2 / 1e6
828
- }),
829
- ...modelsWithCost(["gemini-robotics-er-2-preview"], {
830
- input: 2 / 1e6,
831
- output: 10 / 1e6,
832
- cacheRead: .2 / 1e6
833
- }),
834
- ...modelsWithCost(["gemini-robotics-er-2-streaming-preview"], {
835
- input: 2 / 1e6,
836
- output: 10 / 1e6
837
- }),
838
- ...modelsWithCost([
839
- "gemini-embedding-2",
840
- "embedding-2-preview",
841
- "gemini-embedding-2-preview"
842
- ], {
843
- input: .2 / 1e6,
844
- output: 0
845
- }),
846
- ...modelsWithCost(["gemini-embedding-001"], {
847
- input: .15 / 1e6,
848
- output: 0
849
- }),
850
- { id: "aqa" },
851
- { id: "chat-bison" },
852
- { id: "chat-bison-32k" },
853
- { id: "chat-bison-32k@001" },
854
- { id: "chat-bison-32k@002" },
855
- { id: "chat-bison@001" },
856
- { id: "chat-bison@002" },
857
- { id: "codechat-bison" },
858
- { id: "codechat-bison-32k" },
859
- { id: "codechat-bison-32k@001" },
860
- { id: "codechat-bison-32k@002" },
861
- { id: "codechat-bison@001" },
862
- { id: "codechat-bison@002" },
863
- { id: "gemini-ultra" },
864
- { id: "gemma" },
865
- { id: "gemma-4-31b-it" },
866
- { id: "gemma-4-26b-a4b-it" },
867
- { id: "codegemma" },
868
- { id: "paligemma" },
869
- { id: "medlm-medium" },
870
- { id: "medlm-large" }
871
- ];
872
- /**
873
- * List of chat model IDs for backwards compatibility.
874
- * Used for model validation in ai.studio.ts.
875
- */
876
- const CHAT_MODELS = GOOGLE_MODELS.map((m) => m.id);
877
- function modelsWithCost(ids, cost) {
878
- return ids.map((id) => ({
879
- id,
880
- cost: { ...cost }
881
- }));
882
- }
883
- //#endregion
884
- //#region src/providers/google/types.ts
885
- const VALID_SCHEMA_TYPES = [
886
- "TYPE_UNSPECIFIED",
887
- "STRING",
888
- "NUMBER",
889
- "INTEGER",
890
- "BOOLEAN",
891
- "ARRAY",
892
- "OBJECT"
893
- ];
894
- //#endregion
895
- //#region src/providers/google/util.ts
896
- /**
897
- * Normalizes safety settings to use the correct Google API field name `threshold`.
898
- * Accepts the legacy `probability` field for backwards compatibility and maps it to `threshold`.
899
- */
900
- function normalizeSafetySettings(safetySettings) {
901
- if (!safetySettings) return;
902
- return safetySettings.map(({ category, threshold, probability }) => ({
903
- category,
904
- threshold: threshold || probability || ""
905
- }));
906
- }
907
- /** Normalize supported tier names, including legacy prefixed configuration values. */
908
- function normalizeGoogleServiceTier(serviceTier) {
909
- if (typeof serviceTier !== "string") return;
910
- const normalized = serviceTier.toLowerCase().replace(/^service_tier_/, "");
911
- if (normalized !== "standard" && normalized !== "priority" && normalized !== "flex") return serviceTier;
912
- return normalized;
913
- }
914
- /** Add the documented Vertex PayGo tier without overriding an explicit custom header. */
915
- function getVertexServiceTierHeaders(serviceTier, headers = {}) {
916
- const headerName = "X-Vertex-AI-LLM-Shared-Request-Type";
917
- if (Object.keys(headers).some((name) => name.toLowerCase() === headerName.toLowerCase())) return headers;
918
- const normalized = normalizeGoogleServiceTier(serviceTier);
919
- return normalized === "priority" || normalized === "flex" ? {
920
- [headerName]: normalized,
921
- ...headers
922
- } : headers;
923
- }
924
- /** Read the actual processing tier before estimating costs for a downgraded request. */
925
- function getGoogleResponseServiceTier(headers, usageMetadata, vertexai = false) {
926
- let headerValue;
927
- if (headers && typeof headers === "object") {
928
- const headerCollection = headers;
929
- headerValue = typeof headerCollection.get === "function" ? headerCollection.get("x-gemini-service-tier") : Object.entries(headerCollection).find(([name]) => name.toLowerCase() === "x-gemini-service-tier")?.[1];
930
- }
931
- const metadata = usageMetadata;
932
- if (headerValue == null && vertexai && metadata?.trafficType !== void 0) switch (metadata.trafficType) {
933
- case "ON_DEMAND": return "standard";
934
- case "ON_DEMAND_PRIORITY": return "priority";
935
- case "ON_DEMAND_FLEX": return "flex";
936
- default: return;
937
- }
938
- const normalized = normalizeGoogleServiceTier(headerValue ?? metadata?.serviceTier ?? metadata?.service_tier);
939
- return normalized === "standard" || normalized === "priority" || normalized === "flex" ? normalized : void 0;
940
- }
941
- function normalizeGoogleToolMode(mode) {
942
- if (typeof mode !== "string") return;
943
- switch (mode.toUpperCase()) {
944
- case "MODE_UNSPECIFIED":
945
- case "AUTO":
946
- case "VALIDATED":
947
- case "ANY":
948
- case "NONE": return mode.toUpperCase();
949
- default: return;
950
- }
951
- }
952
- function normalizeCamelCaseGoogleToolConfig(config) {
953
- const { functionCallingConfig: rawFunctionCallingConfig, ...restToolConfig } = config;
954
- const normalizedToolConfig = { ...restToolConfig };
955
- if (rawFunctionCallingConfig) {
956
- const { mode: rawMode, allowedFunctionNames, ...restFunctionCallingConfig } = rawFunctionCallingConfig;
957
- const mode = normalizeGoogleToolMode(rawMode);
958
- const functionCallingConfig = {
959
- ...restFunctionCallingConfig,
960
- ...mode ? { mode } : {},
961
- ...allowedFunctionNames?.length ? { allowedFunctionNames } : {}
962
- };
963
- if (Object.keys(functionCallingConfig).length > 0) normalizedToolConfig.functionCallingConfig = functionCallingConfig;
964
- }
965
- return Object.keys(normalizedToolConfig).length > 0 ? normalizedToolConfig : void 0;
966
- }
967
- function normalizeSnakeCaseGoogleToolConfig(config) {
968
- const { function_calling_config: rawFunctionCallingConfig, retrieval_config: retrievalConfig, include_server_side_tool_invocations: includeServerSideToolInvocations } = config;
969
- const normalizedToolConfig = {
970
- ...retrievalConfig ? { retrievalConfig: {
971
- ...retrievalConfig.lat_lng ? { latLng: retrievalConfig.lat_lng } : {},
972
- ...retrievalConfig.language_code ? { languageCode: retrievalConfig.language_code } : {}
973
- } } : {},
974
- ...includeServerSideToolInvocations === void 0 ? {} : { includeServerSideToolInvocations }
975
- };
976
- if (rawFunctionCallingConfig) {
977
- const { mode: rawMode, allowed_function_names: allowedFunctionNames, stream_function_call_arguments: streamFunctionCallArguments } = rawFunctionCallingConfig;
978
- const mode = normalizeGoogleToolMode(rawMode);
979
- const functionCallingConfig = {
980
- ...mode ? { mode } : {},
981
- ...allowedFunctionNames?.length ? { allowedFunctionNames } : {},
982
- ...streamFunctionCallArguments === void 0 ? {} : { streamFunctionCallArguments }
983
- };
984
- if (Object.keys(functionCallingConfig).length > 0) normalizedToolConfig.functionCallingConfig = functionCallingConfig;
985
- }
986
- return Object.keys(normalizedToolConfig).length > 0 ? normalizedToolConfig : void 0;
987
- }
988
- function normalizeGoogleToolConfig(config) {
989
- if (config.toolConfig) return normalizeCamelCaseGoogleToolConfig(config.toolConfig);
990
- return config.tool_config ? normalizeSnakeCaseGoogleToolConfig(config.tool_config) : void 0;
991
- }
992
- function resolveGoogleToolConfig(config) {
993
- const explicitConfig = normalizeGoogleToolConfig(config);
994
- const passthrough = config.passthrough;
995
- const passthroughConfig = passthrough ? normalizeGoogleToolConfig(passthrough) : void 0;
996
- const transformedToolChoice = transformToolChoice(config.tool_choice, "google");
997
- const toolChoiceConfig = transformedToolChoice && typeof transformedToolChoice === "object" ? transformedToolChoice : void 0;
998
- const toolConfig = {
999
- ...toolChoiceConfig,
1000
- ...explicitConfig,
1001
- ...passthroughConfig
1002
- };
1003
- const functionCallingConfig = {
1004
- ...toolChoiceConfig?.functionCallingConfig,
1005
- ...explicitConfig?.functionCallingConfig,
1006
- ...passthroughConfig?.functionCallingConfig
1007
- };
1008
- if (Object.keys(functionCallingConfig).length > 0) toolConfig.functionCallingConfig = functionCallingConfig;
1009
- return {
1010
- ...Object.keys(toolConfig).length > 0 ? { toolConfig } : {},
1011
- toolsDisabled: functionCallingConfig.mode === "NONE"
1012
- };
1013
- }
1014
- /** Merge configured tools with single-object or array passthrough tools. */
1015
- function mergeGoogleRequestTools(configuredTools, passthroughTools) {
1016
- if (passthroughTools === void 0) return configuredTools.length > 0 ? configuredTools : void 0;
1017
- return [...configuredTools, ...Array.isArray(passthroughTools) ? passthroughTools : [passthroughTools]];
1018
- }
1019
- /** Resolve native Gemini endpoints consistently across text and image adapters. */
1020
- function getGoogleApiBaseUrl(config, env) {
1021
- if (config.apiHost) return `https://${getNunjucksEngine().renderString(config.apiHost, {})}`;
1022
- if (config.apiBaseUrl) return config.apiBaseUrl;
1023
- const endpoint = resolveProviderEnv(env, [
1024
- "GOOGLE_API_HOST",
1025
- "PALM_API_HOST",
1026
- "GOOGLE_API_BASE_URL"
1027
- ]);
1028
- if (endpoint?.name === "GOOGLE_API_BASE_URL") return endpoint.value;
1029
- return `https://${getNunjucksEngine().renderString(endpoint?.value || "generativelanguage.googleapis.com", {})}`;
1030
- }
1031
- function mergeGoogleCompletionOptions(baseConfig, promptConfig) {
1032
- const mergedConfig = {
1033
- ...baseConfig,
1034
- ...promptConfig
1035
- };
1036
- const promptHasToolChoice = promptConfig?.tool_choice !== void 0;
1037
- const promptHasToolConfig = promptConfig?.toolConfig !== void 0;
1038
- const promptHasSnakeToolConfig = promptConfig?.tool_config !== void 0;
1039
- if (promptHasToolChoice || promptHasToolConfig || promptHasSnakeToolConfig) {
1040
- delete mergedConfig.tool_choice;
1041
- delete mergedConfig.toolConfig;
1042
- delete mergedConfig.tool_config;
1043
- if (promptHasToolChoice) mergedConfig.tool_choice = promptConfig.tool_choice;
1044
- if (promptHasToolConfig) mergedConfig.toolConfig = promptConfig.toolConfig;
1045
- if (promptHasSnakeToolConfig) mergedConfig.tool_config = promptConfig.tool_config;
1046
- if (promptHasToolChoice && !promptHasToolConfig && !promptHasSnakeToolConfig) {
1047
- const baseToolConfig = normalizeGoogleToolConfig(baseConfig);
1048
- if (baseToolConfig) {
1049
- const { functionCallingConfig: _functionCallingConfig, ...nonFunctionToolConfig } = baseToolConfig;
1050
- if (Object.keys(nonFunctionToolConfig).length > 0) mergedConfig.toolConfig = nonFunctionToolConfig;
1051
- }
1052
- }
1053
- if (promptConfig?.passthrough === void 0 && baseConfig.passthrough) {
1054
- const passthrough = { ...baseConfig.passthrough };
1055
- const inheritedToolConfig = normalizeGoogleToolConfig(passthrough);
1056
- delete passthrough.toolConfig;
1057
- delete passthrough.tool_config;
1058
- if (inheritedToolConfig) {
1059
- const { functionCallingConfig: _functionCallingConfig, ...nonFunctionToolConfig } = inheritedToolConfig;
1060
- if (Object.keys(nonFunctionToolConfig).length > 0) passthrough.toolConfig = nonFunctionToolConfig;
1061
- }
1062
- mergedConfig.passthrough = passthrough;
1063
- }
1064
- }
1065
- return mergedConfig;
1066
- }
1067
- function removeGoogleFunctionDeclarations(tools) {
1068
- return (Array.isArray(tools) ? tools : [tools]).flatMap((rawTool) => {
1069
- if (!rawTool || typeof rawTool !== "object" || Array.isArray(rawTool)) return [];
1070
- const { functionDeclarations, function_declarations, ...tool } = rawTool;
1071
- return (functionDeclarations || function_declarations) && Object.keys(tool).length === 0 ? [] : [tool];
1072
- });
1073
- }
1074
- /**
1075
- * Current Gemini Flash models ignore sampling parameters and reject penalties
1076
- * and candidate counts. Remove typed and passthrough spellings.
1077
- */
1078
- function removeDeprecatedGeminiGenerationParams(modelName, generationConfig) {
1079
- if (!GEMINI_FLASH_MODELS.some(({ id }) => modelName.startsWith(id)) && modelName !== "gemini-flash-latest" && modelName !== "gemini-flash-lite-latest") return generationConfig;
1080
- if (!generationConfig || typeof generationConfig !== "object" || Array.isArray(generationConfig)) return generationConfig;
1081
- const sanitized = { ...generationConfig };
1082
- for (const field of [
1083
- "temperature",
1084
- "topP",
1085
- "top_p",
1086
- "topK",
1087
- "top_k",
1088
- "candidateCount",
1089
- "candidate_count",
1090
- "presencePenalty",
1091
- "presence_penalty",
1092
- "frequencyPenalty",
1093
- "frequency_penalty"
1094
- ]) delete sanitized[field];
1095
- if (modelName.startsWith("gemini-3.8-flash") || modelName.startsWith("gemini-3.7-flash") || modelName === "gemini-flash-latest") for (const config of [sanitized.thinkingConfig, sanitized.thinking_config]) {
1096
- const thinkingConfig = config;
1097
- if (thinkingConfig?.thinkingBudget !== void 0 || thinkingConfig?.thinking_budget !== void 0) throw new Error(`${modelName} does not support thinkingBudget. Use thinkingLevel (LOW, MEDIUM, or HIGH).`);
1098
- const thinkingLevel = thinkingConfig?.thinkingLevel ?? thinkingConfig?.thinking_level;
1099
- if (typeof thinkingLevel === "string" && thinkingLevel.toUpperCase() === "MINIMAL") throw new Error(`${modelName} does not support MINIMAL thinking. Use LOW, MEDIUM, or HIGH.`);
1100
- }
1101
- return sanitized;
1102
- }
1103
- function stripExecutableToolFileReferencesFromValue(tools) {
1104
- if (typeof tools === "string" && tools.startsWith("file://")) {
1105
- const { filePath } = parseFileUrl(tools);
1106
- if (filePath.endsWith(".py") || isJavascriptFile(filePath)) return;
1107
- }
1108
- if (Array.isArray(tools)) return tools.flatMap((tool) => {
1109
- const strippedTool = stripExecutableToolFileReferencesFromValue(tool);
1110
- return strippedTool === void 0 ? [] : [strippedTool];
1111
- });
1112
- return tools;
1113
- }
1114
- function stripExecutableToolFileReferences(tools, vars) {
1115
- return stripExecutableToolFileReferencesFromValue(renderVarsInObject(tools, vars));
1116
- }
1117
- /** Load and normalize configured tools using the shared file and variable handling. */
1118
- async function loadGoogleTools(tools, vars, options = {}) {
1119
- const requestTools = options.skipExecutableToolFiles ? stripExecutableToolFileReferences(tools, vars) : tools;
1120
- const loadedTools = requestTools ? await maybeLoadToolsFromExternalFile(requestTools, options.skipExecutableToolFiles ? void 0 : vars, options.abortSignal) : [];
1121
- return normalizeTools(Array.isArray(loadedTools) ? transformTools(loadedTools, "google") : loadedTools ? [loadedTools] : []);
1122
- }
1123
- function getServiceTierCacheRead(modelCost, serviceTier, modality = "default") {
1124
- if (serviceTier === "priority") return modality === "audio" ? modelCost.priorityCacheReadAudio ?? modelCost.priorityCacheRead : modelCost.priorityCacheRead;
1125
- if (serviceTier === "flex") return modality === "audio" ? modelCost.flexCacheReadAudio ?? modelCost.flexCacheRead : modelCost.flexCacheRead;
1126
- }
1127
- function resolveServiceTierCacheCost(defaultCost, exactTierCost, serviceTierMultiplier) {
1128
- return exactTierCost === void 0 ? defaultCost : exactTierCost / serviceTierMultiplier;
1129
- }
1130
- function resolveGoogleServiceTierCosts(modelCost, serviceTier, cachedInputCost, cachedAudioInputCost, cachedImageInputCost, audioInputCost) {
1131
- let serviceTierMultiplier = 1;
1132
- if (serviceTier === "priority") serviceTierMultiplier = modelCost.priorityMultiplier ?? 1;
1133
- else if (serviceTier === "flex") serviceTierMultiplier = modelCost.flexMultiplier ?? 1;
1134
- const tierCacheRead = getServiceTierCacheRead(modelCost, serviceTier);
1135
- const tierAudioCacheRead = getServiceTierCacheRead(modelCost, serviceTier, "audio");
1136
- const serviceTierCachedInputCost = resolveServiceTierCacheCost(cachedInputCost, tierCacheRead, serviceTierMultiplier);
1137
- const serviceTierCachedAudioInputCost = resolveServiceTierCacheCost(cachedAudioInputCost, tierAudioCacheRead, serviceTierMultiplier);
1138
- const serviceTierCachedImageInputCost = resolveServiceTierCacheCost(cachedImageInputCost, tierCacheRead, serviceTierMultiplier);
1139
- let serviceTierAudioInputCost = audioInputCost;
1140
- if (serviceTier === "priority" && modelCost.priorityAudioInput !== void 0) serviceTierAudioInputCost = modelCost.priorityAudioInput / serviceTierMultiplier;
1141
- else if (serviceTier === "flex" && modelCost.flexAudioInput !== void 0) serviceTierAudioInputCost = modelCost.flexAudioInput / serviceTierMultiplier;
1142
- return {
1143
- serviceTierMultiplier,
1144
- serviceTierCachedInputCost,
1145
- serviceTierCachedAudioInputCost,
1146
- serviceTierCachedImageInputCost,
1147
- serviceTierAudioInputCost
1148
- };
1149
- }
1150
- function applyGoogleRegionalPremium(modelCost, multiplier) {
1151
- const scale = (value) => value === void 0 ? void 0 : value * multiplier;
1152
- return {
1153
- ...modelCost,
1154
- input: modelCost.input * multiplier,
1155
- output: modelCost.output * multiplier,
1156
- cacheRead: scale(modelCost.cacheRead),
1157
- cacheReadAudio: scale(modelCost.cacheReadAudio),
1158
- audioInput: scale(modelCost.audioInput),
1159
- audioOutput: scale(modelCost.audioOutput),
1160
- imageInput: scale(modelCost.imageInput),
1161
- videoInputPerSecond: scale(modelCost.videoInputPerSecond),
1162
- videoOutput: scale(modelCost.videoOutput),
1163
- priorityCacheRead: scale(modelCost.priorityCacheRead),
1164
- priorityCacheReadAudio: scale(modelCost.priorityCacheReadAudio),
1165
- priorityAudioInput: scale(modelCost.priorityAudioInput),
1166
- flexCacheRead: scale(modelCost.flexCacheRead),
1167
- flexCacheReadAudio: scale(modelCost.flexCacheReadAudio),
1168
- flexAudioInput: scale(modelCost.flexAudioInput)
1169
- };
1170
- }
1171
- function getGoogleCatalogCost(model, promptTokens, isVertexMode, usesNonGlobalVertexEndpoint) {
1172
- if (model?.tieredCost && promptTokens > model.tieredCost.threshold) return model.tieredCost.above;
1173
- if (usesNonGlobalVertexEndpoint && model?.vertexRegionalCost) return model.vertexRegionalCost;
1174
- if (isVertexMode && model?.vertexCost) return model.vertexCost;
1175
- return model?.cost;
1176
- }
1177
- /**
1178
- * Calculates the cost for a Google API call.
1179
- *
1180
- * Handles tiered pricing for models where cost varies by prompt size.
1181
- * For example, Gemini Pro models have higher rates for prompts >200k tokens.
1182
- * Some models (e.g. Gemini 2.0 Flash) have different pricing on Vertex AI.
1183
- *
1184
- * @param modelName - The name of the model used
1185
- * @param config - Provider configuration (may contain custom cost override)
1186
- * @param promptTokens - Number of tokens in the prompt
1187
- * @param completionTokens - Number of tokens in the completion
1188
- * @param isVertexMode - Whether the call was made via Vertex AI (uses Vertex pricing when available)
1189
- * @param audioPromptTokens - Number of audio tokens included in the prompt token count
1190
- * @param audioCompletionTokens - Number of audio tokens included in the completion token count
1191
- * @param videoCompletionTokens - Number of video tokens included in the completion token count
1192
- * @param imagePromptTokens - Number of image tokens included in the prompt token count
1193
- * @param cachedPromptTokens - Number of cached tokens included in the prompt token count
1194
- * @param cachedAudioPromptTokens - Number of cached audio tokens included in the prompt token count
1195
- * @param cachedImagePromptTokens - Number of cached image tokens included in the prompt token count
1196
- * @returns The calculated cost in dollars, or undefined if it cannot be calculated
1197
- */
1198
- function calculateGoogleCost(modelName, config, promptTokens, completionTokens, isVertexMode, audioPromptTokens, audioCompletionTokens, videoCompletionTokens, imagePromptTokens, cachedPromptTokens, cachedAudioPromptTokens, cachedImagePromptTokens, actualServiceTier, vertexRegion, requestedServiceTier, pricingTime = Date.now()) {
1199
- const timestamp = Number.isFinite(pricingTime) ? pricingTime : Date.now();
1200
- const pricingModelName = !isVertexMode && modelName === "gemini-3.5-flash" && timestamp >= Date.UTC(2026, 9, 8) ? "gemini-3.6-flash" : modelName;
1201
- const model = GOOGLE_MODELS.find((m) => m.id === pricingModelName);
1202
- if (typeof promptTokens !== "number" || typeof completionTokens !== "number" || !Number.isFinite(promptTokens) || !Number.isFinite(completionTokens)) return calculateCost(modelName, config, promptTokens, completionTokens, GOOGLE_MODELS);
1203
- const effectiveVertexRegion = vertexRegion ?? config.region;
1204
- const usesNonGlobalVertexEndpoint = isVertexMode && effectiveVertexRegion !== void 0 && effectiveVertexRegion !== "global";
1205
- const baseModelCost = getGoogleCatalogCost(model, promptTokens, isVertexMode, usesNonGlobalVertexEndpoint);
1206
- if (!baseModelCost) return;
1207
- const vertexRegionalMultiplier = usesNonGlobalVertexEndpoint && model?.vertexRegionalCost === void 0 && model?.vertexRegionalPremium !== void 0 ? model.vertexRegionalPremium : 1;
1208
- const catalogMultiplier = model?.introductoryPricing && timestamp < model.introductoryPricing.expiresAt ? model.introductoryPricing.multiplier : 1;
1209
- const applyCatalogMultiplier = (rate) => rate === void 0 ? void 0 : rate * catalogMultiplier;
1210
- const modelCost = vertexRegionalMultiplier === 1 ? baseModelCost : applyGoogleRegionalPremium(baseModelCost, vertexRegionalMultiplier);
1211
- const serviceTier = normalizeGoogleServiceTier(actualServiceTier ?? (isVertexMode ? requestedServiceTier : void 0) ?? config.passthrough?.service_tier ?? config.passthrough?.serviceTier ?? config.service_tier);
1212
- const catalogInputCost = modelCost.input * catalogMultiplier;
1213
- const catalogOutputCost = modelCost.output * catalogMultiplier;
1214
- const catalogAudioInputCost = applyCatalogMultiplier(modelCost.audioInput) ?? catalogInputCost;
1215
- const catalogImageInputCost = applyCatalogMultiplier(modelCost.imageInput) ?? catalogInputCost;
1216
- const catalogCacheRead = applyCatalogMultiplier(modelCost.cacheRead);
1217
- const tierCosts = resolveGoogleServiceTierCosts(applyGoogleRegionalPremium(modelCost, catalogMultiplier), serviceTier, catalogCacheRead ?? catalogInputCost, applyCatalogMultiplier(modelCost.cacheReadAudio) ?? catalogCacheRead ?? catalogAudioInputCost, catalogCacheRead ?? catalogImageInputCost, catalogAudioInputCost);
1218
- const multiplier = tierCosts.serviceTierMultiplier;
1219
- const inputCost = config.inputCost ?? config.cost ?? catalogInputCost * multiplier;
1220
- const outputCost = config.outputCost ?? config.cost ?? catalogOutputCost * multiplier;
1221
- const audioInputTokens = clampCachedTokens(audioPromptTokens, promptTokens);
1222
- const imageInputTokens = clampCachedTokens(imagePromptTokens, Math.max(promptTokens - audioInputTokens, 0));
1223
- const textInputTokens = Math.max(promptTokens - audioInputTokens - imageInputTokens, 0);
1224
- const cachedTokens = clampCachedTokens(cachedPromptTokens, promptTokens);
1225
- let cachedAudioTokens = clampCachedTokens(cachedAudioPromptTokens, Math.min(cachedTokens, audioInputTokens));
1226
- let cachedImageTokens = clampCachedTokens(cachedImagePromptTokens, Math.min(Math.max(cachedTokens - cachedAudioTokens, 0), imageInputTokens));
1227
- if (cachedAudioTokens === 0 && cachedImageTokens === 0) {
1228
- const cachedNonTextTokens = Math.max(cachedTokens - textInputTokens, 0);
1229
- if (imageInputTokens === 0) cachedAudioTokens = Math.min(cachedNonTextTokens, audioInputTokens);
1230
- else if (audioInputTokens === 0) cachedImageTokens = Math.min(cachedNonTextTokens, imageInputTokens);
1231
- }
1232
- const cachedTextTokens = Math.min(Math.max(cachedTokens - cachedAudioTokens - cachedImageTokens, 0), textInputTokens);
1233
- const audioOutputTokens = clampCachedTokens(audioCompletionTokens, completionTokens);
1234
- const videoOutputTokens = clampCachedTokens(videoCompletionTokens, Math.max(completionTokens - audioOutputTokens, 0));
1235
- const audioInputCost = config.audioInputCost ?? config.audioCost ?? config.inputCost ?? config.cost ?? tierCosts.serviceTierAudioInputCost * multiplier;
1236
- const audioOutputCost = config.audioOutputCost ?? config.audioCost ?? config.outputCost ?? config.cost ?? (applyCatalogMultiplier(modelCost.audioOutput) ?? catalogOutputCost) * multiplier;
1237
- const videoOutputCost = config.videoOutputCost ?? config.outputCost ?? config.cost ?? (applyCatalogMultiplier(modelCost.videoOutput) ?? catalogOutputCost) * multiplier;
1238
- const imageInputCost = config.imageInputCost ?? config.inputCost ?? config.cost ?? catalogImageInputCost * multiplier;
1239
- const cachedInputCost = config.inputCost ?? config.cost ?? tierCosts.serviceTierCachedInputCost * multiplier;
1240
- const cachedAudioInputCost = config.audioInputCost ?? config.audioCost ?? config.inputCost ?? config.cost ?? tierCosts.serviceTierCachedAudioInputCost * multiplier;
1241
- const cachedImageInputCost = config.imageInputCost ?? config.inputCost ?? config.cost ?? tierCosts.serviceTierCachedImageInputCost * multiplier;
1242
- return (textInputTokens - cachedTextTokens) * inputCost + cachedTextTokens * cachedInputCost + (audioInputTokens - cachedAudioTokens) * audioInputCost + cachedAudioTokens * cachedAudioInputCost + (imageInputTokens - cachedImageTokens) * imageInputCost + cachedImageTokens * cachedImageInputCost + (completionTokens - audioOutputTokens - videoOutputTokens) * outputCost + audioOutputTokens * audioOutputCost + videoOutputTokens * videoOutputCost;
1243
- }
1244
- const getGoogleModalityTokenCount = (details, modalities) => {
1245
- if (!Array.isArray(details)) return 0;
1246
- return details.reduce((total, detail) => {
1247
- const tokenCount = detail?.tokenCount ?? detail?.token_count;
1248
- return modalities.includes(detail?.modality) && typeof tokenCount === "number" && Number.isFinite(tokenCount) ? total + Math.max(tokenCount, 0) : total;
1249
- }, 0);
1250
- };
1251
- function calculateGoogleCostFromUsage(modelName, config, promptTokens, completionTokens, isVertexMode, usageMetadata, responseServiceTier, vertexRegion, requestedServiceTier, pricingTime) {
1252
- const promptDetails = usageMetadata?.promptTokensDetails ?? usageMetadata?.prompt_tokens_details;
1253
- const toolPromptDetails = usageMetadata?.toolUsePromptTokensDetails ?? usageMetadata?.tool_use_prompt_tokens_details;
1254
- const responseDetails = usageMetadata?.candidatesTokensDetails ?? usageMetadata?.responseTokensDetails ?? usageMetadata?.candidates_tokens_details ?? usageMetadata?.response_tokens_details;
1255
- const cacheDetails = usageMetadata?.cacheTokensDetails ?? usageMetadata?.cache_tokens_details;
1256
- const toolPromptTokens = usageMetadata?.toolUsePromptTokenCount ?? usageMetadata?.tool_use_prompt_token_count ?? 0;
1257
- const promptTokensForCost = typeof promptTokens === "number" && typeof toolPromptTokens === "number" && Number.isFinite(toolPromptTokens) ? promptTokens + Math.max(toolPromptTokens, 0) : promptTokens;
1258
- const audioPromptTokens = getGoogleModalityTokenCount(promptDetails, ["AUDIO"]) + getGoogleModalityTokenCount(toolPromptDetails, ["AUDIO"]);
1259
- const imagePromptTokens = getGoogleModalityTokenCount(promptDetails, [
1260
- "IMAGE",
1261
- "VIDEO",
1262
- "DOCUMENT"
1263
- ]) + getGoogleModalityTokenCount(toolPromptDetails, [
1264
- "IMAGE",
1265
- "VIDEO",
1266
- "DOCUMENT"
1267
- ]);
1268
- return calculateGoogleCost(modelName, config, promptTokensForCost, completionTokens, isVertexMode, audioPromptTokens, getGoogleModalityTokenCount(responseDetails, ["AUDIO"]), getGoogleModalityTokenCount(responseDetails, ["VIDEO"]), imagePromptTokens, usageMetadata?.cachedContentTokenCount ?? usageMetadata?.cached_content_token_count, getGoogleModalityTokenCount(cacheDetails, ["AUDIO"]), getGoogleModalityTokenCount(cacheDetails, [
1269
- "IMAGE",
1270
- "VIDEO",
1271
- "DOCUMENT"
1272
- ]), getGoogleResponseServiceTier(responseServiceTier ? { "x-gemini-service-tier": responseServiceTier } : void 0, usageMetadata, isVertexMode), vertexRegion, requestedServiceTier, pricingTime);
1273
- }
1274
- const clone = Clone();
1275
- const PartSchema = z$1.object({
1276
- text: z$1.string().optional(),
1277
- inline_data: z$1.object({
1278
- mime_type: z$1.string(),
1279
- data: z$1.string()
1280
- }).optional()
1281
- }).passthrough();
1282
- const ContentSchema = z$1.object({
1283
- role: z$1.enum(["user", "model"]).optional(),
1284
- parts: z$1.array(PartSchema)
1285
- });
1286
- const GeminiFormatSchema = z$1.array(ContentSchema);
1287
- function maybeCoerceToGeminiFormat(contents, options) {
1288
- let coerced = false;
1289
- const parseResult = GeminiFormatSchema.safeParse(contents);
1290
- if (parseResult.success) {
1291
- let systemInst = void 0;
1292
- if (typeof contents === "object" && "system_instruction" in contents) {
1293
- systemInst = contents.system_instruction;
1294
- coerced = true;
1295
- }
1296
- return {
1297
- contents: parseResult.data,
1298
- coerced,
1299
- systemInstruction: systemInst
1300
- };
1301
- }
1302
- let coercedContents;
1303
- if (typeof contents === "object" && contents !== null && !Array.isArray(contents) && "system_instruction" in contents) {
1304
- const systemInst = contents.system_instruction;
1305
- if ("contents" in contents) coercedContents = contents.contents;
1306
- else coercedContents = [];
1307
- return {
1308
- contents: coercedContents,
1309
- coerced: true,
1310
- systemInstruction: systemInst
1311
- };
1312
- }
1313
- if (typeof contents === "string") {
1314
- coercedContents = [{ parts: [{ text: contents }] }];
1315
- coerced = true;
1316
- } else if (Array.isArray(contents) && contents.every((item) => typeof item.content === "string")) {
1317
- const targetRole = options?.useAssistantRole ? "assistant" : "model";
1318
- coercedContents = contents.map((item) => ({
1319
- role: item.role === "assistant" ? targetRole : item.role,
1320
- parts: [{ text: item.content }]
1321
- }));
1322
- coerced = true;
1323
- } else if (Array.isArray(contents) && contents.every((item) => item.role && item.content)) {
1324
- const targetRole = options?.useAssistantRole ? "assistant" : "model";
1325
- coercedContents = contents.map((item) => {
1326
- const mappedRole = item.role === "assistant" ? targetRole : item.role;
1327
- if (Array.isArray(item.content)) return {
1328
- role: mappedRole,
1329
- parts: item.content.map((contentItem) => {
1330
- if (typeof contentItem === "string") return { text: contentItem };
1331
- else if (contentItem.type === "text") return { text: contentItem.text };
1332
- else return contentItem;
1333
- })
1334
- };
1335
- else if (typeof item.content === "object") return {
1336
- role: mappedRole,
1337
- parts: [item.content]
1338
- };
1339
- else return {
1340
- role: mappedRole,
1341
- parts: [{ text: item.content }]
1342
- };
1343
- });
1344
- coerced = true;
1345
- } else if (typeof contents === "object" && contents !== null && "parts" in contents) {
1346
- coercedContents = [contents];
1347
- coerced = true;
1348
- } else {
1349
- logger.warn(`Unknown format for Gemini: ${JSON.stringify(contents)}`);
1350
- return {
1351
- contents: Array.isArray(contents) ? contents : [],
1352
- coerced: false,
1353
- systemInstruction: void 0
1354
- };
1355
- }
1356
- let systemPromptParts = [];
1357
- coercedContents = coercedContents.filter((message) => {
1358
- if (message.role === "system" && message.parts.length > 0) {
1359
- systemPromptParts.push(...message.parts.filter((part) => "text" in part && typeof part.text === "string"));
1360
- return false;
1361
- }
1362
- return true;
1363
- });
1364
- if (coercedContents.length === 0 && systemPromptParts.length > 0) {
1365
- coercedContents = [{
1366
- role: "user",
1367
- parts: systemPromptParts
1368
- }];
1369
- coerced = true;
1370
- systemPromptParts = [];
1371
- }
1372
- return {
1373
- contents: coercedContents,
1374
- coerced,
1375
- systemInstruction: systemPromptParts.length > 0 ? { parts: systemPromptParts } : void 0
1376
- };
1377
- }
1378
- let cachedGenerativeLanguageAuth = null;
1379
- /**
1380
- * Gets an OAuth2 access token for Google APIs.
1381
- * Used by providers that need to authenticate via OAuth2 instead of API keys.
1382
- * @param credentials - Optional credentials JSON string or file:// path
1383
- * @param scopes - Optional scopes to use. Defaults to cloud-platform + generative-language scopes
1384
- * @returns The access token string, or undefined if authentication fails
1385
- */
1386
- async function getGoogleAccessToken(credentials) {
1387
- try {
1388
- if (!cachedGenerativeLanguageAuth) {
1389
- let GoogleAuth;
1390
- try {
1391
- GoogleAuth = (await import("google-auth-library")).GoogleAuth;
1392
- cachedGenerativeLanguageAuth = new GoogleAuth({ scopes: [
1393
- "https://www.googleapis.com/auth/cloud-platform",
1394
- "https://www.googleapis.com/auth/generative-language.retriever",
1395
- "https://www.googleapis.com/auth/generative-language.tuning"
1396
- ] });
1397
- } catch {
1398
- throw new Error("The google-auth-library package is required as a peer dependency. Please install it in your project or globally.");
1399
- }
1400
- }
1401
- const processedCredentials = loadCredentials(credentials);
1402
- let client;
1403
- if (processedCredentials) client = await cachedGenerativeLanguageAuth.fromJSON(JSON.parse(processedCredentials));
1404
- else client = await cachedGenerativeLanguageAuth.getClient();
1405
- return (await client.getAccessToken()).token || void 0;
1406
- } catch (error) {
1407
- logger.debug("[GoogleAuth] Could not get access token", { error: error instanceof Error ? error.message : String(error) });
1408
- return;
1409
- }
1410
- }
1411
- function getCandidate(data) {
1412
- if (!data || !data.candidates || data.candidates.length < 1) {
1413
- let errorDetails = "No candidates returned in API response.";
1414
- if (data?.promptFeedback?.blockReason) {
1415
- errorDetails = `Response blocked: ${data.promptFeedback.blockReason}`;
1416
- if (data.promptFeedback.safetyRatings) {
1417
- const flaggedCategories = data.promptFeedback.safetyRatings.filter((rating) => rating.probability !== "NEGLIGIBLE").map((rating) => `${rating.category}: ${rating.probability}`);
1418
- if (flaggedCategories.length > 0) errorDetails += ` (Safety ratings: ${flaggedCategories.join(", ")})`;
1419
- }
1420
- } else if (data?.promptFeedback?.safetyRatings) {
1421
- const flaggedCategories = data.promptFeedback.safetyRatings.filter((rating) => rating.probability !== "NEGLIGIBLE").map((rating) => `${rating.category}: ${rating.probability}`);
1422
- if (flaggedCategories.length > 0) errorDetails = `Response may have been blocked due to safety filters: ${flaggedCategories.join(", ")}`;
1423
- }
1424
- errorDetails += `\n\nGot response: ${JSON.stringify(data)}`;
1425
- throw new Error(errorDetails);
1426
- }
1427
- if (data.candidates.length > 1) logger.debug(`Expected one candidate in AI Studio API response, but got ${data.candidates.length}: ${JSON.stringify(data)}`);
1428
- const candidate = data.candidates[0];
1429
- if (!candidate) throw new Error(`No candidates returned in API response.\n\nGot response: ${JSON.stringify(data)}`);
1430
- return candidate;
1431
- }
1432
- function isNonCandidateStreamChunk(datum) {
1433
- return !datum.candidates?.length && (Boolean(datum.usageMetadata) && !datum.promptFeedback || Boolean(datum.promptFeedback?.safetyRatings) && !datum.promptFeedback?.blockReason);
1434
- }
1435
- function getLastPromptSafetyRatings(data) {
1436
- let safetyRatings;
1437
- for (const datum of data) if (datum.promptFeedback?.safetyRatings) safetyRatings = datum.promptFeedback.safetyRatings;
1438
- return safetyRatings;
1439
- }
1440
- /** Normalize Google's prompt and candidate ratings for guardrails assertions. */
1441
- function getGoogleGuardrails(promptSafetyRatings, candidateSafetyRatings) {
1442
- if (!promptSafetyRatings && !candidateSafetyRatings) return;
1443
- const flaggedInput = promptSafetyRatings?.some((rating) => rating.probability !== "NEGLIGIBLE");
1444
- const flaggedOutput = candidateSafetyRatings?.some((rating) => rating.probability !== "NEGLIGIBLE");
1445
- return {
1446
- flaggedInput,
1447
- flaggedOutput,
1448
- flagged: flaggedInput || flaggedOutput
1449
- };
1450
- }
1451
- function collectThoughtSignatures(data) {
1452
- return data.flatMap((datum) => (datum.candidates ?? []).flatMap((candidate) => (candidate.content?.parts ?? []).flatMap((part) => typeof part.thoughtSignature === "string" ? [part.thoughtSignature] : [])));
1453
- }
1454
- function collectGroundingMetadata(data) {
1455
- const candidates = data.filter((d) => d.candidates?.length).map((d) => getCandidate(d));
1456
- const flatChunks = candidates.flatMap((c) => c.groundingChunks ?? []);
1457
- const flatSupports = candidates.flatMap((c) => c.groundingSupports ?? []);
1458
- const flatQueries = candidates.flatMap((c) => c.webSearchQueries ?? []);
1459
- const metas = candidates.map((c) => c.groundingMetadata).filter((m) => Boolean(m));
1460
- let groundingMetadata;
1461
- if (metas.length === 1) groundingMetadata = metas[0];
1462
- else if (metas.length > 1) {
1463
- const merged = {};
1464
- for (const m of metas) for (const [key, value] of Object.entries(m)) {
1465
- if (key === "groundingChunks" || key === "groundingSupports" || key === "webSearchQueries") continue;
1466
- if (value !== void 0) merged[key] = value;
1467
- }
1468
- const innerChunks = metas.flatMap((m) => m.groundingChunks ?? []);
1469
- const innerSupports = metas.flatMap((m) => m.groundingSupports ?? []);
1470
- const innerQueries = metas.flatMap((m) => m.webSearchQueries ?? []);
1471
- if (innerChunks.length) merged.groundingChunks = innerChunks;
1472
- if (innerSupports.length) merged.groundingSupports = innerSupports;
1473
- if (innerQueries.length) merged.webSearchQueries = innerQueries;
1474
- groundingMetadata = merged;
1475
- }
1476
- return {
1477
- ...groundingMetadata && { groundingMetadata },
1478
- ...flatChunks.length > 0 && { groundingChunks: flatChunks },
1479
- ...flatSupports.length > 0 && { groundingSupports: flatSupports },
1480
- ...flatQueries.length > 0 && { webSearchQueries: flatQueries }
1481
- };
1482
- }
1483
- function formatCandidateContents(candidate) {
1484
- if (candidate.finishReason && [
1485
- "SAFETY",
1486
- "RECITATION",
1487
- "PROHIBITED_CONTENT",
1488
- "BLOCKLIST",
1489
- "SPII"
1490
- ].includes(candidate.finishReason)) {
1491
- let errorMessage = `Response was blocked with finish reason: ${candidate.finishReason}`;
1492
- if (candidate.safetyRatings) {
1493
- const flaggedCategories = candidate.safetyRatings.filter((rating) => rating.probability !== "NEGLIGIBLE" || rating.blocked).map((rating) => `${rating.category}: ${rating.probability}${rating.blocked ? " (BLOCKED)" : ""}`);
1494
- if (flaggedCategories.length > 0) errorMessage += `\nSafety ratings: ${flaggedCategories.join(", ")}`;
1495
- }
1496
- if (candidate.finishReason === "RECITATION") errorMessage += "\n\nThis typically occurs when the response is too similar to content from the model's training data.";
1497
- else if (candidate.finishReason === "SAFETY") errorMessage += "\n\nThe response was blocked due to safety filters. Consider adjusting safety settings or modifying your prompt.";
1498
- throw new Error(errorMessage);
1499
- }
1500
- if (candidate.content?.parts) {
1501
- let output = "";
1502
- let is_text = true;
1503
- for (const part of candidate.content.parts) if ("text" in part) output += part.text;
1504
- else is_text = false;
1505
- if (is_text) return output;
1506
- else return candidate.content.parts;
1507
- } else throw new Error(`No output found in response: ${JSON.stringify(candidate)}`);
1508
- }
1509
- function mergeParts(parts1, parts2) {
1510
- if (parts1 === void 0) return typeof parts2 === "string" ? parts2 : [...parts2];
1511
- if (typeof parts1 === "string" && typeof parts2 === "string") return parts1 + parts2;
1512
- const array1 = typeof parts1 === "string" ? [{ text: parts1 }] : parts1;
1513
- const array2 = typeof parts2 === "string" ? [{ text: parts2 }] : parts2;
1514
- array1.push(...array2);
1515
- return array1;
1516
- }
1517
- function normalizeGeminiAudio(output) {
1518
- if (!Array.isArray(output)) return;
1519
- const audioParts = output.filter((part) => part.inlineData?.mimeType?.startsWith("audio/"));
1520
- if (audioParts.length === 0) return;
1521
- const mimeType = audioParts[0].inlineData.mimeType;
1522
- const audioData = Buffer.concat(audioParts.map((part) => Buffer.from(part.inlineData.data, "base64")));
1523
- if (!/^audio\/(?:L16|pcm)(?:;|$)/i.test(mimeType)) return {
1524
- data: audioData.toString("base64"),
1525
- format: mimeType.split(/[;/]/)[1]
1526
- };
1527
- const sampleRate = Number(mimeType.match(/(?:^|;)\s*rate=(\d+)/i)?.[1] ?? 24e3);
1528
- const header = Buffer.alloc(44);
1529
- header.write("RIFF", 0);
1530
- header.writeUInt32LE(36 + audioData.length, 4);
1531
- header.write("WAVE", 8);
1532
- header.write("fmt ", 12);
1533
- header.writeUInt32LE(16, 16);
1534
- header.writeUInt16LE(1, 20);
1535
- header.writeUInt16LE(1, 22);
1536
- header.writeUInt32LE(sampleRate, 24);
1537
- header.writeUInt32LE(sampleRate * 2, 28);
1538
- header.writeUInt16LE(2, 32);
1539
- header.writeUInt16LE(16, 34);
1540
- header.write("data", 36);
1541
- header.writeUInt32LE(audioData.length, 40);
1542
- return {
1543
- data: Buffer.concat([header, audioData]).toString("base64"),
1544
- format: "wav",
1545
- sampleRate,
1546
- channels: 1
1547
- };
1548
- }
1549
- /**
1550
- * Normalizes and sanitizes tools configuration for Gemini API compatibility.
1551
- * - Canonicalizes snake_case aliases to camelCase for backwards compatibility
1552
- * - Sanitizes function declaration schemas to remove unsupported JSON Schema properties
1553
- * (e.g., additionalProperties, $schema, default) that Gemini doesn't support
1554
- */
1555
- function normalizeTools(tools) {
1556
- const canonicalNames = new Set(tools.flatMap((tool) => tool.functionDeclarations?.map(({ name }) => name) ?? []));
1557
- const seenNames = /* @__PURE__ */ new Set();
1558
- return tools.flatMap((tool) => {
1559
- const { code_execution, google_search, google_search_retrieval, ...canonicalTool } = tool;
1560
- const normalizedTool = { ...canonicalTool };
1561
- if (normalizedTool.codeExecution === void 0 && code_execution !== void 0) normalizedTool.codeExecution = code_execution;
1562
- if (normalizedTool.googleSearch === void 0 && google_search !== void 0) normalizedTool.googleSearch = google_search;
1563
- if (normalizedTool.googleSearchRetrieval === void 0 && google_search_retrieval !== void 0) normalizedTool.googleSearchRetrieval = google_search_retrieval;
1564
- if (tool.functionDeclarations || tool.function_declarations) {
1565
- normalizedTool.functionDeclarations = [...tool.functionDeclarations ?? [], ...(tool.function_declarations ?? []).filter(({ name }) => !canonicalNames.has(name))].filter(({ name }) => {
1566
- if (seenNames.has(name)) return false;
1567
- seenNames.add(name);
1568
- return true;
1569
- });
1570
- delete normalizedTool.function_declarations;
1571
- if (normalizedTool.functionDeclarations.length === 0 && (tool.functionDeclarations?.length || tool.function_declarations?.length)) {
1572
- delete normalizedTool.functionDeclarations;
1573
- if (Object.keys(normalizedTool).length === 0) return [];
1574
- }
1575
- }
1576
- if (normalizedTool.functionDeclarations) normalizedTool.functionDeclarations = normalizedTool.functionDeclarations.map((fd) => ({
1577
- ...fd,
1578
- parameters: fd.parameters ? sanitizeSchemaForGemini(fd.parameters) : void 0
1579
- }));
1580
- return [normalizedTool];
1581
- });
1582
- }
1583
- function loadFile(config_var, context_vars) {
1584
- const fileContents = maybeLoadFromExternalFile(renderVarsInObject(config_var, context_vars));
1585
- if (typeof fileContents === "string") try {
1586
- const parsedContents = JSON.parse(fileContents);
1587
- return Array.isArray(parsedContents) ? normalizeTools(parsedContents) : parsedContents;
1588
- } catch (err) {
1589
- logger.debug(`ERROR: failed to convert file contents to JSON:\n${JSON.stringify(err)}`);
1590
- return fileContents;
1591
- }
1592
- if (Array.isArray(fileContents)) return normalizeTools(fileContents);
1593
- return fileContents;
1594
- }
1595
- function getMimeTypeFromFtypBrand(brand) {
1596
- if ([
1597
- "avif",
1598
- "avis",
1599
- "crx "
1600
- ].includes(brand)) return;
1601
- if ([
1602
- "M4A ",
1603
- "M4B ",
1604
- "M4P ",
1605
- "F4A ",
1606
- "F4B "
1607
- ].includes(brand)) return "audio/mp4";
1608
- else if ([
1609
- "heic",
1610
- "heix",
1611
- "hevc",
1612
- "hevx"
1613
- ].includes(brand)) return "image/heic";
1614
- else if (["mif1", "msf1"].includes(brand)) return "image/heif";
1615
- else if (brand === "qt ") return "video/quicktime";
1616
- else if (brand.startsWith("3g")) return "video/3gpp";
1617
- return "video/mp4";
1618
- }
1619
- const ASF_HEADER_GUID = Buffer.from("3026b2758e66cf11a6d900aa0062ce6c", "hex");
1620
- const ASF_STREAM_PROPERTIES_GUID = Buffer.from("9107dcb7b7a9cf118ee600c00c205365", "hex");
1621
- const ASF_AUDIO_STREAM_GUID = Buffer.from("409e69f84d5bcf11a8fd00805f5c442b", "hex");
1622
- const ASF_VIDEO_STREAM_GUID = Buffer.from("c0ef19bc4d5bcf11a8fd00805f5c442b", "hex");
1623
- const EBML_DOCTYPE_ID = Buffer.from([66, 130]);
1624
- const MAX_MEDIA_SNIFF_BYTES = 65536;
1625
- const SUPPORTED_INLINE_MEDIA_MIME_TYPES = /* @__PURE__ */ new Set([
1626
- "application/pdf",
1627
- "image/jpeg",
1628
- "image/png",
1629
- "image/webp",
1630
- "image/heic",
1631
- "image/heif",
1632
- "audio/wav",
1633
- "audio/mpeg",
1634
- "audio/aiff",
1635
- "audio/aac",
1636
- "audio/ogg",
1637
- "audio/flac",
1638
- "audio/mp4",
1639
- "video/mp4",
1640
- "video/mpeg",
1641
- "video/quicktime",
1642
- "video/avi",
1643
- "video/x-flv",
1644
- "video/webm",
1645
- "video/wmv",
1646
- "video/3gpp"
1647
- ]);
1648
- function getAsfMimeType(bytes) {
1649
- let streamOffset = bytes.indexOf(ASF_STREAM_PROPERTIES_GUID, ASF_HEADER_GUID.length);
1650
- let hasAudio = false;
1651
- while (streamOffset !== -1) {
1652
- const streamTypeOffset = streamOffset + ASF_STREAM_PROPERTIES_GUID.length + 8;
1653
- const streamType = bytes.subarray(streamTypeOffset, streamTypeOffset + 16);
1654
- if (streamType.equals(ASF_VIDEO_STREAM_GUID)) return "video/wmv";
1655
- if (streamType.equals(ASF_AUDIO_STREAM_GUID)) hasAudio = true;
1656
- streamOffset = bytes.indexOf(ASF_STREAM_PROPERTIES_GUID, streamTypeOffset);
1657
- }
1658
- return hasAudio ? "audio/x-ms-wma" : void 0;
1659
- }
1660
- function getEbmlMimeType(bytes) {
1661
- const doctypeOffset = bytes.indexOf(EBML_DOCTYPE_ID, 4);
1662
- if (doctypeOffset < 0) return;
1663
- const sizeOffset = doctypeOffset + EBML_DOCTYPE_ID.length;
1664
- const encodedLength = bytes[sizeOffset];
1665
- if (encodedLength === void 0 || encodedLength === 0) return;
1666
- let width = 1;
1667
- let marker = 128;
1668
- while ((encodedLength & marker) === 0) {
1669
- marker >>= 1;
1670
- width++;
1671
- }
1672
- if (sizeOffset + width > bytes.length) return;
1673
- let doctypeLength = encodedLength & marker - 1;
1674
- for (let index = 1; index < width; index++) {
1675
- doctypeLength = doctypeLength * 256 + bytes[sizeOffset + index];
1676
- if (doctypeLength > 4) return;
1677
- }
1678
- const doctypeOffsetStart = sizeOffset + width;
1679
- if (doctypeLength !== 4 || doctypeOffsetStart + doctypeLength > bytes.length) return;
1680
- return bytes.subarray(doctypeOffsetStart, doctypeOffsetStart + doctypeLength).equals(Buffer.from("webm")) ? "video/webm" : void 0;
1681
- }
1682
- function getOggMimeType(bytes) {
1683
- let offset = 0;
1684
- let hasAudio = false;
1685
- while (offset + 27 <= bytes.length) {
1686
- if (bytes.toString("utf8", offset, offset + 4) !== "OggS" || bytes[offset + 4] !== 0) return;
1687
- const flags = bytes[offset + 5];
1688
- if ((flags & 2) === 0) return hasAudio ? "audio/ogg" : void 0;
1689
- const segmentCount = bytes[offset + 26];
1690
- const payloadOffset = offset + 27 + segmentCount;
1691
- if ((flags & 1) !== 0 || segmentCount === 0 || payloadOffset > bytes.length) return;
1692
- const segments = bytes.subarray(offset + 27, payloadOffset);
1693
- const packetEnd = segments.findIndex((length) => length < 255);
1694
- if (packetEnd < 0) return;
1695
- const packetLength = segments.subarray(0, packetEnd + 1).reduce((sum, length) => sum + length, 0);
1696
- const pageEnd = payloadOffset + segments.reduce((sum, length) => sum + length, 0);
1697
- if (pageEnd > bytes.length) return;
1698
- const packet = bytes.subarray(payloadOffset, payloadOffset + packetLength);
1699
- if (packet.length >= 64 && packet.subarray(0, 8).equals(Buffer.from("fishead\0"))) {
1700
- offset = pageEnd;
1701
- continue;
1702
- }
1703
- if (packet.subarray(0, 7).equals(Buffer.from("€theora", "latin1"))) return "video/ogg";
1704
- if (![
1705
- "OpusHead",
1706
- "vorbis",
1707
- "Speex ",
1708
- "FLAC"
1709
- ].some((header) => packet.subarray(0, header.length).equals(Buffer.from(header)))) return;
1710
- hasAudio = true;
1711
- offset = pageEnd;
1712
- }
1713
- return offset === bytes.length && hasAudio ? "audio/ogg" : void 0;
1714
- }
1715
- function getMimeTypeFromMediaBytes(bytes) {
1716
- const riffType = bytes.subarray(8, 12).toString("ascii");
1717
- if (bytes.subarray(0, 4).toString("ascii") === "RIFF") {
1718
- if (riffType === "WEBP") return "image/webp";
1719
- else if (riffType === "WAVE") return "audio/wav";
1720
- else if (riffType === "AVI ") return "video/avi";
1721
- } else if (bytes.subarray(0, 4).toString("ascii") === "FORM" && ["AIFF", "AIFC"].includes(riffType)) return "audio/aiff";
1722
- else if (bytes.subarray(4, 8).toString("ascii") === "ftyp") return getMimeTypeFromFtypBrand(bytes.subarray(8, 12).toString("ascii"));
1723
- else if ([
1724
- "moov",
1725
- "mdat",
1726
- "wide"
1727
- ].includes(bytes.subarray(4, 8).toString("ascii"))) return "video/quicktime";
1728
- else if (bytes.subarray(0, 4).toString("hex") === "1a45dfa3") return getEbmlMimeType(bytes);
1729
- else if (["000001ba", "000001b3"].includes(bytes.subarray(0, 4).toString("hex"))) return "video/mpeg";
1730
- else if (bytes.subarray(0, 3).toString("ascii") === "FLV") return "video/x-flv";
1731
- else if (bytes.subarray(0, ASF_HEADER_GUID.length).equals(ASF_HEADER_GUID)) return getAsfMimeType(bytes);
1732
- else if (bytes[0] === 255 && (bytes[1] & 246) === 240) return "audio/aac";
1733
- else if (bytes.subarray(0, 3).toString("ascii") === "ID3" || bytes[0] === 255 && (bytes[1] & 224) === 224) return "audio/mpeg";
1734
- else if (bytes.subarray(0, 4).toString("ascii") === "fLaC") return "audio/flac";
1735
- else if (bytes.subarray(0, 4).toString("ascii") === "OggS") return getOggMimeType(bytes);
1736
- }
1737
- function getMimeTypeFromBase64(data) {
1738
- const parsed = parseDataUrl(data);
1739
- const base64Data = parsed ? parsed.base64Data : data;
1740
- if (!base64Data || base64Data.length < 20 || !/^[A-Za-z0-9+/]+={0,2}$/.test(base64Data)) return;
1741
- if (parsed) {
1742
- const normalizedMimeType = parsed.mimeType.toLowerCase();
1743
- const mimeType = {
1744
- "audio/mp3": "audio/mpeg",
1745
- "audio/m4a": "audio/mp4",
1746
- "video/mpg": "video/mpeg",
1747
- "video/mov": "video/quicktime"
1748
- }[normalizedMimeType] ?? normalizedMimeType;
1749
- return SUPPORTED_INLINE_MEDIA_MIME_TYPES.has(mimeType) ? mimeType : void 0;
1750
- }
1751
- if (base64Data.startsWith("/9j/")) return "image/jpeg";
1752
- else if (base64Data.startsWith("iVBORw0KGgo")) return "image/png";
1753
- else if (base64Data.startsWith("JVBER")) return "application/pdf";
1754
- const sniffBase64Length = Math.ceil(MAX_MEDIA_SNIFF_BYTES / 3) * 4;
1755
- const inferredMimeType = getMimeTypeFromMediaBytes(Buffer.from(base64Data.slice(0, sniffBase64Length), "base64"));
1756
- return inferredMimeType && SUPPORTED_INLINE_MEDIA_MIME_TYPES.has(inferredMimeType) ? inferredMimeType : void 0;
1757
- }
1758
- function processImagesInContents(contents, contextVars) {
1759
- if (!contextVars) return contents;
1760
- if (!Array.isArray(contents)) {
1761
- logger.warn("[Google] contents is not an array in processImagesInContents", {
1762
- contentsType: typeof contents,
1763
- contentsValue: contents
1764
- });
1765
- return [];
1766
- }
1767
- const base64ToMimeType = /* @__PURE__ */ new Map();
1768
- for (const value of Object.values(contextVars)) if (typeof value === "string") {
1769
- let mimeType = getMimeTypeFromBase64(value);
1770
- if (mimeType === "video/mp4" && !isDataUrl(value) && getLoadedFileMimeType(contextVars, value) === "audio/mp4") mimeType = "audio/mp4";
1771
- if (mimeType && (mimeType !== "video/mp4" || base64ToMimeType.get(value) !== "audio/mp4")) base64ToMimeType.set(value, mimeType);
1772
- }
1773
- return contents.map((content) => {
1774
- if (content.parts) {
1775
- const newParts = [];
1776
- for (const part of content.parts) if (part.text) {
1777
- const lines = part.text.split("\n");
1778
- let foundValidMedia = false;
1779
- let currentTextBlock = "";
1780
- const processedParts = [];
1781
- for (const line of lines) {
1782
- const trimmedLine = line.trim();
1783
- const mimeType = base64ToMimeType.get(trimmedLine);
1784
- if (mimeType) {
1785
- foundValidMedia = true;
1786
- if (currentTextBlock.length > 0) {
1787
- processedParts.push({ text: currentTextBlock });
1788
- currentTextBlock = "";
1789
- }
1790
- const base64Data = isDataUrl(trimmedLine) ? extractBase64FromDataUrl(trimmedLine) : trimmedLine;
1791
- processedParts.push({ inlineData: {
1792
- mimeType,
1793
- data: base64Data
1794
- } });
1795
- } else {
1796
- if (currentTextBlock.length > 0) currentTextBlock += "\n";
1797
- currentTextBlock += line;
1798
- }
1799
- }
1800
- if (currentTextBlock.length > 0) processedParts.push({ text: currentTextBlock });
1801
- if (foundValidMedia) newParts.push(...processedParts);
1802
- else newParts.push(part);
1803
- } else newParts.push(part);
1804
- return {
1805
- ...content,
1806
- parts: newParts
1807
- };
1808
- }
1809
- return content;
1810
- });
1811
- }
1812
- /**
1813
- * Parses and processes config-level systemInstruction.
1814
- * Handles file loading, string-to-Content conversion, and Nunjucks template rendering.
1815
- *
1816
- * @param configSystemInstruction - The systemInstruction from config (can be string, Content, or undefined)
1817
- * @param contextVars - Variables for Nunjucks template rendering
1818
- * @param basePath - Optional base directory for resolving relative instruction file references
1819
- * @returns Processed Content object or undefined
1820
- */
1821
- function parseConfigSystemInstruction(configSystemInstruction, contextVars, basePath) {
1822
- if (!configSystemInstruction) return;
1823
- let configInstruction = clone(configSystemInstruction);
1824
- let renderInstructionParts = true;
1825
- if (typeof configSystemInstruction === "string") {
1826
- const instructionReference = resolveGoogleConfigFileReference(renderVarsInObject(configSystemInstruction, contextVars), basePath);
1827
- configInstruction = loadFile(instructionReference, void 0);
1828
- renderInstructionParts = instructionReference.startsWith("file://");
1829
- }
1830
- if (typeof configInstruction === "string") configInstruction = { parts: [{ text: configInstruction }] };
1831
- if (renderInstructionParts && contextVars && configInstruction) {
1832
- const nunjucks = getNunjucksEngine();
1833
- for (const part of configInstruction.parts) if (part.text) try {
1834
- part.text = nunjucks.renderString(part.text, contextVars);
1835
- } catch (err) {
1836
- throw new Error(`Unable to render nunjucks in systemInstruction: ${err}`);
1837
- }
1838
- }
1839
- return configInstruction;
1840
- }
1841
- /**
1842
- * Loads, parses, and renders a config-level response schema.
1843
- *
1844
- * @param configResponseSchema - Inline JSON or a reference to an external schema file
1845
- * @param contextVars - Variables for template rendering
1846
- * @param basePath - Optional base directory for resolving relative schema file references
1847
- * @returns The parsed and rendered response schema
1848
- */
1849
- function parseConfigResponseSchema(configResponseSchema, contextVars, basePath) {
1850
- const renderedSchema = renderVarsInObject(configResponseSchema, contextVars);
1851
- const schemaReference = typeof renderedSchema === "string" ? resolveGoogleConfigFileReference(renderedSchema, basePath) : renderedSchema;
1852
- let responseSchema = maybeLoadFromExternalFile(schemaReference);
1853
- if (typeof responseSchema === "string") try {
1854
- responseSchema = JSON.parse(responseSchema);
1855
- } catch (error) {
1856
- throw new Error(`Invalid JSON in responseSchema: ${error}`);
1857
- }
1858
- return typeof schemaReference === "string" && schemaReference.startsWith("file://") ? renderVarsInObject(responseSchema, contextVars) : responseSchema;
1859
- }
1860
- /** Resolve only relative Google config file references against their owning base path. */
1861
- function resolveGoogleConfigFileReference(reference, basePath) {
1862
- if (!basePath || !reference.startsWith("file://")) return reference;
1863
- const { filePath } = parseFileUrl(reference);
1864
- return `file://${path.isAbsolute(filePath) || path.win32.isAbsolute(filePath) ? filePath : path.resolve(basePath, filePath)}`;
1865
- }
1866
- function geminiFormatAndSystemInstructions(prompt, contextVars, configSystemInstruction, options) {
1867
- let contents = parseChatPrompt(prompt, [{
1868
- parts: [{ text: prompt }],
1869
- role: "user"
1870
- }]);
1871
- const { contents: updatedContents, coerced, systemInstruction: parsedSystemInstruction } = maybeCoerceToGeminiFormat(contents, options);
1872
- if (coerced) {
1873
- logger.debug(`Coerced JSON prompt to Gemini format: ${JSON.stringify(contents)}`);
1874
- contents = updatedContents;
1875
- }
1876
- let systemInstruction = parsedSystemInstruction;
1877
- const parsedConfigInstruction = parseConfigSystemInstruction(configSystemInstruction, contextVars, options?.basePath);
1878
- if (parsedConfigInstruction) systemInstruction = systemInstruction ? { parts: [...parsedConfigInstruction.parts, ...systemInstruction.parts] } : parsedConfigInstruction;
1879
- contents = processImagesInContents(contents, contextVars);
1880
- return {
1881
- contents,
1882
- systemInstruction
1883
- };
1884
- }
1885
- /**
1886
- * Recursively traverses a JSON schema object and converts
1887
- * uppercase type keywords (string values) to lowercase.
1888
- * Handles nested objects and arrays within the schema.
1889
- * Creates a deep copy to avoid modifying the original schema.
1890
- *
1891
- * @param {object | any} schemaNode - The current node (object or value) being processed.
1892
- * @returns {object | any} - The processed node with type keywords lowercased.
1893
- */
1894
- function normalizeSchemaTypes(schemaNode) {
1895
- if (typeof schemaNode !== "object" || schemaNode === null) return schemaNode;
1896
- if (Array.isArray(schemaNode)) return schemaNode.map(normalizeSchemaTypes);
1897
- const newNode = {};
1898
- for (const key in schemaNode) if (Object.prototype.hasOwnProperty.call(schemaNode, key)) {
1899
- const value = schemaNode[key];
1900
- if (key === "type") {
1901
- if (typeof value === "string" && VALID_SCHEMA_TYPES.includes(value)) newNode[key] = value.toLowerCase();
1902
- else if (Array.isArray(value)) newNode[key] = value.map((t) => typeof t === "string" && VALID_SCHEMA_TYPES.includes(t) ? t.toLowerCase() : t);
1903
- else newNode[key] = normalizeSchemaTypes(value);
1904
- } else newNode[key] = normalizeSchemaTypes(value);
1905
- }
1906
- return newNode;
1907
- }
1908
- function parseStringObject(input) {
1909
- if (typeof input === "string") return JSON.parse(input);
1910
- return input;
1911
- }
1912
- function validateFunctionCall(output, functions, vars) {
1913
- let functionCalls;
1914
- try {
1915
- let parsedOutput = parseStringObject(output);
1916
- if ("toolCall" in parsedOutput) {
1917
- parsedOutput = parsedOutput.toolCall;
1918
- functionCalls = parsedOutput.functionCalls;
1919
- } else if (Array.isArray(parsedOutput)) functionCalls = parsedOutput.filter((obj) => Object.prototype.hasOwnProperty.call(obj, "functionCall")).map((obj) => obj.functionCall);
1920
- else throw new Error("Unrecognized function call format");
1921
- if (!Array.isArray(functionCalls) || functionCalls.length === 0 || functionCalls.some((call) => !call || typeof call.name !== "string")) throw new Error("Expected at least one function call");
1922
- } catch {
1923
- throw new InvalidToolCallError(`Google did not return a valid-looking function call: ${JSON.stringify(output)}`);
1924
- }
1925
- let interpolatedFunctions;
1926
- try {
1927
- interpolatedFunctions = loadFile(functions, vars);
1928
- } catch (err) {
1929
- throw new InvalidToolSchemaError(err.message);
1930
- }
1931
- if (interpolatedFunctions !== void 0 && !Array.isArray(interpolatedFunctions)) throw new InvalidToolSchemaError("Expected the loaded functions to be an array");
1932
- if (interpolatedFunctions?.some((tool) => !tool || typeof tool !== "object" || tool.functionDeclarations !== void 0 && (!Array.isArray(tool.functionDeclarations) || tool.functionDeclarations.some((declaration) => !declaration || typeof declaration.name !== "string" || !declaration.name.trim())))) throw new InvalidToolSchemaError("Expected valid function declarations in each tool");
1933
- const declarations = interpolatedFunctions?.flatMap((tool) => tool.functionDeclarations ?? []);
1934
- if (!declarations?.length) throw new InvalidToolSchemaError(`Called "${functionCalls[0].name}", but there is no function with that name`);
1935
- const ajv = getAjv();
1936
- for (const functionCall of functionCalls) {
1937
- const functionName = functionCall.name;
1938
- let functionArgs;
1939
- try {
1940
- functionArgs = functionCall.args === void 0 ? {} : parseStringObject(functionCall.args);
1941
- } catch (err) {
1942
- throw new InvalidToolCallError(err.message);
1943
- }
1944
- const functionSchema = declarations.find((declaration) => declaration.name === functionName);
1945
- if (!functionSchema) throw new InvalidToolCallError(`Called "${functionName}", but there is no function with that name`);
1946
- if (functionSchema.parameters) {
1947
- const parameterSchema = normalizeSchemaTypes(functionSchema.parameters);
1948
- let validate;
1949
- try {
1950
- validate = ajv.compile(parameterSchema);
1951
- } catch (err) {
1952
- throw new InvalidToolSchemaError(`Tool schema doesn't compile with ajv: ${err}. If this is a valid tool schema you may need to reformulate your assertion without is-valid-function-call.`);
1953
- }
1954
- if (!validate(functionArgs)) throw new InvalidToolCallError(`Call to "${functionName}":\n${JSON.stringify(functionCall)}\ndoes not match schema:\n${JSON.stringify(validate.errors)}`);
1955
- } else if (!(JSON.stringify(functionArgs) === "{}" && !functionSchema?.parameters)) throw new InvalidToolCallError(`Call to "${functionName}":\n${JSON.stringify(functionCall)}\ndoes not match schema:\n${JSON.stringify(functionSchema)}`);
1956
- }
1957
- }
1958
- /**
1959
- * Properties supported by Gemini's function calling API.
1960
- * Based on Google's Schema type definition and API documentation.
1961
- * @see https://ai.google.dev/api/caching#Schema
1962
- */
1963
- const GEMINI_SUPPORTED_SCHEMA_PROPERTIES = /* @__PURE__ */ new Set([
1964
- "type",
1965
- "format",
1966
- "description",
1967
- "nullable",
1968
- "enum",
1969
- "maxItems",
1970
- "minItems",
1971
- "properties",
1972
- "required",
1973
- "propertyOrdering",
1974
- "items"
1975
- ]);
1976
- /**
1977
- * Valid JSON Schema types mapped to Gemini's expected format (uppercase).
1978
- */
1979
- const JSON_SCHEMA_TYPE_MAP = {
1980
- string: "STRING",
1981
- number: "NUMBER",
1982
- integer: "INTEGER",
1983
- boolean: "BOOLEAN",
1984
- array: "ARRAY",
1985
- object: "OBJECT",
1986
- null: "STRING"
1987
- };
1988
- /**
1989
- * Recursively sanitizes a JSON Schema for Gemini API compatibility.
1990
- *
1991
- * - Removes unsupported properties (additionalProperties, $schema, default, title, etc.)
1992
- * - Converts type values to uppercase (string → STRING, object → OBJECT)
1993
- * - Recursively processes nested schemas in 'properties' and 'items'
1994
- *
1995
- * @param schema - The JSON Schema object to sanitize
1996
- * @returns A sanitized schema compatible with Gemini's function calling API
1997
- */
1998
- function sanitizeSchemaForGemini(schema) {
1999
- if (!schema || typeof schema !== "object") return schema;
2000
- const result = {};
2001
- for (const [key, value] of Object.entries(schema)) {
2002
- if (!GEMINI_SUPPORTED_SCHEMA_PROPERTIES.has(key)) continue;
2003
- if (key === "type") {
2004
- if (typeof value === "string") {
2005
- const lowerType = value.toLowerCase();
2006
- result[key] = JSON_SCHEMA_TYPE_MAP[lowerType] || value.toUpperCase();
2007
- } else result[key] = value;
2008
- } else if (key === "properties" && typeof value === "object" && value !== null) {
2009
- result[key] = {};
2010
- for (const [propName, propSchema] of Object.entries(value)) if (typeof propSchema === "object" && propSchema !== null) result[key][propName] = sanitizeSchemaForGemini(propSchema);
2011
- else result[key][propName] = propSchema;
2012
- } else if (key === "items" && typeof value === "object" && value !== null) result[key] = sanitizeSchemaForGemini(value);
2013
- else result[key] = value;
2014
- }
2015
- return result;
2016
- }
2017
- /**
2018
- * Create a cache discriminator from auth headers.
2019
- *
2020
- * This is used to ensure different API keys/credentials don't share cached responses.
2021
- * The discriminator is included as a custom property in fetchWithCache options,
2022
- * which gets included in the cache key automatically.
2023
- *
2024
- * Security note: We hash auth headers rather than using them directly to avoid
2025
- * exposing sensitive credentials in cache keys or logs. The hash is truncated
2026
- * to 16 hex characters (64 bits) for brevity - collision probability is acceptably
2027
- * low for cache key differentiation (birthday problem: ~4 billion entries needed
2028
- * for 50% collision probability).
2029
- *
2030
- * @param headers - Request headers containing auth info
2031
- * @returns A short hash string for cache key differentiation
2032
- */
2033
- function createAuthCacheDiscriminator(headers) {
2034
- const authValues = [];
2035
- for (const name of [
2036
- "authorization",
2037
- "x-goog-api-key",
2038
- "x-api-key",
2039
- "api-key",
2040
- "x-goog-user-project"
2041
- ]) {
2042
- const value = headers[name] || headers[name.toLowerCase()];
2043
- if (value) authValues.push(`${name}:${value}`);
2044
- }
2045
- if (authValues.length === 0) return "";
2046
- return crypto.createHash("sha256").update(authValues.join("|")).digest("hex").substring(0, 16);
2047
- }
2048
- //#endregion
2049
- export { stripExecutableToolFileReferences as A, getGoogleClient as B, normalizeTools as C, removeGoogleFunctionDeclarations as D, removeDeprecatedGeminiGenerationParams as E, getVertexApiHostForRegion as F, loadCredentials as H, getVertexModelDefaultRegion as I, GoogleAuthManager as L, CHAT_MODELS as M, GEMINI_FLASH_MODELS as N, resolveGoogleToolConfig as O, GOOGLE_MODELS as P, determineGoogleVertexMode as R, normalizeSafetySettings as S, parseConfigSystemInstruction as T, resolveProjectId as U, hasGoogleDefaultCredentials as V, mergeGoogleCompletionOptions as _, createAuthCacheDiscriminator as a, normalizeGeminiAudio as b, getCandidate as c, getGoogleGuardrails as d, getGoogleResponseServiceTier as f, loadGoogleTools as g, isNonCandidateStreamChunk as h, collectThoughtSignatures as i, validateFunctionCall as j, sanitizeSchemaForGemini as k, getGoogleAccessToken as l, getVertexServiceTierHeaders as m, calculateGoogleCostFromUsage as n, formatCandidateContents as o, getLastPromptSafetyRatings as p, collectGroundingMetadata as r, geminiFormatAndSystemInstructions as s, calculateGoogleCost as t, getGoogleApiBaseUrl as u, mergeGoogleRequestTools as v, parseConfigResponseSchema as w, normalizeGoogleServiceTier as x, mergeParts as y, getGoogleApiKey as z };
2050
-
2051
- //# sourceMappingURL=util-CM2Ec_uY.js.map