promptfoo 0.121.3 → 0.121.5

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 (394) hide show
  1. package/README.md +1 -1
  2. package/dist/src/{ListApp-Du7YVwj5.js → ListApp-BRUsT43Y.js} +1 -1
  3. package/dist/src/{accounts-BPyfpSeU.cjs → accounts-BIFntVWB.cjs} +5 -5
  4. package/dist/src/{accounts-CFLK3mnD.js → accounts-CLJHCDDb.js} +6 -6
  5. package/dist/src/{accounts-B2XmGjty.js → accounts-CaLNYnf7.js} +5 -5
  6. package/dist/src/{accounts-Xatc0RYb.js → accounts-bnyHT7Ju.js} +5 -5
  7. package/dist/src/{agentic-utils-36epdqwB.js → agentic-utils-B5krlibj.js} +3 -3
  8. package/dist/src/{agentic-utils-DIYAAYE7.js → agentic-utils-Ba67xmgs.js} +3 -3
  9. package/dist/src/{agentic-utils-D8yXo5Lm.js → agentic-utils-BclbiXiq.js} +4 -4
  10. package/dist/src/{agentic-utils-DAVsChuB.cjs → agentic-utils-D2x0wGhB.cjs} +3 -3
  11. package/dist/src/{agents-CLQ-P15P.js → agents-BGqaTDnr.js} +5 -7
  12. package/dist/src/{agents-wg3ohknq.js → agents-BV9yFpXX.js} +6 -7
  13. package/dist/src/{agents-CgBniSlI.js → agents-BYdMl1UE.js} +5 -9
  14. package/dist/src/{agents-Bqgfdokm.js → agents-DhxWMCtH.js} +35 -14
  15. package/dist/src/{agents-BBWxKSM0.cjs → agents-DiWmQYH9.cjs} +5 -7
  16. package/dist/src/{agents-CAYbM7qD.cjs → agents-WULPVjbH.cjs} +34 -12
  17. package/dist/src/{agents-DSSTV4bv.js → agents-emVcx3yh.js} +35 -13
  18. package/dist/src/{agents-BBVJCIYr.js → agents-n6vPqV3i.js} +35 -13
  19. package/dist/src/{aimlapi-BwGC1TtS.js → aimlapi-BxqK9HF_.js} +8 -14
  20. package/dist/src/{aimlapi-Bv8Fmc-b.cjs → aimlapi-BzLjZI_m.cjs} +8 -15
  21. package/dist/src/{aimlapi-MgSLdvy7.js → aimlapi-DR4pgeiC.js} +7 -14
  22. package/dist/src/{aimlapi-DaC3qZ-o.js → aimlapi-uPGp0Zdo.js} +7 -16
  23. package/dist/src/app/app/tsconfig.app.tsbuildinfo +1 -0
  24. package/dist/src/app/assets/Report-vjzrbgce.js +1 -0
  25. package/dist/src/app/assets/index-B3NQ8HTd.js +385 -0
  26. package/dist/src/app/assets/index-Cli2yAXv.css +1 -0
  27. package/dist/src/app/assets/rolldown-runtime-COnpUsM8.js +1 -0
  28. package/dist/src/app/assets/scroll-timeline-D9IT_e8Z.js +1 -0
  29. package/dist/src/app/assets/sync-IjzpWrOE.js +4 -0
  30. package/dist/src/app/assets/vendor-charts-BNdH8TCw.js +36 -0
  31. package/dist/src/app/assets/vendor-markdown-Ch00wnNI.js +29 -0
  32. package/dist/src/app/assets/vendor-react-CVvmk1UB.js +9 -0
  33. package/dist/src/app/assets/vendor-utils-BnEYbx2Q.js +37 -0
  34. package/dist/src/app/index.html +32 -7
  35. package/dist/src/{audio-Bn44pQxv.js → audio-BvpTOArF.js} +4 -4
  36. package/dist/src/{audio-DVFjQ67_.cjs → audio-C0vDeS0j.cjs} +4 -4
  37. package/dist/src/{audio-DjU9GswO.js → audio-CScmnmEB.js} +4 -5
  38. package/dist/src/{audio-DDA5WHdx.js → audio-Da8U9IS5.js} +4 -4
  39. package/dist/src/{base-CKjwebIH.js → base-BOMaNEes.js} +3 -3
  40. package/dist/src/{base-CqzQ4K8j.js → base-BTux96b1.js} +3 -3
  41. package/dist/src/{base-BboXIF_0.cjs → base-Tw6uhH8K.cjs} +3 -3
  42. package/dist/src/{base-Cz2ZC_iA.js → base-dYsl2hmL.js} +3 -3
  43. package/dist/src/{blobs-C6j0bvFz.cjs → blobs-B95F_7vE.cjs} +3 -3
  44. package/dist/src/{blobs-DXTl6J3H.js → blobs-BW4U31ue.js} +3 -3
  45. package/dist/src/{blobs-BUWmKWzo.js → blobs-D_gg8nbm.js} +4 -4
  46. package/dist/src/{blobs-B1JriOyi.js → blobs-DjLby-uP.js} +4 -4
  47. package/dist/src/cache-BI5BY7ey.js +280 -0
  48. package/dist/src/cache-BRkhlH3k.cjs +3 -0
  49. package/dist/src/cache-BlC6aeJ0.js +3 -0
  50. package/dist/src/cache-Bzttsk0X.js +310 -0
  51. package/dist/src/cache-Cr-qWIbP.js +310 -0
  52. package/dist/src/cache-DGg-yTZG.cjs +376 -0
  53. package/dist/src/{chat-BEwdgGEg.js → chat-BLOdH60v.js} +63 -37
  54. package/dist/src/{chat-B0iaWhoh.js → chat-Cx_LkwvZ.js} +63 -37
  55. package/dist/src/{chat-DK1U-eZ-.js → chat-D9nudO9b.js} +5 -14
  56. package/dist/src/{chat-pxmiVpWe.js → chat-DChSH_Es.js} +63 -37
  57. package/dist/src/{chat-B-52XYI1.js → chat-DG2LkwLq.js} +3 -13
  58. package/dist/src/{chat-BtIKkLKx.cjs → chat-DH97tVV9.cjs} +3 -13
  59. package/dist/src/{chat-BE0qTA8e.js → chat-aMQZw6R7.js} +4 -16
  60. package/dist/src/{chat-CM8qWR3_.cjs → chat-vYqqv1gP.cjs} +64 -38
  61. package/dist/src/{chatkit-_8eJqKcD.js → chatkit-B8X34dQc.js} +4 -4
  62. package/dist/src/{chatkit-BYGQlHlV.js → chatkit-BXu42Qwt.js} +4 -4
  63. package/dist/src/{chatkit-a2D6mY6s.js → chatkit-CbMRoeYw.js} +4 -4
  64. package/dist/src/{chatkit-Cx174XI3.cjs → chatkit-D44VyUyB.cjs} +4 -4
  65. package/dist/src/{claude-agent-sdk-8ddRp1L2.cjs → claude-agent-sdk-BRq0bbIK.cjs} +23 -18
  66. package/dist/src/{claude-agent-sdk-CMjh4LFH.js → claude-agent-sdk-BjriSVRZ.js} +20 -15
  67. package/dist/src/{claude-agent-sdk-HgbFioFw.js → claude-agent-sdk-BzNZeZ0N.js} +20 -15
  68. package/dist/src/{claude-agent-sdk-Bq5EArsX.js → claude-agent-sdk-DYv_AJ8u.js} +21 -17
  69. package/dist/src/cloud-CoD5OacT.js +3 -0
  70. package/dist/src/{cloud-z8KZpUoa.js → cloud-Da0bofJd.js} +25 -13
  71. package/dist/src/{cloudflare-ai-Bbp26N0L.js → cloudflare-ai-CXC4b1EU.js} +5 -14
  72. package/dist/src/{cloudflare-ai-BGyXlpXJ.js → cloudflare-ai-CyBoIs1Q.js} +7 -15
  73. package/dist/src/{cloudflare-ai-DdKP9TKT.js → cloudflare-ai-DGOwgexC.js} +6 -17
  74. package/dist/src/{cloudflare-ai-C62x6MQG.cjs → cloudflare-ai-DJv5qnyb.cjs} +6 -15
  75. package/dist/src/{cloudflare-gateway-DXhtXDRb.js → cloudflare-gateway-1sAoOyft.js} +6 -16
  76. package/dist/src/{cloudflare-gateway-D-e9i1Sn.js → cloudflare-gateway-D-dnkzCF.js} +5 -18
  77. package/dist/src/{cloudflare-gateway-Dx36ftqF.cjs → cloudflare-gateway-DKVjkDav.cjs} +4 -15
  78. package/dist/src/{cloudflare-gateway-BwAaUgeW.js → cloudflare-gateway-TJkVrZlB.js} +4 -15
  79. package/dist/src/codex-app-server-CCLjqCh9.js +1915 -0
  80. package/dist/src/codex-app-server-CCe0TiDc.js +1915 -0
  81. package/dist/src/codex-app-server-CPW1LFwh.js +1916 -0
  82. package/dist/src/codex-app-server-VMRnjZ68.cjs +1920 -0
  83. package/dist/src/codex-sdk-1jm_qPHf.js +3 -0
  84. package/dist/src/codex-sdk-Bd8UbO9q.cjs +1172 -0
  85. package/dist/src/codex-sdk-BgEFQ70r.js +1164 -0
  86. package/dist/src/codex-sdk-Bzb_TqX9.js +1165 -0
  87. package/dist/src/codex-sdk-Danroptg.cjs +2 -0
  88. package/dist/src/codex-sdk-DfvDTN33.js +1165 -0
  89. package/dist/src/{cometapi-BDyV-NNm.js → cometapi-B5ImDlSm.js} +9 -15
  90. package/dist/src/{cometapi-C3hOlM7-.cjs → cometapi-BgAkuYCw.cjs} +9 -16
  91. package/dist/src/{cometapi-hhL4TAh3.js → cometapi-CC7hWxmX.js} +8 -15
  92. package/dist/src/{cometapi-sp7sJpBD.js → cometapi-CCbpHkuF.js} +8 -17
  93. package/dist/src/{completion-DoYy49ti.js → completion-2iuYVxwi.js} +8 -57
  94. package/dist/src/{completion-BCimtq-h.js → completion-CrD6MQ93.js} +8 -57
  95. package/dist/src/{completion-DlXUhj5c.cjs → completion-DtQ72Bm3.cjs} +7 -62
  96. package/dist/src/{completion-DCjv7RZ3.js → completion-Vq_ad618.js} +8 -57
  97. package/dist/src/{createHash-CTQmL3G2.js → createHash-4gFQpDDv.js} +3 -3
  98. package/dist/src/{createHash-Da8fMwqB.js → createHash-DPpsZgFF.js} +3 -3
  99. package/dist/src/{createHash-DmPQkvBh.js → createHash-Un4Q_huE.js} +3 -3
  100. package/dist/src/{createHash-BYwImsYv.cjs → createHash-VvBIc-AW.cjs} +4 -4
  101. package/dist/src/{docker-CxCkwMzc.js → docker--3qzPa-6.js} +6 -14
  102. package/dist/src/{docker-Cqj2-QVi.cjs → docker-D3AY-5F5.cjs} +7 -15
  103. package/dist/src/{docker-FeBni2dw.js → docker-DCsCDvwM.js} +7 -14
  104. package/dist/src/{docker-DpguQj-w.js → docker-Dorv4_Dg.js} +6 -16
  105. package/dist/src/embedding-BXhN5lCH.cjs +63 -0
  106. package/dist/src/embedding-ChS1ivFS.js +58 -0
  107. package/dist/src/embedding-DNRvZwRN.js +59 -0
  108. package/dist/src/embedding-D_bI4NDq.js +58 -0
  109. package/dist/src/entrypoint.js +69 -6
  110. package/dist/src/{errors-P6ll7XSJ.js → errors-DFHe4L-n.js} +1 -1
  111. package/dist/src/{esm-SUNIX1x3.js → esm-B6whoAcf.js} +15 -6
  112. package/dist/src/{esm-CKWP3u_P.js → esm-BRkfNsYs.js} +16 -7
  113. package/dist/src/{esm-7UIl0pPM.js → esm-BX8fwlAO.js} +27 -18
  114. package/dist/src/{esm-CipptfDu.cjs → esm-B_rGuPTo.cjs} +15 -6
  115. package/dist/src/eval-BQPLBJbw.js +3 -0
  116. package/dist/src/{eval-BTqTn7lb.js → eval-DJ_4A-tr.js} +50 -21
  117. package/dist/src/evalResult-BBJAHAtw.cjs +2 -0
  118. package/dist/src/evalResult-BBK58h2B.js +3 -0
  119. package/dist/src/{evalResult-DpARzUCb.cjs → evalResult-Cx-8OWkb.cjs} +29 -11
  120. package/dist/src/{evalResult-DUDShQrm.js → evalResult-D6P5I5il.js} +29 -11
  121. package/dist/src/{evalResult-BkIhRdTe.js → evalResult-pSvGWFMo.js} +29 -11
  122. package/dist/src/evalResult-spPqh1G_.js +2 -0
  123. package/dist/src/{evaluator-BcvOGaam.js → evaluator-D-UIbbYq.js} +3975 -2152
  124. package/dist/src/evaluator-DgLKaZk8.js +3 -0
  125. package/dist/src/{extractor-D_wd8jxt.js → extractor-BM3jRERL.js} +6 -6
  126. package/dist/src/{extractor-DG3sSfXE.cjs → extractor-Dxr2J_wK.cjs} +6 -6
  127. package/dist/src/{extractor-CAZ2G3Kh.js → extractor-DxyiFhPk.js} +6 -6
  128. package/dist/src/{extractor-C8XwivI9.js → extractor-YlZbUMsL.js} +6 -6
  129. package/dist/src/fetch-8viavNv8.js +3 -0
  130. package/dist/src/{fetch-DoVRJZhJ.js → fetch-B6ch2nU2.js} +199 -60
  131. package/dist/src/{fetch-CVAtKnI3.js → fetch-D9xxyC1p.js} +404 -252
  132. package/dist/src/{fetch-BnR9wSnm.cjs → fetch-NuqXW1Xb.cjs} +415 -263
  133. package/dist/src/{fetch-BiYv2BZc.js → fetch-Y5qX_kST.js} +222 -70
  134. package/dist/src/{fileExtensions-LcDYkU4v.js → fileExtensions-8CjoL7vB.js} +1 -1
  135. package/dist/src/{fileExtensions-DnqA1y9x.js → fileExtensions-BGh-W-HT.js} +1 -1
  136. package/dist/src/{fileExtensions-bYh77CN8.cjs → fileExtensions-D9h-8Wxg.cjs} +1 -1
  137. package/dist/src/{fileExtensions-Ds-foDzt.js → fileExtensions-DysCsxNG.js} +1 -1
  138. package/dist/src/{formatDuration-DgBVMN65.js → formatDuration-Ch4A7G3o.js} +1 -1
  139. package/dist/src/{genaiTracer-BfxrvSUb.cjs → genaiTracer-BokHC-MW.cjs} +7 -3
  140. package/dist/src/{genaiTracer-C1rxGO8Q.js → genaiTracer-C3ZPQU60.js} +6 -2
  141. package/dist/src/{genaiTracer-70Z8BIuV.js → genaiTracer-CFny3gOy.js} +6 -2
  142. package/dist/src/{genaiTracer-D3fD9dNV.js → genaiTracer-DxODqT9e.js} +6 -2
  143. package/dist/src/golang/wrapper.go +1 -1
  144. package/dist/src/{graders-DG7mhg-b.js → graders-BoUqsCEm.js} +7402 -5699
  145. package/dist/src/{graders-BElhu9ZY.cjs → graders-Bw1wk_21.cjs} +5220 -3437
  146. package/dist/src/graders-C84JI-m5.js +2 -0
  147. package/dist/src/graders-CBbd0K0Q.cjs +2 -0
  148. package/dist/src/graders-CbQqpHSN.js +3 -0
  149. package/dist/src/{graders-RjHF8VfG.js → graders-CgPn32yp.js} +7400 -5697
  150. package/dist/src/{graders-BXAJ0sbS.js → graders-CwrbifOo.js} +6136 -4433
  151. package/dist/src/graders-DS42d3ZG.js +2 -0
  152. package/dist/src/{image-6WQXK8m8.js → image-BeWaInPF.js} +4 -4
  153. package/dist/src/{image-PoF6DN3x.js → image-BmilRNqO.js} +8 -8
  154. package/dist/src/{image--F58eEIn.cjs → image-CxJoa3aW.cjs} +8 -8
  155. package/dist/src/{image-fza3zuKs.cjs → image-D10dNAav.cjs} +4 -4
  156. package/dist/src/{image-DO0RYnjH.js → image-Dr_3I3nK.js} +4 -5
  157. package/dist/src/{image-B8b6f36E.js → image-DsGRlkh7.js} +8 -8
  158. package/dist/src/{image-CoxZp9PZ.js → image-a_SGUobh.js} +8 -8
  159. package/dist/src/{image-xNbw5ph2.js → image-qjO6FWPs.js} +4 -4
  160. package/dist/src/index.cjs +4835 -2582
  161. package/dist/src/index.d.cts +2782 -31
  162. package/dist/src/index.d.ts +2783 -32
  163. package/dist/src/index.js +4817 -2564
  164. package/dist/src/{interactiveCheck-BnMYOjMu.js → interactiveCheck-CCICw2cy.js} +2 -2
  165. package/dist/src/{invariant-BtWWVVhl.js → invariant-B2Rf6avk.js} +1 -1
  166. package/dist/src/{invariant-vgHWClmd.js → invariant-DIYf9sP1.js} +1 -1
  167. package/dist/src/{knowledgeBase-Bi7CmDbx.js → knowledgeBase-BBETc5-S.js} +6 -8
  168. package/dist/src/{knowledgeBase-DqrLX8fy.cjs → knowledgeBase-C8qOo26M.cjs} +6 -8
  169. package/dist/src/{knowledgeBase-DFRXPZl_.js → knowledgeBase-CzAi2rUI.js} +7 -8
  170. package/dist/src/{knowledgeBase-Ce3ofVan.js → knowledgeBase-Dr3Kib7F.js} +6 -10
  171. package/dist/src/{litellm-CKiAxnoM.js → litellm-BLSiANhk.js} +6 -14
  172. package/dist/src/{litellm-CnHI69aj.cjs → litellm-CaUmV7Mk.cjs} +6 -15
  173. package/dist/src/{litellm-Tc294Jhj.js → litellm-DQGo_juI.js} +5 -14
  174. package/dist/src/{litellm-Bo2gQXpo.js → litellm-DRc4qWfc.js} +5 -16
  175. package/dist/src/{logger-BcJBzSSA.js → logger-BbY6ypFL.js} +41 -12
  176. package/dist/src/{logger-D5iKBpu_.cjs → logger-COuQb2xB.cjs} +51 -10
  177. package/dist/src/{logger-DO8_zM18.js → logger-Ct2S6Yx-.js} +40 -11
  178. package/dist/src/{logger-BnkjG2jt.js → logger-KD8JjCRJ.js} +41 -12
  179. package/dist/src/{luma-ray-C9q8rdQe.js → luma-ray-B-tNZzqW.js} +6 -10
  180. package/dist/src/{luma-ray-DP0QA9qn.js → luma-ray-CtS3OlGq.js} +6 -10
  181. package/dist/src/{luma-ray-0ehMPt5N.js → luma-ray-PJJgUjOc.js} +6 -11
  182. package/dist/src/{luma-ray-m9Ku2meV.cjs → luma-ray-if-Ml4R9.cjs} +6 -10
  183. package/dist/src/main.d.ts +1 -26
  184. package/dist/src/main.js +1188 -679
  185. package/dist/src/messages-B9dSjrNf.js +544 -0
  186. package/dist/src/messages-BnsVHUnm.cjs +558 -0
  187. package/dist/src/messages-CI69Lasb.js +543 -0
  188. package/dist/src/messages-CewuNcNS.js +543 -0
  189. package/dist/src/{meteor-DLZZ3osF.cjs → meteor-BBGcGeCa.cjs} +1 -1
  190. package/dist/src/{meteor-DUiCJRC-.js → meteor-BKTM-7KS.js} +1 -1
  191. package/dist/src/{meteor-44VjEACX.js → meteor-CeGo0Lu2.js} +2 -2
  192. package/dist/src/{meteor-D-SotUw9.js → meteor-Wc_aUVvu.js} +2 -2
  193. package/dist/src/{modelslab-B5J-ZM5c.js → modelslab-BCLOtfek.js} +8 -10
  194. package/dist/src/{modelslab-IQbNg-r7.cjs → modelslab-BkapYJhh.cjs} +7 -10
  195. package/dist/src/{modelslab-BTOT8FUO.js → modelslab-D73OnKSx.js} +7 -10
  196. package/dist/src/{modelslab-BI458moT.js → modelslab-zpz9JcK0.js} +7 -12
  197. package/dist/src/{nova-reel-BZ9y-Y5s.js → nova-reel-B8F_TK5w.js} +7 -10
  198. package/dist/src/{nova-reel-Xw1SXLpg.js → nova-reel-Bx0NFV2f.js} +6 -10
  199. package/dist/src/{nova-reel-DEeQlnOJ.js → nova-reel-CNGJTLtG.js} +6 -12
  200. package/dist/src/{nova-reel-CE5etkv9.cjs → nova-reel-DkT7tnoB.cjs} +6 -10
  201. package/dist/src/{nova-sonic-Ogqf-csn.js → nova-sonic-BaXRN1cr.js} +5 -7
  202. package/dist/src/{nova-sonic-DXTLpi-r.js → nova-sonic-BeTRaFOh.js} +4 -7
  203. package/dist/src/{nova-sonic-DWswpN1E.js → nova-sonic-CL7Zqv0G.js} +4 -9
  204. package/dist/src/{nova-sonic-N0yCm0vb.cjs → nova-sonic-YT426juD.cjs} +4 -7
  205. package/dist/src/{openai-BcB5KlTk.js → openai-BMHD2Huo.js} +6 -3
  206. package/dist/src/{openai-BMcwgD5C.js → openai-BT-JvDse.js} +6 -3
  207. package/dist/src/{openai-CoxGAQwn.cjs → openai-Cy1XLs0c.cjs} +6 -3
  208. package/dist/src/{openai-D6wITiVn.js → openai-D4fxGvRx.js} +6 -3
  209. package/dist/src/openclaw-Bq7RVR3k.js +1200 -0
  210. package/dist/src/openclaw-DA8U4DsD.js +1201 -0
  211. package/dist/src/openclaw-DObVgpjC.js +1200 -0
  212. package/dist/src/openclaw-DUBZP3GL.cjs +1206 -0
  213. package/dist/src/{opencode-sdk-CHCs7dEb.js → opencode-sdk-BB40Wir1.js} +6 -8
  214. package/dist/src/{opencode-sdk-DDxj4QqH.js → opencode-sdk-BM1UAIv1.js} +6 -8
  215. package/dist/src/{opencode-sdk-WWJhnbKr.cjs → opencode-sdk-CeqiOcOU.cjs} +7 -9
  216. package/dist/src/{opencode-sdk-C71Z0ehR.js → opencode-sdk-ChdK7F7z.js} +6 -9
  217. package/dist/src/{otlpReceiver-CZL48YfC.js → otlpReceiver-C6thJRXi.js} +154 -98
  218. package/dist/src/{otlpReceiver-C9KlUtxh.js → otlpReceiver-CcdIikOu.js} +154 -98
  219. package/dist/src/{otlpReceiver-DHKqJlsz.cjs → otlpReceiver-DNSQj6bf.cjs} +154 -98
  220. package/dist/src/{otlpReceiver-CavGAA6k.js → otlpReceiver-UYMQx3sy.js} +154 -98
  221. package/dist/src/{providerRegistry-BkzVH5Ba.js → providerRegistry-1gB5vtzQ.js} +2 -2
  222. package/dist/src/{providerRegistry-BTDgfV5h.cjs → providerRegistry-BESeALrr.cjs} +2 -2
  223. package/dist/src/{providerRegistry-CUWki5mQ.js → providerRegistry-DoACwqhD.js} +2 -2
  224. package/dist/src/{providerRegistry-B9lh-_tx.js → providerRegistry-PMsleEzs.js} +2 -2
  225. package/dist/src/providers-BuyzKt7C.js +2 -0
  226. package/dist/src/providers-C7lNVBjX.cjs +3 -0
  227. package/dist/src/providers-CCE2COJi2.js +2 -0
  228. package/dist/src/{providers-Cn73d5sr.js → providers-CJh7iriU.js} +17180 -16823
  229. package/dist/src/providers-Ctcc592x.js +3 -0
  230. package/dist/src/{providers-DvddrgxL.js → providers-DRrerKra.js} +1052 -695
  231. package/dist/src/{providers-Ch6Mr0gn.js → providers-DT-GtF2t.js} +16716 -16359
  232. package/dist/src/{providers-CScd1wN6.cjs → providers-eDShy16E.cjs} +19893 -19506
  233. package/dist/src/python/persistent_wrapper.py +0 -5
  234. package/dist/src/{pythonUtils-Cpo0Ez1p.js → pythonUtils-C4tltmIn.js} +4 -4
  235. package/dist/src/{pythonUtils-dAVigVK-.cjs → pythonUtils-CoLaCwNY.cjs} +4 -4
  236. package/dist/src/{pythonUtils-Bzwbgpbg.js → pythonUtils-DMO68Jg7.js} +3 -3
  237. package/dist/src/{pythonUtils-wIqk7zAf.js → pythonUtils-DNqbnRdx.js} +3 -3
  238. package/dist/src/{quiverai-BeofbLVc.js → quiverai-BSS9a7wV.js} +4 -4
  239. package/dist/src/{quiverai-DVSEqJiq.js → quiverai-Bk1KrvL6.js} +4 -4
  240. package/dist/src/{quiverai-CcUhPIBg.cjs → quiverai-Bpx6MZ7T.cjs} +4 -4
  241. package/dist/src/{quiverai-CCQn73lq.js → quiverai-CPKhWgaT.js} +4 -5
  242. package/dist/src/render-7uNJ2V14.js +135 -0
  243. package/dist/src/render-DlscvAUJ.js +135 -0
  244. package/dist/src/render-eui5p5mL.js +136 -0
  245. package/dist/src/{render-BHl6QVq9.js → render-nj-UaPdn.js} +2 -3
  246. package/dist/src/render-tG6ir9_g.cjs +165 -0
  247. package/dist/src/{responses-CgNyTPsY.js → responses-1ztiVYsx.js} +56 -17
  248. package/dist/src/{responses-BKP_WYis.js → responses-B8haB-mD.js} +56 -17
  249. package/dist/src/{responses-CQb1Tj69.js → responses-BiaBguAu.js} +56 -17
  250. package/dist/src/{responses-mo0KQDbu.cjs → responses-CF-ayauu.cjs} +56 -17
  251. package/dist/src/rubyUtils-4hjGxvju.js +3 -0
  252. package/dist/src/{rubyUtils-DECSbsfY.js → rubyUtils-BI0p46eZ.js} +3 -3
  253. package/dist/src/{rubyUtils-CiVfln3g.js → rubyUtils-CIQFnVz4.js} +3 -3
  254. package/dist/src/rubyUtils-CO-tuszQ.cjs +2 -0
  255. package/dist/src/{rubyUtils-PgU-gHmx.js → rubyUtils-DGnoCYL2.js} +4 -4
  256. package/dist/src/{rubyUtils-CGeUtCfW.cjs → rubyUtils-DoifqkiA.cjs} +5 -4
  257. package/dist/src/{sagemaker-CqeASYE5.js → sagemaker-BDLeW29y.js} +14 -18
  258. package/dist/src/{sagemaker-MUbD5V3v.js → sagemaker-C5T60MKf.js} +14 -19
  259. package/dist/src/{sagemaker-CVv8W7so.js → sagemaker-ClS_NB07.js} +14 -18
  260. package/dist/src/{sagemaker-jiw1wQa-.cjs → sagemaker-ljtY12VM.cjs} +14 -18
  261. package/dist/src/{scanner-DVDeUz1r.js → scanner-nOCWNIXa.js} +130 -35
  262. package/dist/src/server/golang/wrapper.go +1 -1
  263. package/dist/src/server/index.js +4829 -2529
  264. package/dist/src/server/python/persistent_wrapper.py +0 -5
  265. package/dist/src/{server-BtoCXeXI.cjs → server-BEECpeGG.cjs} +140 -6
  266. package/dist/src/{server-DZ9MtCn0.js → server-ByiF3qlg.js} +129 -9
  267. package/dist/src/{server-Cns05F1j.js → server-ByxbqAcQ.js} +128 -8
  268. package/dist/src/server-C0XKRNB_.cjs +2 -0
  269. package/dist/src/server-C_15p79-.js +3 -0
  270. package/dist/src/{server-CP9qKM40.js → server-gyd6d4Hc.js} +126 -7
  271. package/dist/src/{signal-C3ZTsUgi.js → signal-DTtUuU3l.js} +3 -3
  272. package/dist/src/{slack-DCEV-vWP.js → slack-4zZX1OKP.js} +2 -2
  273. package/dist/src/{slack-94iG3T0s.cjs → slack-BLlsDpfG.cjs} +2 -2
  274. package/dist/src/{slack-BR0HtO3K.js → slack-BPYLQLgb.js} +2 -2
  275. package/dist/src/{slack-2sdpGzbt.js → slack-Bamy_7te.js} +2 -2
  276. package/dist/src/{store-CLyU7AtI.cjs → store-2K0kDi80.cjs} +3 -3
  277. package/dist/src/{store-VB0GP46K.js → store-2OXm_eBY.js} +3 -3
  278. package/dist/src/store-BELqNwvz.js +3 -0
  279. package/dist/src/{store-Cj258DgL.js → store-BPkzEyFM.js} +3 -3
  280. package/dist/src/{store-P8OKm19S.js → store-CPh25336.js} +3 -3
  281. package/dist/src/store-uQZ4AjPe.cjs +2 -0
  282. package/dist/src/{tables-BEIFz2tM.js → tables-BMSOS2Gg.js} +3 -3
  283. package/dist/src/{tables-BdZQEpRz.cjs → tables-CXbaZ9y1.cjs} +3 -3
  284. package/dist/src/{tables-DmzvLbeZ.js → tables-NlvH23ky.js} +3 -3
  285. package/dist/src/{tables-kC7R5kiK.js → tables-WgdUZ8Ck.js} +3 -3
  286. package/dist/src/{telemetry-DPXLd7UE.js → telemetry--iqaGyaS.js} +5 -4
  287. package/dist/src/{telemetry-re627Lre.cjs → telemetry-CEQxGnMZ.cjs} +8 -7
  288. package/dist/src/{telemetry-BugWqKiu.js → telemetry-CgdVGV8N.js} +5 -4
  289. package/dist/src/{telemetry-BnH5VJAU.js → telemetry-DWdGHvEf.js} +5 -4
  290. package/dist/src/telemetry-DjNoC_n3.cjs +2 -0
  291. package/dist/src/telemetry-ZdPZc0fm.js +3 -0
  292. package/dist/src/{text-CW1cyrwj.cjs → text-BiNME7QG.cjs} +1 -1
  293. package/dist/src/{text-Db-Wt2u2.js → text-D4lz-Jg_.js} +1 -1
  294. package/dist/src/{text-TIv0QYnd.js → text-DDQP0tuQ.js} +1 -1
  295. package/dist/src/{text-B_UCRPp2.js → text-NWvfMfkF.js} +1 -1
  296. package/dist/src/{tokenUsageUtils-DflFMjS0.js → tokenUsageUtils-2wIvAhB3.js} +7 -3
  297. package/dist/src/{tokenUsageUtils-BDGe-iyI.js → tokenUsageUtils-4c780gFd.js} +7 -3
  298. package/dist/src/{tokenUsageUtils-NYT-WKS6.js → tokenUsageUtils-BjVkdk18.js} +7 -3
  299. package/dist/src/{tokenUsageUtils-bVa1ga6f.cjs → tokenUsageUtils-C9odhsbW.cjs} +7 -3
  300. package/dist/src/{transcription-CaMivnjG.js → transcription-84t4ALo2.js} +7 -11
  301. package/dist/src/{transcription-Hb3VnC4M.js → transcription-Bm2emLmJ.js} +8 -11
  302. package/dist/src/{transcription-BvtsrzRG.cjs → transcription-CZ4LG5hQ.cjs} +9 -13
  303. package/dist/src/{transcription-DOMMTu01.js → transcription-D7Q0vJsh.js} +7 -13
  304. package/dist/src/{transform-DrleutM3.js → transform-B-b6Cq-q.js} +8 -6
  305. package/dist/src/transform-BQt0BeAW.js +3 -0
  306. package/dist/src/transform-Bq5oqC0s.cjs +2 -0
  307. package/dist/src/{transform-ZrG2dvlo.cjs → transform-C9izGX54.cjs} +5 -5
  308. package/dist/src/{transform-BzK09Q_9.js → transform-CwbAZ84V.js} +5 -5
  309. package/dist/src/{transform-0BwoBsvO.cjs → transform-Dg4LcO1Y.cjs} +18 -10
  310. package/dist/src/{transform-B2-jIv68.js → transform-DtooZqYY.js} +8 -6
  311. package/dist/src/{transform-ljLYHEPh.js → transform-DzCF-wqV.js} +5 -5
  312. package/dist/src/{transform-DyDAwEpE.js → transform-_DpNB4qp.js} +9 -7
  313. package/dist/src/{transform-BqPkNPYm.js → transform-eGiUAv86.js} +5 -5
  314. package/dist/src/{transformersAvailability-DKoRtQLy.cjs → transformersAvailability-B22swDxr.cjs} +1 -1
  315. package/dist/src/{transformersAvailability-BGkzavwb.js → transformersAvailability-lvCCvuPT.js} +1 -1
  316. package/dist/src/{transformersAvailability-D6c6ROpT.js → transformersAvailability-rJGPccjr.js} +1 -1
  317. package/dist/src/{types-Cd3ygw8W.js → types-BDjGOq4E.js} +354 -24
  318. package/dist/src/{types-CIhFeUC4.js → types-BVH9hjgW.js} +364 -23
  319. package/dist/src/{types-D8cGDZbL.cjs → types-CgG2rKiW.cjs} +534 -167
  320. package/dist/src/{types-q8GXGF65.js → types-DNRZVOue.js} +498 -167
  321. package/dist/src/{util-BLvy9qfE.js → util-3pBZZb_H.js} +151 -149
  322. package/dist/src/{util-CFj4YKIn.cjs → util-A5_ZsQUn.cjs} +66 -44
  323. package/dist/src/{util-BtoGs5Cb.js → util-B9CNhyac.js} +66 -44
  324. package/dist/src/{util-Bm3E9jpK.js → util-BQOCAHQC.js} +692 -690
  325. package/dist/src/{util-vNmDL5DT.js → util-BVXcTwXu.js} +138 -36
  326. package/dist/src/{util-CgDCK4KI.js → util-BlFVL0UF.js} +66 -44
  327. package/dist/src/{util-DM2rTn_6.js → util-C-kmRosx.js} +66 -44
  328. package/dist/src/{util-DbVG-yZU.js → util-DFPeFkiV.js} +138 -36
  329. package/dist/src/{util-DMFeUvLz.js → util-DN0-b81k.js} +138 -36
  330. package/dist/src/{util--9u9UVCt.cjs → util-Dpmm_dAI.cjs} +143 -35
  331. package/dist/src/{util-CMMkIxfU.js → util-Dub0f_ej.js} +693 -691
  332. package/dist/src/{util-CuLo2pMR.cjs → util-DvpHnLt0.cjs} +714 -719
  333. package/dist/src/{utils-DOjD4dTC.js → utils-BUMN8orw.js} +6 -4
  334. package/dist/src/{utils-DKw8mrgr.cjs → utils-DkVeShIB.cjs} +6 -4
  335. package/dist/src/{utils-DEuL4VNB.js → utils-kt7lv30R.js} +6 -4
  336. package/dist/src/{utils-CFxO9KGo.js → utils-o8S5huU2.js} +6 -4
  337. package/dist/src/version-0frU0UTr.js +16 -0
  338. package/dist/src/version-CbpiUINz.js +17 -0
  339. package/dist/src/version-CbuBKu2U.js +16 -0
  340. package/dist/src/version-D9zu9FWB.cjs +27 -0
  341. package/dist/tsconfig.tsbuildinfo +1 -1
  342. package/package.json +57 -46
  343. package/dist/src/app/assets/index-B6l9CVVb.js +0 -439
  344. package/dist/src/app/assets/index-DyZ0Ep37.css +0 -1
  345. package/dist/src/app/assets/scroll-timeline-BdJZVXlz.js +0 -1
  346. package/dist/src/app/assets/sync-CStkzc6u.js +0 -4
  347. package/dist/src/app/assets/vendor-charts-BnDWwBlI.js +0 -36
  348. package/dist/src/app/assets/vendor-markdown-Bz7N-ca6.js +0 -29
  349. package/dist/src/app/assets/vendor-react-AtKqiNEf.js +0 -4
  350. package/dist/src/app/assets/vendor-syntax-D06x6TQF.js +0 -2
  351. package/dist/src/app/assets/vendor-utils-BvMHZmO7.js +0 -37
  352. package/dist/src/cache-C5yFZ4gC.cjs +0 -816
  353. package/dist/src/cache-CaT5tPgo.js +0 -756
  354. package/dist/src/cache-CyCanoMu.js +0 -6
  355. package/dist/src/cache-DSqR6ezl.js +0 -726
  356. package/dist/src/cache-Df_QFDNu.cjs +0 -5
  357. package/dist/src/cache-HP0NP4k3.js +0 -756
  358. package/dist/src/cloud-DE3t1-ZI.js +0 -4
  359. package/dist/src/codex-sdk-BQEw16R_.js +0 -834
  360. package/dist/src/codex-sdk-C_07GuVS.js +0 -834
  361. package/dist/src/codex-sdk-DE5G18dx.js +0 -835
  362. package/dist/src/codex-sdk-ZLKfDjqP.cjs +0 -838
  363. package/dist/src/eval-7aEqoMs3.js +0 -15
  364. package/dist/src/evalResult-CYNHkk5A.js +0 -12
  365. package/dist/src/evalResult-CuvJeNiM.js +0 -10
  366. package/dist/src/evalResult-tGdilrWt.cjs +0 -10
  367. package/dist/src/evaluator-BBUqRhz1.js +0 -36
  368. package/dist/src/fetch-UWU706qb.js +0 -5
  369. package/dist/src/graders-BxfEguVY.js +0 -32
  370. package/dist/src/graders-CzVMbEnv.js +0 -34
  371. package/dist/src/graders-DjCXfj0l.cjs +0 -32
  372. package/dist/src/graders-kHzIWOKu.js +0 -32
  373. package/dist/src/messages-DJNo37Ko.js +0 -246
  374. package/dist/src/messages-Dy9QecMs.js +0 -245
  375. package/dist/src/messages-HJsyEh4o.cjs +0 -257
  376. package/dist/src/messages-biC_ex-p.js +0 -245
  377. package/dist/src/openclaw-0Sv7AK3O.js +0 -580
  378. package/dist/src/openclaw-CXxbKgDH.cjs +0 -586
  379. package/dist/src/openclaw-D1FSCps-.js +0 -580
  380. package/dist/src/openclaw-D2ENvu7a.js +0 -582
  381. package/dist/src/providers-BSLEaIQG.js +0 -32
  382. package/dist/src/providers-D-FnDg8k.cjs +0 -31
  383. package/dist/src/providers-DEYiFVAo.js +0 -30
  384. package/dist/src/providers-sS2WI8YD.js +0 -30
  385. package/dist/src/rubyUtils-B1HXG4ej.cjs +0 -4
  386. package/dist/src/rubyUtils-Rt6pKA96.js +0 -5
  387. package/dist/src/server-B0Xh1Gx-.js +0 -7
  388. package/dist/src/server-DJTKu9IR.cjs +0 -5
  389. package/dist/src/store-C5u6MgC8.js +0 -6
  390. package/dist/src/store-CNHk-De4.cjs +0 -5
  391. package/dist/src/telemetry-Yig0Tino.js +0 -7
  392. package/dist/src/telemetry-p8Pwqm1i.cjs +0 -5
  393. package/dist/src/transform-ChNIpHz7.js +0 -6
  394. package/dist/src/transform-PtQ6rAE3.cjs +0 -5
