promptfoo 0.125.0 → 0.125.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/src/accounts-BOxNYxVN.js +229 -0
- package/dist/src/accounts-BezXLdAW.cjs +276 -0
- package/dist/src/accounts-CPISMNlh.js +227 -0
- package/dist/src/accounts-vJBPs89d.js +222 -0
- package/dist/src/agentWorkspace-Bom7SpF2.js +592 -0
- package/dist/src/agentWorkspace-CEomAcws.cjs +619 -0
- package/dist/src/agentWorkspace-DPtMLrlI.js +593 -0
- package/dist/src/agentWorkspace-DkAeEYLz.js +592 -0
- package/dist/src/agentic-utils-121v7mJo.js +197 -0
- package/dist/src/agentic-utils-CBWD_rcd.cjs +237 -0
- package/dist/src/agentic-utils-D8wyQwPG.js +198 -0
- package/dist/src/agentic-utils-EP1QkQCs.js +197 -0
- package/dist/src/agents-Br3ah8iA.js +778 -0
- package/dist/src/agents-C5wj_UTv.js +777 -0
- package/dist/src/agents-C9Efp4mC.js +266 -0
- package/dist/src/agents-CQYwaVCO.js +267 -0
- package/dist/src/agents-CjCd4Vo8.js +777 -0
- package/dist/src/agents-DRWiCHYz.js +266 -0
- package/dist/src/agents-F2rhx0iL.cjs +266 -0
- package/dist/src/agents-RTYyy69h.cjs +777 -0
- package/dist/src/agents-api-CY72O86e.js +711 -0
- package/dist/src/agents-api-CsSsC21b.js +710 -0
- package/dist/src/agents-api-DN-ibDc8.js +710 -0
- package/dist/src/agents-api-cNDsCCv1.cjs +710 -0
- package/dist/src/ai.studio-Bj6Dyi6o.js +2 -0
- package/dist/src/ai.studio-C-e0LzyW.js +369 -0
- package/dist/src/ai.studio-CR8M6Aqf.cjs +391 -0
- package/dist/src/ai.studio-YKk7F0tv.js +374 -0
- package/dist/src/aimlapi-BGunsuTu.js +30 -0
- package/dist/src/aimlapi-BkzcfBsL.js +29 -0
- package/dist/src/aimlapi-DXFcEdP8.js +28 -0
- package/dist/src/aimlapi-r-8iCcAw.cjs +29 -0
- package/dist/src/anthropicMessages-7-YNRgQR.js +114 -0
- package/dist/src/anthropicMessages-C8m9Whrd.cjs +114 -0
- package/dist/src/anthropicMessages-DS1vXD0f.js +115 -0
- package/dist/src/anthropicMessages-DmvGkz-0.js +114 -0
- package/dist/src/app/assets/index-CrdXWTXm.js +392 -0
- package/dist/src/app/browser-inventory.json +4 -4
- package/dist/src/app/index.html +1 -1
- package/dist/src/audio-BLgFgyw-.cjs +104 -0
- package/dist/src/audio-C2sibT7Q.js +104 -0
- package/dist/src/audio-DXEXb03H.js +104 -0
- package/dist/src/audio-TkvojpwO.js +105 -0
- package/dist/src/authoritativeMarkupInjection-BAT9B-Wj.js +79 -0
- package/dist/src/authoritativeMarkupInjection-B_yHETKT.js +78 -0
- package/dist/src/authoritativeMarkupInjection-BfjecQ3Q.cjs +78 -0
- package/dist/src/authoritativeMarkupInjection-D-hDKrhD.js +78 -0
- package/dist/src/aws-B_9unI_-.js +1149 -0
- package/dist/src/aws-D0FY3qkc.js +2433 -0
- package/dist/src/aws-Dh1-a90n.js +2433 -0
- package/dist/src/aws-qskKGczY.cjs +2454 -0
- package/dist/src/base-CaWlBkVz.js +462 -0
- package/dist/src/base-CcViNwVs.js +255 -0
- package/dist/src/base-CsVbPJkU.cjs +467 -0
- package/dist/src/base-DNK9py25.js +255 -0
- package/dist/src/base-DlH5tjEZ.js +463 -0
- package/dist/src/base-DyLOZ_iX.js +256 -0
- package/dist/src/base-RRYXfG7l.cjs +305 -0
- package/dist/src/base-oXVgvtVn.js +462 -0
- package/dist/src/bedrock-BP17ZXbR.cjs +2 -0
- package/dist/src/bedrock-CsjM1dOt.js +1300 -0
- package/dist/src/bedrock-CzPwj8GO.js +1 -0
- package/dist/src/bedrock-eGXZw8oh.js +1 -0
- package/dist/src/bedrock-tSWjmXdj.js +2 -0
- package/dist/src/bestOfN-BQ93nUKV.js +160 -0
- package/dist/src/bestOfN-ByGGwlcb.cjs +161 -0
- package/dist/src/bestOfN-CbP7csHr.js +159 -0
- package/dist/src/bestOfN-xn6i2Xs2.js +159 -0
- package/dist/src/cache-CHq9hPz9.js +2 -0
- package/dist/src/cache-D-9eZN3I.js +754 -0
- package/dist/src/cache-DSm6t1MZ.js +741 -0
- package/dist/src/cache-DeF5zIEN.js +782 -0
- package/dist/src/cache-iG87oYan.cjs +856 -0
- package/dist/src/cerebras-CTtM4yMH.js +98 -0
- package/dist/src/cerebras-CogcJ3ce.cjs +97 -0
- package/dist/src/cerebras-DmkRypTh.js +97 -0
- package/dist/src/cerebras-GUp0B8JY.js +97 -0
- package/dist/src/chat-B4ihd3fw.js +226 -0
- package/dist/src/chat-B9cAQ_rS.js +227 -0
- package/dist/src/chat-BU7EB4R-.cjs +76 -0
- package/dist/src/chat-C8yxJ2-s.cjs +226 -0
- package/dist/src/chat-ClTFM3qq.js +934 -0
- package/dist/src/chat-Cnq0Is68.js +123 -0
- package/dist/src/chat-CwrurR57.cjs +987 -0
- package/dist/src/chat-D0lsojPv.js +124 -0
- package/dist/src/chat-D7_8yFIx.js +76 -0
- package/dist/src/chat-DCoETlLG.js +226 -0
- package/dist/src/chat-DHE7xaTR.js +76 -0
- package/dist/src/chat-DmhT6rz2.cjs +123 -0
- package/dist/src/chat-DvfMe8KI.js +123 -0
- package/dist/src/chat-DwP5kVnl.js +935 -0
- package/dist/src/chat-MB7U-QE2.js +77 -0
- package/dist/src/chat-zCWuBKAj.js +934 -0
- package/dist/src/claude-agent-sdk-23bIVI75.js +999 -0
- package/dist/src/claude-agent-sdk-BACpnIJi.cjs +1005 -0
- package/dist/src/claude-agent-sdk-BlYlmcEr.js +999 -0
- package/dist/src/claude-agent-sdk-Cr-jqJZl.js +1000 -0
- package/dist/src/client-BktbiPx9.cjs +357 -0
- package/dist/src/client-CjztEBmW.js +351 -0
- package/dist/src/client-mRs2UvH9.js +351 -0
- package/dist/src/client-uCz0ydjC.js +352 -0
- package/dist/src/cloud-BtYF555L.js +2 -0
- package/dist/src/cloud-CVSUEmAy.js +287 -0
- package/dist/src/cloud-D7Ifb-Fl.js +599 -0
- package/dist/src/cloud-DB5oK5NX.cjs +666 -0
- package/dist/src/cloud-ecu989Em.js +657 -0
- package/dist/src/cloud-ramjGURF.js +599 -0
- package/dist/src/cloudflare-ai-BfDkIjO8.js +133 -0
- package/dist/src/cloudflare-ai-D9HaXz1M.js +134 -0
- package/dist/src/cloudflare-ai-HrD5WUK8.js +132 -0
- package/dist/src/cloudflare-ai-Qdj8aKP2.cjs +133 -0
- package/dist/src/cloudflare-gateway-C81uKETQ.js +276 -0
- package/dist/src/cloudflare-gateway-CX5Z9X0k.js +276 -0
- package/dist/src/cloudflare-gateway-DW-og8gb.js +277 -0
- package/dist/src/cloudflare-gateway-iRyXo9n2.cjs +276 -0
- package/dist/src/codex-app-server-BFIrSgdy.js +2155 -0
- package/dist/src/codex-app-server-By1eDVD4.js +2 -0
- package/dist/src/codex-app-server-DKsF4qmY.js +2156 -0
- package/dist/src/codex-app-server-n7n4uZzC.cjs +2162 -0
- package/dist/src/codex-app-server-xAoELVxu.js +2155 -0
- package/dist/src/codex-sdk-C2ZLxa6r.js +1552 -0
- package/dist/src/codex-sdk-CzG02tQt.cjs +1588 -0
- package/dist/src/codex-sdk-DNxAOhiV.js +2 -0
- package/dist/src/codex-sdk-DT3aQezK.js +1557 -0
- package/dist/src/codex-sdk-pw9DpcJP.js +1557 -0
- package/dist/src/codex-security-B0bLmXJF.js +406 -0
- package/dist/src/codex-security-BhYs-3iY.js +406 -0
- package/dist/src/codex-security-DQcOfxYW.js +407 -0
- package/dist/src/codex-security-DsCWr6GZ.cjs +411 -0
- package/dist/src/cometapi-B16asPLX.cjs +55 -0
- package/dist/src/cometapi-MgTbZA_H.js +53 -0
- package/dist/src/cometapi-i33vKzPV.js +55 -0
- package/dist/src/cometapi-wK2UWK0X.js +56 -0
- package/dist/src/compatible-COj8ZCy9.js +24 -0
- package/dist/src/compatible-CRSsIUGb.cjs +24 -0
- package/dist/src/compatible-Dy1vCcNF.js +25 -0
- package/dist/src/compatible-aUItQrpk.js +24 -0
- package/dist/src/completion-Bn7COFMk.js +119 -0
- package/dist/src/completion-Bub2N48b.js +118 -0
- package/dist/src/completion-Cf2G9OlM.cjs +123 -0
- package/dist/src/conversationScoring-BiTYJ9MD.js +374 -0
- package/dist/src/conversationScoring-CKL47uIu.js +373 -0
- package/dist/src/conversationScoring-DCvQKp6k.cjs +398 -0
- package/dist/src/conversationScoring-DLNJtDZI.js +373 -0
- package/dist/src/crescendo-5iLk9WiJ.cjs +734 -0
- package/dist/src/crescendo-B5ylG7kW.js +733 -0
- package/dist/src/crescendo-BD7k6TIx.js +730 -0
- package/dist/src/crescendo-DqO2Ch0P.js +732 -0
- package/dist/src/custom-8rv_aG2K.js +617 -0
- package/dist/src/custom-BOtrIHFN.js +619 -0
- package/dist/src/custom-BvN8seCs.cjs +620 -0
- package/dist/src/custom-Cld9v_Y4.js +618 -0
- package/dist/src/dataUrl-BdHUey2l.cjs +3187 -0
- package/dist/src/dataUrl-DBMifX6C.js +3133 -0
- package/dist/src/dataUrl-DUSr-ZvI.js +2868 -0
- package/dist/src/decisions-CLazADTw.js +516 -0
- package/dist/src/decisions-D5X93awq.js +515 -0
- package/dist/src/decisions-DmaeArEn.js +515 -0
- package/dist/src/decisions-DyQJyHJz.cjs +514 -0
- package/dist/src/docker-C9NYQFeu.js +94 -0
- package/dist/src/docker-CGq3mMol.cjs +94 -0
- package/dist/src/docker-DOm7nmpl.js +95 -0
- package/dist/src/docker-skFN-Kfo.js +93 -0
- package/dist/src/embedding-0UbzkTk9.js +82 -0
- package/dist/src/embedding-DTrSDt7k.cjs +86 -0
- package/dist/src/embedding-j2ORNl5H.js +81 -0
- package/dist/src/envoy-BvS8XTQO.js +60 -0
- package/dist/src/envoy-Cn6Hzw0e.js +60 -0
- package/dist/src/envoy-DC3KWcUY.cjs +60 -0
- package/dist/src/envoy-DetHjo5B.js +61 -0
- package/dist/src/eval-Cer9dPe9.js +1920 -0
- package/dist/src/eval-CytYmI2Z.js +2 -0
- package/dist/src/evalResult-DzOq5wt9.js +1300 -0
- package/dist/src/evaluator-BxCmvGtv.js +10578 -0
- package/dist/src/evaluator-Ct7YDELm.js +2 -0
- package/dist/src/evaluatorHelpers-B_AwIrsl.js +600 -0
- package/dist/src/evaluatorHelpers-D1Tpc7gd.js +601 -0
- package/dist/src/evaluatorHelpers-DRR3rLq0.cjs +622 -0
- package/dist/src/fetch-B5KxZuKu.js +1559 -0
- package/dist/src/fetch-BG_Jl7ty.js +1556 -0
- package/dist/src/fetch-BKlgUg08.cjs +1853 -0
- package/dist/src/fetch-C9Fsja0R.js +2 -0
- package/dist/src/fetch-CM7P8KWA.cjs +14 -0
- package/dist/src/fetch-D0FkIB3G.js +9 -0
- package/dist/src/fetch-RXHsZF-J.js +1280 -0
- package/dist/src/fetch-rSECy8jR.js +10 -0
- package/dist/src/functionCallbackUtils-BB9tmf6a.cjs +262 -0
- package/dist/src/functionCallbackUtils-BXk2iY01.js +246 -0
- package/dist/src/functionCallbackUtils-B_cYp7P5.js +245 -0
- package/dist/src/functionCallbackUtils-BfXnPo0o.js +245 -0
- package/dist/src/gemini-image-BXLMADDz.js +471 -0
- package/dist/src/gemini-image-BYUZyEUx.js +472 -0
- package/dist/src/gemini-image-DSt1QubZ.cjs +471 -0
- package/dist/src/gemini-image-DdNDMiZ_.js +471 -0
- package/dist/src/goat-9b-uU_k6.js +514 -0
- package/dist/src/goat-BCJuiDd0.js +515 -0
- package/dist/src/goat-CmAHbemm.js +512 -0
- package/dist/src/goat-DdOTdyoS.cjs +515 -0
- package/dist/src/goblin-Bp5C5lyb.js +22 -0
- package/dist/src/goblin-Dmr7GItI.js +23 -0
- package/dist/src/goblin-DpM8wxlf.cjs +22 -0
- package/dist/src/goblin-cJyH6Pq-.js +22 -0
- package/dist/src/google-B6eaPAbE.js +142 -0
- package/dist/src/google-D-FStdN6.cjs +142 -0
- package/dist/src/google-DAC7BsCW.js +142 -0
- package/dist/src/google-Id18H0Va.js +143 -0
- package/dist/src/graders-BjNQWkaB.js +2 -0
- package/dist/src/graders-CqdIp_vl.js +15470 -0
- package/dist/src/hydra-6Ouh74DE.js +610 -0
- package/dist/src/hydra-BHjhZnLB.cjs +612 -0
- package/dist/src/hydra-BL6k2REV.js +2 -0
- package/dist/src/hydra-BWUc0o67.js +613 -0
- package/dist/src/hydra-CUkEOLKw.js +612 -0
- package/dist/src/image-B6hG_xhb.js +481 -0
- package/dist/src/image-BFaq7Krd.cjs +209 -0
- package/dist/src/image-Bql5C0N9.cjs +504 -0
- package/dist/src/image-BtZfI2pT.js +163 -0
- package/dist/src/image-CIM4oN7Z.cjs +163 -0
- package/dist/src/image-CbAl7Jpu.js +209 -0
- package/dist/src/image-CiYm_yFw.js +209 -0
- package/dist/src/image-DCMNvBiV.js +163 -0
- package/dist/src/image-DL7pIuUZ.js +210 -0
- package/dist/src/image-ey0kxF8o.js +164 -0
- package/dist/src/image-smgIk3rE.js +482 -0
- package/dist/src/index.cjs +27 -27
- package/dist/src/index.d.cts +8 -8
- package/dist/src/index.js +27 -27
- package/dist/src/indirectWebPwn-B_-UpWY5.js +285 -0
- package/dist/src/indirectWebPwn-Cz3SLiEq.js +434 -0
- package/dist/src/indirectWebPwn-D2s8zGiM.cjs +463 -0
- package/dist/src/indirectWebPwn-DXbj2wGu.cjs +285 -0
- package/dist/src/indirectWebPwn-D_4H44E6.js +285 -0
- package/dist/src/indirectWebPwn-L044SrpV.js +434 -0
- package/dist/src/indirectWebPwn-cnmvdavH.js +435 -0
- package/dist/src/indirectWebPwn-zUBzsqTt.js +286 -0
- package/dist/src/interactions-Bu3oVQ-j.js +850 -0
- package/dist/src/interactions-CND010Lh.cjs +850 -0
- package/dist/src/interactions-DAx7tqUz.js +851 -0
- package/dist/src/interactions-DPkIumeh.js +850 -0
- package/dist/src/iterative-BO4JRnpG.js +545 -0
- package/dist/src/iterative-CAK-k9rz.js +548 -0
- package/dist/src/iterative-CDgHc0xO.cjs +549 -0
- package/dist/src/iterative-CXJlHLl9.js +547 -0
- package/dist/src/iterativeImage-BEdGKSmh.cjs +419 -0
- package/dist/src/iterativeImage-BfL0QZw5.js +417 -0
- package/dist/src/iterativeImage-C9KhnibC.js +417 -0
- package/dist/src/iterativeImage-btjkOfWG.js +418 -0
- package/dist/src/iterativeMeta-B5Bdw6QA.js +437 -0
- package/dist/src/iterativeMeta-C3mI4gpT.js +440 -0
- package/dist/src/iterativeMeta-Co2BKyqS.cjs +439 -0
- package/dist/src/iterativeMeta-DD8ihRWD.js +439 -0
- package/dist/src/iterativeTree-AMi4GV2O.js +878 -0
- package/dist/src/iterativeTree-C8FJOEje.cjs +879 -0
- package/dist/src/iterativeTree-CvrY1f2Z.js +877 -0
- package/dist/src/iterativeTree-bPtESmaD.js +876 -0
- package/dist/src/knowledgeBase-Cf5871e3.js +163 -0
- package/dist/src/knowledgeBase-D2PQhqLH.js +164 -0
- package/dist/src/knowledgeBase-DpoMw1IH.cjs +163 -0
- package/dist/src/knowledgeBase-npGFl763.js +163 -0
- package/dist/src/litellm-BBB5DQdt.cjs +146 -0
- package/dist/src/litellm-Bo43ow7r.js +145 -0
- package/dist/src/litellm-CaU8CMLS.js +146 -0
- package/dist/src/litellm-wY7Unh8o.js +147 -0
- package/dist/src/live-5g2w-M-E.js +891 -0
- package/dist/src/live-BfaXsDyD.cjs +891 -0
- package/dist/src/live-C1xewnGD.js +2 -0
- package/dist/src/live-DaF7nYy5.js +892 -0
- package/dist/src/live-lp3urLUw.js +891 -0
- package/dist/src/luma-ray-B7zvKGVG.js +309 -0
- package/dist/src/luma-ray-DCf5fnrz.cjs +309 -0
- package/dist/src/luma-ray-DepBcn6z.js +309 -0
- package/dist/src/luma-ray-XQC4M1pt.js +310 -0
- package/dist/src/main.js +26 -26
- package/dist/src/mantleChat-7xm95vSV.js +154 -0
- package/dist/src/mantleChat-CXhAs5RD.js +155 -0
- package/dist/src/mantleChat-CcE-zjfj.cjs +154 -0
- package/dist/src/mantleChat-Cpefl7Zm.js +154 -0
- package/dist/src/mcp-B0V0ikdM.js +84 -0
- package/dist/src/mcp-CV2k2gwj.js +85 -0
- package/dist/src/memoryPoisoning-BC5FQQWZ.js +111 -0
- package/dist/src/memoryPoisoning-BDwrtZKX.js +111 -0
- package/dist/src/memoryPoisoning-BFemS_FF.js +112 -0
- package/dist/src/memoryPoisoning-DRs2rbVV.cjs +111 -0
- package/dist/src/messages-Bc5oZoAJ.js +1128 -0
- package/dist/src/messages-BkaH8fRW.js +1127 -0
- package/dist/src/messages-CoHlziS5.js +1127 -0
- package/dist/src/messages-Cv_m6kYs.cjs +1161 -0
- package/dist/src/mischievousUser-BcyFxrqJ.js +51 -0
- package/dist/src/mischievousUser-BlhOQSd2.js +52 -0
- package/dist/src/mischievousUser-BuQiKE8D.js +51 -0
- package/dist/src/mischievousUser-ChIOk6cT.cjs +51 -0
- package/dist/src/modelslab-BXIWBTgX.js +171 -0
- package/dist/src/modelslab-ChVsUiaJ.js +170 -0
- package/dist/src/modelslab-DZ6BFlDv.js +170 -0
- package/dist/src/modelslab-DhRr-vyo.cjs +170 -0
- package/dist/src/nova-reel-BL8DrN4_.js +272 -0
- package/dist/src/nova-reel-BiOMUm5q.cjs +272 -0
- package/dist/src/nova-reel-CTsya1hV.js +273 -0
- package/dist/src/nova-reel-kgBY4Svd.js +272 -0
- package/dist/src/nova-sonic-CaSSA3Jq.cjs +374 -0
- package/dist/src/nova-sonic-DLpmoGsR.js +375 -0
- package/dist/src/nova-sonic-DwWc4SoN.js +374 -0
- package/dist/src/nova-sonic-qnReTaXm.js +374 -0
- package/dist/src/novita-B5mAt3Ui.js +114 -0
- package/dist/src/novita-D57vCjDD.js +116 -0
- package/dist/src/novita-ITRtG8IJ.js +115 -0
- package/dist/src/novita-Rh3T13YO.cjs +115 -0
- package/dist/src/nscale-8V7iZ_pI.js +210 -0
- package/dist/src/nscale-BQnMv4pH.cjs +209 -0
- package/dist/src/nscale-BWZXHZVF.js +209 -0
- package/dist/src/nscale-BqrHiUqU.js +207 -0
- package/dist/src/openaiResponses-BMtGTu8R.js +317 -0
- package/dist/src/openaiResponses-CvcI_viE.js +318 -0
- package/dist/src/openaiResponses-DYPZEMX1.cjs +318 -0
- package/dist/src/openaiResponses-DZTg1-kb.js +319 -0
- package/dist/src/openclaw-BeKuig4g.js +1338 -0
- package/dist/src/openclaw-COkdQ83y.js +1337 -0
- package/dist/src/openclaw-CSoX_HQ5.cjs +1344 -0
- package/dist/src/openclaw-DJlhPGCb.js +1336 -0
- package/dist/src/opencode-sdk-BEJftEs6.cjs +1018 -0
- package/dist/src/opencode-sdk-DMvBB3V7.js +1013 -0
- package/dist/src/opencode-sdk-Df7hMjLO.js +1012 -0
- package/dist/src/opencode-sdk-bQp5Xf3W.js +1012 -0
- package/dist/src/openinterpreter-B3GgVZjK.js +431 -0
- package/dist/src/openinterpreter-BiGcU-HN.cjs +435 -0
- package/dist/src/openinterpreter-Buj2l3Eh.js +432 -0
- package/dist/src/openinterpreter-C3_Cg5b_.js +431 -0
- package/dist/src/pricing-0Pampf0q.cjs +999 -0
- package/dist/src/pricing-B8VdhEhY.js +976 -0
- package/dist/src/pricing-CtLA-rKA.js +976 -0
- package/dist/src/promptfoo-4OkHtH9P.cjs +341 -0
- package/dist/src/promptfoo-Bhpm7sH6.js +286 -0
- package/dist/src/promptfoo-BqV8ogVA.js +285 -0
- package/dist/src/promptfoo-S1Q9OHk_.js +286 -0
- package/dist/src/providers-B5zs1ZRv.js +24437 -0
- package/dist/src/providers-Cd6CJh6m.js +2 -0
- package/dist/src/providers-CpJlgHET.js +24039 -0
- package/dist/src/providers-CzvLvK6G.cjs +24180 -0
- package/dist/src/quiverai-1E_IvLHn.js +325 -0
- package/dist/src/quiverai-BXH004Vv.js +325 -0
- package/dist/src/quiverai-Ccya2z8Y.cjs +325 -0
- package/dist/src/quiverai-Cez57oe-.js +326 -0
- package/dist/src/registry-3zX_M9Ik.js +131 -0
- package/dist/src/registry-AuCrKTvS.js +132 -0
- package/dist/src/registry-CxXWKtQG.js +131 -0
- package/dist/src/registry-DG3o66JQ.cjs +131 -0
- package/dist/src/remoteGeneration-CAtvamG6.js +370 -0
- package/dist/src/remoteGeneration-CF225pDl.cjs +482 -0
- package/dist/src/remoteGeneration-DtnqocnL.js +370 -0
- package/dist/src/remoteGeneration-g3KvW-sP.js +371 -0
- package/dist/src/responses-BMbaUXQI.js +1098 -0
- package/dist/src/responses-B_TOSof-.js +1099 -0
- package/dist/src/responses-v-yANwTA.cjs +1109 -0
- package/dist/src/runtimeTransform-BBZv-oUZ.js +156 -0
- package/dist/src/runtimeTransform-DT2v5ovW.js +156 -0
- package/dist/src/runtimeTransform-GXXEIXdS.cjs +161 -0
- package/dist/src/runtimeTransform-JTwBQc-P.js +157 -0
- package/dist/src/sagemaker-B8D0L4rj.cjs +716 -0
- package/dist/src/sagemaker-CR2_AGdB.js +713 -0
- package/dist/src/sagemaker-Cd9qSQUV.js +714 -0
- package/dist/src/sagemaker-mKlltN4p.js +713 -0
- package/dist/src/scanner-PG_8lh8r.js +1971 -0
- package/dist/src/server/index.js +55 -55
- package/dist/src/server-Bmh7sd9F.js +155 -0
- package/dist/src/server-C7b8z6aC.js +63 -0
- package/dist/src/server-CAcovgtL.js +2 -0
- package/dist/src/server-CuuMfKlh.cjs +74 -0
- package/dist/src/server-DMPCj9jy.js +189 -0
- package/dist/src/session-BksXvRH_.cjs +69 -0
- package/dist/src/session-DOxUjqGQ.js +63 -0
- package/dist/src/session-Dujsc-b9.js +62 -0
- package/dist/src/session-VjtIxREd.js +62 -0
- package/dist/src/shared-Bkyz_7e5.cjs +2185 -0
- package/dist/src/shared-DDJg8ycC.js +1929 -0
- package/dist/src/shared-Dh3yfRBd.js +1927 -0
- package/dist/src/shared-tfPT8Tna.js +1928 -0
- package/dist/src/simulatedUser-6JdkyL3k.cjs +252 -0
- package/dist/src/simulatedUser-CFr2mr3M.js +248 -0
- package/dist/src/simulatedUser-DjwwUqx-.js +247 -0
- package/dist/src/slack-C_gIYiUs.js +144 -0
- package/dist/src/slack-DhNbz9CM.cjs +144 -0
- package/dist/src/slack-Dm2iI1zu.js +145 -0
- package/dist/src/strategies-BIY-bNul.js +2248 -0
- package/dist/src/strategies-C1KQQj9G.cjs +2420 -0
- package/dist/src/strategies-DM_3mReG.js +2385 -0
- package/dist/src/telemetry-BhMTibZO.js +2 -0
- package/dist/src/telemetry-C04d25BM.cjs +216 -0
- package/dist/src/telemetry-CIqy4fSC.js +201 -0
- package/dist/src/telemetry-CXozp_6C.js +205 -0
- package/dist/src/telemetry-g7PkBxmY.js +205 -0
- package/dist/src/togetherai-BvCim68-.js +50 -0
- package/dist/src/togetherai-CWyDCA9m.cjs +49 -0
- package/dist/src/togetherai-CeSE31vK.js +49 -0
- package/dist/src/togetherai-_2W0URf8.js +48 -0
- package/dist/src/traceContext-Brw3Oe41.js +1016 -0
- package/dist/src/traceContext-DpAYv27G.js +1015 -0
- package/dist/src/traceContext-KSqhzZI2.cjs +1032 -0
- package/dist/src/transcription-BySopazW.js +175 -0
- package/dist/src/transcription-DO4UPkRI.cjs +178 -0
- package/dist/src/transcription-RJGBa-pC.js +176 -0
- package/dist/src/transcription-fZenF3G5.js +175 -0
- package/dist/src/transform-BzhRc5z2.js +125 -0
- package/dist/src/transform-CPQu05u6.cjs +154 -0
- package/dist/src/transform-DAED8imp.js +126 -0
- package/dist/src/transform-DIOIQDmM.js +125 -0
- package/dist/src/typesafe-ByE0Kxfg.js +253 -0
- package/dist/src/typesafe-CFqGFY34.js +253 -0
- package/dist/src/typesafe-DCWIw-CP.cjs +253 -0
- package/dist/src/typesafe-DyHFV5Qk.js +254 -0
- package/dist/src/util-BHkj9joz.js +2049 -0
- package/dist/src/util-CICwIpmu.cjs +934 -0
- package/dist/src/util-CePiY2xZ.js +286 -0
- package/dist/src/util-CgT3uf4p.js +743 -0
- package/dist/src/util-Cj9drvOY.js +1770 -0
- package/dist/src/util-ClJRjlQA.cjs +357 -0
- package/dist/src/util-Cxf8VF2M.js +395 -0
- package/dist/src/util-D7RdV7rS.js +395 -0
- package/dist/src/util-DMNFhk47.js +351 -0
- package/dist/src/util-DNzh3M0z.js +396 -0
- package/dist/src/util-Df7rfMGb.cjs +2305 -0
- package/dist/src/util-Kf0KnG_6.js +2051 -0
- package/dist/src/util-LEbeiYw_.js +743 -0
- package/dist/src/util-WH8CgVs4.js +352 -0
- package/dist/src/util-cx6Xw8Lw.cjs +478 -0
- package/dist/src/util-qzBqirBH.js +2050 -0
- package/dist/src/vertex-CBAMfRz3.js +854 -0
- package/dist/src/vertex-CMP2IpN9.js +2 -0
- package/dist/src/vertex-CZ5YOotT.js +848 -0
- package/dist/src/vertex-DNsh1F1M.cjs +871 -0
- package/dist/src/vertexLive-BTXYj3-F.js +55 -0
- package/dist/src/vertexLive-Ba_LAqEF.cjs +55 -0
- package/dist/src/vertexLive-DM4sFaaj.js +56 -0
- package/dist/src/vertexLive-JqZOw7HC.js +55 -0
- package/dist/src/video-BY7Q2Gii.cjs +706 -0
- package/dist/src/video-CYElP-CK.js +703 -0
- package/dist/src/video-C_AdEDH0.js +702 -0
- package/dist/src/video-DGvjQ_4j.js +702 -0
- package/package.json +1 -1
- package/dist/src/accounts-Dpb43yde.cjs +0 -276
- package/dist/src/accounts-GKrO1olH.js +0 -229
- package/dist/src/accounts-e4FGOsji.js +0 -227
- package/dist/src/accounts-sUiEJfkB.js +0 -222
- package/dist/src/agentWorkspace-B8A_wuMR.cjs +0 -619
- package/dist/src/agentWorkspace-DSPIscXR.js +0 -593
- package/dist/src/agentWorkspace-DxUqd-XK.js +0 -592
- package/dist/src/agentWorkspace-n0uOJXhD.js +0 -592
- package/dist/src/agentic-utils-9bCj4twQ.js +0 -197
- package/dist/src/agentic-utils-CyCLuLoj.js +0 -197
- package/dist/src/agentic-utils-D23qtOlx.cjs +0 -237
- package/dist/src/agentic-utils-DuBMMNCw.js +0 -198
- package/dist/src/agents-6hDRNoYD.js +0 -777
- package/dist/src/agents-B8w2o7Sc.cjs +0 -777
- package/dist/src/agents-Ck0NXl7v.js +0 -777
- package/dist/src/agents-CwT3B1qB.js +0 -778
- package/dist/src/agents-DOLjfOEq.js +0 -266
- package/dist/src/agents-OcF9hq--.js +0 -267
- package/dist/src/agents-api-CnZZt8bn.cjs +0 -710
- package/dist/src/agents-api-D04u3bmL.js +0 -711
- package/dist/src/agents-api-DWw0_Vio.js +0 -710
- package/dist/src/agents-api-IWHEwp8i.js +0 -710
- package/dist/src/agents-mHt2Mh9O.cjs +0 -266
- package/dist/src/agents-sICccZCA.js +0 -266
- package/dist/src/ai.studio-Ci4rypDT.js +0 -2
- package/dist/src/ai.studio-KkQ6KaHa.js +0 -369
- package/dist/src/ai.studio-gSXK2cGI.js +0 -374
- package/dist/src/ai.studio-nQF_B4DH.cjs +0 -391
- package/dist/src/aimlapi-BeSk5BDV.js +0 -30
- package/dist/src/aimlapi-CzNUhdKu.cjs +0 -29
- package/dist/src/aimlapi-DCkazDPI.js +0 -29
- package/dist/src/aimlapi-WeH5B6K1.js +0 -28
- package/dist/src/anthropicMessages-AcNWTpYO.js +0 -115
- package/dist/src/anthropicMessages-BUtvzbpL.js +0 -114
- package/dist/src/anthropicMessages-DTWhZDCd.js +0 -114
- package/dist/src/anthropicMessages-lGVnSgyx.cjs +0 -114
- package/dist/src/app/assets/index-CyEI5aDN.js +0 -392
- package/dist/src/audio-BE_Duiu1.js +0 -104
- package/dist/src/audio-CiUd00k2.cjs +0 -104
- package/dist/src/audio-Dop6omna.js +0 -105
- package/dist/src/audio-EZNTInr_.js +0 -104
- package/dist/src/authoritativeMarkupInjection-BUqH6hNk.js +0 -78
- package/dist/src/authoritativeMarkupInjection-BmbJdJO0.cjs +0 -78
- package/dist/src/authoritativeMarkupInjection-Cpz12Y3w.js +0 -78
- package/dist/src/authoritativeMarkupInjection-W4XfcH91.js +0 -79
- package/dist/src/aws-B2Jqbnet.js +0 -2433
- package/dist/src/aws-DHtuUIzQ.js +0 -1149
- package/dist/src/aws-DLqXP6wY.js +0 -2433
- package/dist/src/aws-DfduhmwL.cjs +0 -2454
- package/dist/src/base-B9L2Xvpc.js +0 -255
- package/dist/src/base-BTZnIsuH.cjs +0 -305
- package/dist/src/base-BhaWNQPJ.js +0 -462
- package/dist/src/base-Br-G_Xou.js +0 -256
- package/dist/src/base-Bzo8hiUS.cjs +0 -467
- package/dist/src/base-C82fd2jq.js +0 -463
- package/dist/src/base-CRdQwC1W.js +0 -462
- package/dist/src/base-CjGwZNOQ.js +0 -255
- package/dist/src/bedrock-BdMru_ro.js +0 -1300
- package/dist/src/bedrock-CBUmfLX1.cjs +0 -2
- package/dist/src/bedrock-DBDxBaF9.js +0 -2
- package/dist/src/bedrock-DDrECM21.js +0 -1
- package/dist/src/bedrock-DVwkgvRS.js +0 -1
- package/dist/src/bestOfN-AKF5beq4.js +0 -159
- package/dist/src/bestOfN-C1UIVGJV.js +0 -160
- package/dist/src/bestOfN-DlkETbXy.cjs +0 -161
- package/dist/src/bestOfN-XIfEgU-g.js +0 -159
- package/dist/src/cache-BZaVoKaA.js +0 -2
- package/dist/src/cache-CEYhFUsH.js +0 -741
- package/dist/src/cache-Cbw1zH6q.js +0 -782
- package/dist/src/cache-CdaZNb75.js +0 -754
- package/dist/src/cache-DpuIzPxh.cjs +0 -856
- package/dist/src/cerebras-Bpn6FPkJ.js +0 -97
- package/dist/src/cerebras-CqJ0BRCJ.cjs +0 -97
- package/dist/src/cerebras-D4ILa_TY.js +0 -97
- package/dist/src/cerebras-DR8uc7ee.js +0 -98
- package/dist/src/chat-B7PZfaYp.cjs +0 -987
- package/dist/src/chat-BVuSjdEb.js +0 -227
- package/dist/src/chat-BsaZRjXN.js +0 -76
- package/dist/src/chat-C5liqe3Y.js +0 -226
- package/dist/src/chat-C9hyHf5B.js +0 -124
- package/dist/src/chat-CFLalAck.js +0 -226
- package/dist/src/chat-CN8JGrHu.js +0 -76
- package/dist/src/chat-CaHBBpCb.js +0 -123
- package/dist/src/chat-CcbLSghx.js +0 -123
- package/dist/src/chat-CoSN6sr2.js +0 -934
- package/dist/src/chat-CsJRFX8a.cjs +0 -226
- package/dist/src/chat-DFoZLvO_.js +0 -934
- package/dist/src/chat-DiLQvL7r.js +0 -77
- package/dist/src/chat-F6qVSDk3.cjs +0 -123
- package/dist/src/chat-Oq4FaJgI.cjs +0 -76
- package/dist/src/chat-knMfQUKz.js +0 -935
- package/dist/src/claude-agent-sdk-CJkOLpnI.js +0 -999
- package/dist/src/claude-agent-sdk-Ckn76PRD.js +0 -999
- package/dist/src/claude-agent-sdk-DX0gTr11.cjs +0 -1005
- package/dist/src/claude-agent-sdk-LMeikxoR.js +0 -1000
- package/dist/src/client-BFf1r6Z8.js +0 -352
- package/dist/src/client-CdXyDdDi.js +0 -351
- package/dist/src/client-DV8XMu7i.js +0 -351
- package/dist/src/client-iEXtOBKW.cjs +0 -357
- package/dist/src/cloud-B02qcpjf.js +0 -2
- package/dist/src/cloud-BlHP-g1v.cjs +0 -666
- package/dist/src/cloud-C9BI4isF.js +0 -287
- package/dist/src/cloud-CTTLNdvj.js +0 -657
- package/dist/src/cloud-D5X5yQ_d.js +0 -599
- package/dist/src/cloud-QxPkpsHA.js +0 -599
- package/dist/src/cloudflare-ai-DRTRT1fc.js +0 -132
- package/dist/src/cloudflare-ai-DgaXapAV.cjs +0 -133
- package/dist/src/cloudflare-ai-DkuJXijS.js +0 -134
- package/dist/src/cloudflare-ai-wy9QCHku.js +0 -133
- package/dist/src/cloudflare-gateway-9cAN8g29.cjs +0 -276
- package/dist/src/cloudflare-gateway-BVFMD292.js +0 -277
- package/dist/src/cloudflare-gateway-BuUI4p6I.js +0 -276
- package/dist/src/cloudflare-gateway-TlYHizbW.js +0 -276
- package/dist/src/codex-app-server-BPz_feug.cjs +0 -2162
- package/dist/src/codex-app-server-C9noXM9C.js +0 -2155
- package/dist/src/codex-app-server-CEmD-Y5U.js +0 -2
- package/dist/src/codex-app-server-DZolc18r.js +0 -2156
- package/dist/src/codex-app-server-Dd0A37nO.js +0 -2155
- package/dist/src/codex-sdk-BbxjBvBk.cjs +0 -1588
- package/dist/src/codex-sdk-BpXeIs-_.js +0 -1557
- package/dist/src/codex-sdk-BtQp5X0f.js +0 -1552
- package/dist/src/codex-sdk-CH0v9Bk1.js +0 -2
- package/dist/src/codex-sdk-CgrN7JB8.js +0 -1557
- package/dist/src/codex-security-B5fENNUr.js +0 -406
- package/dist/src/codex-security-C6uuJx-y.cjs +0 -411
- package/dist/src/codex-security-CifWtZR_.js +0 -407
- package/dist/src/codex-security-Kg2bOEKy.js +0 -406
- package/dist/src/cometapi-BFpIDLIx.js +0 -55
- package/dist/src/cometapi-C6O2PIrN.js +0 -56
- package/dist/src/cometapi-D5Yupc6F.js +0 -53
- package/dist/src/cometapi-DzgIwJzJ.cjs +0 -55
- package/dist/src/compatible-0jhmVfOp.js +0 -25
- package/dist/src/compatible-DdtwWdJi.cjs +0 -24
- package/dist/src/compatible-Di4nR3sU.js +0 -24
- package/dist/src/compatible-iJKLWdnf.js +0 -24
- package/dist/src/completion-B0_hVUDG.js +0 -119
- package/dist/src/completion-BdI6v0-Q.cjs +0 -123
- package/dist/src/completion-CWcJscwv.js +0 -118
- package/dist/src/conversationScoring-99EOPJRa.js +0 -373
- package/dist/src/conversationScoring-BIq4J0Cq.js +0 -374
- package/dist/src/conversationScoring-DARyeATr.cjs +0 -398
- package/dist/src/conversationScoring-DS48t4Hb.js +0 -373
- package/dist/src/crescendo-CebvXIu4.js +0 -730
- package/dist/src/crescendo-CxrLS0oo.js +0 -732
- package/dist/src/crescendo-DZQXBSkj.js +0 -733
- package/dist/src/crescendo-wjEx68uD.cjs +0 -734
- package/dist/src/custom-BiQ-aUNw.cjs +0 -620
- package/dist/src/custom-ByyB5Z93.js +0 -619
- package/dist/src/custom-C5jOevNb.js +0 -617
- package/dist/src/custom-CCrsCz8o.js +0 -618
- package/dist/src/dataUrl-C9J7wz9H.js +0 -3133
- package/dist/src/dataUrl-CGsBT7UZ.cjs +0 -3187
- package/dist/src/dataUrl-CzKvvWNO.js +0 -2868
- package/dist/src/decisions-BTusXCUx.cjs +0 -514
- package/dist/src/decisions-BYtL9edD.js +0 -515
- package/dist/src/decisions-jYix_gCF.js +0 -515
- package/dist/src/decisions-nxxfHRAN.js +0 -516
- package/dist/src/docker-DDIv4zkg.js +0 -93
- package/dist/src/docker-DVLp_5OG.js +0 -94
- package/dist/src/docker-INm9w0SY.cjs +0 -94
- package/dist/src/docker-sGuoCul_.js +0 -95
- package/dist/src/embedding-CAhqLLrR.js +0 -82
- package/dist/src/embedding-D94GAsti.cjs +0 -86
- package/dist/src/embedding-zb4MAzQy.js +0 -81
- package/dist/src/envoy-BMPszwEa.cjs +0 -60
- package/dist/src/envoy-Bp-s39_8.js +0 -60
- package/dist/src/envoy-BswDt-Ou.js +0 -61
- package/dist/src/envoy-rVbYcV80.js +0 -60
- package/dist/src/eval-B1-XfrC7.js +0 -2
- package/dist/src/eval-pC4qCvLw.js +0 -1920
- package/dist/src/evalResult-CzjCb5bd.js +0 -1300
- package/dist/src/evaluator-CNq2K7J_.js +0 -10578
- package/dist/src/evaluator-LtfxdxEu.js +0 -2
- package/dist/src/evaluatorHelpers-C5J0NYpQ.js +0 -601
- package/dist/src/evaluatorHelpers-DcdCglCs.cjs +0 -622
- package/dist/src/evaluatorHelpers-Rvb88W6B.js +0 -600
- package/dist/src/fetch-5HtnNhHg.js +0 -1556
- package/dist/src/fetch-BCwjoIFd.js +0 -1559
- package/dist/src/fetch-BhfUnKen.js +0 -1280
- package/dist/src/fetch-C08w4vVl.js +0 -9
- package/dist/src/fetch-DBxy8Tlb.cjs +0 -14
- package/dist/src/fetch-DYte6oQX.cjs +0 -1853
- package/dist/src/fetch-ElpfcAVG.js +0 -10
- package/dist/src/fetch-lM1OIaSt.js +0 -2
- package/dist/src/functionCallbackUtils-BCAdWfHO.js +0 -246
- package/dist/src/functionCallbackUtils-BYq9qOhG.js +0 -245
- package/dist/src/functionCallbackUtils-ByWkmVud.cjs +0 -262
- package/dist/src/functionCallbackUtils-D_C_JaFd.js +0 -245
- package/dist/src/gemini-image-CAlwaJhZ.js +0 -471
- package/dist/src/gemini-image-DJoVoOnZ.cjs +0 -471
- package/dist/src/gemini-image-Waio-9Xx.js +0 -472
- package/dist/src/gemini-image-vbY6Ftbf.js +0 -471
- package/dist/src/goat-BWbtyY9c.js +0 -512
- package/dist/src/goat-CXzzeCOQ.cjs +0 -515
- package/dist/src/goat-CfgvzSgZ.js +0 -514
- package/dist/src/goat-DLeoIHBp.js +0 -515
- package/dist/src/goblin-CmfCfwqk.cjs +0 -22
- package/dist/src/goblin-CtcaORRH.js +0 -22
- package/dist/src/goblin-DF6DDhM-.js +0 -22
- package/dist/src/goblin-Nai0xxBV.js +0 -23
- package/dist/src/google-ClpkLtKL.cjs +0 -142
- package/dist/src/google-CrFgKu9k.js +0 -143
- package/dist/src/google-Dj_EIBqS.js +0 -142
- package/dist/src/google-e4-vARv6.js +0 -142
- package/dist/src/graders-BN1IIa71.js +0 -15470
- package/dist/src/graders-C5sCfSP5.js +0 -2
- package/dist/src/hydra-B7RfXVBK.js +0 -2
- package/dist/src/hydra-C1cFN-Jg.js +0 -613
- package/dist/src/hydra-CK6Uc1ia.js +0 -612
- package/dist/src/hydra-Dg65rAP_.js +0 -610
- package/dist/src/hydra-Fqx8l_Xu.cjs +0 -612
- package/dist/src/image-BdlUDAtp.js +0 -163
- package/dist/src/image-C-KwEhwt.cjs +0 -163
- package/dist/src/image-C76fp6NK.cjs +0 -209
- package/dist/src/image-D75ehv3D.js +0 -482
- package/dist/src/image-DKtc5v5W.js +0 -209
- package/dist/src/image-DT_xOkJY.js +0 -163
- package/dist/src/image-DVpdllEE.js +0 -209
- package/dist/src/image-DXZ8AzMf.js +0 -481
- package/dist/src/image-DZl_1mvy.js +0 -164
- package/dist/src/image-DcTD7Ak0.cjs +0 -504
- package/dist/src/image-ndxEvBKB.js +0 -210
- package/dist/src/indirectWebPwn-70WA5x_q.js +0 -435
- package/dist/src/indirectWebPwn-BRVyd3qV.cjs +0 -463
- package/dist/src/indirectWebPwn-BsJVsu0q.js +0 -285
- package/dist/src/indirectWebPwn-Cw6yJu0i.js +0 -285
- package/dist/src/indirectWebPwn-D-PhJzo4.js +0 -286
- package/dist/src/indirectWebPwn-DRPHt2I8.js +0 -434
- package/dist/src/indirectWebPwn-DXtfFhd9.cjs +0 -285
- package/dist/src/indirectWebPwn-DvpNouzc.js +0 -434
- package/dist/src/interactions-5ixfW7Cl.js +0 -850
- package/dist/src/interactions-BOUzfmg1.cjs +0 -850
- package/dist/src/interactions-CSSXcGNc.js +0 -851
- package/dist/src/interactions-WB_sgkN0.js +0 -850
- package/dist/src/iterative-BShRNqjC.cjs +0 -549
- package/dist/src/iterative-BcW_ELtB.js +0 -548
- package/dist/src/iterative-BpHbHz8B.js +0 -547
- package/dist/src/iterative-YcchP12d.js +0 -545
- package/dist/src/iterativeImage-BMFE5Hl7.cjs +0 -419
- package/dist/src/iterativeImage-CkSaYLMY.js +0 -417
- package/dist/src/iterativeImage-DAEUlQX_.js +0 -418
- package/dist/src/iterativeImage-DeUSkEnj.js +0 -417
- package/dist/src/iterativeMeta-DbdaKdEO.cjs +0 -439
- package/dist/src/iterativeMeta-DcF9JWEK.js +0 -437
- package/dist/src/iterativeMeta-DkfPqWIC.js +0 -439
- package/dist/src/iterativeMeta-DkrpnVSs.js +0 -440
- package/dist/src/iterativeTree-CEMY1FhE.cjs +0 -879
- package/dist/src/iterativeTree-Cv5W4tX9.js +0 -877
- package/dist/src/iterativeTree-DGvomd3M.js +0 -876
- package/dist/src/iterativeTree-KbtC2Mkz.js +0 -878
- package/dist/src/knowledgeBase-AYRXn4wO.js +0 -163
- package/dist/src/knowledgeBase-BNqQfx01.js +0 -163
- package/dist/src/knowledgeBase-C0IaCCVs.js +0 -164
- package/dist/src/knowledgeBase-C2uj6wK4.cjs +0 -163
- package/dist/src/litellm-CN1ScAwZ.js +0 -147
- package/dist/src/litellm-CTjwiKSa.js +0 -146
- package/dist/src/litellm-Cd4Nj5ue.js +0 -145
- package/dist/src/litellm-DMqLpEBg.cjs +0 -146
- package/dist/src/live-Bt50-InO.cjs +0 -891
- package/dist/src/live-Bu2ujadG.js +0 -2
- package/dist/src/live-C3M52i3p.js +0 -891
- package/dist/src/live-CRfHMO3B.js +0 -892
- package/dist/src/live-iCIpO14m.js +0 -891
- package/dist/src/luma-ray-B8eHC4c8.cjs +0 -309
- package/dist/src/luma-ray-BIvkPw0s.js +0 -309
- package/dist/src/luma-ray-ChsiBxMA.js +0 -309
- package/dist/src/luma-ray-DAvKrInz.js +0 -310
- package/dist/src/mantleChat-5YeEXAZI.js +0 -154
- package/dist/src/mantleChat-D--mW3hl.js +0 -154
- package/dist/src/mantleChat-DHP3siNg.cjs +0 -154
- package/dist/src/mantleChat-wBfAX46o.js +0 -155
- package/dist/src/mcp-49jlEcTQ.js +0 -85
- package/dist/src/mcp-__PIz81I.js +0 -84
- package/dist/src/memoryPoisoning-Chxge74M.js +0 -111
- package/dist/src/memoryPoisoning-QH6NCUVE.js +0 -112
- package/dist/src/memoryPoisoning-tCxZt8Nz.js +0 -111
- package/dist/src/memoryPoisoning-ymrRItRR.cjs +0 -111
- package/dist/src/messages-BE_eZ7NA.js +0 -1127
- package/dist/src/messages-Bo638ShI.js +0 -1127
- package/dist/src/messages-BzR0-NQ1.js +0 -1128
- package/dist/src/messages-Cbg5Pfd0.cjs +0 -1161
- package/dist/src/mischievousUser-BtED2Z5Z.cjs +0 -51
- package/dist/src/mischievousUser-KqSOjrDJ.js +0 -51
- package/dist/src/mischievousUser-YMD41YNZ.js +0 -51
- package/dist/src/mischievousUser-zBxlNdCu.js +0 -52
- package/dist/src/modelslab-B8gZxtfE.js +0 -171
- package/dist/src/modelslab-C7bmVpTB.js +0 -170
- package/dist/src/modelslab-CCeQCTZg.js +0 -170
- package/dist/src/modelslab-CvBJGv7y.cjs +0 -170
- package/dist/src/nova-reel-BOEWsEKA.cjs +0 -272
- package/dist/src/nova-reel-BtyBXq5M.js +0 -273
- package/dist/src/nova-reel-C1eF3-EE.js +0 -272
- package/dist/src/nova-reel-YhgrxEKT.js +0 -272
- package/dist/src/nova-sonic-BaERP20w.js +0 -374
- package/dist/src/nova-sonic-CxgM3O-P.cjs +0 -374
- package/dist/src/nova-sonic-DJS22fC3.js +0 -375
- package/dist/src/nova-sonic-DwvwHyRX.js +0 -374
- package/dist/src/novita-D1l2tG0O.js +0 -116
- package/dist/src/novita-D84VM3v0.cjs +0 -115
- package/dist/src/novita-DGInvwfR.js +0 -115
- package/dist/src/novita-vXHkXhTg.js +0 -114
- package/dist/src/nscale-CU0Ldr00.js +0 -209
- package/dist/src/nscale-ClfKlQeM.cjs +0 -209
- package/dist/src/nscale-DxaVnF0x.js +0 -210
- package/dist/src/nscale-_poVxIrO.js +0 -207
- package/dist/src/openaiResponses-CJGsneNj.js +0 -317
- package/dist/src/openaiResponses-CKSl5Sdg.js +0 -319
- package/dist/src/openaiResponses-DC8rzFUc.js +0 -318
- package/dist/src/openaiResponses-rMHIA3dV.cjs +0 -318
- package/dist/src/openclaw-CCbvsNFW.cjs +0 -1344
- package/dist/src/openclaw-CZw1lCDZ.js +0 -1336
- package/dist/src/openclaw-ChFLgC-a.js +0 -1338
- package/dist/src/openclaw-DrPMoRrH.js +0 -1337
- package/dist/src/opencode-sdk-2EfIDhFp.cjs +0 -1018
- package/dist/src/opencode-sdk-CHw3F845.js +0 -1013
- package/dist/src/opencode-sdk-D0EGGxvy.js +0 -1012
- package/dist/src/opencode-sdk-jSS7NI2Q.js +0 -1012
- package/dist/src/openinterpreter-CY622xHC.js +0 -431
- package/dist/src/openinterpreter-DATyhuhP.js +0 -432
- package/dist/src/openinterpreter-DDUMyIf1.js +0 -431
- package/dist/src/openinterpreter-s5Tz6Lid.cjs +0 -435
- package/dist/src/pricing-C498twd2.js +0 -976
- package/dist/src/pricing-DBd_bMIh.cjs +0 -999
- package/dist/src/pricing-ISrMCskv.js +0 -976
- package/dist/src/promptfoo-6p0WG2ih.js +0 -286
- package/dist/src/promptfoo-BQRfgNs_.js +0 -285
- package/dist/src/promptfoo-Bqo88z20.cjs +0 -341
- package/dist/src/promptfoo-Cq5AVI3I.js +0 -286
- package/dist/src/providers-ATbeMX5E.cjs +0 -24180
- package/dist/src/providers-B7F1FiNI.js +0 -2
- package/dist/src/providers-DazIw8mI.js +0 -24039
- package/dist/src/providers-QvGlNAD0.js +0 -24437
- package/dist/src/quiverai-BPlNcLkV.cjs +0 -325
- package/dist/src/quiverai-By99-YmJ.js +0 -325
- package/dist/src/quiverai-CmmByDqo.js +0 -325
- package/dist/src/quiverai-HZkoJJqw.js +0 -326
- package/dist/src/registry-BLTnTfjT.cjs +0 -131
- package/dist/src/registry-BMC-COHT.js +0 -132
- package/dist/src/registry-C8UZtmBp.js +0 -131
- package/dist/src/registry-CfwEUYXG.js +0 -131
- package/dist/src/remoteGeneration-Bgg6kC5V.js +0 -370
- package/dist/src/remoteGeneration-CKJFE960.cjs +0 -482
- package/dist/src/remoteGeneration-DaxwJDKv.js +0 -370
- package/dist/src/remoteGeneration-vHMGVKr1.js +0 -371
- package/dist/src/responses-BvnyIHrq.js +0 -1099
- package/dist/src/responses-CERAgvf-.js +0 -1098
- package/dist/src/responses-CwgjeuOg.cjs +0 -1109
- package/dist/src/runtimeTransform-3RF9Avyg.cjs +0 -161
- package/dist/src/runtimeTransform-C51Z5j4H.js +0 -156
- package/dist/src/runtimeTransform-CKE_Iyv8.js +0 -157
- package/dist/src/runtimeTransform-Cs11xJpj.js +0 -156
- package/dist/src/sagemaker-BJ4dOCxE.js +0 -713
- package/dist/src/sagemaker-Bt3JUAWq.js +0 -714
- package/dist/src/sagemaker-QVKyLgLF.cjs +0 -716
- package/dist/src/sagemaker-l3IB8iTs.js +0 -713
- package/dist/src/scanner-DGjIiTZ1.js +0 -1971
- package/dist/src/server-BNaLZH6u.js +0 -63
- package/dist/src/server-CBMuQul3.js +0 -189
- package/dist/src/server-CMKKIzKv.cjs +0 -74
- package/dist/src/server-CN2IS9Cs.js +0 -155
- package/dist/src/server-ua4cqbjC.js +0 -2
- package/dist/src/session-CQIjq_HZ.cjs +0 -69
- package/dist/src/session-FTlg8sEu.js +0 -62
- package/dist/src/session-GBQXtPWp.js +0 -63
- package/dist/src/session-_0-rTdwY.js +0 -62
- package/dist/src/shared-BtuO-OAM.js +0 -1927
- package/dist/src/shared-Ci78wTZX.js +0 -1928
- package/dist/src/shared-Dd3rimdM.js +0 -1929
- package/dist/src/shared-KAjFxRre.cjs +0 -2185
- package/dist/src/simulatedUser--OjW6xCx.js +0 -247
- package/dist/src/simulatedUser-D0-slRye.cjs +0 -252
- package/dist/src/simulatedUser-D1Kh_cwA.js +0 -248
- package/dist/src/slack-BX0FUevO.js +0 -144
- package/dist/src/slack-CcwXFiJE.cjs +0 -144
- package/dist/src/slack-CnfqKfXp.js +0 -145
- package/dist/src/strategies-2ntcK4tN.js +0 -2248
- package/dist/src/strategies-DZIW7Zcs.js +0 -2385
- package/dist/src/strategies-YRDF2j-N.cjs +0 -2420
- package/dist/src/telemetry-CL8CVA4p.js +0 -205
- package/dist/src/telemetry-Cix90qqz.js +0 -201
- package/dist/src/telemetry-CkmlqTjV.js +0 -205
- package/dist/src/telemetry-DQH7l5bb.js +0 -2
- package/dist/src/telemetry-DUCXc1-r.cjs +0 -216
- package/dist/src/togetherai-3yUt5Ck7.js +0 -49
- package/dist/src/togetherai-BJUByLwt.cjs +0 -49
- package/dist/src/togetherai-Bh6KZkmd.js +0 -50
- package/dist/src/togetherai-DDl9yk3b.js +0 -48
- package/dist/src/traceContext-BiJVppjT.cjs +0 -1032
- package/dist/src/traceContext-CKKluULP.js +0 -1016
- package/dist/src/traceContext-D3Sk8fO-.js +0 -1015
- package/dist/src/transcription-BoVQKIVz.js +0 -175
- package/dist/src/transcription-Bs5u8780.js +0 -175
- package/dist/src/transcription-Dl654d1p.cjs +0 -178
- package/dist/src/transcription-VEvhM1Fu.js +0 -176
- package/dist/src/transform-BAbkGpvl.js +0 -125
- package/dist/src/transform-C_j4hUH8.js +0 -126
- package/dist/src/transform-Da86hs4M.cjs +0 -154
- package/dist/src/transform-_i1raQNo.js +0 -125
- package/dist/src/typesafe-CKXBeh82.cjs +0 -253
- package/dist/src/typesafe-D3VaGeNm.js +0 -253
- package/dist/src/typesafe-DYM-SFNH.js +0 -253
- package/dist/src/typesafe-LXmSbw8F.js +0 -254
- package/dist/src/util-41rb0XHX.js +0 -743
- package/dist/src/util-B0WlHYFM.js +0 -2049
- package/dist/src/util-BD1R_PsR.js +0 -1770
- package/dist/src/util-BLbM_ItC.js +0 -395
- package/dist/src/util-C72P0iIa.js +0 -352
- package/dist/src/util-C7MpGlJ6.cjs +0 -2305
- package/dist/src/util-CCtqagKc.js +0 -286
- package/dist/src/util-CM2Ec_uY.js +0 -2051
- package/dist/src/util-CSSAWO8v.js +0 -351
- package/dist/src/util-CkQc-fx3.cjs +0 -934
- package/dist/src/util-DcOlFTFa.cjs +0 -478
- package/dist/src/util-DluGTGVB.js +0 -395
- package/dist/src/util-PfQ60chz.js +0 -743
- package/dist/src/util-f14-CPij.js +0 -396
- package/dist/src/util-l9pXX3Eu.cjs +0 -357
- package/dist/src/util-o_BnlYqS.js +0 -2050
- package/dist/src/vertex-B_-gQgzc.js +0 -2
- package/dist/src/vertex-CU4gqoYa.js +0 -854
- package/dist/src/vertex-DZ42UHb3.js +0 -848
- package/dist/src/vertex-DsYQJA0T.cjs +0 -871
- package/dist/src/vertexLive-BvIaHKGB.js +0 -55
- package/dist/src/vertexLive-CTULqNx7.js +0 -56
- package/dist/src/vertexLive-DjJ_YQBe.cjs +0 -55
- package/dist/src/vertexLive-STUGcteB.js +0 -55
- package/dist/src/video-CAQGmtEV.js +0 -703
- package/dist/src/video-_FSTWlwX.js +0 -702
- package/dist/src/video-aBPJPWdt.js +0 -702
- package/dist/src/video-gDjkWv5m.cjs +0 -706
|
@@ -1,1770 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { E as sanitizeUrl, F as isApiProvider, I as isProviderOptions, K as refreshConfigDirectoryPathFromEnv, S as sanitizeConfigForOutput, W as loadYaml, c as logger, ct as loadEnvFiles, w as sanitizeRuntimeOptions } from "./logger-pCNnmVuz.js";
|
|
3
|
-
import { a as getStripFlags, i as getResultIndexKey, l as projectTracesForOutput, r as asEvaluateResult, u as sanitizeResultForJsonlArtifact } from "./evalResult-CzjCb5bd.js";
|
|
4
|
-
import { U as TERMINAL_MAX_WIDTH, Y as VERSION, r as fetchWithProxy } from "./fetch-BhfUnKen.js";
|
|
5
|
-
import { t as invariant } from "./invariant-CbHB1xyx.js";
|
|
6
|
-
import { C as OutputFileExtension, O as ResultFailureReason } from "./tables-BONxKPrt.js";
|
|
7
|
-
import { r as getDirectory } from "./esm-B4NX_h4K.js";
|
|
8
|
-
import { i as maybeLoadConfigFromExternalFile } from "./file-DnhgJopr.js";
|
|
9
|
-
import { o as getNunjucksEngine } from "./render-DdqOpT1Z.js";
|
|
10
|
-
import { n as sha256 } from "./createHash-DqA6GWxE.js";
|
|
11
|
-
import "./blobs-BKHs1MZ-.js";
|
|
12
|
-
import { o as collectBlobHashes } from "./extractor-CW3spiLZ.js";
|
|
13
|
-
import { t as isMissingPackageImportError } from "./packageImportErrors-B9NSwzz-.js";
|
|
14
|
-
import fs, * as fs$2 from "fs";
|
|
15
|
-
import path, * as path$1 from "path";
|
|
16
|
-
import * as os$1 from "os";
|
|
17
|
-
import * as yaml from "js-yaml";
|
|
18
|
-
import deepEqual from "fast-deep-equal";
|
|
19
|
-
import dedent from "dedent";
|
|
20
|
-
import * as fsPromises from "fs/promises";
|
|
21
|
-
import { randomUUID } from "crypto";
|
|
22
|
-
import { XMLBuilder } from "fast-xml-parser";
|
|
23
|
-
import { stringify } from "csv-stringify/sync";
|
|
24
|
-
//#region src/util/providerRef.ts
|
|
25
|
-
const PROVIDER_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
26
|
-
"id",
|
|
27
|
-
"label",
|
|
28
|
-
"config",
|
|
29
|
-
"prompts",
|
|
30
|
-
"transform",
|
|
31
|
-
"delay",
|
|
32
|
-
"env",
|
|
33
|
-
"inputs"
|
|
34
|
-
]);
|
|
35
|
-
/** Returns true if the value is a non-empty string suitable as a provider identifier. */
|
|
36
|
-
function isValidProviderId(id) {
|
|
37
|
-
return typeof id === "string" && id !== "";
|
|
38
|
-
}
|
|
39
|
-
function getProviderLabel(provider) {
|
|
40
|
-
if ((typeof provider === "object" || typeof provider === "function") && provider !== null && "label" in provider && typeof provider.label === "string") return provider.label;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Resolves relative file paths in provider IDs to absolute paths for consistent matching.
|
|
44
|
-
* Handles file://, exec:, python:, golang: prefixes and bare .js/.ts/.mjs paths.
|
|
45
|
-
*/
|
|
46
|
-
function canonicalizeProviderId(id) {
|
|
47
|
-
if (id.startsWith("file://")) {
|
|
48
|
-
const filePath = id.slice(7);
|
|
49
|
-
return path.isAbsolute(filePath) ? id : `file://${path.resolve(filePath)}`;
|
|
50
|
-
}
|
|
51
|
-
for (const prefix of [
|
|
52
|
-
"exec:",
|
|
53
|
-
"python:",
|
|
54
|
-
"golang:"
|
|
55
|
-
]) if (id.startsWith(prefix)) {
|
|
56
|
-
const filePath = id.slice(prefix.length);
|
|
57
|
-
if (filePath.includes("/") || filePath.includes("\\")) return `${prefix}${path.resolve(filePath)}`;
|
|
58
|
-
return id;
|
|
59
|
-
}
|
|
60
|
-
if ((id.endsWith(".js") || id.endsWith(".ts") || id.endsWith(".mjs")) && (id.includes("/") || id.includes("\\"))) return `file://${path.resolve(id)}`;
|
|
61
|
-
return id;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Returns true for provider refs that should be expanded from YAML/JSON config files.
|
|
65
|
-
*/
|
|
66
|
-
function isProviderConfigFileReference(providerPath) {
|
|
67
|
-
return providerPath.startsWith("file://") && (providerPath.endsWith(".yaml") || providerPath.endsWith(".yml") || providerPath.endsWith(".json"));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Reads a provider config file and normalizes single-provider and multi-provider files.
|
|
71
|
-
* An explicit base path also scopes nested configuration files; otherwise their
|
|
72
|
-
* caller scope is retained.
|
|
73
|
-
* Returns a `wasArray` flag so callers can detect multi-provider files that require
|
|
74
|
-
* `loadApiProviders` instead of `loadApiProvider`.
|
|
75
|
-
*/
|
|
76
|
-
function readProviderConfigFile(providerPath, basePath) {
|
|
77
|
-
const relativePath = providerPath.slice(7);
|
|
78
|
-
const resolvedPath = path.isAbsolute(relativePath) ? relativePath : path.join(basePath || process.cwd(), relativePath);
|
|
79
|
-
let rawContent;
|
|
80
|
-
try {
|
|
81
|
-
rawContent = loadYaml(fs.readFileSync(resolvedPath, "utf8"));
|
|
82
|
-
} catch (err) {
|
|
83
|
-
throw new Error(`Failed to load provider config ${relativePath}: ${err instanceof Error ? err.message : err}`);
|
|
84
|
-
}
|
|
85
|
-
const fileContent = maybeLoadConfigFromExternalFile(rawContent, void 0, basePath);
|
|
86
|
-
invariant(fileContent, `Provider config ${relativePath} is undefined`);
|
|
87
|
-
return {
|
|
88
|
-
configs: [fileContent].flat(),
|
|
89
|
-
relativePath,
|
|
90
|
-
wasArray: Array.isArray(fileContent)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Loads provider config objects from a file-backed provider reference.
|
|
95
|
-
*/
|
|
96
|
-
function loadProviderConfigsFromFile(providerPath, basePath) {
|
|
97
|
-
return readProviderConfigFile(providerPath, basePath).configs;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Pure, synchronous classifier that converts every supported provider reference shape
|
|
101
|
-
* into a discriminated descriptor. Does not read files or instantiate providers.
|
|
102
|
-
*/
|
|
103
|
-
function normalizeProviderRef(provider, options = {}) {
|
|
104
|
-
const { index } = options;
|
|
105
|
-
if (typeof provider === "string") {
|
|
106
|
-
if (!isValidProviderId(provider)) return {
|
|
107
|
-
kind: "unknown",
|
|
108
|
-
id: index === void 0 ? "unknown" : `unknown-${index}`
|
|
109
|
-
};
|
|
110
|
-
if (isProviderConfigFileReference(provider)) return {
|
|
111
|
-
kind: "file",
|
|
112
|
-
id: provider,
|
|
113
|
-
loadProviderPath: provider
|
|
114
|
-
};
|
|
115
|
-
return {
|
|
116
|
-
kind: "named",
|
|
117
|
-
id: provider,
|
|
118
|
-
loadProviderPath: provider
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (typeof provider === "function") {
|
|
122
|
-
const label = getProviderLabel(provider);
|
|
123
|
-
return {
|
|
124
|
-
kind: "function",
|
|
125
|
-
id: label ?? (index === void 0 ? "custom-function" : `custom-function-${index}`),
|
|
126
|
-
label
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
if (typeof provider === "object" && provider !== null && !Array.isArray(provider)) {
|
|
130
|
-
const providerId = provider.id;
|
|
131
|
-
const label = getProviderLabel(provider);
|
|
132
|
-
if (isValidProviderId(providerId)) return {
|
|
133
|
-
kind: "options",
|
|
134
|
-
id: providerId,
|
|
135
|
-
label,
|
|
136
|
-
loadOptions: provider,
|
|
137
|
-
loadProviderPath: providerId
|
|
138
|
-
};
|
|
139
|
-
const keys = Object.keys(provider);
|
|
140
|
-
if (keys.length === 1 && !PROVIDER_OPTION_KEYS.has(keys[0])) {
|
|
141
|
-
const originalId = keys[0];
|
|
142
|
-
const providerObject = provider[originalId];
|
|
143
|
-
if (typeof providerObject === "object" && providerObject !== null && !Array.isArray(providerObject) && isValidProviderId(originalId)) {
|
|
144
|
-
const id = isValidProviderId(providerObject.id) ? providerObject.id : originalId;
|
|
145
|
-
return {
|
|
146
|
-
kind: "map",
|
|
147
|
-
id,
|
|
148
|
-
label: getProviderLabel(providerObject),
|
|
149
|
-
loadOptions: {
|
|
150
|
-
...providerObject,
|
|
151
|
-
id
|
|
152
|
-
},
|
|
153
|
-
loadProviderPath: originalId
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (isValidProviderId(label)) return {
|
|
158
|
-
kind: "unknown",
|
|
159
|
-
id: label,
|
|
160
|
-
label
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
kind: "unknown",
|
|
165
|
-
id: index === void 0 ? "unknown" : `unknown-${index}`
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/util/provider.ts
|
|
170
|
-
function providerToIdentifier(provider) {
|
|
171
|
-
if (!provider) return;
|
|
172
|
-
if (typeof provider === "string") return canonicalizeProviderId(provider);
|
|
173
|
-
const { label } = normalizeProviderRef(provider);
|
|
174
|
-
if (label) return label;
|
|
175
|
-
if (isApiProvider(provider)) return canonicalizeProviderId(provider.id());
|
|
176
|
-
if (isProviderOptions(provider)) {
|
|
177
|
-
if (provider.id) return canonicalizeProviderId(provider.id);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (typeof provider === "object" && "id" in provider && typeof provider.id === "string") return canonicalizeProviderId(provider.id);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Gets the identifier string for a provider (label or id).
|
|
184
|
-
*/
|
|
185
|
-
function getProviderIdentifier(provider) {
|
|
186
|
-
return provider.label || provider.id();
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Gets a descriptive identifier string for a provider, showing both label and ID when both exist.
|
|
190
|
-
* Useful for error messages to help users debug provider reference issues.
|
|
191
|
-
*/
|
|
192
|
-
function getProviderDescription(provider) {
|
|
193
|
-
const label = provider.label;
|
|
194
|
-
const id = provider.id();
|
|
195
|
-
if (label && label !== id) return `${label} (${id})`;
|
|
196
|
-
return id;
|
|
197
|
-
}
|
|
198
|
-
function sanitizeProviderIdForLog(providerId) {
|
|
199
|
-
const descriptionMatch = providerId.match(/^(\S+)(\s+\(.+\))$/);
|
|
200
|
-
if (descriptionMatch) {
|
|
201
|
-
const [, id, description] = descriptionMatch;
|
|
202
|
-
return `${sanitizeProviderIdForLog(id)}${description}`;
|
|
203
|
-
}
|
|
204
|
-
return providerId.includes("://") || providerId.startsWith("/") ? sanitizeUrl(providerId) : providerId;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Checks if a provider reference matches a given provider.
|
|
208
|
-
* Supports exact matching and wildcard patterns.
|
|
209
|
-
*/
|
|
210
|
-
function doesProviderRefMatch(ref, provider) {
|
|
211
|
-
const label = provider.label;
|
|
212
|
-
const id = provider.id();
|
|
213
|
-
const canonicalRef = canonicalizeProviderId(ref);
|
|
214
|
-
const canonicalId = canonicalizeProviderId(id);
|
|
215
|
-
if (label && label === ref) return true;
|
|
216
|
-
if (id === ref || canonicalId === canonicalRef) return true;
|
|
217
|
-
if (ref.endsWith("*")) {
|
|
218
|
-
const prefix = ref.slice(0, -1);
|
|
219
|
-
if (label?.startsWith(prefix) || id.startsWith(prefix) || canonicalId.startsWith(prefix)) return true;
|
|
220
|
-
}
|
|
221
|
-
if (label?.startsWith(`${ref}:`) || id.startsWith(`${ref}:`) || canonicalId.startsWith(`${ref}:`)) return true;
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Checks if a provider is allowed based on a list of allowed references.
|
|
226
|
-
*/
|
|
227
|
-
function isProviderAllowed(provider, allowedProviders) {
|
|
228
|
-
if (!Array.isArray(allowedProviders)) return true;
|
|
229
|
-
if (allowedProviders.length === 0) return false;
|
|
230
|
-
return allowedProviders.some((ref) => doesProviderRefMatch(ref, provider));
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Detects if a provider uses OpenAI models.
|
|
234
|
-
* This includes direct OpenAI providers and Azure OpenAI.
|
|
235
|
-
*/
|
|
236
|
-
function isOpenAiProvider(providerId) {
|
|
237
|
-
const lowerProviderId = providerId.toLowerCase();
|
|
238
|
-
if (lowerProviderId.startsWith("openai:")) return true;
|
|
239
|
-
if (lowerProviderId.startsWith("azureopenai:")) return true;
|
|
240
|
-
if (lowerProviderId.startsWith("azure:")) {
|
|
241
|
-
if ([
|
|
242
|
-
"gpt",
|
|
243
|
-
"openai",
|
|
244
|
-
"davinci",
|
|
245
|
-
"curie",
|
|
246
|
-
"babbage",
|
|
247
|
-
"ada",
|
|
248
|
-
"text-embedding",
|
|
249
|
-
"whisper",
|
|
250
|
-
"dall-e",
|
|
251
|
-
"tts"
|
|
252
|
-
].some((indicator) => lowerProviderId.includes(indicator))) return true;
|
|
253
|
-
}
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Detects if a provider uses Anthropic/Claude models.
|
|
258
|
-
* This includes direct Anthropic providers, Bedrock with Claude, and Vertex with Claude.
|
|
259
|
-
*/
|
|
260
|
-
function isAnthropicProvider(providerId) {
|
|
261
|
-
const lowerProviderId = providerId.toLowerCase();
|
|
262
|
-
if (lowerProviderId.startsWith("anthropic:")) return true;
|
|
263
|
-
if (lowerProviderId.startsWith("bedrock:")) {
|
|
264
|
-
if (lowerProviderId.includes("claude") || lowerProviderId.includes("anthropic")) return true;
|
|
265
|
-
}
|
|
266
|
-
if (lowerProviderId.startsWith("vertex:")) {
|
|
267
|
-
if (lowerProviderId.includes("claude")) return true;
|
|
268
|
-
}
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
const KNOWN_ENV_VARS = {
|
|
272
|
-
openai: "OPENAI_API_KEY",
|
|
273
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
274
|
-
google: "GOOGLE_API_KEY",
|
|
275
|
-
mistral: "MISTRAL_API_KEY",
|
|
276
|
-
cohere: "COHERE_API_KEY",
|
|
277
|
-
replicate: "REPLICATE_API_TOKEN",
|
|
278
|
-
voyage: "VOYAGE_API_KEY",
|
|
279
|
-
ai21: "AI21_API_KEY",
|
|
280
|
-
xai: "XAI_API_KEY",
|
|
281
|
-
groq: "GROQ_API_KEY",
|
|
282
|
-
deepseek: "DEEPSEEK_API_KEY",
|
|
283
|
-
meta: "MODEL_API_KEY",
|
|
284
|
-
moonshot: "MOONSHOT_API_KEY",
|
|
285
|
-
perplexity: "PERPLEXITY_API_KEY",
|
|
286
|
-
hyperbolic: "HYPERBOLIC_API_KEY",
|
|
287
|
-
cerebras: "CEREBRAS_API_KEY",
|
|
288
|
-
togetherai: "TOGETHER_API_KEY",
|
|
289
|
-
fal: "FAL_KEY",
|
|
290
|
-
huggingface: "HF_TOKEN",
|
|
291
|
-
"cloudflare-ai": "CLOUDFLARE_API_KEY"
|
|
292
|
-
};
|
|
293
|
-
function getDefaultEnvVar(providerId) {
|
|
294
|
-
const prefix = providerId.split(":")[0];
|
|
295
|
-
return KNOWN_ENV_VARS[prefix] || `${prefix.toUpperCase()}_API_KEY`;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Pre-checks providers for missing API keys before evaluation starts.
|
|
299
|
-
* Assumes getApiKey() is side-effect free (no network calls or token refresh).
|
|
300
|
-
* Returns stable provider IDs by default; descriptions are for user-facing diagnostics only.
|
|
301
|
-
*/
|
|
302
|
-
function checkProviderApiKeys(providers, options = {}) {
|
|
303
|
-
const missingApiKeys = /* @__PURE__ */ new Map();
|
|
304
|
-
for (const provider of providers) {
|
|
305
|
-
const p = provider;
|
|
306
|
-
if (typeof p.getApiKey !== "function") continue;
|
|
307
|
-
if (provider.id().startsWith("azure:")) continue;
|
|
308
|
-
const requiresKey = typeof p.requiresApiKey === "function" ? p.requiresApiKey() : p.config?.apiKeyRequired !== false;
|
|
309
|
-
let apiKey;
|
|
310
|
-
try {
|
|
311
|
-
apiKey = p.getApiKey();
|
|
312
|
-
} catch {
|
|
313
|
-
apiKey = void 0;
|
|
314
|
-
}
|
|
315
|
-
if (requiresKey && !apiKey) {
|
|
316
|
-
const envVar = p.config?.apiKeyEnvar || getDefaultEnvVar(provider.id());
|
|
317
|
-
const providerIdentifier = options.useDescriptions ? getProviderDescription(provider) : provider.id();
|
|
318
|
-
if (!missingApiKeys.has(envVar)) missingApiKeys.set(envVar, []);
|
|
319
|
-
missingApiKeys.get(envVar).push(providerIdentifier);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return missingApiKeys;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Detects if a provider uses Google models.
|
|
326
|
-
* This includes direct Google/Vertex providers with Gemini and other Google models.
|
|
327
|
-
* Note: Vertex with Claude models is NOT counted as Google (it's Anthropic).
|
|
328
|
-
*/
|
|
329
|
-
function isGoogleProvider(providerId) {
|
|
330
|
-
const lowerProviderId = providerId.toLowerCase();
|
|
331
|
-
if (lowerProviderId.startsWith("google:")) return true;
|
|
332
|
-
if (lowerProviderId.startsWith("vertex:")) {
|
|
333
|
-
if (!lowerProviderId.includes("claude")) return true;
|
|
334
|
-
}
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/util/comparison.ts
|
|
339
|
-
/**
|
|
340
|
-
* Explicit runtime variable names that don't follow the underscore convention.
|
|
341
|
-
* These are added during evaluation but aren't part of the original test definition.
|
|
342
|
-
*
|
|
343
|
-
* - sessionId: Added by multi-turn strategy providers (GOAT, Crescendo)
|
|
344
|
-
*
|
|
345
|
-
* Note: Variables starting with underscore (e.g., _conversation) are automatically
|
|
346
|
-
* treated as runtime variables and filtered out.
|
|
347
|
-
*/
|
|
348
|
-
const EXPLICIT_RUNTIME_VAR_KEYS = ["sessionId"];
|
|
349
|
-
/**
|
|
350
|
-
* Checks if a variable key is a runtime-only variable that should be filtered
|
|
351
|
-
* when comparing test cases.
|
|
352
|
-
*
|
|
353
|
-
* Runtime variables are identified by:
|
|
354
|
-
* 1. Starting with underscore (_) - convention for internal/runtime vars
|
|
355
|
-
* 2. Being in the explicit runtime var list (for legacy vars like sessionId)
|
|
356
|
-
*/
|
|
357
|
-
function isRuntimeVar(key) {
|
|
358
|
-
return key.startsWith("_") || EXPLICIT_RUNTIME_VAR_KEYS.includes(key);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Filters out runtime-only variables that are added during evaluation
|
|
362
|
-
* but aren't part of the original test definition.
|
|
363
|
-
*
|
|
364
|
-
* This is used when comparing test cases to determine if a result
|
|
365
|
-
* corresponds to a particular test, regardless of runtime state.
|
|
366
|
-
*
|
|
367
|
-
* Runtime variables are identified by:
|
|
368
|
-
* - Starting with underscore (e.g., _conversation, _metadata)
|
|
369
|
-
* - Being in the explicit list (e.g., sessionId for backward compatibility)
|
|
370
|
-
*/
|
|
371
|
-
function filterRuntimeVars(vars) {
|
|
372
|
-
if (!vars || typeof vars !== "object" || Array.isArray(vars)) return vars;
|
|
373
|
-
const filtered = {};
|
|
374
|
-
for (const [key, value] of Object.entries(vars)) if (!isRuntimeVar(key)) filtered[key] = value;
|
|
375
|
-
return filtered;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Extracts only runtime variables from a vars object.
|
|
379
|
-
* This is the inverse of filterRuntimeVars.
|
|
380
|
-
*
|
|
381
|
-
* Used to restore runtime state when re-running filtered tests.
|
|
382
|
-
*/
|
|
383
|
-
function extractRuntimeVars(vars) {
|
|
384
|
-
if (!vars || typeof vars !== "object" || Array.isArray(vars)) return;
|
|
385
|
-
const extracted = {};
|
|
386
|
-
for (const [key, value] of Object.entries(vars)) if (isRuntimeVar(key)) extracted[key] = value;
|
|
387
|
-
return Object.keys(extracted).length > 0 ? extracted : void 0;
|
|
388
|
-
}
|
|
389
|
-
function varsMatch(vars1, vars2) {
|
|
390
|
-
return deepEqual(vars1, vars2);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Generate a unique key for a test case for deduplication purposes.
|
|
394
|
-
* Excludes runtime variables and includes strategyId to distinguish tests
|
|
395
|
-
* with the same prompt but different strategies.
|
|
396
|
-
*
|
|
397
|
-
* @param testCase - The test case to generate a key for
|
|
398
|
-
* @returns A JSON string that uniquely identifies the test case
|
|
399
|
-
*/
|
|
400
|
-
function getTestCaseDeduplicationKey(testCase) {
|
|
401
|
-
const filteredVars = filterRuntimeVars(testCase.vars);
|
|
402
|
-
const strategyId = testCase.metadata?.strategyId || "none";
|
|
403
|
-
return JSON.stringify({
|
|
404
|
-
vars: filteredVars,
|
|
405
|
-
strategyId
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Deduplicates an array of test cases based on their vars and strategyId.
|
|
410
|
-
* Tests with the same vars but different strategies are considered different.
|
|
411
|
-
* Runtime variables (like _conversation, sessionId) are filtered out before comparison.
|
|
412
|
-
*
|
|
413
|
-
* @param tests - Array of test cases to deduplicate
|
|
414
|
-
* @returns Deduplicated array of test cases
|
|
415
|
-
*/
|
|
416
|
-
function deduplicateTestCases(tests) {
|
|
417
|
-
const seen = /* @__PURE__ */ new Set();
|
|
418
|
-
return tests.filter((test) => {
|
|
419
|
-
const key = getTestCaseDeduplicationKey(test);
|
|
420
|
-
if (seen.has(key)) return false;
|
|
421
|
-
seen.add(key);
|
|
422
|
-
return true;
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
function resultIsForTestCase(result, testCase) {
|
|
426
|
-
const testProviderId = testCase.provider ? providerToIdentifier(testCase.provider) : void 0;
|
|
427
|
-
const resultProviderId = providerToIdentifier(result.provider);
|
|
428
|
-
const providersMatch = !testProviderId || !resultProviderId || testProviderId === resultProviderId;
|
|
429
|
-
const resultVars = filterRuntimeVars(result.vars);
|
|
430
|
-
const testVars = filterRuntimeVars(testCase.vars);
|
|
431
|
-
const doVarsMatch = varsMatch(testVars, resultVars);
|
|
432
|
-
const isMatch = doVarsMatch && providersMatch;
|
|
433
|
-
if (!isMatch) {
|
|
434
|
-
const varKeys = testVars ? Object.keys(testVars).join(", ") : "none";
|
|
435
|
-
logger.debug(`[resultIsForTestCase] No match: vars=${doVarsMatch}, providers=${providersMatch}`, {
|
|
436
|
-
testProvider: testProviderId || "none",
|
|
437
|
-
resultProvider: resultProviderId || "none",
|
|
438
|
-
testVarKeys: varKeys
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
return isMatch;
|
|
442
|
-
}
|
|
443
|
-
//#endregion
|
|
444
|
-
//#region src/util/env.ts
|
|
445
|
-
/**
|
|
446
|
-
* Load environment variables from .env file(s).
|
|
447
|
-
* @param envPath - Single path, array of paths, or undefined for default .env loading.
|
|
448
|
-
* When paths are explicitly specified, all files must exist or an error is thrown.
|
|
449
|
-
* When multiple files are provided, later files override values from earlier files.
|
|
450
|
-
*/
|
|
451
|
-
function setupEnv(envPath, options = {}) {
|
|
452
|
-
const paths = (Array.isArray(envPath) ? envPath : [envPath ?? ""]).flatMap((p) => p.split(",").map((s) => s.trim())).filter(Boolean);
|
|
453
|
-
if (paths.length > 0) {
|
|
454
|
-
for (const p of paths) if (!fs$2.existsSync(p)) throw new Error(`Environment file not found: ${p}`);
|
|
455
|
-
if (paths.length === 1) logger.info(`Loading environment variables from ${paths[0]}`);
|
|
456
|
-
else logger.info(`Loading environment variables from: ${paths.join(", ")}`);
|
|
457
|
-
}
|
|
458
|
-
const previousEnv = { ...options.processEnv };
|
|
459
|
-
loadEnvFiles(paths.length > 0 ? paths : void 0, {
|
|
460
|
-
...paths.length > 0 && { override: true },
|
|
461
|
-
...options.processEnv && { processEnv: options.processEnv }
|
|
462
|
-
});
|
|
463
|
-
if (options.processEnv && paths.length === 0) {
|
|
464
|
-
for (const key of Object.keys(options.processEnv)) if (!Object.prototype.hasOwnProperty.call(previousEnv, key) && process.env[key] !== void 0) delete options.processEnv[key];
|
|
465
|
-
}
|
|
466
|
-
if (options.refreshConfigDirectory) refreshConfigDirectoryPathFromEnv();
|
|
467
|
-
}
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/googleSheets.ts
|
|
470
|
-
var GoogleSheetAuthenticationRequiredError = class extends Error {
|
|
471
|
-
constructor(message) {
|
|
472
|
-
super(message);
|
|
473
|
-
this.name = "GoogleSheetAuthenticationRequiredError";
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
async function loadGoogleSheetsApi() {
|
|
477
|
-
try {
|
|
478
|
-
return await import("@googleapis/sheets");
|
|
479
|
-
} catch (error) {
|
|
480
|
-
if (isMissingPackageImportError(error, "@googleapis/sheets")) throw new Error("The @googleapis/sheets package is required for authenticated Google Sheets access. Install it with: npm install @googleapis/sheets");
|
|
481
|
-
throw error;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
async function checkGoogleSheetAccess(url) {
|
|
485
|
-
try {
|
|
486
|
-
const response = await fetchWithProxy(url);
|
|
487
|
-
if (response.ok) return {
|
|
488
|
-
public: true,
|
|
489
|
-
status: response.status
|
|
490
|
-
};
|
|
491
|
-
else return {
|
|
492
|
-
public: false,
|
|
493
|
-
status: response.status
|
|
494
|
-
};
|
|
495
|
-
} catch (error) {
|
|
496
|
-
logger.error(`Error checking sheet access: ${error}`);
|
|
497
|
-
return { public: false };
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
function isHtmlExportResponse(response, body) {
|
|
501
|
-
const contentType = response.headers?.get("content-type")?.toLowerCase() ?? "";
|
|
502
|
-
if (contentType.includes("text/html")) return true;
|
|
503
|
-
if (contentType.includes("text/csv") || contentType.includes("application/csv")) return false;
|
|
504
|
-
const prefix = body.trimStart().slice(0, 32).toLowerCase();
|
|
505
|
-
return prefix.startsWith("<!doctype html") || prefix.startsWith("<html");
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Returns the sheet id (`gid`) a Google Sheets URL selects. The browser keeps it in the fragment
|
|
509
|
-
* (`/edit#gid=123`); newer URLs also repeat it in the query (`/edit?gid=123#gid=123`). It stays a
|
|
510
|
-
* string so that sheet id 0 is still truthy.
|
|
511
|
-
*/
|
|
512
|
-
function getSheetGid(url) {
|
|
513
|
-
const { searchParams, hash } = new URL(url);
|
|
514
|
-
return searchParams.get("gid") || new URLSearchParams(hash.slice(1)).get("gid") || void 0;
|
|
515
|
-
}
|
|
516
|
-
async function fetchCsvFromGoogleSheetUnauthenticated(url) {
|
|
517
|
-
const { parse: parseCsv } = await import("csv-parse/sync");
|
|
518
|
-
const gid = getSheetGid(url);
|
|
519
|
-
const csvUrl = `${url.replace(/\/edit.*$/, "/export")}?format=csv${gid ? `&gid=${gid}` : ""}`;
|
|
520
|
-
const response = await fetchWithProxy(csvUrl);
|
|
521
|
-
if (response.status !== 200) throw new Error(`Failed to fetch CSV from Google Sheets URL: ${url}`);
|
|
522
|
-
const csvData = await response.text();
|
|
523
|
-
if (isHtmlExportResponse(response, csvData)) throw new GoogleSheetAuthenticationRequiredError(`Failed to fetch CSV from Google Sheets URL: ${url}`);
|
|
524
|
-
return parseCsv(csvData, { columns: true });
|
|
525
|
-
}
|
|
526
|
-
async function fetchCsvFromGoogleSheetAuthenticated(url) {
|
|
527
|
-
const { sheets: googleSheets, auth: googleAuth } = await loadGoogleSheetsApi();
|
|
528
|
-
const auth = new googleAuth.GoogleAuth({ scopes: ["https://www.googleapis.com/auth/spreadsheets.readonly"] });
|
|
529
|
-
const sheets = googleSheets("v4");
|
|
530
|
-
const match = url.match(/\/d\/([^/]+)/);
|
|
531
|
-
if (!match) throw new Error(`Invalid Google Sheets URL: ${url}`);
|
|
532
|
-
const spreadsheetId = match[1];
|
|
533
|
-
let range;
|
|
534
|
-
const gid = getSheetGid(url);
|
|
535
|
-
if (gid) {
|
|
536
|
-
const sheet = (await sheets.spreadsheets.get({
|
|
537
|
-
spreadsheetId,
|
|
538
|
-
auth
|
|
539
|
-
})).data.sheets?.find((sheet) => sheet.properties?.sheetId === Number(gid));
|
|
540
|
-
if (!sheet || !sheet.properties?.title) throw new Error(`Sheet not found for gid: ${gid}`);
|
|
541
|
-
range = sheet.properties.title;
|
|
542
|
-
} else {
|
|
543
|
-
const firstSheet = (await sheets.spreadsheets.get({
|
|
544
|
-
spreadsheetId,
|
|
545
|
-
auth
|
|
546
|
-
})).data.sheets?.[0];
|
|
547
|
-
if (!firstSheet || !firstSheet.properties?.title) throw new Error(`No sheets found in spreadsheet`);
|
|
548
|
-
range = firstSheet.properties.title;
|
|
549
|
-
}
|
|
550
|
-
const rows = (await sheets.spreadsheets.values.get({
|
|
551
|
-
spreadsheetId,
|
|
552
|
-
range,
|
|
553
|
-
auth
|
|
554
|
-
})).data.values;
|
|
555
|
-
if (!rows?.length) throw new Error(`No data found in Google Sheets URL: ${url}`);
|
|
556
|
-
const headers = rows[0];
|
|
557
|
-
return rows.slice(1).map((row) => {
|
|
558
|
-
const csvRow = {};
|
|
559
|
-
headers.forEach((header, index) => {
|
|
560
|
-
csvRow[header] = row[index] ?? "";
|
|
561
|
-
});
|
|
562
|
-
return csvRow;
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
async function fetchCsvFromGoogleSheet(url) {
|
|
566
|
-
const access = await checkGoogleSheetAccess(url);
|
|
567
|
-
const { public: isPublic } = access;
|
|
568
|
-
logger.debug(`Google Sheets URL: ${url}, isPublic: ${isPublic}`);
|
|
569
|
-
if (isPublic) try {
|
|
570
|
-
return await fetchCsvFromGoogleSheetUnauthenticated(url);
|
|
571
|
-
} catch (error) {
|
|
572
|
-
if (error instanceof GoogleSheetAuthenticationRequiredError) return fetchCsvFromGoogleSheetAuthenticated(url);
|
|
573
|
-
throw error;
|
|
574
|
-
}
|
|
575
|
-
if (!("status" in access)) try {
|
|
576
|
-
return await fetchCsvFromGoogleSheetUnauthenticated(url);
|
|
577
|
-
} catch {
|
|
578
|
-
return fetchCsvFromGoogleSheetAuthenticated(url);
|
|
579
|
-
}
|
|
580
|
-
return fetchCsvFromGoogleSheetAuthenticated(url);
|
|
581
|
-
}
|
|
582
|
-
async function writeCsvToGoogleSheet(rows, url) {
|
|
583
|
-
const { sheets: googleSheets, auth: googleAuth } = await loadGoogleSheetsApi();
|
|
584
|
-
const auth = new googleAuth.GoogleAuth({ scopes: ["https://www.googleapis.com/auth/spreadsheets"] });
|
|
585
|
-
const sheets = googleSheets("v4");
|
|
586
|
-
const match = url.match(/\/d\/([^/]+)/);
|
|
587
|
-
if (!match) throw new Error(`Invalid Google Sheets URL: ${url}`);
|
|
588
|
-
const spreadsheetId = match[1];
|
|
589
|
-
const headers = Object.keys(rows[0]);
|
|
590
|
-
const values = [headers, ...rows.map((row) => headers.map((header) => row[header]))];
|
|
591
|
-
const getColumnLetter = (col) => {
|
|
592
|
-
let letter = "";
|
|
593
|
-
while (col > 0) {
|
|
594
|
-
col--;
|
|
595
|
-
letter = String.fromCharCode(65 + col % 26) + letter;
|
|
596
|
-
col = Math.floor(col / 26);
|
|
597
|
-
}
|
|
598
|
-
return letter;
|
|
599
|
-
};
|
|
600
|
-
const numRows = values.length;
|
|
601
|
-
const numCols = headers.length;
|
|
602
|
-
const endColumn = getColumnLetter(numCols);
|
|
603
|
-
let range;
|
|
604
|
-
const gid = getSheetGid(url);
|
|
605
|
-
if (gid) {
|
|
606
|
-
const sheet = (await sheets.spreadsheets.get({
|
|
607
|
-
spreadsheetId,
|
|
608
|
-
auth
|
|
609
|
-
})).data.sheets?.find((sheet) => sheet.properties?.sheetId === Number(gid));
|
|
610
|
-
if (!sheet || !sheet.properties?.title) throw new Error(`Sheet not found for gid: ${gid}`);
|
|
611
|
-
range = `${sheet.properties.title}!A1:${endColumn}${numRows}`;
|
|
612
|
-
} else {
|
|
613
|
-
const newSheetTitle = `Sheet${Date.now()}`;
|
|
614
|
-
await sheets.spreadsheets.batchUpdate({
|
|
615
|
-
spreadsheetId,
|
|
616
|
-
auth,
|
|
617
|
-
requestBody: { requests: [{ addSheet: { properties: { title: newSheetTitle } } }] }
|
|
618
|
-
});
|
|
619
|
-
range = `${newSheetTitle}!A1:${endColumn}${numRows}`;
|
|
620
|
-
}
|
|
621
|
-
logger.debug(`Writing CSV to Google Sheets URL: ${url} with ${values.length} rows`);
|
|
622
|
-
await sheets.spreadsheets.values.update({
|
|
623
|
-
spreadsheetId,
|
|
624
|
-
range,
|
|
625
|
-
valueInputOption: "USER_ENTERED",
|
|
626
|
-
auth,
|
|
627
|
-
requestBody: { values }
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region src/util/eval/evalTableUtils.ts
|
|
632
|
-
/**
|
|
633
|
-
* Error thrown when a comparison eval is not found.
|
|
634
|
-
*/
|
|
635
|
-
var ComparisonEvalNotFoundError = class extends Error {
|
|
636
|
-
constructor(evalId) {
|
|
637
|
-
super(`Comparison eval not found: ${evalId}`);
|
|
638
|
-
this.name = "ComparisonEvalNotFoundError";
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
/**
|
|
642
|
-
* Keep this in its current order, as it is used to map the columns in the CSV, so it needs to be static.
|
|
643
|
-
*
|
|
644
|
-
* The keys are the names of the columns in the metadata object, and the values are the names of the columns in the CSV.
|
|
645
|
-
*
|
|
646
|
-
* This is imported by enterprise so it doesn't need to be copied.
|
|
647
|
-
*/
|
|
648
|
-
const REDTEAM_METADATA_KEYS_TO_CSV_COLUMN_NAMES = {
|
|
649
|
-
messages: "Messages",
|
|
650
|
-
redteamHistory: "RedteamHistory",
|
|
651
|
-
redteamTreeHistory: "RedteamTreeHistory",
|
|
652
|
-
pluginId: "pluginId",
|
|
653
|
-
strategyId: "strategyId",
|
|
654
|
-
sessionId: "sessionId",
|
|
655
|
-
sessionIds: "sessionIds"
|
|
656
|
-
};
|
|
657
|
-
const REDTEAM_METADATA_COLUMNS = Object.values(REDTEAM_METADATA_KEYS_TO_CSV_COLUMN_NAMES);
|
|
658
|
-
/**
|
|
659
|
-
* Get the status string for an output
|
|
660
|
-
*/
|
|
661
|
-
function getOutputStatus(output) {
|
|
662
|
-
if (output.pass) return "PASS";
|
|
663
|
-
return output.failureReason === ResultFailureReason.ASSERT ? "FAIL" : "ERROR";
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Format named scores for CSV output.
|
|
667
|
-
* Returns empty string if no named scores, otherwise JSON string.
|
|
668
|
-
*/
|
|
669
|
-
function formatNamedScores(namedScores) {
|
|
670
|
-
if (!namedScores || Object.keys(namedScores).length === 0) return "";
|
|
671
|
-
const rounded = {};
|
|
672
|
-
for (const [key, value] of Object.entries(namedScores)) if (typeof value === "number" && !Number.isNaN(value)) rounded[key] = Number(value.toFixed(2));
|
|
673
|
-
if (Object.keys(rounded).length === 0) return "";
|
|
674
|
-
return JSON.stringify(rounded);
|
|
675
|
-
}
|
|
676
|
-
function formatNamedScoreValue(value) {
|
|
677
|
-
return typeof value === "number" && !Number.isNaN(value) ? value.toFixed(2) : "";
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Build a per-prompt list of `Metric: <name>` column names, deduplicated and
|
|
681
|
-
* sorted with `localeCompare`. Shared shell for both the row-scanning helper
|
|
682
|
-
* (WebUI path) and the aggregate-reading helper (streaming CLI path); see the
|
|
683
|
-
* two call sites below.
|
|
684
|
-
*/
|
|
685
|
-
function collectMetricNamesByPrompt(items, namesFor) {
|
|
686
|
-
return items.map((item, index) => [...new Set(namesFor(item, index))].sort((a, b) => a.localeCompare(b)));
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* Collect per-row named metric names by scanning row outputs. Used by the
|
|
690
|
-
* non-streaming WebUI export, which has the full table in memory.
|
|
691
|
-
*
|
|
692
|
-
* Returns one sorted name list per prompt, aligned with `table.head.prompts`.
|
|
693
|
-
* Names whose only values are non-numeric or NaN are skipped so we don't emit
|
|
694
|
-
* blank columns for invalid data.
|
|
695
|
-
*/
|
|
696
|
-
function collectNamedScoreNamesByPrompt(table) {
|
|
697
|
-
return collectMetricNamesByPrompt(table.head.prompts, (_, promptIndex) => {
|
|
698
|
-
const names = [];
|
|
699
|
-
for (const row of table.body) {
|
|
700
|
-
const namedScores = row.outputs[promptIndex]?.namedScores;
|
|
701
|
-
if (!namedScores) continue;
|
|
702
|
-
for (const [name, value] of Object.entries(namedScores)) if (typeof value === "number" && !Number.isNaN(value)) names.push(name);
|
|
703
|
-
}
|
|
704
|
-
return names;
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Collect per-row named metric names from prompt-level aggregate metrics, for
|
|
709
|
-
* use by the streaming CSV path which cannot scan rows up front.
|
|
710
|
-
*
|
|
711
|
-
* Uses `namedScoresCount` because it is incremented only when a per-row
|
|
712
|
-
* result contributes a metric (`src/util/namedMetrics.ts`). Derived metrics
|
|
713
|
-
* write to `namedScores` but not `namedScoresCount` (`src/evaluator.ts`
|
|
714
|
-
* `updateDerivedMetrics`), so this keeps the streaming column set aligned
|
|
715
|
-
* with what `collectNamedScoreNamesByPrompt` would produce from row outputs.
|
|
716
|
-
*
|
|
717
|
-
* Returns an empty list both for prompts with no per-row contributions
|
|
718
|
-
* (`namedScoresCount: {}` — modern eval with no named metrics configured)
|
|
719
|
-
* and for prompts whose count map is missing entirely (legacy/imported
|
|
720
|
-
* evals). Use `promptNeedsDiscoveryFallback` to distinguish the two: only
|
|
721
|
-
* the latter requires a row-scan pre-pass.
|
|
722
|
-
*/
|
|
723
|
-
function collectNamedScoreNamesByPromptFromAggregate(prompts) {
|
|
724
|
-
return collectMetricNamesByPrompt(prompts, (prompt) => {
|
|
725
|
-
const counts = prompt.metrics?.namedScoresCount;
|
|
726
|
-
if (!counts) return [];
|
|
727
|
-
return Object.keys(counts).filter((name) => (counts[name] ?? 0) > 0);
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* True when a prompt's aggregate `metrics.namedScoresCount` is missing/absent,
|
|
732
|
-
* not merely empty. Legacy evals persisted before count tracking shipped, and
|
|
733
|
-
* external imports via `POST /api/eval` that don't backfill the count, both
|
|
734
|
-
* land here. Modern evals always have an object (possibly empty) and skip the
|
|
735
|
-
* discovery pass.
|
|
736
|
-
*/
|
|
737
|
-
function promptNeedsDiscoveryFallback(prompt) {
|
|
738
|
-
const metrics = prompt.metrics;
|
|
739
|
-
return !metrics || !metrics.namedScoresCount;
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Scan one batch of `EvalResult` rows for the metric names that will need
|
|
743
|
-
* dedicated `Metric: <name>` columns. Only inspects the prompts in
|
|
744
|
-
* `fallbackPromptIndices` (those whose aggregate `namedScoresCount` is
|
|
745
|
-
* missing/empty), and only touches `namedScores` + `testCase.description` —
|
|
746
|
-
* not the full row shape — so the discovery pass stays allocation-light even
|
|
747
|
-
* for very large legacy evals.
|
|
748
|
-
*
|
|
749
|
-
* Mirrors the row-output filter in `collectNamedScoreNamesByPrompt` so the
|
|
750
|
-
* streaming CSV column set matches the WebUI CSV column set.
|
|
751
|
-
*/
|
|
752
|
-
function scanBatchForDiscovery(batchResults, acc, fallbackPromptIndices) {
|
|
753
|
-
for (const result of batchResults) {
|
|
754
|
-
if (!acc.hasDescriptions && result.testCase?.description) acc.hasDescriptions = true;
|
|
755
|
-
if (!fallbackPromptIndices.has(result.promptIdx)) continue;
|
|
756
|
-
const namedScores = result.namedScores;
|
|
757
|
-
if (!namedScores) continue;
|
|
758
|
-
let names = acc.metricNamesByPrompt.get(result.promptIdx);
|
|
759
|
-
if (!names) {
|
|
760
|
-
names = /* @__PURE__ */ new Set();
|
|
761
|
-
acc.metricNamesByPrompt.set(result.promptIdx, names);
|
|
762
|
-
}
|
|
763
|
-
for (const [name, value] of Object.entries(namedScores)) if (typeof value === "number" && !Number.isNaN(value)) names.add(name);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Convert a batch of `EvalResult` rows (grouped by testIdx) into the table-row
|
|
768
|
-
* shape that `tableRowToCsvValues` accepts. Used by `streamEvalCsv` to keep its
|
|
769
|
-
* per-batch processing tight; the outputs array is pre-sized so columns line up
|
|
770
|
-
* with prompts even when results arrive out of promptIdx order.
|
|
771
|
-
*/
|
|
772
|
-
function batchToStreamRows(batchResults, varNames, numPrompts) {
|
|
773
|
-
const rowsByTestIdx = /* @__PURE__ */ new Map();
|
|
774
|
-
for (const result of batchResults) {
|
|
775
|
-
let row = rowsByTestIdx.get(result.testIdx);
|
|
776
|
-
if (!row) {
|
|
777
|
-
row = {
|
|
778
|
-
vars: varNames.map((varName) => {
|
|
779
|
-
const value = result.testCase?.vars?.[varName];
|
|
780
|
-
return value === void 0 ? "" : String(value);
|
|
781
|
-
}),
|
|
782
|
-
outputs: new Array(numPrompts).fill(null),
|
|
783
|
-
test: { description: result.testCase?.description }
|
|
784
|
-
};
|
|
785
|
-
rowsByTestIdx.set(result.testIdx, row);
|
|
786
|
-
}
|
|
787
|
-
row.outputs[result.promptIdx] = {
|
|
788
|
-
text: result.response?.output ?? "",
|
|
789
|
-
pass: result.success,
|
|
790
|
-
score: result.score,
|
|
791
|
-
namedScores: result.namedScores,
|
|
792
|
-
failureReason: result.failureReason,
|
|
793
|
-
gradingResult: result.gradingResult,
|
|
794
|
-
metadata: result.metadata
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
return Array.from(rowsByTestIdx.values());
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Build CSV headers for an evaluation table.
|
|
801
|
-
*
|
|
802
|
-
* @param vars - Variable names from the table head
|
|
803
|
-
* @param prompts - Prompt definitions from the table head
|
|
804
|
-
* @param options - Export options
|
|
805
|
-
* @param options.namedScoreNamesByPrompt - Named metric names that should get
|
|
806
|
-
* dedicated `Metric: <name>` columns, one sorted list per prompt (aligned
|
|
807
|
-
* with `prompts`). Must match the value passed to `tableRowToCsvValues` so
|
|
808
|
-
* header and row column counts stay in sync.
|
|
809
|
-
* @returns Array of header strings
|
|
810
|
-
*/
|
|
811
|
-
function buildCsvHeaders(vars, prompts, options = {}) {
|
|
812
|
-
const headers = [
|
|
813
|
-
...options.hasDescriptions ? ["Description"] : [],
|
|
814
|
-
...vars,
|
|
815
|
-
...prompts.flatMap((prompt, promptIndex) => {
|
|
816
|
-
const provider = prompt.provider || "";
|
|
817
|
-
return [
|
|
818
|
-
provider ? `[${provider}] ${prompt.label}` : prompt.label,
|
|
819
|
-
"Status",
|
|
820
|
-
"Score",
|
|
821
|
-
"Named Scores",
|
|
822
|
-
...(options.namedScoreNamesByPrompt?.[promptIndex] || []).map((name) => `Metric: ${name}`),
|
|
823
|
-
"Grader Reason",
|
|
824
|
-
"Comment"
|
|
825
|
-
];
|
|
826
|
-
})
|
|
827
|
-
];
|
|
828
|
-
if (options.isRedteam) headers.push(...REDTEAM_METADATA_COLUMNS);
|
|
829
|
-
return headers;
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Convert a single table row to CSV row values.
|
|
833
|
-
*
|
|
834
|
-
* @param row - The table row to convert
|
|
835
|
-
* @param options - Export options (`namedScoreNamesByPrompt` must match the
|
|
836
|
-
* array passed to `buildCsvHeaders`)
|
|
837
|
-
* @returns Array of values for the CSV row
|
|
838
|
-
*/
|
|
839
|
-
function tableRowToCsvValues(row, options = {}) {
|
|
840
|
-
const rowValues = [
|
|
841
|
-
...options.hasDescriptions ? [row.test.description || ""] : [],
|
|
842
|
-
...row.vars,
|
|
843
|
-
...row.outputs.flatMap((output, outputIndex) => {
|
|
844
|
-
const namedScoreNames = options.namedScoreNamesByPrompt?.[outputIndex] || [];
|
|
845
|
-
if (!output) return [
|
|
846
|
-
"",
|
|
847
|
-
"",
|
|
848
|
-
"",
|
|
849
|
-
"",
|
|
850
|
-
...namedScoreNames.map(() => ""),
|
|
851
|
-
"",
|
|
852
|
-
""
|
|
853
|
-
];
|
|
854
|
-
const status = getOutputStatus(output);
|
|
855
|
-
const score = output.score?.toFixed(2) ?? "";
|
|
856
|
-
const namedScores = formatNamedScores(output.namedScores);
|
|
857
|
-
const namedScoreValues = namedScoreNames.map((name) => formatNamedScoreValue(output.namedScores?.[name]));
|
|
858
|
-
return [
|
|
859
|
-
output.text || "",
|
|
860
|
-
status,
|
|
861
|
-
score,
|
|
862
|
-
namedScores,
|
|
863
|
-
...namedScoreValues,
|
|
864
|
-
output.gradingResult?.reason || "",
|
|
865
|
-
output.gradingResult?.comment || ""
|
|
866
|
-
];
|
|
867
|
-
})
|
|
868
|
-
];
|
|
869
|
-
if (options.isRedteam) {
|
|
870
|
-
const redteamKeys = Object.keys(REDTEAM_METADATA_KEYS_TO_CSV_COLUMN_NAMES);
|
|
871
|
-
const firstOutputMetadata = row.outputs[0]?.metadata;
|
|
872
|
-
for (const key of redteamKeys) {
|
|
873
|
-
let value = firstOutputMetadata?.[key];
|
|
874
|
-
if (key === "strategyId" && (value === null || value === void 0)) value = "basic";
|
|
875
|
-
if (value === null || value === void 0) rowValues.push("");
|
|
876
|
-
else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") rowValues.push(value.toString());
|
|
877
|
-
else rowValues.push(JSON.stringify(value));
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
return rowValues;
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Escape every cell of a CSV row matrix (headers + body) against spreadsheet
|
|
884
|
-
* formula injection (CWE-1236), unless disabled via
|
|
885
|
-
* `PROMPTFOO_DISABLE_CSV_FORMULA_ESCAPING`. Numbers and booleans pass through
|
|
886
|
-
* untouched; only string cells are inspected. Applied at the `csvStringify`
|
|
887
|
-
* boundary so `buildCsvHeaders`/`tableRowToCsvValues` stay pure and re-importable
|
|
888
|
-
* CSVs are never produced from un-escaped data.
|
|
889
|
-
*/
|
|
890
|
-
function escapeCsvRowsForFormulaInjection(rows, env) {
|
|
891
|
-
const configuredValue = env?.PROMPTFOO_DISABLE_CSV_FORMULA_ESCAPING ?? process.env.PROMPTFOO_DISABLE_CSV_FORMULA_ESCAPING;
|
|
892
|
-
if ([
|
|
893
|
-
"1",
|
|
894
|
-
"true",
|
|
895
|
-
"yes",
|
|
896
|
-
"yup",
|
|
897
|
-
"yeppers"
|
|
898
|
-
].includes(configuredValue?.toLowerCase() ?? "")) return rows;
|
|
899
|
-
return rows.map((row) => row.map((cell) => typeof cell === "string" ? escapeCsvFormula(cell) : cell));
|
|
900
|
-
}
|
|
901
|
-
function isNumericCell(value) {
|
|
902
|
-
return value.trim() !== "" && Number.isFinite(Number(value));
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Neutralize spreadsheet formula (CSV) injection at eval export time (CWE-1236).
|
|
906
|
-
*
|
|
907
|
-
* Spreadsheet applications execute cells beginning with `=`, `+`, `-`, or `@`
|
|
908
|
-
* as formulas. Exported eval data can contain attacker-controlled model output,
|
|
909
|
-
* variables, and grader comments, and CSV quoting alone does not neutralize
|
|
910
|
-
* those formulas. Prefix dangerous values with the spreadsheet-native text
|
|
911
|
-
* marker while preserving finite signed numbers.
|
|
912
|
-
*
|
|
913
|
-
* Leading whitespace and zero-width characters are ignored when identifying a
|
|
914
|
-
* trigger because spreadsheet applications can strip them before evaluation.
|
|
915
|
-
*/
|
|
916
|
-
function escapeCsvFormula(value) {
|
|
917
|
-
if (value.length === 0) return value;
|
|
918
|
-
const unpadded = value.replace(/^[\s\u200B\u200C\u200D]+/, "");
|
|
919
|
-
const firstChar = unpadded[0];
|
|
920
|
-
if (firstChar === void 0) return value;
|
|
921
|
-
return firstChar === "=" || firstChar === "@" || (firstChar === "-" || firstChar === "+") && !isNumericCell(unpadded) ? `'${value}` : value;
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* Generates CSV data from evaluation table data.
|
|
925
|
-
*
|
|
926
|
-
* Column structure per prompt:
|
|
927
|
-
* - Output: Pure LLM output text (no pass/fail prefix)
|
|
928
|
-
* - Status: PASS | FAIL | ERROR
|
|
929
|
-
* - Score: Numeric score (e.g., "1.00")
|
|
930
|
-
* - Named Scores: JSON object with per-assertion scores (e.g., {"clarity": 0.90, "accuracy": 0.85})
|
|
931
|
-
* - Metric: <name>: One dedicated column per distinct per-row named score,
|
|
932
|
-
* sorted alphabetically by name. Empty when a row has no value for that
|
|
933
|
-
* metric. Derived metrics are intentionally omitted (they live on the
|
|
934
|
-
* aggregate prompt metrics, not on individual rows).
|
|
935
|
-
* - Grader Reason: Explanation from the grader
|
|
936
|
-
* - Comment: Additional grader comment
|
|
937
|
-
*
|
|
938
|
-
* This function is the single source of truth for CSV generation,
|
|
939
|
-
* used by both the WebUI export and CLI export.
|
|
940
|
-
*
|
|
941
|
-
* @param table - The evaluation table data
|
|
942
|
-
* @param options - Export options
|
|
943
|
-
* @returns CSV formatted string
|
|
944
|
-
*/
|
|
945
|
-
function evalTableToCsv(table, options = {}) {
|
|
946
|
-
const { env, isRedteam = false } = options;
|
|
947
|
-
const hasDescriptions = table.body.some((row) => row.test.description);
|
|
948
|
-
const namedScoreNamesByPrompt = collectNamedScoreNamesByPrompt(table);
|
|
949
|
-
const csvRows = [buildCsvHeaders(table.head.vars, table.head.prompts, {
|
|
950
|
-
hasDescriptions,
|
|
951
|
-
isRedteam,
|
|
952
|
-
namedScoreNamesByPrompt
|
|
953
|
-
}), ...table.body.map((row) => tableRowToCsvValues(row, {
|
|
954
|
-
hasDescriptions,
|
|
955
|
-
isRedteam,
|
|
956
|
-
namedScoreNamesByPrompt
|
|
957
|
-
}))];
|
|
958
|
-
return stringify(escapeCsvRowsForFormulaInjection(csvRows, env));
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Generate JSON data from evaluation table
|
|
962
|
-
* @param table Evaluation table data
|
|
963
|
-
* @returns JSON object
|
|
964
|
-
*/
|
|
965
|
-
function evalTableToJson(table) {
|
|
966
|
-
return table;
|
|
967
|
-
}
|
|
968
|
-
function getEvalTableOutputPromptLocationsBySize(payload) {
|
|
969
|
-
return payload.table.body.flatMap((row, rowIndex) => row.outputs.flatMap((output, outputIndex) => output?.prompt ? [{
|
|
970
|
-
rowIndex,
|
|
971
|
-
outputIndex,
|
|
972
|
-
length: output.prompt.length
|
|
973
|
-
}] : [])).sort((a, b) => b.length - a.length);
|
|
974
|
-
}
|
|
975
|
-
function stripEvalTableOutputPrompts(payload, locationsToStrip) {
|
|
976
|
-
return {
|
|
977
|
-
...payload,
|
|
978
|
-
table: {
|
|
979
|
-
...payload.table,
|
|
980
|
-
body: payload.table.body.map((row, rowIndex) => ({
|
|
981
|
-
...row,
|
|
982
|
-
outputs: row.outputs.map((output, outputIndex) => {
|
|
983
|
-
if (!output || !locationsToStrip.has(`${rowIndex}:${outputIndex}`)) return output;
|
|
984
|
-
return {
|
|
985
|
-
...output,
|
|
986
|
-
prompt: ""
|
|
987
|
-
};
|
|
988
|
-
})
|
|
989
|
-
}))
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
function getEvalTablePromptStrippedPayload(payload, promptLocations, promptCountToStrip) {
|
|
994
|
-
return stripEvalTableOutputPrompts(payload, new Set(promptLocations.slice(0, promptCountToStrip).map(({ rowIndex, outputIndex }) => `${rowIndex}:${outputIndex}`)));
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Merges comparison tables with the main table for side-by-side CSV export.
|
|
998
|
-
*
|
|
999
|
-
* @param mainEvalId - The ID of the main evaluation
|
|
1000
|
-
* @param mainTable - The main evaluation table
|
|
1001
|
-
* @param comparisonData - Array of comparison eval data (eval ID and table)
|
|
1002
|
-
* @returns Merged table with all prompts and outputs combined
|
|
1003
|
-
*/
|
|
1004
|
-
function mergeComparisonTables(mainEvalId, mainTable, comparisonData) {
|
|
1005
|
-
return {
|
|
1006
|
-
head: {
|
|
1007
|
-
prompts: [...mainTable.head.prompts.map((prompt) => ({
|
|
1008
|
-
...prompt,
|
|
1009
|
-
label: `[${mainEvalId}] ${prompt.label || ""}`
|
|
1010
|
-
})), ...comparisonData.flatMap(({ evalId, table }) => table.head.prompts.map((prompt) => ({
|
|
1011
|
-
...prompt,
|
|
1012
|
-
label: `[${evalId}] ${prompt.label || ""}`
|
|
1013
|
-
})))],
|
|
1014
|
-
vars: mainTable.head.vars
|
|
1015
|
-
},
|
|
1016
|
-
body: mainTable.body.map((row) => {
|
|
1017
|
-
const testIdx = row.testIdx;
|
|
1018
|
-
const matchingRows = comparisonData.map(({ table }) => table.body.find((compRow) => compRow.testIdx === testIdx)).filter((r) => r !== void 0);
|
|
1019
|
-
return {
|
|
1020
|
-
...row,
|
|
1021
|
-
outputs: [...row.outputs, ...matchingRows.flatMap((r) => r.outputs)]
|
|
1022
|
-
};
|
|
1023
|
-
})
|
|
1024
|
-
};
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* High-level function to generate CSV from an evaluation.
|
|
1028
|
-
*
|
|
1029
|
-
* Used by WebUI for CSV downloads (with or without comparison evals).
|
|
1030
|
-
* For CLI exports, use `streamEvalCsv` which is more memory-efficient
|
|
1031
|
-
* for large datasets.
|
|
1032
|
-
*
|
|
1033
|
-
* Both functions use the same underlying formatting (`evalTableToCsv`,
|
|
1034
|
-
* `buildCsvHeaders`, `tableRowToCsvValues`) to ensure consistent output.
|
|
1035
|
-
*
|
|
1036
|
-
* @param eval_ - The evaluation to export
|
|
1037
|
-
* @param options - Export options including filters and comparison eval IDs
|
|
1038
|
-
* @returns CSV formatted string
|
|
1039
|
-
* @throws ComparisonEvalNotFoundError if a comparison eval ID is not found
|
|
1040
|
-
* @throws Error if comparison exports requested without findEvalById callback
|
|
1041
|
-
*/
|
|
1042
|
-
async function generateEvalCsv(eval_, options = {}) {
|
|
1043
|
-
const UNLIMITED_RESULTS = Number.MAX_SAFE_INTEGER;
|
|
1044
|
-
const mainTable = await eval_.getTablePage({
|
|
1045
|
-
offset: 0,
|
|
1046
|
-
limit: UNLIMITED_RESULTS,
|
|
1047
|
-
filterMode: options.filterMode,
|
|
1048
|
-
searchQuery: options.searchQuery,
|
|
1049
|
-
filters: options.filters
|
|
1050
|
-
});
|
|
1051
|
-
let finalTable = mainTable;
|
|
1052
|
-
if (options.comparisonEvalIds && options.comparisonEvalIds.length > 0) {
|
|
1053
|
-
if (!options.findEvalById) throw new Error("findEvalById callback is required for comparison exports. Pass Eval.findById when calling from server routes.");
|
|
1054
|
-
const indices = mainTable.body.map((row) => row.testIdx);
|
|
1055
|
-
const comparisonData = await Promise.all(options.comparisonEvalIds.map(async (comparisonEvalId) => {
|
|
1056
|
-
const comparisonEval = await options.findEvalById(comparisonEvalId);
|
|
1057
|
-
if (!comparisonEval) throw new ComparisonEvalNotFoundError(comparisonEvalId);
|
|
1058
|
-
const table = await comparisonEval.getTablePage({
|
|
1059
|
-
offset: 0,
|
|
1060
|
-
limit: indices.length,
|
|
1061
|
-
filterMode: "all",
|
|
1062
|
-
testIndices: indices,
|
|
1063
|
-
searchQuery: options.searchQuery,
|
|
1064
|
-
filters: options.filters
|
|
1065
|
-
});
|
|
1066
|
-
return {
|
|
1067
|
-
evalId: comparisonEval.id,
|
|
1068
|
-
table
|
|
1069
|
-
};
|
|
1070
|
-
}));
|
|
1071
|
-
finalTable = mergeComparisonTables(eval_.id, mainTable, comparisonData);
|
|
1072
|
-
}
|
|
1073
|
-
return evalTableToCsv(finalTable, {
|
|
1074
|
-
env: eval_.config.env,
|
|
1075
|
-
isRedteam: Boolean(eval_.config.redteam)
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Stream CSV data from an evaluation in batches.
|
|
1080
|
-
*
|
|
1081
|
-
* This is more memory-efficient for large evaluations as it processes
|
|
1082
|
-
* results in batches rather than loading everything into memory.
|
|
1083
|
-
*
|
|
1084
|
-
* Used by the CLI export (`promptfoo eval -o output.csv`) to maintain
|
|
1085
|
-
* consistent CSV format with WebUI exports while handling large datasets.
|
|
1086
|
-
*
|
|
1087
|
-
* @param eval_ - The evaluation to export
|
|
1088
|
-
* @param options - Streaming options including the write callback
|
|
1089
|
-
*/
|
|
1090
|
-
async function streamEvalCsv(eval_, options) {
|
|
1091
|
-
const { isRedteam = false, write } = options;
|
|
1092
|
-
const env = eval_.config?.env;
|
|
1093
|
-
const varNames = eval_.vars;
|
|
1094
|
-
const prompts = eval_.prompts;
|
|
1095
|
-
const numPrompts = prompts.length;
|
|
1096
|
-
const namedScoreNamesByPrompt = collectNamedScoreNamesByPromptFromAggregate(prompts);
|
|
1097
|
-
const fallbackPromptIndices = prompts.flatMap((prompt, promptIndex) => promptNeedsDiscoveryFallback(prompt) ? [promptIndex] : []);
|
|
1098
|
-
const fallbackPromptIndexSet = new Set(fallbackPromptIndices);
|
|
1099
|
-
const accumulator = {
|
|
1100
|
-
metricNamesByPrompt: /* @__PURE__ */ new Map(),
|
|
1101
|
-
hasDescriptions: false
|
|
1102
|
-
};
|
|
1103
|
-
for await (const batchResults of eval_.fetchResultsBatched()) scanBatchForDiscovery(batchResults, accumulator, fallbackPromptIndexSet);
|
|
1104
|
-
const hasDescriptions = accumulator.hasDescriptions;
|
|
1105
|
-
for (const promptIndex of fallbackPromptIndices) {
|
|
1106
|
-
const names = accumulator.metricNamesByPrompt.get(promptIndex);
|
|
1107
|
-
namedScoreNamesByPrompt[promptIndex] = names ? [...names].sort((a, b) => a.localeCompare(b)) : [];
|
|
1108
|
-
}
|
|
1109
|
-
const headers = buildCsvHeaders(varNames, prompts, {
|
|
1110
|
-
hasDescriptions,
|
|
1111
|
-
isRedteam,
|
|
1112
|
-
namedScoreNamesByPrompt
|
|
1113
|
-
});
|
|
1114
|
-
await write(stringify(escapeCsvRowsForFormulaInjection([headers], env)));
|
|
1115
|
-
for await (const batchResults of eval_.fetchResultsBatched()) {
|
|
1116
|
-
const csvRows = batchToStreamRows(batchResults, varNames, numPrompts).map((row) => tableRowToCsvValues(row, {
|
|
1117
|
-
hasDescriptions,
|
|
1118
|
-
isRedteam,
|
|
1119
|
-
namedScoreNamesByPrompt
|
|
1120
|
-
}));
|
|
1121
|
-
if (csvRows.length > 0) await write(stringify(escapeCsvRowsForFormulaInjection(csvRows, env)));
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
//#endregion
|
|
1125
|
-
//#region src/util/junit.ts
|
|
1126
|
-
const MAX_JUNIT_NAME_LENGTH = 512;
|
|
1127
|
-
const MAX_JUNIT_DETAIL_LENGTH = 8192;
|
|
1128
|
-
const JUNIT_ASSERTION_FAILURE_MESSAGE = "Assertion failed";
|
|
1129
|
-
const JUNIT_EVALUATION_ERROR_MESSAGE = "Evaluation error";
|
|
1130
|
-
const INVALID_XML_CHARACTERS = /[^\t\n\r\u0020-\ud7ff\ue000-\ufffd\u{10000}-\u{10ffff}]/gu;
|
|
1131
|
-
function truncateText(value, maxLength) {
|
|
1132
|
-
if (value.length <= maxLength) return value;
|
|
1133
|
-
const cutoff = maxLength - 3;
|
|
1134
|
-
const end = (value.codePointAt(cutoff - 1) ?? 0) > 65535 ? cutoff + 1 : cutoff;
|
|
1135
|
-
return `${value.slice(0, end)}...`;
|
|
1136
|
-
}
|
|
1137
|
-
function normalizeInlineText(value, fallback, maxLength = MAX_JUNIT_NAME_LENGTH) {
|
|
1138
|
-
return truncateText((value ?? "").replace(/\s+/g, " ").replace(INVALID_XML_CHARACTERS, "").replace(/\s+/g, " ").trim() || fallback, maxLength);
|
|
1139
|
-
}
|
|
1140
|
-
function formatDurationSeconds(durationMs) {
|
|
1141
|
-
return Number(((typeof durationMs === "number" && Number.isFinite(durationMs) && durationMs > 0 ? durationMs : 0) / 1e3).toFixed(3)).toString();
|
|
1142
|
-
}
|
|
1143
|
-
function getEvaluationTimestamp(evalRecord) {
|
|
1144
|
-
const date = new Date(evalRecord.createdAt);
|
|
1145
|
-
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1146
|
-
}
|
|
1147
|
-
function getTestCaseName(result) {
|
|
1148
|
-
const prefix = `test ${result.testIdx + 1}`;
|
|
1149
|
-
const description = normalizeInlineText(result.description || result.testCase.description, "");
|
|
1150
|
-
return description ? `${prefix}: ${description}` : prefix;
|
|
1151
|
-
}
|
|
1152
|
-
function getFailedComponentResults(gradingResult) {
|
|
1153
|
-
return gradingResult?.componentResults?.filter((component) => !component.pass) ?? [];
|
|
1154
|
-
}
|
|
1155
|
-
function getAssertionLabel(gradingResult) {
|
|
1156
|
-
return gradingResult.assertion?.type ?? "assertion";
|
|
1157
|
-
}
|
|
1158
|
-
function getFailedAssertionLabels(gradingResult) {
|
|
1159
|
-
const failedComponents = getFailedComponentResults(gradingResult);
|
|
1160
|
-
if (failedComponents.length > 0) return failedComponents.map(getAssertionLabel);
|
|
1161
|
-
return gradingResult ? [getAssertionLabel(gradingResult)] : [];
|
|
1162
|
-
}
|
|
1163
|
-
function getFailureDetails(result) {
|
|
1164
|
-
const lines = [`Score: ${result.score}`, `Reason: ${JUNIT_ASSERTION_FAILURE_MESSAGE}`];
|
|
1165
|
-
const failedAssertionLabels = getFailedAssertionLabels(result.gradingResult);
|
|
1166
|
-
if (failedAssertionLabels.length > 0) {
|
|
1167
|
-
lines.push("Failed assertions:");
|
|
1168
|
-
for (const label of failedAssertionLabels) lines.push(`- ${label}`);
|
|
1169
|
-
}
|
|
1170
|
-
return truncateText(lines.join("\n").replace(INVALID_XML_CHARACTERS, ""), MAX_JUNIT_DETAIL_LENGTH);
|
|
1171
|
-
}
|
|
1172
|
-
function projectEvalResult(result) {
|
|
1173
|
-
const projected = "toEvaluateResult" in result ? result.toEvaluateResult() : result;
|
|
1174
|
-
return {
|
|
1175
|
-
description: projected.description,
|
|
1176
|
-
error: projected.error,
|
|
1177
|
-
failureReason: projected.failureReason,
|
|
1178
|
-
gradingResult: projected.gradingResult,
|
|
1179
|
-
latencyMs: projected.latencyMs,
|
|
1180
|
-
prompt: projected.prompt,
|
|
1181
|
-
promptId: projected.promptId,
|
|
1182
|
-
promptIdx: projected.promptIdx,
|
|
1183
|
-
provider: projected.provider,
|
|
1184
|
-
score: projected.score,
|
|
1185
|
-
success: projected.success,
|
|
1186
|
-
testCase: projected.testCase,
|
|
1187
|
-
testIdx: projected.testIdx
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
async function* iterateJunitProjectedResults(evalRecord) {
|
|
1191
|
-
if (evalRecord.useOldResults()) {
|
|
1192
|
-
const results = await evalRecord.getResults();
|
|
1193
|
-
for (const result of results) yield projectEvalResult(result);
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
if (!evalRecord.persisted) {
|
|
1197
|
-
for (const result of evalRecord.results) yield projectEvalResult(result);
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
for await (const batchResults of evalRecord.fetchResultsBatched()) for (const result of batchResults) yield projectEvalResult(result);
|
|
1201
|
-
}
|
|
1202
|
-
async function buildJunitSuites(evalRecord) {
|
|
1203
|
-
const suites = /* @__PURE__ */ new Map();
|
|
1204
|
-
const providersByDisplayName = /* @__PURE__ */ new Map();
|
|
1205
|
-
for await (const result of iterateJunitProjectedResults(evalRecord)) {
|
|
1206
|
-
const { provider } = result;
|
|
1207
|
-
const providerKey = JSON.stringify([provider.id ?? "", provider.label ?? ""]);
|
|
1208
|
-
const promptKey = result.promptId || `prompt-index:${result.promptIdx}`;
|
|
1209
|
-
const key = JSON.stringify([providerKey, promptKey]);
|
|
1210
|
-
let suite = suites.get(key);
|
|
1211
|
-
if (!suite) {
|
|
1212
|
-
const rawName = provider.label || provider.id || "";
|
|
1213
|
-
const displayName = normalizeInlineText(rawName, "unknown provider");
|
|
1214
|
-
const providers = providersByDisplayName.get(displayName) ?? /* @__PURE__ */ new Set();
|
|
1215
|
-
providers.add(providerKey);
|
|
1216
|
-
providersByDisplayName.set(displayName, providers);
|
|
1217
|
-
suite = {
|
|
1218
|
-
providerKey,
|
|
1219
|
-
rawName,
|
|
1220
|
-
promptKey,
|
|
1221
|
-
promptIdx: result.promptIdx,
|
|
1222
|
-
displayName: "",
|
|
1223
|
-
errors: 0,
|
|
1224
|
-
failures: 0,
|
|
1225
|
-
testcases: [],
|
|
1226
|
-
timeMs: 0
|
|
1227
|
-
};
|
|
1228
|
-
suites.set(key, suite);
|
|
1229
|
-
}
|
|
1230
|
-
suite.promptIdx = Math.min(suite.promptIdx, result.promptIdx);
|
|
1231
|
-
suite.testcases.push({
|
|
1232
|
-
testcase: buildJunitTestCase(result),
|
|
1233
|
-
testIdx: result.testIdx
|
|
1234
|
-
});
|
|
1235
|
-
suite.timeMs += result.latencyMs;
|
|
1236
|
-
if (!result.success) {
|
|
1237
|
-
if (result.failureReason === ResultFailureReason.ASSERT) suite.failures += 1;
|
|
1238
|
-
else suite.errors += 1;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
const promptCountsByProvider = /* @__PURE__ */ new Map();
|
|
1242
|
-
const orderedSuites = [...suites.values()].sort((a, b) => a.promptIdx - b.promptIdx || a.promptKey.localeCompare(b.promptKey));
|
|
1243
|
-
for (const suite of orderedSuites) {
|
|
1244
|
-
const baseName = normalizeInlineText(suite.rawName, "unknown provider");
|
|
1245
|
-
const suffix = (providersByDisplayName.get(baseName)?.size ?? 0) > 1 || suite.rawName.search(INVALID_XML_CHARACTERS) !== -1 ? ` (${sha256(suite.providerKey).slice(0, 16)})` : "";
|
|
1246
|
-
const providerName = normalizeInlineText(suite.rawName, "unknown provider", MAX_JUNIT_NAME_LENGTH - suffix.length);
|
|
1247
|
-
const ordinal = (promptCountsByProvider.get(suite.providerKey) ?? 0) + 1;
|
|
1248
|
-
promptCountsByProvider.set(suite.providerKey, ordinal);
|
|
1249
|
-
suite.displayName = `[${providerName}] prompt ${ordinal}${suffix}`;
|
|
1250
|
-
for (const { testcase } of suite.testcases) testcase["@_classname"] = suite.displayName;
|
|
1251
|
-
}
|
|
1252
|
-
return [...suites.values()];
|
|
1253
|
-
}
|
|
1254
|
-
function buildJunitTestCase(result) {
|
|
1255
|
-
const testcase = {
|
|
1256
|
-
"@_name": getTestCaseName(result),
|
|
1257
|
-
"@_time": formatDurationSeconds(result.latencyMs)
|
|
1258
|
-
};
|
|
1259
|
-
if (!result.success) {
|
|
1260
|
-
if (result.failureReason === ResultFailureReason.ASSERT) testcase.failure = {
|
|
1261
|
-
"#text": getFailureDetails(result),
|
|
1262
|
-
"@_message": JUNIT_ASSERTION_FAILURE_MESSAGE,
|
|
1263
|
-
"@_type": "assertion"
|
|
1264
|
-
};
|
|
1265
|
-
else testcase.error = {
|
|
1266
|
-
"#text": `Reason: ${JUNIT_EVALUATION_ERROR_MESSAGE}`,
|
|
1267
|
-
"@_message": JUNIT_EVALUATION_ERROR_MESSAGE,
|
|
1268
|
-
"@_type": "error"
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
return testcase;
|
|
1272
|
-
}
|
|
1273
|
-
async function createJunitXml(evalRecord) {
|
|
1274
|
-
const suites = await buildJunitSuites(evalRecord);
|
|
1275
|
-
const tests = suites.reduce((sum, suite) => sum + suite.testcases.length, 0);
|
|
1276
|
-
const failures = suites.reduce((sum, suite) => sum + suite.failures, 0);
|
|
1277
|
-
const errors = suites.reduce((sum, suite) => sum + suite.errors, 0);
|
|
1278
|
-
const totalTimeMs = suites.reduce((sum, suite) => sum + suite.timeMs, 0);
|
|
1279
|
-
const timestamp = getEvaluationTimestamp(evalRecord);
|
|
1280
|
-
return new XMLBuilder({
|
|
1281
|
-
format: true,
|
|
1282
|
-
ignoreAttributes: false,
|
|
1283
|
-
indentBy: " "
|
|
1284
|
-
}).build({
|
|
1285
|
-
"?xml": {
|
|
1286
|
-
"@_version": "1.0",
|
|
1287
|
-
"@_encoding": "UTF-8"
|
|
1288
|
-
},
|
|
1289
|
-
testsuites: {
|
|
1290
|
-
"@_errors": errors,
|
|
1291
|
-
"@_failures": failures,
|
|
1292
|
-
"@_name": "promptfoo",
|
|
1293
|
-
"@_skipped": 0,
|
|
1294
|
-
"@_tests": tests,
|
|
1295
|
-
"@_time": formatDurationSeconds(totalTimeMs),
|
|
1296
|
-
testsuite: suites.map((suite) => ({
|
|
1297
|
-
"@_errors": suite.errors,
|
|
1298
|
-
"@_failures": suite.failures,
|
|
1299
|
-
"@_name": suite.displayName,
|
|
1300
|
-
"@_skipped": 0,
|
|
1301
|
-
"@_tests": suite.testcases.length,
|
|
1302
|
-
"@_time": formatDurationSeconds(suite.timeMs),
|
|
1303
|
-
...timestamp ? { "@_timestamp": timestamp } : {},
|
|
1304
|
-
testcase: suite.testcases.sort((a, b) => a.testIdx - b.testIdx).map(({ testcase }) => testcase)
|
|
1305
|
-
}))
|
|
1306
|
-
}
|
|
1307
|
-
}).replace(INVALID_XML_CHARACTERS, "");
|
|
1308
|
-
}
|
|
1309
|
-
async function writeJunitXmlOutput(outputPath, evalRecord) {
|
|
1310
|
-
await fsPromises.writeFile(outputPath, await createJunitXml(evalRecord));
|
|
1311
|
-
}
|
|
1312
|
-
const SUPPORTED_OUTPUT_FILE_FORMATS = [...OutputFileExtension.options, "junit.xml"];
|
|
1313
|
-
function getOutputFileFormat(outputPath) {
|
|
1314
|
-
if (outputPath.toLowerCase().endsWith(".junit.xml")) return "junit.xml";
|
|
1315
|
-
return OutputFileExtension.safeParse(path$1.extname(outputPath).slice(1).toLowerCase()).data;
|
|
1316
|
-
}
|
|
1317
|
-
//#endregion
|
|
1318
|
-
//#region src/util/output.ts
|
|
1319
|
-
function warnOnDegradedJsonlRecovery(evalRecord, outputPaths) {
|
|
1320
|
-
if (!evalRecord.resultPersistenceFailed) return;
|
|
1321
|
-
if (outputPaths.some((outputPath) => getOutputFileFormat(outputPath) === "jsonl")) logger.warn("[Output] Reconciling JSONL from streamed rows and the eval record because one or more rows failed to persist");
|
|
1322
|
-
}
|
|
1323
|
-
function isFileNotFoundError(error) {
|
|
1324
|
-
return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
1325
|
-
}
|
|
1326
|
-
function isPermissionDeniedError(error) {
|
|
1327
|
-
return error !== null && typeof error === "object" && "code" in error && (error.code === "EACCES" || error.code === "EPERM");
|
|
1328
|
-
}
|
|
1329
|
-
async function resolveJsonlOutputPath(outputPath) {
|
|
1330
|
-
try {
|
|
1331
|
-
if (!(await fsPromises.lstat(outputPath)).isSymbolicLink()) return outputPath;
|
|
1332
|
-
try {
|
|
1333
|
-
return await fsPromises.realpath(outputPath);
|
|
1334
|
-
} catch (error) {
|
|
1335
|
-
if (isFileNotFoundError(error)) return path$1.resolve(path$1.dirname(outputPath), await fsPromises.readlink(outputPath));
|
|
1336
|
-
throw error;
|
|
1337
|
-
}
|
|
1338
|
-
} catch (error) {
|
|
1339
|
-
if (isFileNotFoundError(error)) return outputPath;
|
|
1340
|
-
throw error;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
async function appendJsonlResultBatch(outputPath, results, stripFlags) {
|
|
1344
|
-
if (results.length === 0) return;
|
|
1345
|
-
const text = results.map((result) => JSON.stringify(sanitizeResultForJsonlArtifact(result, stripFlags))).join(os$1.EOL) + os$1.EOL;
|
|
1346
|
-
await fsPromises.appendFile(outputPath, text);
|
|
1347
|
-
}
|
|
1348
|
-
async function readStreamedJsonlResults(outputPath) {
|
|
1349
|
-
let contents;
|
|
1350
|
-
try {
|
|
1351
|
-
contents = await fsPromises.readFile(outputPath, "utf8");
|
|
1352
|
-
} catch (error) {
|
|
1353
|
-
if (error.code === "ENOENT") return [];
|
|
1354
|
-
throw error;
|
|
1355
|
-
}
|
|
1356
|
-
const results = [];
|
|
1357
|
-
const lines = contents.split(/\r?\n/).filter(Boolean);
|
|
1358
|
-
for (const [index, line] of lines.entries()) try {
|
|
1359
|
-
results.push(JSON.parse(line));
|
|
1360
|
-
} catch (error) {
|
|
1361
|
-
logger.warn(`[Output] Skipping malformed streamed JSONL row at ${outputPath}:${index + 1} during recovery: ${error instanceof Error ? error.message : String(error)}`);
|
|
1362
|
-
}
|
|
1363
|
-
return results;
|
|
1364
|
-
}
|
|
1365
|
-
async function collectJsonlResultsAfterPersistenceFailure(outputPath, evalRecord) {
|
|
1366
|
-
const stripFlags = getStripFlags(evalRecord.config.env);
|
|
1367
|
-
const finalResults = /* @__PURE__ */ new Map();
|
|
1368
|
-
const put = (result) => finalResults.set(getResultIndexKey(result), result);
|
|
1369
|
-
for (const result of await readStreamedJsonlResults(outputPath)) put(result);
|
|
1370
|
-
for await (const batchResults of evalRecord.fetchResultsBatched()) for (const result of batchResults) {
|
|
1371
|
-
const evaluateResult = asEvaluateResult(result, stripFlags);
|
|
1372
|
-
if (!evalRecord.hasResultPersistenceFailure(evaluateResult)) put(evaluateResult);
|
|
1373
|
-
}
|
|
1374
|
-
for (const result of evalRecord.getFinalJsonlResults()) put(result);
|
|
1375
|
-
return Array.from(finalResults.values());
|
|
1376
|
-
}
|
|
1377
|
-
async function getExistingFileMode(outputPath) {
|
|
1378
|
-
try {
|
|
1379
|
-
return (await fsPromises.stat(outputPath)).mode & 4095;
|
|
1380
|
-
} catch (error) {
|
|
1381
|
-
if (isFileNotFoundError(error)) return;
|
|
1382
|
-
throw error;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
async function appendJsonlResults(outputPath, evalRecord, recoveredResults) {
|
|
1386
|
-
const stripFlags = getStripFlags(evalRecord.config.env);
|
|
1387
|
-
if (recoveredResults) {
|
|
1388
|
-
await appendJsonlResultBatch(outputPath, recoveredResults, stripFlags);
|
|
1389
|
-
return;
|
|
1390
|
-
}
|
|
1391
|
-
for await (const batchResults of evalRecord.fetchResultsBatched()) await appendJsonlResultBatch(outputPath, batchResults.map((result) => asEvaluateResult(result, stripFlags)), stripFlags);
|
|
1392
|
-
}
|
|
1393
|
-
async function rewriteJsonlWithExternalBackup(outputPath, outputMode, evalRecord, preparedReplacementPath, recoveredResults) {
|
|
1394
|
-
const tempDirectory = await fsPromises.mkdtemp(path$1.join(os$1.tmpdir(), "promptfoo-jsonl-"));
|
|
1395
|
-
const backupPath = path$1.join(tempDirectory, "backup.jsonl");
|
|
1396
|
-
const replacementPath = path$1.join(tempDirectory, "replacement.jsonl");
|
|
1397
|
-
let overwriteAttempted = false;
|
|
1398
|
-
let preserveTempDirectory = false;
|
|
1399
|
-
let hasBackup = false;
|
|
1400
|
-
try {
|
|
1401
|
-
try {
|
|
1402
|
-
await fsPromises.copyFile(outputPath, backupPath);
|
|
1403
|
-
hasBackup = true;
|
|
1404
|
-
} catch (error) {
|
|
1405
|
-
if (!isFileNotFoundError(error)) throw error;
|
|
1406
|
-
}
|
|
1407
|
-
if (preparedReplacementPath) await fsPromises.copyFile(preparedReplacementPath, replacementPath);
|
|
1408
|
-
else {
|
|
1409
|
-
if (outputMode === void 0) await fsPromises.writeFile(replacementPath, "");
|
|
1410
|
-
else await fsPromises.writeFile(replacementPath, "", { mode: outputMode });
|
|
1411
|
-
await appendJsonlResults(replacementPath, evalRecord, recoveredResults);
|
|
1412
|
-
}
|
|
1413
|
-
overwriteAttempted = true;
|
|
1414
|
-
await fsPromises.copyFile(replacementPath, outputPath);
|
|
1415
|
-
if (outputMode !== void 0) await fsPromises.chmod(outputPath, outputMode);
|
|
1416
|
-
} catch (error) {
|
|
1417
|
-
if (overwriteAttempted && hasBackup) try {
|
|
1418
|
-
await fsPromises.copyFile(backupPath, outputPath);
|
|
1419
|
-
} catch (restoreError) {
|
|
1420
|
-
preserveTempDirectory = true;
|
|
1421
|
-
logger.error("[Output] Failed to restore JSONL output after rewrite failure", {
|
|
1422
|
-
backupPath,
|
|
1423
|
-
error: restoreError
|
|
1424
|
-
});
|
|
1425
|
-
throw new Error(`Failed to rewrite JSONL output (${error instanceof Error ? error.message : String(error)}) and restore backup (${restoreError instanceof Error ? restoreError.message : String(restoreError)}). Backup retained at ${backupPath}`);
|
|
1426
|
-
}
|
|
1427
|
-
throw error;
|
|
1428
|
-
} finally {
|
|
1429
|
-
if (!preserveTempDirectory) await fsPromises.rm(tempDirectory, {
|
|
1430
|
-
recursive: true,
|
|
1431
|
-
force: true
|
|
1432
|
-
}).catch((error) => {
|
|
1433
|
-
logger.warn("[Output] Failed to remove temporary JSONL backup directory", {
|
|
1434
|
-
error,
|
|
1435
|
-
tempDirectory
|
|
1436
|
-
});
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
async function removeTemporaryJsonlOutput(tempOutputPath) {
|
|
1441
|
-
await fsPromises.rm(tempOutputPath, { force: true }).catch((error) => {
|
|
1442
|
-
logger.warn("[Output] Failed to remove temporary JSONL output", {
|
|
1443
|
-
error,
|
|
1444
|
-
tempOutputPath
|
|
1445
|
-
});
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
const outputToSimpleString = (output) => {
|
|
1449
|
-
const passFailText = output.pass ? "[PASS]" : output.failureReason === ResultFailureReason.ASSERT ? "[FAIL]" : "[ERROR]";
|
|
1450
|
-
const namedScoresText = Object.entries(output.namedScores).map(([name, value]) => `${name}: ${value?.toFixed(2)}`).join(", ");
|
|
1451
|
-
const scoreText = namedScoresText.length > 0 ? `(${output.score?.toFixed(2)}, ${namedScoresText})` : `(${output.score?.toFixed(2)})`;
|
|
1452
|
-
const gradingResultText = output.gradingResult ? `${output.pass ? "Pass" : "Fail"} Reason: ${output.gradingResult.reason}` : "";
|
|
1453
|
-
return dedent`
|
|
1454
|
-
${passFailText} ${scoreText}
|
|
1455
|
-
|
|
1456
|
-
${output.text}
|
|
1457
|
-
|
|
1458
|
-
${gradingResultText}
|
|
1459
|
-
`.trim();
|
|
1460
|
-
};
|
|
1461
|
-
const outputToHtmlReportCell = (output) => {
|
|
1462
|
-
const status = output.pass ? "pass" : output.failureReason === ResultFailureReason.ERROR ? "error" : "fail";
|
|
1463
|
-
const namedScores = Object.entries(output.namedScores).map(([name, value]) => ({
|
|
1464
|
-
name,
|
|
1465
|
-
value: value?.toFixed(2)
|
|
1466
|
-
}));
|
|
1467
|
-
return {
|
|
1468
|
-
status,
|
|
1469
|
-
statusLabel: status.toUpperCase(),
|
|
1470
|
-
score: output.score?.toFixed(2),
|
|
1471
|
-
namedScores,
|
|
1472
|
-
text: output.text,
|
|
1473
|
-
reason: output.gradingResult?.reason || "",
|
|
1474
|
-
prompt: output.prompt,
|
|
1475
|
-
provider: output.provider || "",
|
|
1476
|
-
error: output.error || "",
|
|
1477
|
-
failureReason: output.failureReason,
|
|
1478
|
-
latencyDisplay: Number.isFinite(output.latencyMs) ? `${output.latencyMs.toFixed(0)} ms` : "",
|
|
1479
|
-
costDisplay: Number.isFinite(output.cost) && output.cost > 0 ? `$${output.cost.toFixed(6)}` : "",
|
|
1480
|
-
totalTokensDisplay: typeof output.tokenUsage?.total === "number" ? output.tokenUsage.total.toLocaleString("en-US") : "",
|
|
1481
|
-
promptTokensDisplay: typeof output.tokenUsage?.prompt === "number" ? output.tokenUsage.prompt.toLocaleString("en-US") : "",
|
|
1482
|
-
completionTokensDisplay: typeof output.tokenUsage?.completion === "number" ? output.tokenUsage.completion.toLocaleString("en-US") : ""
|
|
1483
|
-
};
|
|
1484
|
-
};
|
|
1485
|
-
async function createOutputSummary(evalRecord, stripFlags) {
|
|
1486
|
-
const summary = await evalRecord.toEvaluateSummary();
|
|
1487
|
-
const prompts = ("prompts" in summary ? summary.prompts : summary.table.head.prompts).map((prompt) => prompt.config ? {
|
|
1488
|
-
...prompt,
|
|
1489
|
-
config: sanitizeConfigForOutput(prompt.config, stripFlags)
|
|
1490
|
-
} : prompt);
|
|
1491
|
-
return "prompts" in summary ? {
|
|
1492
|
-
...summary,
|
|
1493
|
-
prompts
|
|
1494
|
-
} : {
|
|
1495
|
-
...summary,
|
|
1496
|
-
table: {
|
|
1497
|
-
...summary.table,
|
|
1498
|
-
head: {
|
|
1499
|
-
...summary.table.head,
|
|
1500
|
-
prompts
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
}
|
|
1505
|
-
function resultsForMediaExportScan(results, shouldStripResponseOutput) {
|
|
1506
|
-
if (!shouldStripResponseOutput) return results;
|
|
1507
|
-
return {
|
|
1508
|
-
...results,
|
|
1509
|
-
results: results.results.map((result) => {
|
|
1510
|
-
const response = result.response;
|
|
1511
|
-
if (!response?.metadata || !("blobUris" in response.metadata)) return result;
|
|
1512
|
-
const { metadata: responseMetadata, ...projectedResponse } = response;
|
|
1513
|
-
const { blobUris: _blobUris, ...metadata } = responseMetadata;
|
|
1514
|
-
return {
|
|
1515
|
-
...result,
|
|
1516
|
-
response: {
|
|
1517
|
-
...projectedResponse,
|
|
1518
|
-
...Object.keys(metadata).length > 0 && { metadata }
|
|
1519
|
-
}
|
|
1520
|
-
};
|
|
1521
|
-
})
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
function createOutputMetadata(evalRecord) {
|
|
1525
|
-
let evaluationCreatedAt;
|
|
1526
|
-
if (evalRecord.createdAt) try {
|
|
1527
|
-
const date = new Date(evalRecord.createdAt);
|
|
1528
|
-
evaluationCreatedAt = Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1529
|
-
} catch {
|
|
1530
|
-
evaluationCreatedAt = void 0;
|
|
1531
|
-
}
|
|
1532
|
-
return {
|
|
1533
|
-
promptfooVersion: VERSION,
|
|
1534
|
-
nodeVersion: process.version,
|
|
1535
|
-
platform: os$1.platform(),
|
|
1536
|
-
arch: os$1.arch(),
|
|
1537
|
-
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1538
|
-
evaluationCreatedAt,
|
|
1539
|
-
author: evalRecord.author ?? void 0
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
async function createOutputData(evalRecord, shareableUrl, options = {}) {
|
|
1543
|
-
const stripFlags = getStripFlags(evalRecord.config.env);
|
|
1544
|
-
const summary = await createOutputSummary(evalRecord, stripFlags);
|
|
1545
|
-
const redactedConfig = sanitizeConfigForOutput(evalRecord.config, stripFlags);
|
|
1546
|
-
let traces;
|
|
1547
|
-
try {
|
|
1548
|
-
const { getTraceStore } = await import("./store-D2b7vhhQ.js");
|
|
1549
|
-
traces = await getTraceStore().getTracesByEvaluation(evalRecord.id);
|
|
1550
|
-
} catch (error) {
|
|
1551
|
-
logger.warn(`Failed to fetch traces for output ${evalRecord.id}; traces omitted from export: ${error}`);
|
|
1552
|
-
}
|
|
1553
|
-
const output = {
|
|
1554
|
-
evalId: evalRecord.id,
|
|
1555
|
-
results: summary,
|
|
1556
|
-
config: redactedConfig,
|
|
1557
|
-
shareableUrl,
|
|
1558
|
-
metadata: createOutputMetadata(evalRecord),
|
|
1559
|
-
...evalRecord.vars?.length > 0 && { vars: [...evalRecord.vars] },
|
|
1560
|
-
...evalRecord.runtimeOptions && { runtimeOptions: sanitizeRuntimeOptions(evalRecord.runtimeOptions) },
|
|
1561
|
-
...traces && traces.length > 0 && { traces: projectTracesForOutput(traces, stripFlags) }
|
|
1562
|
-
};
|
|
1563
|
-
if (options.includeMedia) {
|
|
1564
|
-
const blobAssets = await exportBlobAssets(evalRecord.id, summary, stripFlags.shouldStripResponseOutput, output.traces);
|
|
1565
|
-
if (blobAssets.length > 0) output.blobAssets = blobAssets;
|
|
1566
|
-
}
|
|
1567
|
-
return output;
|
|
1568
|
-
}
|
|
1569
|
-
async function exportBlobAssets(evalId, results, shouldStripResponseOutput, traces) {
|
|
1570
|
-
const { getShareAuthorizedBlob } = await import("./blobs-DQI39YOh.js");
|
|
1571
|
-
const assets = [];
|
|
1572
|
-
for (const hash of collectBlobHashes({
|
|
1573
|
-
results: resultsForMediaExportScan(results, shouldStripResponseOutput),
|
|
1574
|
-
traces
|
|
1575
|
-
})) try {
|
|
1576
|
-
const blob = await getShareAuthorizedBlob(hash, evalId);
|
|
1577
|
-
if (!blob) continue;
|
|
1578
|
-
if (blob.data.length > 52428800) {
|
|
1579
|
-
logger.warn("[Output] Skipping oversized blob in eval export", {
|
|
1580
|
-
hash,
|
|
1581
|
-
sizeBytes: blob.data.length
|
|
1582
|
-
});
|
|
1583
|
-
continue;
|
|
1584
|
-
}
|
|
1585
|
-
assets.push({
|
|
1586
|
-
hash,
|
|
1587
|
-
mimeType: blob.metadata.mimeType,
|
|
1588
|
-
sizeBytes: blob.data.length,
|
|
1589
|
-
data: blob.data.toString("base64")
|
|
1590
|
-
});
|
|
1591
|
-
} catch (error) {
|
|
1592
|
-
logger.warn("[Output] Skipping missing blob in eval export", {
|
|
1593
|
-
error,
|
|
1594
|
-
hash
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
return assets;
|
|
1598
|
-
}
|
|
1599
|
-
/**
|
|
1600
|
-
* JSON writer with improved error handling for large datasets.
|
|
1601
|
-
* Provides helpful error messages when memory limits are exceeded.
|
|
1602
|
-
*/
|
|
1603
|
-
async function writeJsonOutputSafely(outputPath, evalRecord, shareableUrl, options) {
|
|
1604
|
-
try {
|
|
1605
|
-
const outputData = await createOutputData(evalRecord, shareableUrl, options);
|
|
1606
|
-
const jsonString = JSON.stringify(outputData, null, 2);
|
|
1607
|
-
await fsPromises.writeFile(outputPath, jsonString);
|
|
1608
|
-
} catch (error) {
|
|
1609
|
-
const msg = error?.message ?? "";
|
|
1610
|
-
const isStringLen = error instanceof RangeError && msg.includes("Invalid string length");
|
|
1611
|
-
const isHeapOOM = /heap out of memory|Array buffer allocation failed|ERR_STRING_TOO_LONG/i.test(msg);
|
|
1612
|
-
if (isStringLen || isHeapOOM) {
|
|
1613
|
-
const resultCount = await evalRecord.getResultsCount();
|
|
1614
|
-
logger.error(`Dataset too large for JSON export (${resultCount} results).`);
|
|
1615
|
-
throw new Error(`Dataset too large for JSON export. The evaluation has ${resultCount} results which exceeds memory limits. Consider using JSONL format instead: --output output.jsonl`);
|
|
1616
|
-
} else throw error;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
async function writeOutput(outputPath, evalRecord, shareableUrl, options = {}) {
|
|
1620
|
-
if (outputPath.match(/^https:\/\/docs\.google\.com\/spreadsheets\//)) {
|
|
1621
|
-
const table = await evalRecord.getTable();
|
|
1622
|
-
const rows = table.body.map((row) => {
|
|
1623
|
-
const csvRow = {};
|
|
1624
|
-
table.head.vars.forEach((varName, index) => {
|
|
1625
|
-
csvRow[varName] = row.vars[index];
|
|
1626
|
-
});
|
|
1627
|
-
table.head.prompts.forEach((prompt, index) => {
|
|
1628
|
-
csvRow[`[${prompt.provider}] ${prompt.label}`] = outputToSimpleString(row.outputs[index]);
|
|
1629
|
-
});
|
|
1630
|
-
return csvRow;
|
|
1631
|
-
});
|
|
1632
|
-
logger.info(`Writing ${rows.length} rows to Google Sheets...`);
|
|
1633
|
-
await writeCsvToGoogleSheet(rows, outputPath);
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
const outputExtension = getOutputFileFormat(outputPath);
|
|
1637
|
-
invariant(outputExtension, `Unsupported output file format ${path$1.extname(outputPath).slice(1).toLowerCase()}. Please use one of: ${SUPPORTED_OUTPUT_FILE_FORMATS.join(", ")}.`);
|
|
1638
|
-
const outputDir = path$1.dirname(outputPath);
|
|
1639
|
-
await fsPromises.mkdir(outputDir, { recursive: true });
|
|
1640
|
-
if (outputExtension === "junit.xml") await writeJunitXmlOutput(outputPath, evalRecord);
|
|
1641
|
-
else if (outputExtension === "csv") {
|
|
1642
|
-
const fileHandle = await fsPromises.open(outputPath, "w");
|
|
1643
|
-
try {
|
|
1644
|
-
await streamEvalCsv(evalRecord, {
|
|
1645
|
-
isRedteam: Boolean(evalRecord.config.redteam),
|
|
1646
|
-
write: async (data) => {
|
|
1647
|
-
await fileHandle.write(data);
|
|
1648
|
-
}
|
|
1649
|
-
});
|
|
1650
|
-
} finally {
|
|
1651
|
-
await fileHandle.close();
|
|
1652
|
-
}
|
|
1653
|
-
} else if (outputExtension === "json") await writeJsonOutputSafely(outputPath, evalRecord, shareableUrl, options);
|
|
1654
|
-
else if (outputExtension === "yaml" || outputExtension === "yml" || outputExtension === "txt") await fsPromises.writeFile(outputPath, yaml.dump(await createOutputData(evalRecord, shareableUrl, options)));
|
|
1655
|
-
else if (outputExtension === "html") {
|
|
1656
|
-
const table = await evalRecord.getTable();
|
|
1657
|
-
const stripFlags = getStripFlags(evalRecord.config.env);
|
|
1658
|
-
const summary = await createOutputSummary(evalRecord, stripFlags);
|
|
1659
|
-
const redactedConfig = sanitizeConfigForOutput(evalRecord.config, stripFlags);
|
|
1660
|
-
const metadata = createOutputMetadata(evalRecord);
|
|
1661
|
-
const template = await fsPromises.readFile(path$1.join(getDirectory(), "tableOutput.html"), "utf-8");
|
|
1662
|
-
const htmlTable = [[...table.head.vars, ...table.head.prompts.map((prompt) => `[${prompt.provider}] ${prompt.label}`)], ...table.body.map((row, rowIndex) => [...row.vars.map((value, variableIndex) => ({
|
|
1663
|
-
kind: "variable",
|
|
1664
|
-
name: table.head.vars[variableIndex],
|
|
1665
|
-
text: value
|
|
1666
|
-
})), ...row.outputs.map((output, outputIndex) => ({
|
|
1667
|
-
kind: "output",
|
|
1668
|
-
detailId: `result-detail-${rowIndex}-${outputIndex}`,
|
|
1669
|
-
detailTitle: `Result detail - row ${rowIndex + 1}, prompt ${outputIndex + 1}`,
|
|
1670
|
-
description: row.description || row.test?.description || "",
|
|
1671
|
-
...outputToHtmlReportCell(output)
|
|
1672
|
-
}))])];
|
|
1673
|
-
const reportOutputs = table.body.flatMap((row) => row.outputs);
|
|
1674
|
-
const totalResults = reportOutputs.length;
|
|
1675
|
-
const successes = reportOutputs.filter((output) => output.pass).length;
|
|
1676
|
-
const errors = reportOutputs.filter((output) => !output.pass && output.failureReason === ResultFailureReason.ERROR).length;
|
|
1677
|
-
const failures = totalResults - successes - errors;
|
|
1678
|
-
const passRate = totalResults > 0 ? successes / totalResults * 100 : 0;
|
|
1679
|
-
const htmlOutput = getNunjucksEngine().renderString(template, {
|
|
1680
|
-
config: redactedConfig,
|
|
1681
|
-
table: htmlTable,
|
|
1682
|
-
results: summary,
|
|
1683
|
-
metadata,
|
|
1684
|
-
report: {
|
|
1685
|
-
totalResults,
|
|
1686
|
-
totalRows: table.body.length,
|
|
1687
|
-
promptCount: table.head.prompts.length,
|
|
1688
|
-
variableCount: table.head.vars.length,
|
|
1689
|
-
successes,
|
|
1690
|
-
failures,
|
|
1691
|
-
errors,
|
|
1692
|
-
passRateDisplay: `${passRate.toFixed(1)}%`
|
|
1693
|
-
}
|
|
1694
|
-
});
|
|
1695
|
-
await fsPromises.writeFile(outputPath, htmlOutput);
|
|
1696
|
-
} else if (outputExtension === "jsonl") {
|
|
1697
|
-
const jsonlOutputPath = await resolveJsonlOutputPath(outputPath);
|
|
1698
|
-
if (jsonlOutputPath !== outputPath) await fsPromises.mkdir(path$1.dirname(jsonlOutputPath), { recursive: true });
|
|
1699
|
-
const outputMode = await getExistingFileMode(jsonlOutputPath);
|
|
1700
|
-
const recoveredResults = evalRecord.resultPersistenceFailed ? await collectJsonlResultsAfterPersistenceFailure(jsonlOutputPath, evalRecord) : void 0;
|
|
1701
|
-
const tempOutputPath = path$1.join(path$1.dirname(jsonlOutputPath), `.promptfoo-${randomUUID()}.tmp`);
|
|
1702
|
-
try {
|
|
1703
|
-
try {
|
|
1704
|
-
await fsPromises.writeFile(tempOutputPath, "");
|
|
1705
|
-
} catch (error) {
|
|
1706
|
-
if (isPermissionDeniedError(error)) {
|
|
1707
|
-
logger.warn("[Output] Falling back to JSONL rewrite with external backup because the output directory is not writable");
|
|
1708
|
-
await rewriteJsonlWithExternalBackup(jsonlOutputPath, outputMode, evalRecord, void 0, recoveredResults);
|
|
1709
|
-
return;
|
|
1710
|
-
}
|
|
1711
|
-
throw error;
|
|
1712
|
-
}
|
|
1713
|
-
await appendJsonlResults(tempOutputPath, evalRecord, recoveredResults);
|
|
1714
|
-
if (outputMode !== void 0) await fsPromises.chmod(tempOutputPath, outputMode);
|
|
1715
|
-
try {
|
|
1716
|
-
await fsPromises.rename(tempOutputPath, jsonlOutputPath);
|
|
1717
|
-
} catch (error) {
|
|
1718
|
-
if (isPermissionDeniedError(error)) {
|
|
1719
|
-
logger.warn("[Output] Falling back to JSONL rewrite with external backup because replacing the output file is not permitted");
|
|
1720
|
-
await rewriteJsonlWithExternalBackup(jsonlOutputPath, outputMode, evalRecord, tempOutputPath);
|
|
1721
|
-
await removeTemporaryJsonlOutput(tempOutputPath);
|
|
1722
|
-
return;
|
|
1723
|
-
}
|
|
1724
|
-
throw error;
|
|
1725
|
-
}
|
|
1726
|
-
} catch (error) {
|
|
1727
|
-
await removeTemporaryJsonlOutput(tempOutputPath);
|
|
1728
|
-
throw error;
|
|
1729
|
-
}
|
|
1730
|
-
} else if (outputExtension === "xml") {
|
|
1731
|
-
const stripFlags = getStripFlags(evalRecord.config.env);
|
|
1732
|
-
const summary = await createOutputSummary(evalRecord, stripFlags);
|
|
1733
|
-
const redactedConfig = sanitizeConfigForOutput(evalRecord.config, stripFlags);
|
|
1734
|
-
const sanitizeForXml = (obj) => {
|
|
1735
|
-
if (obj === null || obj === void 0) return "";
|
|
1736
|
-
if (Array.isArray(obj)) return obj.map(sanitizeForXml);
|
|
1737
|
-
if (typeof obj === "object") {
|
|
1738
|
-
const sanitized = {};
|
|
1739
|
-
for (const [key, value] of Object.entries(obj)) sanitized[key] = sanitizeForXml(value);
|
|
1740
|
-
return sanitized;
|
|
1741
|
-
}
|
|
1742
|
-
return String(obj);
|
|
1743
|
-
};
|
|
1744
|
-
const xmlData = new XMLBuilder({
|
|
1745
|
-
ignoreAttributes: false,
|
|
1746
|
-
format: true,
|
|
1747
|
-
indentBy: " "
|
|
1748
|
-
}).build({ promptfoo: {
|
|
1749
|
-
evalId: evalRecord.id,
|
|
1750
|
-
results: sanitizeForXml(summary),
|
|
1751
|
-
config: sanitizeForXml(redactedConfig),
|
|
1752
|
-
shareableUrl: shareableUrl || ""
|
|
1753
|
-
} });
|
|
1754
|
-
await fsPromises.writeFile(outputPath, xmlData);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
async function writeMultipleOutputs(outputPaths, evalRecord, shareableUrl) {
|
|
1758
|
-
const errors = (await Promise.allSettled(outputPaths.map((outputPath) => writeOutput(outputPath, evalRecord, shareableUrl)))).flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
1759
|
-
if (errors.length > 0) throw Object.assign(/* @__PURE__ */ new Error("One or more output writes failed"), { errors });
|
|
1760
|
-
}
|
|
1761
|
-
//#endregion
|
|
1762
|
-
//#region src/util/runtime.ts
|
|
1763
|
-
function printBorder() {
|
|
1764
|
-
const border = "=".repeat(TERMINAL_MAX_WIDTH);
|
|
1765
|
-
logger.info(border);
|
|
1766
|
-
}
|
|
1767
|
-
//#endregion
|
|
1768
|
-
export { isProviderConfigFileReference as A, getProviderIdentifier as C, isProviderAllowed as D, isOpenAiProvider as E, normalizeProviderRef as M, readProviderConfigFile as N, providerToIdentifier as O, getProviderDescription as S, isGoogleProvider as T, extractRuntimeVars as _, writeOutput as a, checkProviderApiKeys as b, ComparisonEvalNotFoundError as c, getEvalTableOutputPromptLocationsBySize as d, getEvalTablePromptStrippedPayload as f, deduplicateTestCases as g, setupEnv as h, writeMultipleOutputs as i, loadProviderConfigsFromFile as j, sanitizeProviderIdForLog as k, evalTableToJson as l, fetchCsvFromGoogleSheet as m, createOutputData as n, SUPPORTED_OUTPUT_FILE_FORMATS as o, mergeComparisonTables as p, warnOnDegradedJsonlRecovery as r, getOutputFileFormat as s, printBorder as t, generateEvalCsv as u, filterRuntimeVars as v, isAnthropicProvider as w, doesProviderRefMatch as x, resultIsForTestCase as y };
|
|
1769
|
-
|
|
1770
|
-
//# sourceMappingURL=util-BD1R_PsR.js.map
|