@@ -1,11 +1,14 @@
1
- import { D as state, a as logger, b as getEnvBool, u as sanitizeObject } from "./logger-DO8_zM18.js";
1
+ import { S as getEnvBool, a as logger, f as sanitizeObject, k as state } from "./logger-Ct2S6Yx-.js";
2
2
  import { t as invariant } from "./invariant-Ddh24eXh.js";
3
- import { o as safeResolve, r as importModule, t as getDirectory } from "./esm-SUNIX1x3.js";
4
- import { r as runPython } from "./pythonUtils-Cpo0Ez1p.js";
5
- import { i as isJavascriptFile, t as JAVASCRIPT_EXTENSIONS } from "./fileExtensions-DnqA1y9x.js";
6
- import { A as isApiProvider, g as ResultFailureReason, h as OutputFileExtension, j as isProviderOptions } from "./types-q8GXGF65.js";
7
- import { N as VERSION, O as TERMINAL_MAX_WIDTH, t as fetchWithProxy } from "./fetch-CVAtKnI3.js";
8
- import * as fs$1 from "fs";
3
+ import { A as TERMINAL_MAX_WIDTH, t as fetchWithProxy } from "./fetch-D9xxyC1p.js";
4
+ import { n as VERSION } from "./version-CbuBKu2U.js";
5
+ import { A as isApiProvider, g as ResultFailureReason, h as OutputFileExtension, j as isProviderOptions } from "./types-DNRZVOue.js";
6
+ import { o as safeResolve, r as importModule, t as getDirectory } from "./esm-BRkfNsYs.js";
7
+ import { a as getNunjucksEngine, n as renderVarsInObject } from "./render-DlscvAUJ.js";
8
+ import { r as runPython } from "./pythonUtils-DMO68Jg7.js";
9
+ import { i as isJavascriptFile, t as JAVASCRIPT_EXTENSIONS } from "./fileExtensions-8CjoL7vB.js";
10
+ import * as fs$2 from "fs";
11
+ import fs from "fs";
9
12
  import * as path$1 from "path";
10
13
  import path from "path";
11
14
  import yaml from "js-yaml";
@@ -13,800 +16,799 @@ import dotenv from "dotenv";
13
16
  import * as os$1 from "os";
14
17
  import dedent from "dedent";
15
18
  import * as fsPromises from "fs/promises";
19
+ import nunjucks from "nunjucks";
20
+ import { parse as parse$1 } from "csv-parse/sync";
16
21
  import { globSync, hasMagic } from "glob";
17
22
  import deepEqual from "fast-deep-equal";
18
- import { parse as parse$1 } from "csv-parse/sync";
19
- import nunjucks from "nunjucks";
20
23
  import { XMLBuilder } from "fast-xml-parser";
21
24
  import { stringify } from "csv-stringify/sync";
22
- //#region src/util/provider.ts
23
- function canonicalizeProviderId(id) {
24
- if (id.startsWith("file://")) {
25
- const filePath = id.slice(7);
26
- return path$1.isAbsolute(filePath) ? id : `file://${path$1.resolve(filePath)}`;
27
- }
28
- for (const prefix of [
29
- "exec:",
30
- "python:",
31
- "golang:"
32
- ]) if (id.startsWith(prefix)) {
33
- const filePath = id.slice(prefix.length);
34
- if (filePath.includes("/") || filePath.includes("\\")) return `${prefix}${path$1.resolve(filePath)}`;
35
- return id;
25
+ //#region src/util/functions/loadFunction.ts
26
+ const functionCache = {};
27
+ /**
28
+ * Loads a function from a JavaScript or Python file
29
+ * @param options Options for loading the function
30
+ * @returns The loaded function
31
+ */
32
+ async function loadFunction({ filePath, functionName, defaultFunctionName = "func", basePath = state.basePath, useCache = true }) {
33
+ const cacheKey = `${filePath}${functionName ? `:${functionName}` : ""}`;
34
+ if (useCache && functionCache[cacheKey]) return functionCache[cacheKey];
35
+ const resolvedPath = basePath ? path.resolve(basePath, filePath) : filePath;
36
+ if (!isJavascriptFile(resolvedPath) && !resolvedPath.endsWith(".py")) throw new Error(`File must be a JavaScript (${JAVASCRIPT_EXTENSIONS.join(", ")}) or Python (.py) file`);
37
+ try {
38
+ let func;
39
+ if (isJavascriptFile(resolvedPath)) {
40
+ const module = await importModule(resolvedPath, functionName);
41
+ let moduleFunc;
42
+ if (functionName) moduleFunc = module;
43
+ else moduleFunc = typeof module === "function" ? module : module?.default?.default || module?.default || module?.[defaultFunctionName] || module;
44
+ if (typeof moduleFunc !== "function") throw new Error(functionName ? `JavaScript file must export a "${functionName}" function` : `JavaScript file must export a function (as default export or named export "${defaultFunctionName}")`);
45
+ func = moduleFunc;
46
+ } else {
47
+ const result = (...args) => runPython(resolvedPath, functionName || defaultFunctionName, args);
48
+ func = result;
49
+ }
50
+ if (useCache) functionCache[cacheKey] = func;
51
+ return func;
52
+ } catch (err) {
53
+ logger.error(`Failed to load function: ${err.message}`);
54
+ throw err;
36
55
  }
37
- if ((id.endsWith(".js") || id.endsWith(".ts") || id.endsWith(".mjs")) && (id.includes("/") || id.includes("\\"))) return `file://${path$1.resolve(id)}`;
38
- return id;
39
- }
40
- function getProviderLabel(provider) {
41
- return provider?.label && typeof provider.label === "string" ? provider.label : void 0;
42
56
  }
43
- function providerToIdentifier(provider) {
44
- if (!provider) return;
45
- if (typeof provider === "string") return canonicalizeProviderId(provider);
46
- const label = getProviderLabel(provider);
47
- if (label) return label;
48
- if (isApiProvider(provider)) return canonicalizeProviderId(provider.id());
49
- if (isProviderOptions(provider)) {
50
- if (provider.id) return canonicalizeProviderId(provider.id);
51
- return;
52
- }
53
- if (typeof provider === "object" && "id" in provider && typeof provider.id === "string") return canonicalizeProviderId(provider.id);
57
+ /**
58
+ * Extracts the file path and function name from a file:// URL
59
+ * @param fileUrl The file:// URL (e.g., "file://path/to/file.js:functionName")
60
+ * @returns The file path and optional function name
61
+ */
62
+ function parseFileUrl(fileUrl) {
63
+ if (!fileUrl.startsWith("file://")) throw new Error("URL must start with file://");
64
+ const urlWithoutProtocol = fileUrl.slice(7);
65
+ const lastColonIndex = urlWithoutProtocol.lastIndexOf(":");
66
+ if (lastColonIndex > 1) return {
67
+ filePath: urlWithoutProtocol.slice(0, lastColonIndex),
68
+ functionName: urlWithoutProtocol.slice(lastColonIndex + 1)
69
+ };
70
+ return { filePath: urlWithoutProtocol };
54
71
  }
72
+ //#endregion
73
+ //#region src/util/file.ts
55
74
  /**
56
- * Gets a descriptive identifier string for a provider, showing both label and ID when both exist.
57
- * Useful for error messages to help users debug provider reference issues.
75
+ * Simple Nunjucks engine specifically for file paths
76
+ * This function is separate from the main getNunjucksEngine to avoid circular dependencies
58
77
  */
59
- function getProviderDescription(provider) {
60
- const label = provider.label;
61
- const id = provider.id();
62
- if (label && label !== id) return `${label} (${id})`;
63
- return id;
78
+ function getNunjucksEngineForFilePath() {
79
+ const env = nunjucks.configure({ autoescape: false });
80
+ env.addGlobal("env", {
81
+ ...process.env,
82
+ ...state.config?.env
83
+ });
84
+ return env;
64
85
  }
65
86
  /**
66
- * Checks if a provider reference matches a given provider.
67
- * Supports exact matching and wildcard patterns.
87
+ * Loads content from an external file if the input is a file path, otherwise
88
+ * returns the input as-is. Supports Nunjucks templating for file paths.
89
+ *
90
+ * @param filePath - The input to process. Can be a file path string starting with "file://",
91
+ * an array of file paths, or any other type of data.
92
+ * @param context - Optional context to control file loading behavior. 'assertion' context
93
+ * preserves Python/JS file references instead of loading their content.
94
+ * @returns The loaded content if the input was a file path, otherwise the original input.
95
+ * For JSON and YAML files, the content is parsed into an object.
96
+ * For other file types, the raw file content is returned as a string.
97
+ *
98
+ * @throws {Error} If the specified file does not exist.
68
99
  */
69
- function doesProviderRefMatch(ref, provider) {
70
- const label = provider.label;
71
- const id = provider.id();
72
- const canonicalRef = canonicalizeProviderId(ref);
73
- const canonicalId = canonicalizeProviderId(id);
74
- if (label && label === ref) return true;
75
- if (id === ref || canonicalId === canonicalRef) return true;
76
- if (ref.endsWith("*")) {
77
- const prefix = ref.slice(0, -1);
78
- if (label?.startsWith(prefix) || id.startsWith(prefix) || canonicalId.startsWith(prefix)) return true;
100
+ function maybeLoadFromExternalFile(filePath, context) {
101
+ if (Array.isArray(filePath)) return filePath.map((path) => {
102
+ return maybeLoadFromExternalFile(path, context);
103
+ });
104
+ if (typeof filePath !== "string") return filePath;
105
+ if (!filePath.startsWith("file://")) return filePath;
106
+ const renderedFilePath = getNunjucksEngineForFilePath().renderString(filePath, {});
107
+ const { filePath: cleanPath, functionName } = parseFileUrl(renderedFilePath);
108
+ if (context === "assertion" && (cleanPath.endsWith(".py") || isJavascriptFile(cleanPath))) {
109
+ logger.debug(`Preserving Python/JS file reference in assertion context: ${renderedFilePath}`);
110
+ return renderedFilePath;
79
111
  }
80
- if (label?.startsWith(`${ref}:`) || id.startsWith(`${ref}:`) || canonicalId.startsWith(`${ref}:`)) return true;
81
- return false;
112
+ if (context === "vars") {
113
+ logger.debug(`Preserving file reference in vars context: ${renderedFilePath}`);
114
+ return renderedFilePath;
115
+ }
116
+ if (functionName && (cleanPath.endsWith(".py") || isJavascriptFile(cleanPath))) return renderedFilePath;
117
+ const pathToUse = functionName && !(cleanPath.endsWith(".py") || isJavascriptFile(cleanPath)) ? renderedFilePath.slice(7) : cleanPath;
118
+ const resolvedPath = path$1.resolve(state.basePath || "", pathToUse);
119
+ if (hasMagic(pathToUse)) {
120
+ const matchedFiles = globSync(resolvedPath, { windowsPathsNoEscape: true });
121
+ if (matchedFiles.length === 0) throw new Error(`No files found matching pattern: ${resolvedPath}`);
122
+ const allContents = [];
123
+ for (const matchedFile of matchedFiles) {
124
+ let contents;
125
+ try {
126
+ contents = fs$2.readFileSync(matchedFile, "utf8");
127
+ } catch (error) {
128
+ if (error.code === "ENOENT") {
129
+ logger.debug(`File disappeared during glob expansion: ${matchedFile}`);
130
+ continue;
131
+ }
132
+ throw error;
133
+ }
134
+ if (matchedFile.endsWith(".json")) {
135
+ const parsed = JSON.parse(contents);
136
+ if (Array.isArray(parsed)) allContents.push(...parsed);
137
+ else allContents.push(parsed);
138
+ } else if (matchedFile.endsWith(".yaml") || matchedFile.endsWith(".yml")) {
139
+ const parsed = yaml.load(contents);
140
+ if (parsed === null || parsed === void 0) continue;
141
+ if (Array.isArray(parsed)) allContents.push(...parsed);
142
+ else allContents.push(parsed);
143
+ } else if (matchedFile.endsWith(".csv")) {
144
+ const records = parse$1(contents, { columns: true });
145
+ if (records.length > 0 && Object.keys(records[0]).length === 1) allContents.push(...records.map((record) => Object.values(record)[0]));
146
+ else allContents.push(...records);
147
+ } else allContents.push(contents);
148
+ }
149
+ return allContents;
150
+ }
151
+ const finalPath = resolvedPath;
152
+ let contents;
153
+ try {
154
+ contents = fs$2.readFileSync(finalPath, "utf8");
155
+ } catch (error) {
156
+ if (error.code === "ENOENT") throw new Error(`File does not exist: ${finalPath}`);
157
+ throw new Error(`Failed to read file ${finalPath}: ${error}`);
158
+ }
159
+ if (finalPath.endsWith(".json")) try {
160
+ return JSON.parse(contents);
161
+ } catch (error) {
162
+ throw new Error(`Failed to parse JSON file ${finalPath}: ${error}`);
163
+ }
164
+ if (finalPath.endsWith(".yaml") || finalPath.endsWith(".yml")) try {
165
+ return yaml.load(contents);
166
+ } catch (error) {
167
+ throw new Error(`Failed to parse YAML file ${finalPath}: ${error}`);
168
+ }
169
+ if (finalPath.endsWith(".csv")) {
170
+ const records = parse$1(contents, { columns: true });
171
+ if (records.length > 0 && Object.keys(records[0]).length === 1) return records.map((record) => Object.values(record)[0]);
172
+ return records;
173
+ }
174
+ return contents;
82
175
  }
83
176
  /**
84
- * Checks if a provider is allowed based on a list of allowed references.
177
+ * Resolves a relative file path with respect to a base path, handling cloud configuration appropriately.
178
+ * When using a cloud configuration, the current working directory is always used instead of the context's base path.
179
+ *
180
+ * @param filePath - The relative or absolute file path to resolve.
181
+ * @param isCloudConfig - Whether this is a cloud configuration.
182
+ * @returns The resolved absolute file path.
85
183
  */
86
- function isProviderAllowed(provider, allowedProviders) {
87
- if (!Array.isArray(allowedProviders)) return true;
88
- if (allowedProviders.length === 0) return false;
89
- return allowedProviders.some((ref) => doesProviderRefMatch(ref, provider));
184
+ function getResolvedRelativePath(filePath, isCloudConfig) {
185
+ if (path$1.isAbsolute(filePath) || !isCloudConfig) return filePath;
186
+ return path$1.join(process.cwd(), filePath);
90
187
  }
91
188
  /**
92
- * Detects if a provider uses OpenAI models.
93
- * This includes direct OpenAI providers and Azure OpenAI.
189
+ * Recursively loads external file references from a configuration object.
190
+ *
191
+ * @param config - The configuration object to process
192
+ * @param context - Optional context to control file loading behavior
193
+ * @returns The configuration with external file references resolved
94
194
  */
95
- function isOpenAiProvider(providerId) {
96
- const lowerProviderId = providerId.toLowerCase();
97
- if (lowerProviderId.startsWith("openai:")) return true;
98
- if (lowerProviderId.startsWith("azureopenai:")) return true;
99
- if (lowerProviderId.startsWith("azure:")) {
100
- if ([
101
- "gpt",
102
- "openai",
103
- "davinci",
104
- "curie",
105
- "babbage",
106
- "ada",
107
- "text-embedding",
108
- "whisper",
109
- "dall-e",
110
- "tts"
111
- ].some((indicator) => lowerProviderId.includes(indicator))) return true;
195
+ function maybeLoadConfigFromExternalFile(config, context) {
196
+ if (Array.isArray(config)) return config.map((item) => maybeLoadConfigFromExternalFile(item, context));
197
+ if (typeof config === "object" && config !== null) {
198
+ const result = {};
199
+ for (const key of Object.keys(config)) {
200
+ const childContext = key === "value" && "type" in config && typeof config.type === "string" && (config.type === "python" || config.type === "javascript") ? "assertion" : key === "vars" ? "vars" : context;
201
+ result[key] = maybeLoadConfigFromExternalFile(config[key], childContext);
202
+ }
203
+ return result;
112
204
  }
113
- return false;
205
+ return maybeLoadFromExternalFile(config, context);
114
206
  }
115
207
  /**
116
- * Detects if a provider uses Anthropic/Claude models.
117
- * This includes direct Anthropic providers, Bedrock with Claude, and Vertex with Claude.
208
+ * Parses a file path or glob pattern to extract function names and file extensions.
209
+ * Function names can be specified in the filename like this:
210
+ * prompt.py:myFunction or prompts.js:myFunction.
211
+ * @param basePath - The base path for file resolution.
212
+ * @param promptPath - The path or glob pattern.
213
+ * @returns Parsed details including function name, file extension, and directory status.
118
214
  */
119
- function isAnthropicProvider(providerId) {
120
- const lowerProviderId = providerId.toLowerCase();
121
- if (lowerProviderId.startsWith("anthropic:")) return true;
122
- if (lowerProviderId.startsWith("bedrock:")) {
123
- if (lowerProviderId.includes("claude") || lowerProviderId.includes("anthropic")) return true;
124
- }
125
- if (lowerProviderId.startsWith("vertex:")) {
126
- if (lowerProviderId.includes("claude")) return true;
127
- }
128
- return false;
129
- }
130
- const KNOWN_ENV_VARS = {
131
- openai: "OPENAI_API_KEY",
132
- anthropic: "ANTHROPIC_API_KEY",
133
- google: "GOOGLE_API_KEY",
134
- mistral: "MISTRAL_API_KEY",
135
- cohere: "COHERE_API_KEY",
136
- replicate: "REPLICATE_API_TOKEN",
137
- voyage: "VOYAGE_API_KEY",
138
- ai21: "AI21_API_KEY",
139
- xai: "XAI_API_KEY",
140
- groq: "GROQ_API_KEY",
141
- deepseek: "DEEPSEEK_API_KEY",
142
- perplexity: "PERPLEXITY_API_KEY",
143
- hyperbolic: "HYPERBOLIC_API_KEY",
144
- cerebras: "CEREBRAS_API_KEY",
145
- togetherai: "TOGETHER_API_KEY",
146
- fal: "FAL_KEY",
147
- huggingface: "HF_TOKEN",
148
- "cloudflare-ai": "CLOUDFLARE_API_KEY"
149
- };
150
- function getDefaultEnvVar(providerId) {
151
- const prefix = providerId.split(":")[0];
152
- return KNOWN_ENV_VARS[prefix] || `${prefix.toUpperCase()}_API_KEY`;
153
- }
154
- /**
155
- * Pre-checks providers for missing API keys before evaluation starts.
156
- * Assumes getApiKey() is side-effect free (no network calls or token refresh).
157
- */
158
- function checkProviderApiKeys(providers) {
159
- const missingApiKeys = /* @__PURE__ */ new Map();
160
- for (const provider of providers) {
161
- const p = provider;
162
- if (typeof p.getApiKey !== "function") continue;
163
- if (provider.id().startsWith("azure:")) continue;
164
- const requiresKey = typeof p.requiresApiKey === "function" ? p.requiresApiKey() : p.config?.apiKeyRequired !== false;
165
- let apiKey;
166
- try {
167
- apiKey = p.getApiKey();
168
- } catch {
169
- apiKey = void 0;
170
- }
171
- if (requiresKey && !apiKey) {
172
- const envVar = p.config?.apiKeyEnvar || getDefaultEnvVar(provider.id());
173
- if (!missingApiKeys.has(envVar)) missingApiKeys.set(envVar, []);
174
- missingApiKeys.get(envVar).push(provider.id());
215
+ function parsePathOrGlob(basePath, promptPath) {
216
+ if (promptPath.startsWith("file://")) promptPath = promptPath.slice(7);
217
+ const filePath = path$1.resolve(basePath, promptPath);
218
+ let filename = path$1.relative(basePath, filePath);
219
+ let functionName;
220
+ if (filename.includes(":")) {
221
+ const lastColonIndex = filename.lastIndexOf(":");
222
+ if (lastColonIndex > 1) {
223
+ const pathWithoutFunction = filename.slice(0, lastColonIndex);
224
+ if (isJavascriptFile(pathWithoutFunction) || pathWithoutFunction.endsWith(".py") || pathWithoutFunction.endsWith(".go") || pathWithoutFunction.endsWith(".rb")) {
225
+ functionName = filename.slice(lastColonIndex + 1);
226
+ filename = pathWithoutFunction;
227
+ }
175
228
  }
176
229
  }
177
- return missingApiKeys;
230
+ let stats;
231
+ try {
232
+ stats = fs$2.statSync(path$1.join(basePath, filename));
233
+ } catch (err) {
234
+ if (getEnvBool("PROMPTFOO_STRICT_FILES")) throw err;
235
+ }
236
+ const normalizedFilePath = filePath.replace(/\\/g, "/");
237
+ const isPathPattern = stats?.isDirectory() || hasMagic(promptPath) || hasMagic(normalizedFilePath);
238
+ const safeFilename = path$1.relative(basePath, safeResolve(basePath, filename));
239
+ return {
240
+ extension: isPathPattern ? void 0 : path$1.parse(safeFilename).ext,
241
+ filePath: path$1.join(basePath, safeFilename),
242
+ functionName,
243
+ isPathPattern
244
+ };
245
+ }
246
+ function readOutput(outputPath) {
247
+ const ext = path$1.parse(outputPath).ext.slice(1);
248
+ switch (ext) {
249
+ case "json": return JSON.parse(fs$2.readFileSync(outputPath, "utf-8"));
250
+ default: throw new Error(`Unsupported output file format: ${ext} currently only supports json`);
251
+ }
178
252
  }
179
253
  /**
180
- * Detects if a provider uses Google models.
181
- * This includes direct Google/Vertex providers with Gemini and other Google models.
182
- * Note: Vertex with Claude models is NOT counted as Google (it's Anthropic).
254
+ * Load custom Nunjucks filters from external files.
255
+ * Note: If a glob pattern matches multiple files, only the last file's export is used.
256
+ * Each filter name should typically resolve to a single file.
183
257
  */
184
- function isGoogleProvider(providerId) {
185
- const lowerProviderId = providerId.toLowerCase();
186
- if (lowerProviderId.startsWith("google:")) return true;
187
- if (lowerProviderId.startsWith("vertex:")) {
188
- if (!lowerProviderId.includes("claude")) return true;
258
+ async function readFilters(filters, basePath = "") {
259
+ const ret = {};
260
+ for (const [name, filterPath] of Object.entries(filters)) {
261
+ const filePaths = globSync(path$1.join(basePath, filterPath), { windowsPathsNoEscape: true });
262
+ for (const filePath of filePaths) ret[name] = await importModule(path$1.resolve(filePath));
189
263
  }
190
- return false;
264
+ return ret;
191
265
  }
192
- //#endregion
193
- //#region src/util/comparison.ts
194
266
  /**
195
- * Explicit runtime variable names that don't follow the underscore convention.
196
- * These are added during evaluation but aren't part of the original test definition.
267
+ * Loads configuration from an external file with variable rendering.
268
+ * This is a convenience wrapper that combines renderVarsInObject and maybeLoadFromExternalFile.
197
269
  *
198
- * - sessionId: Added by multi-turn strategy providers (GOAT, Crescendo)
270
+ * Use this for simple config fields that:
271
+ * - Need variable rendering ({{ vars.x }}, {{ env.X }})
272
+ * - May reference external files (file://path.json)
273
+ * - Don't have nested file references that need loading
199
274
  *
200
- * Note: Variables starting with underscore (e.g., _conversation) are automatically
201
- * treated as runtime variables and filtered out.
202
- */
203
- const EXPLICIT_RUNTIME_VAR_KEYS = ["sessionId"];
204
- /**
205
- * Checks if a variable key is a runtime-only variable that should be filtered
206
- * when comparing test cases.
275
+ * For fields with nested file references (like response_format.schema),
276
+ * use maybeLoadResponseFormatFromExternalFile instead.
207
277
  *
208
- * Runtime variables are identified by:
209
- * 1. Starting with underscore (_) - convention for internal/runtime vars
210
- * 2. Being in the explicit runtime var list (for legacy vars like sessionId)
278
+ * @param config - The configuration to process
279
+ * @param vars - Variables for template rendering
280
+ * @returns The processed configuration with variables rendered and files loaded
211
281
  */
212
- function isRuntimeVar(key) {
213
- return key.startsWith("_") || EXPLICIT_RUNTIME_VAR_KEYS.includes(key);
282
+ function maybeLoadFromExternalFileWithVars(config, vars) {
283
+ return maybeLoadFromExternalFile(renderVarsInObject(config, vars));
214
284
  }
215
285
  /**
216
- * Filters out runtime-only variables that are added during evaluation
217
- * but aren't part of the original test definition.
286
+ * Loads response_format configuration from an external file with variable rendering.
218
287
  *
219
- * This is used when comparing test cases to determine if a result
220
- * corresponds to a particular test, regardless of runtime state.
288
+ * This function handles the special case where response_format may contain:
289
+ * 1. A top-level file reference (file://format.json)
290
+ * 2. A nested schema reference for json_schema type (schema: file://schema.json)
221
291
  *
222
- * Runtime variables are identified by:
223
- * - Starting with underscore (e.g., _conversation, _metadata)
224
- * - Being in the explicit list (e.g., sessionId for backward compatibility)
292
+ * Both levels need variable rendering and file loading.
293
+ *
294
+ * @param responseFormat - The response_format configuration
295
+ * @param vars - Variables for template rendering
296
+ * @returns The processed response_format with all files loaded
225
297
  */
226
- function filterRuntimeVars(vars) {
227
- if (!vars || typeof vars !== "object" || Array.isArray(vars)) return vars;
228
- const filtered = {};
229
- for (const [key, value] of Object.entries(vars)) if (!isRuntimeVar(key)) filtered[key] = value;
230
- return filtered;
298
+ function maybeLoadResponseFormatFromExternalFile(responseFormat, vars) {
299
+ if (responseFormat === void 0 || responseFormat === null) return responseFormat;
300
+ const loaded = maybeLoadFromExternalFile(renderVarsInObject(responseFormat, vars));
301
+ if (!loaded || typeof loaded !== "object") return loaded;
302
+ if (loaded.type === "json_schema") {
303
+ const nestedSchema = loaded.schema || loaded.json_schema?.schema;
304
+ if (nestedSchema) {
305
+ const loadedSchema = maybeLoadFromExternalFile(renderVarsInObject(nestedSchema, vars));
306
+ if (loaded.schema !== void 0) return {
307
+ ...loaded,
308
+ schema: loadedSchema
309
+ };
310
+ else if (loaded.json_schema?.schema !== void 0) return {
311
+ ...loaded,
312
+ json_schema: {
313
+ ...loaded.json_schema,
314
+ schema: loadedSchema
315
+ }
316
+ };
317
+ }
318
+ }
319
+ return loaded;
231
320
  }
232
321
  /**
233
- * Extracts only runtime variables from a vars object.
234
- * This is the inverse of filterRuntimeVars.
322
+ * Renders variables in a tools object and loads from external file if applicable.
323
+ * This function combines renderVarsInObject and maybeLoadFromExternalFile into a single step
324
+ * specifically for handling tools configurations.
235
325
  *
236
- * Used to restore runtime state when re-running filtered tests.
326
+ * Supports loading from JSON, YAML, Python, and JavaScript files.
327
+ *
328
+ * @param tools - The tools configuration object or array to process.
329
+ * @param vars - Variables to use for rendering.
330
+ * @returns The processed tools configuration with variables rendered and content loaded from files if needed.
331
+ * @throws {Error} If the loaded tools are in an invalid format
237
332
  */
238
- function extractRuntimeVars(vars) {
239
- if (!vars || typeof vars !== "object" || Array.isArray(vars)) return;
240
- const extracted = {};
241
- for (const [key, value] of Object.entries(vars)) if (isRuntimeVar(key)) extracted[key] = value;
242
- return Object.keys(extracted).length > 0 ? extracted : void 0;
333
+ async function maybeLoadToolsFromExternalFile(tools, vars) {
334
+ const rendered = renderVarsInObject(tools, vars);
335
+ if (typeof rendered === "string" && rendered.startsWith("file://")) {
336
+ const { filePath, functionName } = parseFileUrl(rendered);
337
+ if (functionName && (filePath.endsWith(".py") || isJavascriptFile(filePath))) {
338
+ const fileType = filePath.endsWith(".py") ? "Python" : "JavaScript";
339
+ logger.debug(`[maybeLoadToolsFromExternalFile] Loading tools from ${fileType} file: ${filePath}:${functionName}`);
340
+ try {
341
+ let toolDefinitions;
342
+ if (filePath.endsWith(".py")) {
343
+ const absPath = safeResolve(state.basePath || process.cwd(), filePath);
344
+ logger.debug(`[maybeLoadToolsFromExternalFile] Resolved Python path: ${absPath}`);
345
+ toolDefinitions = await runPython(absPath, functionName, []);
346
+ } else {
347
+ const absPath = safeResolve(state.basePath || process.cwd(), filePath);
348
+ logger.debug(`[maybeLoadToolsFromExternalFile] Resolved JavaScript path: ${absPath}`);
349
+ const module = await importModule(absPath);
350
+ const fn = module[functionName] || module.default?.[functionName];
351
+ if (typeof fn !== "function") {
352
+ const availableExports = Object.keys(module).filter((k) => k !== "default");
353
+ const basePath = state.basePath || process.cwd();
354
+ throw new Error(`Function "${functionName}" not found in ${filePath}. Available exports: ${availableExports.length > 0 ? availableExports.join(", ") : "(none)"}\nResolved from: ${basePath}`);
355
+ }
356
+ toolDefinitions = await Promise.resolve(fn());
357
+ }
358
+ if (!toolDefinitions || typeof toolDefinitions === "string" || typeof toolDefinitions === "number" || typeof toolDefinitions === "boolean") throw new Error(`Function "${functionName}" must return an array or object of tool definitions, but returned: ${toolDefinitions === null ? "null" : typeof toolDefinitions}`);
359
+ logger.debug(`[maybeLoadToolsFromExternalFile] Successfully loaded ${Array.isArray(toolDefinitions) ? toolDefinitions.length : "object"} tools`);
360
+ return toolDefinitions;
361
+ } catch (err) {
362
+ const errorMessage = err instanceof Error ? err.message : String(err);
363
+ const basePath = state.basePath || process.cwd();
364
+ throw new Error(`Failed to load tools from ${rendered}:\n${errorMessage}\n\nMake sure the function "${functionName}" exists and returns a valid tool definition array.\nResolved from: ${basePath}`);
365
+ }
366
+ }
367
+ if (filePath.endsWith(".py") || isJavascriptFile(filePath)) {
368
+ const ext = filePath.endsWith(".py") ? "Python" : "JavaScript";
369
+ const basePath = state.basePath || process.cwd();
370
+ throw new Error(`Cannot load tools from ${rendered}\n${ext} files require a function name. Use this format:\n tools: file://${filePath}:get_tools\n\nYour ${ext} file should export a function that returns tool definitions:\n` + (filePath.endsWith(".py") ? ` def get_tools():\n return [{"type": "function", "function": {...}}]` : ` module.exports.get_tools = () => [{ type: "function", function: {...} }];`) + `\n\nResolved from: ${basePath}`);
371
+ }
372
+ }
373
+ if (Array.isArray(rendered)) {
374
+ const results = await Promise.all(rendered.map((item) => maybeLoadToolsFromExternalFile(item, vars)));
375
+ if (results.every((r) => Array.isArray(r))) return results.flat();
376
+ return results;
377
+ }
378
+ if (typeof rendered !== "string") return rendered;
379
+ const loaded = maybeLoadFromExternalFile(rendered);
380
+ if (loaded !== void 0 && loaded !== null && typeof loaded === "string") {
381
+ if (loaded.startsWith("file://")) throw new Error(`Failed to load tools from ${loaded}\nEnsure the file exists and contains valid JSON or YAML tool definitions.`);
382
+ if (loaded.includes("def ") || loaded.includes("import ")) throw new Error("Invalid tools configuration: file appears to contain Python code.\nPython files require a function name. Use this format:\n tools: file://tools.py:get_tools");
383
+ throw new Error("Invalid tools configuration: expected an array or object, but got a string.\nIf using file://, ensure the file contains valid JSON or YAML tool definitions.");
384
+ }
385
+ return loaded;
243
386
  }
244
- function varsMatch(vars1, vars2) {
245
- return deepEqual(vars1, vars2);
387
+ //#endregion
388
+ //#region src/util/providerRef.ts
389
+ const PROVIDER_OPTION_KEYS = new Set([
390
+ "id",
391
+ "label",
392
+ "config",
393
+ "prompts",
394
+ "transform",
395
+ "delay",
396
+ "env",
397
+ "inputs"
398
+ ]);
399
+ /** Returns true if the value is a non-empty string suitable as a provider identifier. */
400
+ function isValidProviderId(id) {
401
+ return typeof id === "string" && id !== "";
402
+ }
403
+ function getProviderLabel(provider) {
404
+ if ((typeof provider === "object" || typeof provider === "function") && provider !== null && "label" in provider && typeof provider.label === "string") return provider.label;
246
405
  }
247
406
  /**
248
- * Generate a unique key for a test case for deduplication purposes.
249
- * Excludes runtime variables and includes strategyId to distinguish tests
250
- * with the same prompt but different strategies.
251
- *
252
- * @param testCase - The test case to generate a key for
253
- * @returns A JSON string that uniquely identifies the test case
407
+ * Resolves relative file paths in provider IDs to absolute paths for consistent matching.
408
+ * Handles file://, exec:, python:, golang: prefixes and bare .js/.ts/.mjs paths.
254
409
  */
255
- function getTestCaseDeduplicationKey(testCase) {
256
- const filteredVars = filterRuntimeVars(testCase.vars);
257
- const strategyId = testCase.metadata?.strategyId || "none";
258
- return JSON.stringify({
259
- vars: filteredVars,
260
- strategyId
261
- });
262
- }
263
- /**
264
- * Deduplicates an array of test cases based on their vars and strategyId.
265
- * Tests with the same vars but different strategies are considered different.
266
- * Runtime variables (like _conversation, sessionId) are filtered out before comparison.
267
- *
268
- * @param tests - Array of test cases to deduplicate
269
- * @returns Deduplicated array of test cases
270
- */
271
- function deduplicateTestCases(tests) {
272
- const seen = /* @__PURE__ */ new Set();
273
- return tests.filter((test) => {
274
- const key = getTestCaseDeduplicationKey(test);
275
- if (seen.has(key)) return false;
276
- seen.add(key);
277
- return true;
278
- });
279
- }
280
- function resultIsForTestCase(result, testCase) {
281
- const testProviderId = testCase.provider ? providerToIdentifier(testCase.provider) : void 0;
282
- const resultProviderId = providerToIdentifier(result.provider);
283
- const providersMatch = !testProviderId || !resultProviderId || testProviderId === resultProviderId;
284
- const resultVars = filterRuntimeVars(result.vars);
285
- const testVars = filterRuntimeVars(testCase.vars);
286
- const doVarsMatch = varsMatch(testVars, resultVars);
287
- const isMatch = doVarsMatch && providersMatch;
288
- if (!isMatch) {
289
- const varKeys = testVars ? Object.keys(testVars).join(", ") : "none";
290
- logger.debug(`[resultIsForTestCase] No match: vars=${doVarsMatch}, providers=${providersMatch}`, {
291
- testProvider: testProviderId || "none",
292
- resultProvider: resultProviderId || "none",
293
- testVarKeys: varKeys
294
- });
410
+ function canonicalizeProviderId(id) {
411
+ if (id.startsWith("file://")) {
412
+ const filePath = id.slice(7);
413
+ return path.isAbsolute(filePath) ? id : `file://${path.resolve(filePath)}`;
295
414
  }
296
- return isMatch;
415
+ for (const prefix of [
416
+ "exec:",
417
+ "python:",
418
+ "golang:"
419
+ ]) if (id.startsWith(prefix)) {
420
+ const filePath = id.slice(prefix.length);
421
+ if (filePath.includes("/") || filePath.includes("\\")) return `${prefix}${path.resolve(filePath)}`;
422
+ return id;
423
+ }
424
+ if ((id.endsWith(".js") || id.endsWith(".ts") || id.endsWith(".mjs")) && (id.includes("/") || id.includes("\\"))) return `file://${path.resolve(id)}`;
425
+ return id;
297
426
  }
298
- //#endregion
299
- //#region src/util/env.ts
300
427
  /**
301
- * Load environment variables from .env file(s).
302
- * @param envPath - Single path, array of paths, or undefined for default .env loading.
303
- * When paths are explicitly specified, all files must exist or an error is thrown.
304
- * When multiple files are provided, later files override values from earlier files.
428
+ * Returns true for provider refs that should be expanded from YAML/JSON config files.
305
429
  */
306
- function setupEnv(envPath) {
307
- if (envPath) {
308
- const paths = (Array.isArray(envPath) ? envPath : [envPath]).flatMap((p) => p.includes(",") ? p.split(",").map((s) => s.trim()) : p.trim()).filter((p) => p.length > 0);
309
- if (paths.length === 0) {
310
- dotenv.config({ quiet: true });
311
- return;
312
- }
313
- for (const p of paths) if (!fs$1.existsSync(p)) throw new Error(`Environment file not found: ${p}`);
314
- if (paths.length === 1) logger.info(`Loading environment variables from ${paths[0]}`);
315
- else logger.info(`Loading environment variables from: ${paths.join(", ")}`);
316
- const pathArg = paths.length === 1 ? paths[0] : paths;
317
- dotenv.config({
318
- path: pathArg,
319
- override: true,
320
- quiet: true
321
- });
322
- } else dotenv.config({ quiet: true });
430
+ function isProviderConfigFileReference(providerPath) {
431
+ return providerPath.startsWith("file://") && (providerPath.endsWith(".yaml") || providerPath.endsWith(".yml") || providerPath.endsWith(".json"));
323
432
  }
324
- //#endregion
325
- //#region src/util/functions/loadFunction.ts
326
- const functionCache = {};
327
433
  /**
328
- * Loads a function from a JavaScript or Python file
329
- * @param options Options for loading the function
330
- * @returns The loaded function
434
+ * Reads a provider config file and normalizes single-provider and multi-provider files.
435
+ * Returns a `wasArray` flag so callers can detect multi-provider files that require
436
+ * `loadApiProviders` instead of `loadApiProvider`.
331
437
  */
332
- async function loadFunction({ filePath, functionName, defaultFunctionName = "func", basePath = state.basePath, useCache = true }) {
333
- const cacheKey = `${filePath}${functionName ? `:${functionName}` : ""}`;
334
- if (useCache && functionCache[cacheKey]) return functionCache[cacheKey];
335
- const resolvedPath = basePath ? path.resolve(basePath, filePath) : filePath;
336
- if (!isJavascriptFile(resolvedPath) && !resolvedPath.endsWith(".py")) throw new Error(`File must be a JavaScript (${JAVASCRIPT_EXTENSIONS.join(", ")}) or Python (.py) file`);
438
+ function readProviderConfigFile(providerPath, basePath) {
439
+ const relativePath = providerPath.slice(7);
440
+ const resolvedPath = path.isAbsolute(relativePath) ? relativePath : path.join(basePath || process.cwd(), relativePath);
441
+ let rawContent;
337
442
  try {
338
- let func;
339
- if (isJavascriptFile(resolvedPath)) {
340
- const module = await importModule(resolvedPath, functionName);
341
- let moduleFunc;
342
- if (functionName) moduleFunc = module;
343
- else moduleFunc = typeof module === "function" ? module : module?.default?.default || module?.default || module?.[defaultFunctionName] || module;
344
- if (typeof moduleFunc !== "function") throw new Error(functionName ? `JavaScript file must export a "${functionName}" function` : `JavaScript file must export a function (as default export or named export "${defaultFunctionName}")`);
345
- func = moduleFunc;
346
- } else {
347
- const result = (...args) => runPython(resolvedPath, functionName || defaultFunctionName, args);
348
- func = result;
349
- }
350
- if (useCache) functionCache[cacheKey] = func;
351
- return func;
443
+ rawContent = yaml.load(fs.readFileSync(resolvedPath, "utf8"));
352
444
  } catch (err) {
353
- logger.error(`Failed to load function: ${err.message}`);
354
- throw err;
445
+ throw new Error(`Failed to load provider config ${relativePath}: ${err instanceof Error ? err.message : err}`);
355
446
  }
356
- }
357
- /**
358
- * Extracts the file path and function name from a file:// URL
359
- * @param fileUrl The file:// URL (e.g., "file://path/to/file.js:functionName")
360
- * @returns The file path and optional function name
361
- */
362
- function parseFileUrl(fileUrl) {
363
- if (!fileUrl.startsWith("file://")) throw new Error("URL must start with file://");
364
- const urlWithoutProtocol = fileUrl.slice(7);
365
- const lastColonIndex = urlWithoutProtocol.lastIndexOf(":");
366
- if (lastColonIndex > 1) return {
367
- filePath: urlWithoutProtocol.slice(0, lastColonIndex),
368
- functionName: urlWithoutProtocol.slice(lastColonIndex + 1)
447
+ const fileContent = maybeLoadConfigFromExternalFile(rawContent);
448
+ invariant(fileContent, `Provider config ${relativePath} is undefined`);
449
+ return {
450
+ configs: [fileContent].flat(),
451
+ relativePath,
452
+ wasArray: Array.isArray(fileContent)
369
453
  };
370
- return { filePath: urlWithoutProtocol };
371
454
  }
372
- //#endregion
373
- //#region src/util/templates.ts
374
455
  /**
375
- * Get a Nunjucks engine instance with optional filters and configuration.
376
- * @param filters - Optional map of custom Nunjucks filters.
377
- * @param throwOnUndefined - Whether to throw an error on undefined variables.
378
- * @param isGrader - Whether this engine is being used in a grader context.
379
- * Nunjucks is always enabled in grader mode.
380
- * @returns A configured Nunjucks environment.
456
+ * Loads provider config objects from a file-backed provider reference.
381
457
  */
382
- function getNunjucksEngine(filters, throwOnUndefined = false, isGrader = false) {
383
- if (!isGrader && getEnvBool("PROMPTFOO_DISABLE_TEMPLATING")) return { renderString: (template) => template };
384
- const env = nunjucks.configure({
385
- autoescape: false,
386
- throwOnUndefined
387
- });
388
- const envGlobals = {
389
- ...getEnvBool("PROMPTFOO_DISABLE_TEMPLATE_ENV_VARS", getEnvBool("PROMPTFOO_SELF_HOSTED", false)) ? {} : process.env,
390
- ...state.config?.env
391
- };
392
- env.addGlobal("env", envGlobals);
393
- env.addFilter("load", function(str) {
394
- return JSON.parse(str);
395
- });
396
- if (filters) for (const [name, filter] of Object.entries(filters)) env.addFilter(name, filter);
397
- return env;
458
+ function loadProviderConfigsFromFile(providerPath, basePath) {
459
+ return readProviderConfigFile(providerPath, basePath).configs;
398
460
  }
399
461
  /**
400
- * Parse Nunjucks template to extract variables.
401
- * @param template - The Nunjucks template string.
402
- * @returns An array of variables used in the template.
462
+ * Pure, synchronous classifier that converts every supported provider reference shape
463
+ * into a discriminated descriptor. Does not read files or instantiate providers.
403
464
  */
404
- function extractVariablesFromTemplate(template) {
405
- const variableSet = /* @__PURE__ */ new Set();
406
- const regex = /\{\{[\s]*([^{}\s|]+)[\s]*(?:\|[^}]+)?\}\}|\{%[\s]*(?:if|for)[\s]+([^{}\s]+)[\s]*.*?%\}/g;
407
- template = template.replace(/\{#[\s\S]*?#\}/g, "");
408
- let match;
409
- while ((match = regex.exec(template)) !== null) {
410
- const variable = match[1] || match[2];
411
- if (variable) variableSet.add(variable);
465
+ function normalizeProviderRef(provider, options = {}) {
466
+ const { index } = options;
467
+ if (typeof provider === "string") {
468
+ if (!isValidProviderId(provider)) return {
469
+ kind: "unknown",
470
+ id: index === void 0 ? "unknown" : `unknown-${index}`
471
+ };
472
+ if (isProviderConfigFileReference(provider)) return {
473
+ kind: "file",
474
+ id: provider,
475
+ loadProviderPath: provider
476
+ };
477
+ return {
478
+ kind: "named",
479
+ id: provider,
480
+ loadProviderPath: provider
481
+ };
412
482
  }
413
- const forLoopRegex = /\{%[\s]*for[\s]+(\w+)[\s]+in[\s]+(\w+)[\s]*%\}/g;
414
- while ((match = forLoopRegex.exec(template)) !== null) {
415
- variableSet.delete(match[1]);
416
- variableSet.add(match[2]);
483
+ if (typeof provider === "function") {
484
+ const label = getProviderLabel(provider);
485
+ return {
486
+ kind: "function",
487
+ id: label ?? (index === void 0 ? "custom-function" : `custom-function-${index}`),
488
+ label
489
+ };
417
490
  }
418
- return Array.from(variableSet);
491
+ if (typeof provider === "object" && provider !== null && !Array.isArray(provider)) {
492
+ const providerId = provider.id;
493
+ const label = getProviderLabel(provider);
494
+ if (isValidProviderId(providerId)) return {
495
+ kind: "options",
496
+ id: providerId,
497
+ label,
498
+ loadOptions: provider,
499
+ loadProviderPath: providerId
500
+ };
501
+ const keys = Object.keys(provider);
502
+ if (keys.length === 1 && !PROVIDER_OPTION_KEYS.has(keys[0])) {
503
+ const originalId = keys[0];
504
+ const providerObject = provider[originalId];
505
+ if (typeof providerObject === "object" && providerObject !== null && !Array.isArray(providerObject) && isValidProviderId(originalId)) {
506
+ const id = isValidProviderId(providerObject.id) ? providerObject.id : originalId;
507
+ return {
508
+ kind: "map",
509
+ id,
510
+ label: getProviderLabel(providerObject),
511
+ loadOptions: {
512
+ ...providerObject,
513
+ id
514
+ },
515
+ loadProviderPath: originalId
516
+ };
517
+ }
518
+ }
519
+ if (isValidProviderId(label)) return {
520
+ kind: "unknown",
521
+ id: label,
522
+ label
523
+ };
524
+ }
525
+ return {
526
+ kind: "unknown",
527
+ id: index === void 0 ? "unknown" : `unknown-${index}`
528
+ };
529
+ }
530
+ //#endregion
531
+ //#region src/util/provider.ts
532
+ function providerToIdentifier(provider) {
533
+ if (!provider) return;
534
+ if (typeof provider === "string") return canonicalizeProviderId(provider);
535
+ const { label } = normalizeProviderRef(provider);
536
+ if (label) return label;
537
+ if (isApiProvider(provider)) return canonicalizeProviderId(provider.id());
538
+ if (isProviderOptions(provider)) {
539
+ if (provider.id) return canonicalizeProviderId(provider.id);
540
+ return;
541
+ }
542
+ if (typeof provider === "object" && "id" in provider && typeof provider.id === "string") return canonicalizeProviderId(provider.id);
419
543
  }
420
544
  /**
421
- * Extract variables from multiple Nunjucks templates.
422
- * @param templates - An array of Nunjucks template strings.
423
- * @returns An array of variables used in the templates.
545
+ * Gets a descriptive identifier string for a provider, showing both label and ID when both exist.
546
+ * Useful for error messages to help users debug provider reference issues.
424
547
  */
425
- function extractVariablesFromTemplates(templates) {
426
- const variableSet = /* @__PURE__ */ new Set();
427
- for (const template of templates) extractVariablesFromTemplate(template).forEach((variable) => variableSet.add(variable));
428
- return Array.from(variableSet);
548
+ function getProviderDescription(provider) {
549
+ const label = provider.label;
550
+ const id = provider.id();
551
+ if (label && label !== id) return `${label} (${id})`;
552
+ return id;
429
553
  }
430
- //#endregion
431
- //#region src/util/render.ts
432
554
  /**
433
- * Renders ONLY environment variable templates in an object, leaving all other templates untouched.
434
- * This allows env vars to be resolved at provider load time while preserving runtime var templates.
435
- *
436
- * Supports full Nunjucks syntax for env vars including filters and expressions:
437
- * - {{ env.VAR_NAME }}
438
- * - {{ env['VAR-NAME'] }}
439
- * - {{ env["VAR-NAME"] }}
440
- * - {{ env.VAR | default('fallback') }}
441
- * - {{ env.VAR | upper }}
442
- *
443
- * Preserves non-env templates for runtime rendering:
444
- * - {{ vars.x }} - preserved as literal
445
- * - {{ prompt }} - preserved as literal
446
- *
447
- * Implementation: Uses regex to find env templates, delegates to Nunjucks for rendering.
448
- * This ensures full Nunjucks feature support while preserving non-env templates.
449
- *
450
- * @param obj - The object to process
451
- * @param envOverrides - Optional env vars to merge with (or replace) the base env
452
- * @param replaceBase - If true, envOverrides replaces the base env entirely instead of merging
453
- * @returns The object with only env templates rendered
555
+ * Checks if a provider reference matches a given provider.
556
+ * Supports exact matching and wildcard patterns.
454
557
  */
455
- function renderEnvOnlyInObject(obj, envOverrides, replaceBase) {
456
- if (getEnvBool("PROMPTFOO_DISABLE_TEMPLATING")) return obj;
457
- if (typeof obj === "string") {
458
- const nunjucks = getNunjucksEngine();
459
- const baseEnvGlobals = nunjucks.getGlobal("env");
460
- const envGlobals = replaceBase ? envOverrides ?? {} : envOverrides ? {
461
- ...baseEnvGlobals,
462
- ...envOverrides
463
- } : baseEnvGlobals;
464
- return obj.replace(/\{\{(?:[^}]|\}(?!\}))*\}\}/g, (match) => {
465
- if (!match.match(/\benv\.|env\[/)) return match;
466
- const varMatch = match.match(/env\.(\w+)|env\[['"]([^'"]+)['"]\]/);
467
- const varName = varMatch?.[1] || varMatch?.[2];
468
- if (match.includes("|") || varName && varName in envGlobals && envGlobals[varName] !== void 0) try {
469
- return nunjucks.renderString(match, { env: envGlobals });
470
- } catch (error) {
471
- logger.debug(`Failed to render env template "${match}": ${error instanceof Error ? error.message : String(error)}`);
472
- return match;
473
- }
474
- return match;
475
- });
476
- }
477
- if (Array.isArray(obj)) return obj.map((item) => renderEnvOnlyInObject(item, envOverrides, replaceBase));
478
- if (typeof obj === "object" && obj !== null) {
479
- const result = {};
480
- for (const key in obj) result[key] = renderEnvOnlyInObject(obj[key], envOverrides, replaceBase);
481
- return result;
558
+ function doesProviderRefMatch(ref, provider) {
559
+ const label = provider.label;
560
+ const id = provider.id();
561
+ const canonicalRef = canonicalizeProviderId(ref);
562
+ const canonicalId = canonicalizeProviderId(id);
563
+ if (label && label === ref) return true;
564
+ if (id === ref || canonicalId === canonicalRef) return true;
565
+ if (ref.endsWith("*")) {
566
+ const prefix = ref.slice(0, -1);
567
+ if (label?.startsWith(prefix) || id.startsWith(prefix) || canonicalId.startsWith(prefix)) return true;
482
568
  }
483
- return obj;
484
- }
485
- function renderVarsInObject(obj, vars) {
486
- if (!vars || getEnvBool("PROMPTFOO_DISABLE_TEMPLATING")) return obj;
487
- if (typeof obj === "string") return getNunjucksEngine().renderString(obj, vars);
488
- if (Array.isArray(obj)) return obj.map((item) => renderVarsInObject(item, vars));
489
- if (typeof obj === "object" && obj !== null) {
490
- const result = {};
491
- for (const key in obj) result[key] = renderVarsInObject(obj[key], vars);
492
- return result;
493
- } else if (typeof obj === "function") return renderVarsInObject(obj({ vars }));
494
- return obj;
569
+ if (label?.startsWith(`${ref}:`) || id.startsWith(`${ref}:`) || canonicalId.startsWith(`${ref}:`)) return true;
570
+ return false;
495
571
  }
496
- //#endregion
497
- //#region src/util/file.ts
498
572
  /**
499
- * Simple Nunjucks engine specifically for file paths
500
- * This function is separate from the main getNunjucksEngine to avoid circular dependencies
573
+ * Checks if a provider is allowed based on a list of allowed references.
501
574
  */
502
- function getNunjucksEngineForFilePath() {
503
- const env = nunjucks.configure({ autoescape: false });
504
- env.addGlobal("env", {
505
- ...process.env,
506
- ...state.config?.env
507
- });
508
- return env;
575
+ function isProviderAllowed(provider, allowedProviders) {
576
+ if (!Array.isArray(allowedProviders)) return true;
577
+ if (allowedProviders.length === 0) return false;
578
+ return allowedProviders.some((ref) => doesProviderRefMatch(ref, provider));
509
579
  }
510
580
  /**
511
- * Loads content from an external file if the input is a file path, otherwise
512
- * returns the input as-is. Supports Nunjucks templating for file paths.
513
- *
514
- * @param filePath - The input to process. Can be a file path string starting with "file://",
515
- * an array of file paths, or any other type of data.
516
- * @param context - Optional context to control file loading behavior. 'assertion' context
517
- * preserves Python/JS file references instead of loading their content.
518
- * @returns The loaded content if the input was a file path, otherwise the original input.
519
- * For JSON and YAML files, the content is parsed into an object.
520
- * For other file types, the raw file content is returned as a string.
521
- *
522
- * @throws {Error} If the specified file does not exist.
581
+ * Detects if a provider uses OpenAI models.
582
+ * This includes direct OpenAI providers and Azure OpenAI.
523
583
  */
524
- function maybeLoadFromExternalFile(filePath, context) {
525
- if (Array.isArray(filePath)) return filePath.map((path) => {
526
- return maybeLoadFromExternalFile(path, context);
527
- });
528
- if (typeof filePath !== "string") return filePath;
529
- if (!filePath.startsWith("file://")) return filePath;
530
- const renderedFilePath = getNunjucksEngineForFilePath().renderString(filePath, {});
531
- const { filePath: cleanPath, functionName } = parseFileUrl(renderedFilePath);
532
- if (context === "assertion" && (cleanPath.endsWith(".py") || isJavascriptFile(cleanPath))) {
533
- logger.debug(`Preserving Python/JS file reference in assertion context: ${renderedFilePath}`);
534
- return renderedFilePath;
535
- }
536
- if (context === "vars") {
537
- logger.debug(`Preserving file reference in vars context: ${renderedFilePath}`);
538
- return renderedFilePath;
539
- }
540
- if (functionName && (cleanPath.endsWith(".py") || isJavascriptFile(cleanPath))) return renderedFilePath;
541
- const pathToUse = functionName && !(cleanPath.endsWith(".py") || isJavascriptFile(cleanPath)) ? renderedFilePath.slice(7) : cleanPath;
542
- const resolvedPath = path$1.resolve(state.basePath || "", pathToUse);
543
- if (hasMagic(pathToUse)) {
544
- const matchedFiles = globSync(resolvedPath, { windowsPathsNoEscape: true });
545
- if (matchedFiles.length === 0) throw new Error(`No files found matching pattern: ${resolvedPath}`);
546
- const allContents = [];
547
- for (const matchedFile of matchedFiles) {
548
- let contents;
549
- try {
550
- contents = fs$1.readFileSync(matchedFile, "utf8");
551
- } catch (error) {
552
- if (error.code === "ENOENT") {
553
- logger.debug(`File disappeared during glob expansion: ${matchedFile}`);
554
- continue;
555
- }
556
- throw error;
557
- }
558
- if (matchedFile.endsWith(".json")) {
559
- const parsed = JSON.parse(contents);
560
- if (Array.isArray(parsed)) allContents.push(...parsed);
561
- else allContents.push(parsed);
562
- } else if (matchedFile.endsWith(".yaml") || matchedFile.endsWith(".yml")) {
563
- const parsed = yaml.load(contents);
564
- if (parsed === null || parsed === void 0) continue;
565
- if (Array.isArray(parsed)) allContents.push(...parsed);
566
- else allContents.push(parsed);
567
- } else if (matchedFile.endsWith(".csv")) {
568
- const records = parse$1(contents, { columns: true });
569
- if (records.length > 0 && Object.keys(records[0]).length === 1) allContents.push(...records.map((record) => Object.values(record)[0]));
570
- else allContents.push(...records);
571
- } else allContents.push(contents);
572
- }
573
- return allContents;
574
- }
575
- const finalPath = resolvedPath;
576
- let contents;
577
- try {
578
- contents = fs$1.readFileSync(finalPath, "utf8");
579
- } catch (error) {
580
- if (error.code === "ENOENT") throw new Error(`File does not exist: ${finalPath}`);
581
- throw new Error(`Failed to read file ${finalPath}: ${error}`);
582
- }
583
- if (finalPath.endsWith(".json")) try {
584
- return JSON.parse(contents);
585
- } catch (error) {
586
- throw new Error(`Failed to parse JSON file ${finalPath}: ${error}`);
587
- }
588
- if (finalPath.endsWith(".yaml") || finalPath.endsWith(".yml")) try {
589
- return yaml.load(contents);
590
- } catch (error) {
591
- throw new Error(`Failed to parse YAML file ${finalPath}: ${error}`);
592
- }
593
- if (finalPath.endsWith(".csv")) {
594
- const records = parse$1(contents, { columns: true });
595
- if (records.length > 0 && Object.keys(records[0]).length === 1) return records.map((record) => Object.values(record)[0]);
596
- return records;
584
+ function isOpenAiProvider(providerId) {
585
+ const lowerProviderId = providerId.toLowerCase();
586
+ if (lowerProviderId.startsWith("openai:")) return true;
587
+ if (lowerProviderId.startsWith("azureopenai:")) return true;
588
+ if (lowerProviderId.startsWith("azure:")) {
589
+ if ([
590
+ "gpt",
591
+ "openai",
592
+ "davinci",
593
+ "curie",
594
+ "babbage",
595
+ "ada",
596
+ "text-embedding",
597
+ "whisper",
598
+ "dall-e",
599
+ "tts"
600
+ ].some((indicator) => lowerProviderId.includes(indicator))) return true;
597
601
  }
598
- return contents;
599
- }
600
- /**
601
- * Resolves a relative file path with respect to a base path, handling cloud configuration appropriately.
602
- * When using a cloud configuration, the current working directory is always used instead of the context's base path.
603
- *
604
- * @param filePath - The relative or absolute file path to resolve.
605
- * @param isCloudConfig - Whether this is a cloud configuration.
606
- * @returns The resolved absolute file path.
607
- */
608
- function getResolvedRelativePath(filePath, isCloudConfig) {
609
- if (path$1.isAbsolute(filePath) || !isCloudConfig) return filePath;
610
- return path$1.join(process.cwd(), filePath);
602
+ return false;
611
603
  }
612
604
  /**
613
- * Recursively loads external file references from a configuration object.
614
- *
615
- * @param config - The configuration object to process
616
- * @param context - Optional context to control file loading behavior
617
- * @returns The configuration with external file references resolved
605
+ * Detects if a provider uses Anthropic/Claude models.
606
+ * This includes direct Anthropic providers, Bedrock with Claude, and Vertex with Claude.
618
607
  */
619
- function maybeLoadConfigFromExternalFile(config, context) {
620
- if (Array.isArray(config)) return config.map((item) => maybeLoadConfigFromExternalFile(item, context));
621
- if (config && typeof config === "object" && config !== null) {
622
- const result = {};
623
- for (const key of Object.keys(config)) {
624
- const childContext = key === "value" && typeof config === "object" && config && "type" in config && typeof config.type === "string" && (config.type === "python" || config.type === "javascript") ? "assertion" : key === "vars" ? "vars" : context;
625
- result[key] = maybeLoadConfigFromExternalFile(config[key], childContext);
626
- }
627
- return result;
608
+ function isAnthropicProvider(providerId) {
609
+ const lowerProviderId = providerId.toLowerCase();
610
+ if (lowerProviderId.startsWith("anthropic:")) return true;
611
+ if (lowerProviderId.startsWith("bedrock:")) {
612
+ if (lowerProviderId.includes("claude") || lowerProviderId.includes("anthropic")) return true;
628
613
  }
629
- return maybeLoadFromExternalFile(config, context);
614
+ if (lowerProviderId.startsWith("vertex:")) {
615
+ if (lowerProviderId.includes("claude")) return true;
616
+ }
617
+ return false;
618
+ }
619
+ const KNOWN_ENV_VARS = {
620
+ openai: "OPENAI_API_KEY",
621
+ anthropic: "ANTHROPIC_API_KEY",
622
+ google: "GOOGLE_API_KEY",
623
+ mistral: "MISTRAL_API_KEY",
624
+ cohere: "COHERE_API_KEY",
625
+ replicate: "REPLICATE_API_TOKEN",
626
+ voyage: "VOYAGE_API_KEY",
627
+ ai21: "AI21_API_KEY",
628
+ xai: "XAI_API_KEY",
629
+ groq: "GROQ_API_KEY",
630
+ deepseek: "DEEPSEEK_API_KEY",
631
+ perplexity: "PERPLEXITY_API_KEY",
632
+ hyperbolic: "HYPERBOLIC_API_KEY",
633
+ cerebras: "CEREBRAS_API_KEY",
634
+ togetherai: "TOGETHER_API_KEY",
635
+ fal: "FAL_KEY",
636
+ huggingface: "HF_TOKEN",
637
+ "cloudflare-ai": "CLOUDFLARE_API_KEY"
638
+ };
639
+ function getDefaultEnvVar(providerId) {
640
+ const prefix = providerId.split(":")[0];
641
+ return KNOWN_ENV_VARS[prefix] || `${prefix.toUpperCase()}_API_KEY`;
630
642
  }
631
643
  /**
632
- * Parses a file path or glob pattern to extract function names and file extensions.
633
- * Function names can be specified in the filename like this:
634
- * prompt.py:myFunction or prompts.js:myFunction.
635
- * @param basePath - The base path for file resolution.
636
- * @param promptPath - The path or glob pattern.
637
- * @returns Parsed details including function name, file extension, and directory status.
644
+ * Pre-checks providers for missing API keys before evaluation starts.
645
+ * Assumes getApiKey() is side-effect free (no network calls or token refresh).
638
646
  */
639
- function parsePathOrGlob(basePath, promptPath) {
640
- if (promptPath.startsWith("file://")) promptPath = promptPath.slice(7);
641
- const filePath = path$1.resolve(basePath, promptPath);
642
- let filename = path$1.relative(basePath, filePath);
643
- let functionName;
644
- if (filename.includes(":")) {
645
- const lastColonIndex = filename.lastIndexOf(":");
646
- if (lastColonIndex > 1) {
647
- const pathWithoutFunction = filename.slice(0, lastColonIndex);
648
- if (isJavascriptFile(pathWithoutFunction) || pathWithoutFunction.endsWith(".py") || pathWithoutFunction.endsWith(".go") || pathWithoutFunction.endsWith(".rb")) {
649
- functionName = filename.slice(lastColonIndex + 1);
650
- filename = pathWithoutFunction;
651
- }
647
+ function checkProviderApiKeys(providers) {
648
+ const missingApiKeys = /* @__PURE__ */ new Map();
649
+ for (const provider of providers) {
650
+ const p = provider;
651
+ if (typeof p.getApiKey !== "function") continue;
652
+ if (provider.id().startsWith("azure:")) continue;
653
+ const requiresKey = typeof p.requiresApiKey === "function" ? p.requiresApiKey() : p.config?.apiKeyRequired !== false;
654
+ let apiKey;
655
+ try {
656
+ apiKey = p.getApiKey();
657
+ } catch {
658
+ apiKey = void 0;
659
+ }
660
+ if (requiresKey && !apiKey) {
661
+ const envVar = p.config?.apiKeyEnvar || getDefaultEnvVar(provider.id());
662
+ if (!missingApiKeys.has(envVar)) missingApiKeys.set(envVar, []);
663
+ missingApiKeys.get(envVar).push(provider.id());
652
664
  }
653
665
  }
654
- let stats;
655
- try {
656
- stats = fs$1.statSync(path$1.join(basePath, filename));
657
- } catch (err) {
658
- if (getEnvBool("PROMPTFOO_STRICT_FILES")) throw err;
659
- }
660
- const normalizedFilePath = filePath.replace(/\\/g, "/");
661
- const isPathPattern = stats?.isDirectory() || hasMagic(promptPath) || hasMagic(normalizedFilePath);
662
- const safeFilename = path$1.relative(basePath, safeResolve(basePath, filename));
663
- return {
664
- extension: isPathPattern ? void 0 : path$1.parse(safeFilename).ext,
665
- filePath: path$1.join(basePath, safeFilename),
666
- functionName,
667
- isPathPattern
668
- };
669
- }
670
- function readOutput(outputPath) {
671
- const ext = path$1.parse(outputPath).ext.slice(1);
672
- switch (ext) {
673
- case "json": return JSON.parse(fs$1.readFileSync(outputPath, "utf-8"));
674
- default: throw new Error(`Unsupported output file format: ${ext} currently only supports json`);
675
- }
666
+ return missingApiKeys;
676
667
  }
677
668
  /**
678
- * Load custom Nunjucks filters from external files.
679
- * Note: If a glob pattern matches multiple files, only the last file's export is used.
680
- * Each filter name should typically resolve to a single file.
669
+ * Detects if a provider uses Google models.
670
+ * This includes direct Google/Vertex providers with Gemini and other Google models.
671
+ * Note: Vertex with Claude models is NOT counted as Google (it's Anthropic).
681
672
  */
682
- async function readFilters(filters, basePath = "") {
683
- const ret = {};
684
- for (const [name, filterPath] of Object.entries(filters)) {
685
- const filePaths = globSync(path$1.join(basePath, filterPath), { windowsPathsNoEscape: true });
686
- for (const filePath of filePaths) ret[name] = await importModule(path$1.resolve(filePath));
673
+ function isGoogleProvider(providerId) {
674
+ const lowerProviderId = providerId.toLowerCase();
675
+ if (lowerProviderId.startsWith("google:")) return true;
676
+ if (lowerProviderId.startsWith("vertex:")) {
677
+ if (!lowerProviderId.includes("claude")) return true;
687
678
  }
688
- return ret;
679
+ return false;
689
680
  }
681
+ //#endregion
682
+ //#region src/util/comparison.ts
690
683
  /**
691
- * Loads configuration from an external file with variable rendering.
692
- * This is a convenience wrapper that combines renderVarsInObject and maybeLoadFromExternalFile.
684
+ * Explicit runtime variable names that don't follow the underscore convention.
685
+ * These are added during evaluation but aren't part of the original test definition.
693
686
  *
694
- * Use this for simple config fields that:
695
- * - Need variable rendering ({{ vars.x }}, {{ env.X }})
696
- * - May reference external files (file://path.json)
697
- * - Don't have nested file references that need loading
687
+ * - sessionId: Added by multi-turn strategy providers (GOAT, Crescendo)
698
688
  *
699
- * For fields with nested file references (like response_format.schema),
700
- * use maybeLoadResponseFormatFromExternalFile instead.
689
+ * Note: Variables starting with underscore (e.g., _conversation) are automatically
690
+ * treated as runtime variables and filtered out.
691
+ */
692
+ const EXPLICIT_RUNTIME_VAR_KEYS = ["sessionId"];
693
+ /**
694
+ * Checks if a variable key is a runtime-only variable that should be filtered
695
+ * when comparing test cases.
701
696
  *
702
- * @param config - The configuration to process
703
- * @param vars - Variables for template rendering
704
- * @returns The processed configuration with variables rendered and files loaded
697
+ * Runtime variables are identified by:
698
+ * 1. Starting with underscore (_) - convention for internal/runtime vars
699
+ * 2. Being in the explicit runtime var list (for legacy vars like sessionId)
705
700
  */
706
- function maybeLoadFromExternalFileWithVars(config, vars) {
707
- return maybeLoadFromExternalFile(renderVarsInObject(config, vars));
701
+ function isRuntimeVar(key) {
702
+ return key.startsWith("_") || EXPLICIT_RUNTIME_VAR_KEYS.includes(key);
708
703
  }
709
704
  /**
710
- * Loads response_format configuration from an external file with variable rendering.
705
+ * Filters out runtime-only variables that are added during evaluation
706
+ * but aren't part of the original test definition.
711
707
  *
712
- * This function handles the special case where response_format may contain:
713
- * 1. A top-level file reference (file://format.json)
714
- * 2. A nested schema reference for json_schema type (schema: file://schema.json)
708
+ * This is used when comparing test cases to determine if a result
709
+ * corresponds to a particular test, regardless of runtime state.
715
710
  *
716
- * Both levels need variable rendering and file loading.
711
+ * Runtime variables are identified by:
712
+ * - Starting with underscore (e.g., _conversation, _metadata)
713
+ * - Being in the explicit list (e.g., sessionId for backward compatibility)
714
+ */
715
+ function filterRuntimeVars(vars) {
716
+ if (!vars || typeof vars !== "object" || Array.isArray(vars)) return vars;
717
+ const filtered = {};
718
+ for (const [key, value] of Object.entries(vars)) if (!isRuntimeVar(key)) filtered[key] = value;
719
+ return filtered;
720
+ }
721
+ /**
722
+ * Extracts only runtime variables from a vars object.
723
+ * This is the inverse of filterRuntimeVars.
717
724
  *
718
- * @param responseFormat - The response_format configuration
719
- * @param vars - Variables for template rendering
720
- * @returns The processed response_format with all files loaded
725
+ * Used to restore runtime state when re-running filtered tests.
721
726
  */
722
- function maybeLoadResponseFormatFromExternalFile(responseFormat, vars) {
723
- if (responseFormat === void 0 || responseFormat === null) return responseFormat;
724
- const loaded = maybeLoadFromExternalFile(renderVarsInObject(responseFormat, vars));
725
- if (!loaded || typeof loaded !== "object") return loaded;
726
- if (loaded.type === "json_schema") {
727
- const nestedSchema = loaded.schema || loaded.json_schema?.schema;
728
- if (nestedSchema) {
729
- const loadedSchema = maybeLoadFromExternalFile(renderVarsInObject(nestedSchema, vars));
730
- if (loaded.schema !== void 0) return {
731
- ...loaded,
732
- schema: loadedSchema
733
- };
734
- else if (loaded.json_schema?.schema !== void 0) return {
735
- ...loaded,
736
- json_schema: {
737
- ...loaded.json_schema,
738
- schema: loadedSchema
739
- }
740
- };
741
- }
742
- }
743
- return loaded;
727
+ function extractRuntimeVars(vars) {
728
+ if (!vars || typeof vars !== "object" || Array.isArray(vars)) return;
729
+ const extracted = {};
730
+ for (const [key, value] of Object.entries(vars)) if (isRuntimeVar(key)) extracted[key] = value;
731
+ return Object.keys(extracted).length > 0 ? extracted : void 0;
732
+ }
733
+ function varsMatch(vars1, vars2) {
734
+ return deepEqual(vars1, vars2);
744
735
  }
745
736
  /**
746
- * Renders variables in a tools object and loads from external file if applicable.
747
- * This function combines renderVarsInObject and maybeLoadFromExternalFile into a single step
748
- * specifically for handling tools configurations.
737
+ * Generate a unique key for a test case for deduplication purposes.
738
+ * Excludes runtime variables and includes strategyId to distinguish tests
739
+ * with the same prompt but different strategies.
749
740
  *
750
- * Supports loading from JSON, YAML, Python, and JavaScript files.
741
+ * @param testCase - The test case to generate a key for
742
+ * @returns A JSON string that uniquely identifies the test case
743
+ */
744
+ function getTestCaseDeduplicationKey(testCase) {
745
+ const filteredVars = filterRuntimeVars(testCase.vars);
746
+ const strategyId = testCase.metadata?.strategyId || "none";
747
+ return JSON.stringify({
748
+ vars: filteredVars,
749
+ strategyId
750
+ });
751
+ }
752
+ /**
753
+ * Deduplicates an array of test cases based on their vars and strategyId.
754
+ * Tests with the same vars but different strategies are considered different.
755
+ * Runtime variables (like _conversation, sessionId) are filtered out before comparison.
751
756
  *
752
- * @param tools - The tools configuration object or array to process.
753
- * @param vars - Variables to use for rendering.
754
- * @returns The processed tools configuration with variables rendered and content loaded from files if needed.
755
- * @throws {Error} If the loaded tools are in an invalid format
757
+ * @param tests - Array of test cases to deduplicate
758
+ * @returns Deduplicated array of test cases
756
759
  */
757
- async function maybeLoadToolsFromExternalFile(tools, vars) {
758
- const rendered = renderVarsInObject(tools, vars);
759
- if (typeof rendered === "string" && rendered.startsWith("file://")) {
760
- const { filePath, functionName } = parseFileUrl(rendered);
761
- if (functionName && (filePath.endsWith(".py") || isJavascriptFile(filePath))) {
762
- const fileType = filePath.endsWith(".py") ? "Python" : "JavaScript";
763
- logger.debug(`[maybeLoadToolsFromExternalFile] Loading tools from ${fileType} file: ${filePath}:${functionName}`);
764
- try {
765
- let toolDefinitions;
766
- if (filePath.endsWith(".py")) {
767
- const absPath = safeResolve(state.basePath || process.cwd(), filePath);
768
- logger.debug(`[maybeLoadToolsFromExternalFile] Resolved Python path: ${absPath}`);
769
- toolDefinitions = await runPython(absPath, functionName, []);
770
- } else {
771
- const absPath = safeResolve(state.basePath || process.cwd(), filePath);
772
- logger.debug(`[maybeLoadToolsFromExternalFile] Resolved JavaScript path: ${absPath}`);
773
- const module = await importModule(absPath);
774
- const fn = module[functionName] || module.default?.[functionName];
775
- if (typeof fn !== "function") {
776
- const availableExports = Object.keys(module).filter((k) => k !== "default");
777
- const basePath = state.basePath || process.cwd();
778
- throw new Error(`Function "${functionName}" not found in ${filePath}. Available exports: ${availableExports.length > 0 ? availableExports.join(", ") : "(none)"}\nResolved from: ${basePath}`);
779
- }
780
- toolDefinitions = await Promise.resolve(fn());
781
- }
782
- if (!toolDefinitions || typeof toolDefinitions === "string" || typeof toolDefinitions === "number" || typeof toolDefinitions === "boolean") throw new Error(`Function "${functionName}" must return an array or object of tool definitions, but returned: ${toolDefinitions === null ? "null" : typeof toolDefinitions}`);
783
- logger.debug(`[maybeLoadToolsFromExternalFile] Successfully loaded ${Array.isArray(toolDefinitions) ? toolDefinitions.length : "object"} tools`);
784
- return toolDefinitions;
785
- } catch (err) {
786
- const errorMessage = err instanceof Error ? err.message : String(err);
787
- const basePath = state.basePath || process.cwd();
788
- throw new Error(`Failed to load tools from ${rendered}:\n${errorMessage}\n\nMake sure the function "${functionName}" exists and returns a valid tool definition array.\nResolved from: ${basePath}`);
789
- }
790
- }
791
- if (filePath.endsWith(".py") || isJavascriptFile(filePath)) {
792
- const ext = filePath.endsWith(".py") ? "Python" : "JavaScript";
793
- const basePath = state.basePath || process.cwd();
794
- throw new Error(`Cannot load tools from ${rendered}\n${ext} files require a function name. Use this format:\n tools: file://${filePath}:get_tools\n\nYour ${ext} file should export a function that returns tool definitions:\n` + (filePath.endsWith(".py") ? ` def get_tools():\n return [{"type": "function", "function": {...}}]` : ` module.exports.get_tools = () => [{ type: "function", function: {...} }];`) + `\n\nResolved from: ${basePath}`);
795
- }
796
- }
797
- if (Array.isArray(rendered)) {
798
- const results = await Promise.all(rendered.map((item) => maybeLoadToolsFromExternalFile(item, vars)));
799
- if (results.every((r) => Array.isArray(r))) return results.flat();
800
- return results;
801
- }
802
- if (typeof rendered !== "string") return rendered;
803
- const loaded = maybeLoadFromExternalFile(rendered);
804
- if (loaded !== void 0 && loaded !== null && typeof loaded === "string") {
805
- if (loaded.startsWith("file://")) throw new Error(`Failed to load tools from ${loaded}\nEnsure the file exists and contains valid JSON or YAML tool definitions.`);
806
- if (loaded.includes("def ") || loaded.includes("import ")) throw new Error("Invalid tools configuration: file appears to contain Python code.\nPython files require a function name. Use this format:\n tools: file://tools.py:get_tools");
807
- throw new Error("Invalid tools configuration: expected an array or object, but got a string.\nIf using file://, ensure the file contains valid JSON or YAML tool definitions.");
760
+ function deduplicateTestCases(tests) {
761
+ const seen = /* @__PURE__ */ new Set();
762
+ return tests.filter((test) => {
763
+ const key = getTestCaseDeduplicationKey(test);
764
+ if (seen.has(key)) return false;
765
+ seen.add(key);
766
+ return true;
767
+ });
768
+ }
769
+ function resultIsForTestCase(result, testCase) {
770
+ const testProviderId = testCase.provider ? providerToIdentifier(testCase.provider) : void 0;
771
+ const resultProviderId = providerToIdentifier(result.provider);
772
+ const providersMatch = !testProviderId || !resultProviderId || testProviderId === resultProviderId;
773
+ const resultVars = filterRuntimeVars(result.vars);
774
+ const testVars = filterRuntimeVars(testCase.vars);
775
+ const doVarsMatch = varsMatch(testVars, resultVars);
776
+ const isMatch = doVarsMatch && providersMatch;
777
+ if (!isMatch) {
778
+ const varKeys = testVars ? Object.keys(testVars).join(", ") : "none";
779
+ logger.debug(`[resultIsForTestCase] No match: vars=${doVarsMatch}, providers=${providersMatch}`, {
780
+ testProvider: testProviderId || "none",
781
+ resultProvider: resultProviderId || "none",
782
+ testVarKeys: varKeys
783
+ });
808
784
  }
809
- return loaded;
785
+ return isMatch;
786
+ }
787
+ //#endregion
788
+ //#region src/util/env.ts
789
+ /**
790
+ * Load environment variables from .env file(s).
791
+ * @param envPath - Single path, array of paths, or undefined for default .env loading.
792
+ * When paths are explicitly specified, all files must exist or an error is thrown.
793
+ * When multiple files are provided, later files override values from earlier files.
794
+ */
795
+ function setupEnv(envPath) {
796
+ if (envPath) {
797
+ const paths = (Array.isArray(envPath) ? envPath : [envPath]).flatMap((p) => p.includes(",") ? p.split(",").map((s) => s.trim()) : p.trim()).filter((p) => p.length > 0);
798
+ if (paths.length === 0) {
799
+ dotenv.config({ quiet: true });
800
+ return;
801
+ }
802
+ for (const p of paths) if (!fs$2.existsSync(p)) throw new Error(`Environment file not found: ${p}`);
803
+ if (paths.length === 1) logger.info(`Loading environment variables from ${paths[0]}`);
804
+ else logger.info(`Loading environment variables from: ${paths.join(", ")}`);
805
+ const pathArg = paths.length === 1 ? paths[0] : paths;
806
+ dotenv.config({
807
+ path: pathArg,
808
+ override: true,
809
+ quiet: true
810
+ });
811
+ } else dotenv.config({ quiet: true });
810
812
  }
811
813
  //#endregion
812
814
  //#region src/googleSheets.ts
@@ -1296,6 +1298,6 @@ function printBorder() {
1296
1298
  logger.info(border);
1297
1299
  }
1298
1300
  //#endregion
1299
- export { getProviderDescription as A, deduplicateTestCases as C, resultIsForTestCase as D, getTestCaseDeduplicationKey as E, isGoogleProvider as M, isOpenAiProvider as N, checkProviderApiKeys as O, isProviderAllowed as P, setupEnv as S, filterRuntimeVars as T, extractVariablesFromTemplate as _, getNunjucksEngineForFilePath as a, loadFunction as b, maybeLoadFromExternalFile as c, maybeLoadToolsFromExternalFile as d, parsePathOrGlob as f, renderVarsInObject as g, renderEnvOnlyInObject as h, fetchCsvFromGoogleSheet as i, isAnthropicProvider as j, doesProviderRefMatch as k, maybeLoadFromExternalFileWithVars as l, readOutput as m, writeMultipleOutputs as n, getResolvedRelativePath as o, readFilters as p, writeOutput as r, maybeLoadConfigFromExternalFile as s, printBorder as t, maybeLoadResponseFormatFromExternalFile as u, extractVariablesFromTemplates as v, extractRuntimeVars as w, parseFileUrl as x, getNunjucksEngine as y };
1301
+ export { readFilters as A, getResolvedRelativePath as C, maybeLoadResponseFormatFromExternalFile as D, maybeLoadFromExternalFileWithVars as E, loadFunction as M, parseFileUrl as N, maybeLoadToolsFromExternalFile as O, getNunjucksEngineForFilePath as S, maybeLoadFromExternalFile as T, isProviderAllowed as _, setupEnv as a, normalizeProviderRef as b, filterRuntimeVars as c, checkProviderApiKeys as d, doesProviderRefMatch as f, isOpenAiProvider as g, isGoogleProvider as h, fetchCsvFromGoogleSheet as i, readOutput as j, parsePathOrGlob as k, getTestCaseDeduplicationKey as l, isAnthropicProvider as m, writeMultipleOutputs as n, deduplicateTestCases as o, getProviderDescription as p, writeOutput as r, extractRuntimeVars as s, printBorder as t, resultIsForTestCase as u, isProviderConfigFileReference as v, maybeLoadConfigFromExternalFile as w, readProviderConfigFile as x, loadProviderConfigsFromFile as y };
1300
1302
 
1301
- //# sourceMappingURL=util-CMMkIxfU.js.map
1303
+ //# sourceMappingURL=util-Dub0f_ej.js.map