promptfoo 0.121.3 → 0.121.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/{ListApp-Du7YVwj5.js → ListApp-BRUsT43Y.js} +1 -1
- package/dist/src/{accounts-BPyfpSeU.cjs → accounts-BIFntVWB.cjs} +5 -5
- package/dist/src/{accounts-CFLK3mnD.js → accounts-CLJHCDDb.js} +6 -6
- package/dist/src/{accounts-B2XmGjty.js → accounts-CaLNYnf7.js} +5 -5
- package/dist/src/{accounts-Xatc0RYb.js → accounts-bnyHT7Ju.js} +5 -5
- package/dist/src/{agentic-utils-36epdqwB.js → agentic-utils-B5krlibj.js} +3 -3
- package/dist/src/{agentic-utils-DIYAAYE7.js → agentic-utils-Ba67xmgs.js} +3 -3
- package/dist/src/{agentic-utils-D8yXo5Lm.js → agentic-utils-BclbiXiq.js} +4 -4
- package/dist/src/{agentic-utils-DAVsChuB.cjs → agentic-utils-D2x0wGhB.cjs} +3 -3
- package/dist/src/{agents-CLQ-P15P.js → agents-BGqaTDnr.js} +5 -7
- package/dist/src/{agents-wg3ohknq.js → agents-BV9yFpXX.js} +6 -7
- package/dist/src/{agents-CgBniSlI.js → agents-BYdMl1UE.js} +5 -9
- package/dist/src/{agents-Bqgfdokm.js → agents-DhxWMCtH.js} +35 -14
- package/dist/src/{agents-BBWxKSM0.cjs → agents-DiWmQYH9.cjs} +5 -7
- package/dist/src/{agents-CAYbM7qD.cjs → agents-WULPVjbH.cjs} +34 -12
- package/dist/src/{agents-DSSTV4bv.js → agents-emVcx3yh.js} +35 -13
- package/dist/src/{agents-BBVJCIYr.js → agents-n6vPqV3i.js} +35 -13
- package/dist/src/{aimlapi-BwGC1TtS.js → aimlapi-BxqK9HF_.js} +8 -14
- package/dist/src/{aimlapi-Bv8Fmc-b.cjs → aimlapi-BzLjZI_m.cjs} +8 -15
- package/dist/src/{aimlapi-MgSLdvy7.js → aimlapi-DR4pgeiC.js} +7 -14
- package/dist/src/{aimlapi-DaC3qZ-o.js → aimlapi-uPGp0Zdo.js} +7 -16
- package/dist/src/app/app/tsconfig.app.tsbuildinfo +1 -0
- package/dist/src/app/assets/Report-vjzrbgce.js +1 -0
- package/dist/src/app/assets/index-B3NQ8HTd.js +385 -0
- package/dist/src/app/assets/index-Cli2yAXv.css +1 -0
- package/dist/src/app/assets/rolldown-runtime-COnpUsM8.js +1 -0
- package/dist/src/app/assets/scroll-timeline-D9IT_e8Z.js +1 -0
- package/dist/src/app/assets/sync-IjzpWrOE.js +4 -0
- package/dist/src/app/assets/vendor-charts-BNdH8TCw.js +36 -0
- package/dist/src/app/assets/vendor-markdown-Ch00wnNI.js +29 -0
- package/dist/src/app/assets/vendor-react-CVvmk1UB.js +9 -0
- package/dist/src/app/assets/vendor-utils-BnEYbx2Q.js +37 -0
- package/dist/src/app/index.html +32 -7
- package/dist/src/{audio-Bn44pQxv.js → audio-BvpTOArF.js} +4 -4
- package/dist/src/{audio-DVFjQ67_.cjs → audio-C0vDeS0j.cjs} +4 -4
- package/dist/src/{audio-DjU9GswO.js → audio-CScmnmEB.js} +4 -5
- package/dist/src/{audio-DDA5WHdx.js → audio-Da8U9IS5.js} +4 -4
- package/dist/src/{base-CKjwebIH.js → base-BOMaNEes.js} +3 -3
- package/dist/src/{base-CqzQ4K8j.js → base-BTux96b1.js} +3 -3
- package/dist/src/{base-BboXIF_0.cjs → base-Tw6uhH8K.cjs} +3 -3
- package/dist/src/{base-Cz2ZC_iA.js → base-dYsl2hmL.js} +3 -3
- package/dist/src/{blobs-C6j0bvFz.cjs → blobs-B95F_7vE.cjs} +3 -3
- package/dist/src/{blobs-DXTl6J3H.js → blobs-BW4U31ue.js} +3 -3
- package/dist/src/{blobs-BUWmKWzo.js → blobs-D_gg8nbm.js} +4 -4
- package/dist/src/{blobs-B1JriOyi.js → blobs-DjLby-uP.js} +4 -4
- package/dist/src/cache-BI5BY7ey.js +280 -0
- package/dist/src/cache-BRkhlH3k.cjs +3 -0
- package/dist/src/cache-BlC6aeJ0.js +3 -0
- package/dist/src/cache-Bzttsk0X.js +310 -0
- package/dist/src/cache-Cr-qWIbP.js +310 -0
- package/dist/src/cache-DGg-yTZG.cjs +376 -0
- package/dist/src/{chat-BEwdgGEg.js → chat-BLOdH60v.js} +63 -37
- package/dist/src/{chat-B0iaWhoh.js → chat-Cx_LkwvZ.js} +63 -37
- package/dist/src/{chat-DK1U-eZ-.js → chat-D9nudO9b.js} +5 -14
- package/dist/src/{chat-pxmiVpWe.js → chat-DChSH_Es.js} +63 -37
- package/dist/src/{chat-B-52XYI1.js → chat-DG2LkwLq.js} +3 -13
- package/dist/src/{chat-BtIKkLKx.cjs → chat-DH97tVV9.cjs} +3 -13
- package/dist/src/{chat-BE0qTA8e.js → chat-aMQZw6R7.js} +4 -16
- package/dist/src/{chat-CM8qWR3_.cjs → chat-vYqqv1gP.cjs} +64 -38
- package/dist/src/{chatkit-_8eJqKcD.js → chatkit-B8X34dQc.js} +4 -4
- package/dist/src/{chatkit-BYGQlHlV.js → chatkit-BXu42Qwt.js} +4 -4
- package/dist/src/{chatkit-a2D6mY6s.js → chatkit-CbMRoeYw.js} +4 -4
- package/dist/src/{chatkit-Cx174XI3.cjs → chatkit-D44VyUyB.cjs} +4 -4
- package/dist/src/{claude-agent-sdk-8ddRp1L2.cjs → claude-agent-sdk-BRq0bbIK.cjs} +23 -18
- package/dist/src/{claude-agent-sdk-CMjh4LFH.js → claude-agent-sdk-BjriSVRZ.js} +20 -15
- package/dist/src/{claude-agent-sdk-HgbFioFw.js → claude-agent-sdk-BzNZeZ0N.js} +20 -15
- package/dist/src/{claude-agent-sdk-Bq5EArsX.js → claude-agent-sdk-DYv_AJ8u.js} +21 -17
- package/dist/src/cloud-CoD5OacT.js +3 -0
- package/dist/src/{cloud-z8KZpUoa.js → cloud-Da0bofJd.js} +25 -13
- package/dist/src/{cloudflare-ai-Bbp26N0L.js → cloudflare-ai-CXC4b1EU.js} +5 -14
- package/dist/src/{cloudflare-ai-BGyXlpXJ.js → cloudflare-ai-CyBoIs1Q.js} +7 -15
- package/dist/src/{cloudflare-ai-DdKP9TKT.js → cloudflare-ai-DGOwgexC.js} +6 -17
- package/dist/src/{cloudflare-ai-C62x6MQG.cjs → cloudflare-ai-DJv5qnyb.cjs} +6 -15
- package/dist/src/{cloudflare-gateway-DXhtXDRb.js → cloudflare-gateway-1sAoOyft.js} +6 -16
- package/dist/src/{cloudflare-gateway-D-e9i1Sn.js → cloudflare-gateway-D-dnkzCF.js} +5 -18
- package/dist/src/{cloudflare-gateway-Dx36ftqF.cjs → cloudflare-gateway-DKVjkDav.cjs} +4 -15
- package/dist/src/{cloudflare-gateway-BwAaUgeW.js → cloudflare-gateway-TJkVrZlB.js} +4 -15
- package/dist/src/codex-app-server-CCLjqCh9.js +1915 -0
- package/dist/src/codex-app-server-CCe0TiDc.js +1915 -0
- package/dist/src/codex-app-server-CPW1LFwh.js +1916 -0
- package/dist/src/codex-app-server-VMRnjZ68.cjs +1920 -0
- package/dist/src/codex-sdk-1jm_qPHf.js +3 -0
- package/dist/src/codex-sdk-Bd8UbO9q.cjs +1172 -0
- package/dist/src/codex-sdk-BgEFQ70r.js +1164 -0
- package/dist/src/codex-sdk-Bzb_TqX9.js +1165 -0
- package/dist/src/codex-sdk-Danroptg.cjs +2 -0
- package/dist/src/codex-sdk-DfvDTN33.js +1165 -0
- package/dist/src/{cometapi-BDyV-NNm.js → cometapi-B5ImDlSm.js} +9 -15
- package/dist/src/{cometapi-C3hOlM7-.cjs → cometapi-BgAkuYCw.cjs} +9 -16
- package/dist/src/{cometapi-hhL4TAh3.js → cometapi-CC7hWxmX.js} +8 -15
- package/dist/src/{cometapi-sp7sJpBD.js → cometapi-CCbpHkuF.js} +8 -17
- package/dist/src/{completion-DoYy49ti.js → completion-2iuYVxwi.js} +8 -57
- package/dist/src/{completion-BCimtq-h.js → completion-CrD6MQ93.js} +8 -57
- package/dist/src/{completion-DlXUhj5c.cjs → completion-DtQ72Bm3.cjs} +7 -62
- package/dist/src/{completion-DCjv7RZ3.js → completion-Vq_ad618.js} +8 -57
- package/dist/src/{createHash-CTQmL3G2.js → createHash-4gFQpDDv.js} +3 -3
- package/dist/src/{createHash-Da8fMwqB.js → createHash-DPpsZgFF.js} +3 -3
- package/dist/src/{createHash-DmPQkvBh.js → createHash-Un4Q_huE.js} +3 -3
- package/dist/src/{createHash-BYwImsYv.cjs → createHash-VvBIc-AW.cjs} +4 -4
- package/dist/src/{docker-CxCkwMzc.js → docker--3qzPa-6.js} +6 -14
- package/dist/src/{docker-Cqj2-QVi.cjs → docker-D3AY-5F5.cjs} +7 -15
- package/dist/src/{docker-FeBni2dw.js → docker-DCsCDvwM.js} +7 -14
- package/dist/src/{docker-DpguQj-w.js → docker-Dorv4_Dg.js} +6 -16
- package/dist/src/embedding-BXhN5lCH.cjs +63 -0
- package/dist/src/embedding-ChS1ivFS.js +58 -0
- package/dist/src/embedding-DNRvZwRN.js +59 -0
- package/dist/src/embedding-D_bI4NDq.js +58 -0
- package/dist/src/entrypoint.js +69 -6
- package/dist/src/{errors-P6ll7XSJ.js → errors-DFHe4L-n.js} +1 -1
- package/dist/src/{esm-SUNIX1x3.js → esm-B6whoAcf.js} +15 -6
- package/dist/src/{esm-CKWP3u_P.js → esm-BRkfNsYs.js} +16 -7
- package/dist/src/{esm-7UIl0pPM.js → esm-BX8fwlAO.js} +27 -18
- package/dist/src/{esm-CipptfDu.cjs → esm-B_rGuPTo.cjs} +15 -6
- package/dist/src/eval-BQPLBJbw.js +3 -0
- package/dist/src/{eval-BTqTn7lb.js → eval-DJ_4A-tr.js} +50 -21
- package/dist/src/evalResult-BBJAHAtw.cjs +2 -0
- package/dist/src/evalResult-BBK58h2B.js +3 -0
- package/dist/src/{evalResult-DpARzUCb.cjs → evalResult-Cx-8OWkb.cjs} +29 -11
- package/dist/src/{evalResult-DUDShQrm.js → evalResult-D6P5I5il.js} +29 -11
- package/dist/src/{evalResult-BkIhRdTe.js → evalResult-pSvGWFMo.js} +29 -11
- package/dist/src/evalResult-spPqh1G_.js +2 -0
- package/dist/src/{evaluator-BcvOGaam.js → evaluator-D-UIbbYq.js} +3975 -2152
- package/dist/src/evaluator-DgLKaZk8.js +3 -0
- package/dist/src/{extractor-D_wd8jxt.js → extractor-BM3jRERL.js} +6 -6
- package/dist/src/{extractor-DG3sSfXE.cjs → extractor-Dxr2J_wK.cjs} +6 -6
- package/dist/src/{extractor-CAZ2G3Kh.js → extractor-DxyiFhPk.js} +6 -6
- package/dist/src/{extractor-C8XwivI9.js → extractor-YlZbUMsL.js} +6 -6
- package/dist/src/fetch-8viavNv8.js +3 -0
- package/dist/src/{fetch-DoVRJZhJ.js → fetch-B6ch2nU2.js} +199 -60
- package/dist/src/{fetch-CVAtKnI3.js → fetch-D9xxyC1p.js} +404 -252
- package/dist/src/{fetch-BnR9wSnm.cjs → fetch-NuqXW1Xb.cjs} +415 -263
- package/dist/src/{fetch-BiYv2BZc.js → fetch-Y5qX_kST.js} +222 -70
- package/dist/src/{fileExtensions-LcDYkU4v.js → fileExtensions-8CjoL7vB.js} +1 -1
- package/dist/src/{fileExtensions-DnqA1y9x.js → fileExtensions-BGh-W-HT.js} +1 -1
- package/dist/src/{fileExtensions-bYh77CN8.cjs → fileExtensions-D9h-8Wxg.cjs} +1 -1
- package/dist/src/{fileExtensions-Ds-foDzt.js → fileExtensions-DysCsxNG.js} +1 -1
- package/dist/src/{formatDuration-DgBVMN65.js → formatDuration-Ch4A7G3o.js} +1 -1
- package/dist/src/{genaiTracer-BfxrvSUb.cjs → genaiTracer-BokHC-MW.cjs} +7 -3
- package/dist/src/{genaiTracer-C1rxGO8Q.js → genaiTracer-C3ZPQU60.js} +6 -2
- package/dist/src/{genaiTracer-70Z8BIuV.js → genaiTracer-CFny3gOy.js} +6 -2
- package/dist/src/{genaiTracer-D3fD9dNV.js → genaiTracer-DxODqT9e.js} +6 -2
- package/dist/src/golang/wrapper.go +1 -1
- package/dist/src/{graders-DG7mhg-b.js → graders-BoUqsCEm.js} +7402 -5699
- package/dist/src/{graders-BElhu9ZY.cjs → graders-Bw1wk_21.cjs} +5220 -3437
- package/dist/src/graders-C84JI-m5.js +2 -0
- package/dist/src/graders-CBbd0K0Q.cjs +2 -0
- package/dist/src/graders-CbQqpHSN.js +3 -0
- package/dist/src/{graders-RjHF8VfG.js → graders-CgPn32yp.js} +7400 -5697
- package/dist/src/{graders-BXAJ0sbS.js → graders-CwrbifOo.js} +6136 -4433
- package/dist/src/graders-DS42d3ZG.js +2 -0
- package/dist/src/{image-6WQXK8m8.js → image-BeWaInPF.js} +4 -4
- package/dist/src/{image-PoF6DN3x.js → image-BmilRNqO.js} +8 -8
- package/dist/src/{image--F58eEIn.cjs → image-CxJoa3aW.cjs} +8 -8
- package/dist/src/{image-fza3zuKs.cjs → image-D10dNAav.cjs} +4 -4
- package/dist/src/{image-DO0RYnjH.js → image-Dr_3I3nK.js} +4 -5
- package/dist/src/{image-B8b6f36E.js → image-DsGRlkh7.js} +8 -8
- package/dist/src/{image-CoxZp9PZ.js → image-a_SGUobh.js} +8 -8
- package/dist/src/{image-xNbw5ph2.js → image-qjO6FWPs.js} +4 -4
- package/dist/src/index.cjs +4835 -2582
- package/dist/src/index.d.cts +2782 -31
- package/dist/src/index.d.ts +2783 -32
- package/dist/src/index.js +4817 -2564
- package/dist/src/{interactiveCheck-BnMYOjMu.js → interactiveCheck-CCICw2cy.js} +2 -2
- package/dist/src/{invariant-BtWWVVhl.js → invariant-B2Rf6avk.js} +1 -1
- package/dist/src/{invariant-vgHWClmd.js → invariant-DIYf9sP1.js} +1 -1
- package/dist/src/{knowledgeBase-Bi7CmDbx.js → knowledgeBase-BBETc5-S.js} +6 -8
- package/dist/src/{knowledgeBase-DqrLX8fy.cjs → knowledgeBase-C8qOo26M.cjs} +6 -8
- package/dist/src/{knowledgeBase-DFRXPZl_.js → knowledgeBase-CzAi2rUI.js} +7 -8
- package/dist/src/{knowledgeBase-Ce3ofVan.js → knowledgeBase-Dr3Kib7F.js} +6 -10
- package/dist/src/{litellm-CKiAxnoM.js → litellm-BLSiANhk.js} +6 -14
- package/dist/src/{litellm-CnHI69aj.cjs → litellm-CaUmV7Mk.cjs} +6 -15
- package/dist/src/{litellm-Tc294Jhj.js → litellm-DQGo_juI.js} +5 -14
- package/dist/src/{litellm-Bo2gQXpo.js → litellm-DRc4qWfc.js} +5 -16
- package/dist/src/{logger-BcJBzSSA.js → logger-BbY6ypFL.js} +41 -12
- package/dist/src/{logger-D5iKBpu_.cjs → logger-COuQb2xB.cjs} +51 -10
- package/dist/src/{logger-DO8_zM18.js → logger-Ct2S6Yx-.js} +40 -11
- package/dist/src/{logger-BnkjG2jt.js → logger-KD8JjCRJ.js} +41 -12
- package/dist/src/{luma-ray-C9q8rdQe.js → luma-ray-B-tNZzqW.js} +6 -10
- package/dist/src/{luma-ray-DP0QA9qn.js → luma-ray-CtS3OlGq.js} +6 -10
- package/dist/src/{luma-ray-0ehMPt5N.js → luma-ray-PJJgUjOc.js} +6 -11
- package/dist/src/{luma-ray-m9Ku2meV.cjs → luma-ray-if-Ml4R9.cjs} +6 -10
- package/dist/src/main.d.ts +1 -26
- package/dist/src/main.js +1188 -679
- package/dist/src/messages-B9dSjrNf.js +544 -0
- package/dist/src/messages-BnsVHUnm.cjs +558 -0
- package/dist/src/messages-CI69Lasb.js +543 -0
- package/dist/src/messages-CewuNcNS.js +543 -0
- package/dist/src/{meteor-DLZZ3osF.cjs → meteor-BBGcGeCa.cjs} +1 -1
- package/dist/src/{meteor-DUiCJRC-.js → meteor-BKTM-7KS.js} +1 -1
- package/dist/src/{meteor-44VjEACX.js → meteor-CeGo0Lu2.js} +2 -2
- package/dist/src/{meteor-D-SotUw9.js → meteor-Wc_aUVvu.js} +2 -2
- package/dist/src/{modelslab-B5J-ZM5c.js → modelslab-BCLOtfek.js} +8 -10
- package/dist/src/{modelslab-IQbNg-r7.cjs → modelslab-BkapYJhh.cjs} +7 -10
- package/dist/src/{modelslab-BTOT8FUO.js → modelslab-D73OnKSx.js} +7 -10
- package/dist/src/{modelslab-BI458moT.js → modelslab-zpz9JcK0.js} +7 -12
- package/dist/src/{nova-reel-BZ9y-Y5s.js → nova-reel-B8F_TK5w.js} +7 -10
- package/dist/src/{nova-reel-Xw1SXLpg.js → nova-reel-Bx0NFV2f.js} +6 -10
- package/dist/src/{nova-reel-DEeQlnOJ.js → nova-reel-CNGJTLtG.js} +6 -12
- package/dist/src/{nova-reel-CE5etkv9.cjs → nova-reel-DkT7tnoB.cjs} +6 -10
- package/dist/src/{nova-sonic-Ogqf-csn.js → nova-sonic-BaXRN1cr.js} +5 -7
- package/dist/src/{nova-sonic-DXTLpi-r.js → nova-sonic-BeTRaFOh.js} +4 -7
- package/dist/src/{nova-sonic-DWswpN1E.js → nova-sonic-CL7Zqv0G.js} +4 -9
- package/dist/src/{nova-sonic-N0yCm0vb.cjs → nova-sonic-YT426juD.cjs} +4 -7
- package/dist/src/{openai-BcB5KlTk.js → openai-BMHD2Huo.js} +6 -3
- package/dist/src/{openai-BMcwgD5C.js → openai-BT-JvDse.js} +6 -3
- package/dist/src/{openai-CoxGAQwn.cjs → openai-Cy1XLs0c.cjs} +6 -3
- package/dist/src/{openai-D6wITiVn.js → openai-D4fxGvRx.js} +6 -3
- package/dist/src/openclaw-Bq7RVR3k.js +1200 -0
- package/dist/src/openclaw-DA8U4DsD.js +1201 -0
- package/dist/src/openclaw-DObVgpjC.js +1200 -0
- package/dist/src/openclaw-DUBZP3GL.cjs +1206 -0
- package/dist/src/{opencode-sdk-CHCs7dEb.js → opencode-sdk-BB40Wir1.js} +6 -8
- package/dist/src/{opencode-sdk-DDxj4QqH.js → opencode-sdk-BM1UAIv1.js} +6 -8
- package/dist/src/{opencode-sdk-WWJhnbKr.cjs → opencode-sdk-CeqiOcOU.cjs} +7 -9
- package/dist/src/{opencode-sdk-C71Z0ehR.js → opencode-sdk-ChdK7F7z.js} +6 -9
- package/dist/src/{otlpReceiver-CZL48YfC.js → otlpReceiver-C6thJRXi.js} +154 -98
- package/dist/src/{otlpReceiver-C9KlUtxh.js → otlpReceiver-CcdIikOu.js} +154 -98
- package/dist/src/{otlpReceiver-DHKqJlsz.cjs → otlpReceiver-DNSQj6bf.cjs} +154 -98
- package/dist/src/{otlpReceiver-CavGAA6k.js → otlpReceiver-UYMQx3sy.js} +154 -98
- package/dist/src/{providerRegistry-BkzVH5Ba.js → providerRegistry-1gB5vtzQ.js} +2 -2
- package/dist/src/{providerRegistry-BTDgfV5h.cjs → providerRegistry-BESeALrr.cjs} +2 -2
- package/dist/src/{providerRegistry-CUWki5mQ.js → providerRegistry-DoACwqhD.js} +2 -2
- package/dist/src/{providerRegistry-B9lh-_tx.js → providerRegistry-PMsleEzs.js} +2 -2
- package/dist/src/providers-BuyzKt7C.js +2 -0
- package/dist/src/providers-C7lNVBjX.cjs +3 -0
- package/dist/src/providers-CCE2COJi2.js +2 -0
- package/dist/src/{providers-Cn73d5sr.js → providers-CJh7iriU.js} +17180 -16823
- package/dist/src/providers-Ctcc592x.js +3 -0
- package/dist/src/{providers-DvddrgxL.js → providers-DRrerKra.js} +1052 -695
- package/dist/src/{providers-Ch6Mr0gn.js → providers-DT-GtF2t.js} +16716 -16359
- package/dist/src/{providers-CScd1wN6.cjs → providers-eDShy16E.cjs} +19893 -19506
- package/dist/src/python/persistent_wrapper.py +0 -5
- package/dist/src/{pythonUtils-Cpo0Ez1p.js → pythonUtils-C4tltmIn.js} +4 -4
- package/dist/src/{pythonUtils-dAVigVK-.cjs → pythonUtils-CoLaCwNY.cjs} +4 -4
- package/dist/src/{pythonUtils-Bzwbgpbg.js → pythonUtils-DMO68Jg7.js} +3 -3
- package/dist/src/{pythonUtils-wIqk7zAf.js → pythonUtils-DNqbnRdx.js} +3 -3
- package/dist/src/{quiverai-BeofbLVc.js → quiverai-BSS9a7wV.js} +4 -4
- package/dist/src/{quiverai-DVSEqJiq.js → quiverai-Bk1KrvL6.js} +4 -4
- package/dist/src/{quiverai-CcUhPIBg.cjs → quiverai-Bpx6MZ7T.cjs} +4 -4
- package/dist/src/{quiverai-CCQn73lq.js → quiverai-CPKhWgaT.js} +4 -5
- package/dist/src/render-7uNJ2V14.js +135 -0
- package/dist/src/render-DlscvAUJ.js +135 -0
- package/dist/src/render-eui5p5mL.js +136 -0
- package/dist/src/{render-BHl6QVq9.js → render-nj-UaPdn.js} +2 -3
- package/dist/src/render-tG6ir9_g.cjs +165 -0
- package/dist/src/{responses-CgNyTPsY.js → responses-1ztiVYsx.js} +56 -17
- package/dist/src/{responses-BKP_WYis.js → responses-B8haB-mD.js} +56 -17
- package/dist/src/{responses-CQb1Tj69.js → responses-BiaBguAu.js} +56 -17
- package/dist/src/{responses-mo0KQDbu.cjs → responses-CF-ayauu.cjs} +56 -17
- package/dist/src/rubyUtils-4hjGxvju.js +3 -0
- package/dist/src/{rubyUtils-DECSbsfY.js → rubyUtils-BI0p46eZ.js} +3 -3
- package/dist/src/{rubyUtils-CiVfln3g.js → rubyUtils-CIQFnVz4.js} +3 -3
- package/dist/src/rubyUtils-CO-tuszQ.cjs +2 -0
- package/dist/src/{rubyUtils-PgU-gHmx.js → rubyUtils-DGnoCYL2.js} +4 -4
- package/dist/src/{rubyUtils-CGeUtCfW.cjs → rubyUtils-DoifqkiA.cjs} +5 -4
- package/dist/src/{sagemaker-CqeASYE5.js → sagemaker-BDLeW29y.js} +14 -18
- package/dist/src/{sagemaker-MUbD5V3v.js → sagemaker-C5T60MKf.js} +14 -19
- package/dist/src/{sagemaker-CVv8W7so.js → sagemaker-ClS_NB07.js} +14 -18
- package/dist/src/{sagemaker-jiw1wQa-.cjs → sagemaker-ljtY12VM.cjs} +14 -18
- package/dist/src/{scanner-DVDeUz1r.js → scanner-nOCWNIXa.js} +130 -35
- package/dist/src/server/golang/wrapper.go +1 -1
- package/dist/src/server/index.js +4829 -2529
- package/dist/src/server/python/persistent_wrapper.py +0 -5
- package/dist/src/{server-BtoCXeXI.cjs → server-BEECpeGG.cjs} +140 -6
- package/dist/src/{server-DZ9MtCn0.js → server-ByiF3qlg.js} +129 -9
- package/dist/src/{server-Cns05F1j.js → server-ByxbqAcQ.js} +128 -8
- package/dist/src/server-C0XKRNB_.cjs +2 -0
- package/dist/src/server-C_15p79-.js +3 -0
- package/dist/src/{server-CP9qKM40.js → server-gyd6d4Hc.js} +126 -7
- package/dist/src/{signal-C3ZTsUgi.js → signal-DTtUuU3l.js} +3 -3
- package/dist/src/{slack-DCEV-vWP.js → slack-4zZX1OKP.js} +2 -2
- package/dist/src/{slack-94iG3T0s.cjs → slack-BLlsDpfG.cjs} +2 -2
- package/dist/src/{slack-BR0HtO3K.js → slack-BPYLQLgb.js} +2 -2
- package/dist/src/{slack-2sdpGzbt.js → slack-Bamy_7te.js} +2 -2
- package/dist/src/{store-CLyU7AtI.cjs → store-2K0kDi80.cjs} +3 -3
- package/dist/src/{store-VB0GP46K.js → store-2OXm_eBY.js} +3 -3
- package/dist/src/store-BELqNwvz.js +3 -0
- package/dist/src/{store-Cj258DgL.js → store-BPkzEyFM.js} +3 -3
- package/dist/src/{store-P8OKm19S.js → store-CPh25336.js} +3 -3
- package/dist/src/store-uQZ4AjPe.cjs +2 -0
- package/dist/src/{tables-BEIFz2tM.js → tables-BMSOS2Gg.js} +3 -3
- package/dist/src/{tables-BdZQEpRz.cjs → tables-CXbaZ9y1.cjs} +3 -3
- package/dist/src/{tables-DmzvLbeZ.js → tables-NlvH23ky.js} +3 -3
- package/dist/src/{tables-kC7R5kiK.js → tables-WgdUZ8Ck.js} +3 -3
- package/dist/src/{telemetry-DPXLd7UE.js → telemetry--iqaGyaS.js} +5 -4
- package/dist/src/{telemetry-re627Lre.cjs → telemetry-CEQxGnMZ.cjs} +8 -7
- package/dist/src/{telemetry-BugWqKiu.js → telemetry-CgdVGV8N.js} +5 -4
- package/dist/src/{telemetry-BnH5VJAU.js → telemetry-DWdGHvEf.js} +5 -4
- package/dist/src/telemetry-DjNoC_n3.cjs +2 -0
- package/dist/src/telemetry-ZdPZc0fm.js +3 -0
- package/dist/src/{text-CW1cyrwj.cjs → text-BiNME7QG.cjs} +1 -1
- package/dist/src/{text-Db-Wt2u2.js → text-D4lz-Jg_.js} +1 -1
- package/dist/src/{text-TIv0QYnd.js → text-DDQP0tuQ.js} +1 -1
- package/dist/src/{text-B_UCRPp2.js → text-NWvfMfkF.js} +1 -1
- package/dist/src/{tokenUsageUtils-DflFMjS0.js → tokenUsageUtils-2wIvAhB3.js} +7 -3
- package/dist/src/{tokenUsageUtils-BDGe-iyI.js → tokenUsageUtils-4c780gFd.js} +7 -3
- package/dist/src/{tokenUsageUtils-NYT-WKS6.js → tokenUsageUtils-BjVkdk18.js} +7 -3
- package/dist/src/{tokenUsageUtils-bVa1ga6f.cjs → tokenUsageUtils-C9odhsbW.cjs} +7 -3
- package/dist/src/{transcription-CaMivnjG.js → transcription-84t4ALo2.js} +7 -11
- package/dist/src/{transcription-Hb3VnC4M.js → transcription-Bm2emLmJ.js} +8 -11
- package/dist/src/{transcription-BvtsrzRG.cjs → transcription-CZ4LG5hQ.cjs} +9 -13
- package/dist/src/{transcription-DOMMTu01.js → transcription-D7Q0vJsh.js} +7 -13
- package/dist/src/{transform-DrleutM3.js → transform-B-b6Cq-q.js} +8 -6
- package/dist/src/transform-BQt0BeAW.js +3 -0
- package/dist/src/transform-Bq5oqC0s.cjs +2 -0
- package/dist/src/{transform-ZrG2dvlo.cjs → transform-C9izGX54.cjs} +5 -5
- package/dist/src/{transform-BzK09Q_9.js → transform-CwbAZ84V.js} +5 -5
- package/dist/src/{transform-0BwoBsvO.cjs → transform-Dg4LcO1Y.cjs} +18 -10
- package/dist/src/{transform-B2-jIv68.js → transform-DtooZqYY.js} +8 -6
- package/dist/src/{transform-ljLYHEPh.js → transform-DzCF-wqV.js} +5 -5
- package/dist/src/{transform-DyDAwEpE.js → transform-_DpNB4qp.js} +9 -7
- package/dist/src/{transform-BqPkNPYm.js → transform-eGiUAv86.js} +5 -5
- package/dist/src/{transformersAvailability-DKoRtQLy.cjs → transformersAvailability-B22swDxr.cjs} +1 -1
- package/dist/src/{transformersAvailability-BGkzavwb.js → transformersAvailability-lvCCvuPT.js} +1 -1
- package/dist/src/{transformersAvailability-D6c6ROpT.js → transformersAvailability-rJGPccjr.js} +1 -1
- package/dist/src/{types-Cd3ygw8W.js → types-BDjGOq4E.js} +354 -24
- package/dist/src/{types-CIhFeUC4.js → types-BVH9hjgW.js} +364 -23
- package/dist/src/{types-D8cGDZbL.cjs → types-CgG2rKiW.cjs} +534 -167
- package/dist/src/{types-q8GXGF65.js → types-DNRZVOue.js} +498 -167
- package/dist/src/{util-BLvy9qfE.js → util-3pBZZb_H.js} +151 -149
- package/dist/src/{util-CFj4YKIn.cjs → util-A5_ZsQUn.cjs} +66 -44
- package/dist/src/{util-BtoGs5Cb.js → util-B9CNhyac.js} +66 -44
- package/dist/src/{util-Bm3E9jpK.js → util-BQOCAHQC.js} +692 -690
- package/dist/src/{util-vNmDL5DT.js → util-BVXcTwXu.js} +138 -36
- package/dist/src/{util-CgDCK4KI.js → util-BlFVL0UF.js} +66 -44
- package/dist/src/{util-DM2rTn_6.js → util-C-kmRosx.js} +66 -44
- package/dist/src/{util-DbVG-yZU.js → util-DFPeFkiV.js} +138 -36
- package/dist/src/{util-DMFeUvLz.js → util-DN0-b81k.js} +138 -36
- package/dist/src/{util--9u9UVCt.cjs → util-Dpmm_dAI.cjs} +143 -35
- package/dist/src/{util-CMMkIxfU.js → util-Dub0f_ej.js} +693 -691
- package/dist/src/{util-CuLo2pMR.cjs → util-DvpHnLt0.cjs} +714 -719
- package/dist/src/{utils-DOjD4dTC.js → utils-BUMN8orw.js} +6 -4
- package/dist/src/{utils-DKw8mrgr.cjs → utils-DkVeShIB.cjs} +6 -4
- package/dist/src/{utils-DEuL4VNB.js → utils-kt7lv30R.js} +6 -4
- package/dist/src/{utils-CFxO9KGo.js → utils-o8S5huU2.js} +6 -4
- package/dist/src/version-0frU0UTr.js +16 -0
- package/dist/src/version-CbpiUINz.js +17 -0
- package/dist/src/version-CbuBKu2U.js +16 -0
- package/dist/src/version-D9zu9FWB.cjs +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -46
- package/dist/src/app/assets/index-B6l9CVVb.js +0 -439
- package/dist/src/app/assets/index-DyZ0Ep37.css +0 -1
- package/dist/src/app/assets/scroll-timeline-BdJZVXlz.js +0 -1
- package/dist/src/app/assets/sync-CStkzc6u.js +0 -4
- package/dist/src/app/assets/vendor-charts-BnDWwBlI.js +0 -36
- package/dist/src/app/assets/vendor-markdown-Bz7N-ca6.js +0 -29
- package/dist/src/app/assets/vendor-react-AtKqiNEf.js +0 -4
- package/dist/src/app/assets/vendor-syntax-D06x6TQF.js +0 -2
- package/dist/src/app/assets/vendor-utils-BvMHZmO7.js +0 -37
- package/dist/src/cache-C5yFZ4gC.cjs +0 -816
- package/dist/src/cache-CaT5tPgo.js +0 -756
- package/dist/src/cache-CyCanoMu.js +0 -6
- package/dist/src/cache-DSqR6ezl.js +0 -726
- package/dist/src/cache-Df_QFDNu.cjs +0 -5
- package/dist/src/cache-HP0NP4k3.js +0 -756
- package/dist/src/cloud-DE3t1-ZI.js +0 -4
- package/dist/src/codex-sdk-BQEw16R_.js +0 -834
- package/dist/src/codex-sdk-C_07GuVS.js +0 -834
- package/dist/src/codex-sdk-DE5G18dx.js +0 -835
- package/dist/src/codex-sdk-ZLKfDjqP.cjs +0 -838
- package/dist/src/eval-7aEqoMs3.js +0 -15
- package/dist/src/evalResult-CYNHkk5A.js +0 -12
- package/dist/src/evalResult-CuvJeNiM.js +0 -10
- package/dist/src/evalResult-tGdilrWt.cjs +0 -10
- package/dist/src/evaluator-BBUqRhz1.js +0 -36
- package/dist/src/fetch-UWU706qb.js +0 -5
- package/dist/src/graders-BxfEguVY.js +0 -32
- package/dist/src/graders-CzVMbEnv.js +0 -34
- package/dist/src/graders-DjCXfj0l.cjs +0 -32
- package/dist/src/graders-kHzIWOKu.js +0 -32
- package/dist/src/messages-DJNo37Ko.js +0 -246
- package/dist/src/messages-Dy9QecMs.js +0 -245
- package/dist/src/messages-HJsyEh4o.cjs +0 -257
- package/dist/src/messages-biC_ex-p.js +0 -245
- package/dist/src/openclaw-0Sv7AK3O.js +0 -580
- package/dist/src/openclaw-CXxbKgDH.cjs +0 -586
- package/dist/src/openclaw-D1FSCps-.js +0 -580
- package/dist/src/openclaw-D2ENvu7a.js +0 -582
- package/dist/src/providers-BSLEaIQG.js +0 -32
- package/dist/src/providers-D-FnDg8k.cjs +0 -31
- package/dist/src/providers-DEYiFVAo.js +0 -30
- package/dist/src/providers-sS2WI8YD.js +0 -30
- package/dist/src/rubyUtils-B1HXG4ej.cjs +0 -4
- package/dist/src/rubyUtils-Rt6pKA96.js +0 -5
- package/dist/src/server-B0Xh1Gx-.js +0 -7
- package/dist/src/server-DJTKu9IR.cjs +0 -5
- package/dist/src/store-C5u6MgC8.js +0 -6
- package/dist/src/store-CNHk-De4.cjs +0 -5
- package/dist/src/telemetry-Yig0Tino.js +0 -7
- package/dist/src/telemetry-p8Pwqm1i.cjs +0 -5
- package/dist/src/transform-ChNIpHz7.js +0 -6
- package/dist/src/transform-PtQ6rAE3.cjs +0 -5
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-DEq-mXcV.js";
|
|
2
|
-
import {
|
|
2
|
+
import { S as getEnvBool, T as getEnvString, a as logger, i as logRequestResponse, k as state, p as sanitizeUrl, w as getEnvInt, x as getConfigDirectoryPath } from "./logger-Ct2S6Yx-.js";
|
|
3
3
|
import { t as invariant } from "./invariant-Ddh24eXh.js";
|
|
4
|
-
import
|
|
4
|
+
import { n as VERSION } from "./version-CbuBKu2U.js";
|
|
5
|
+
import * as fs$2 from "fs";
|
|
5
6
|
import * as path$1 from "path";
|
|
6
7
|
import path from "path";
|
|
7
8
|
import yaml from "js-yaml";
|
|
8
|
-
import { promisify } from "util";
|
|
9
9
|
import * as fsPromises from "fs/promises";
|
|
10
10
|
import { getProxyForUrl } from "proxy-from-env";
|
|
11
11
|
import { Agent, ProxyAgent } from "undici";
|
|
12
|
+
import { promisify } from "util";
|
|
12
13
|
import { gzip } from "zlib";
|
|
13
14
|
//#region src/providers/constants.ts
|
|
14
15
|
const FILE_METADATA_KEY = "_promptfooFileMetadata";
|
|
@@ -17,19 +18,6 @@ const FILE_METADATA_KEY = "_promptfooFileMetadata";
|
|
|
17
18
|
* Used to distinguish human ratings from automated assertions.
|
|
18
19
|
*/
|
|
19
20
|
const HUMAN_ASSERTION_TYPE = "human";
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/version.ts
|
|
22
|
-
/**
|
|
23
|
-
* Application version from package.json.
|
|
24
|
-
* Injected at build time, or read from npm environment in development.
|
|
25
|
-
*/
|
|
26
|
-
const VERSION = "0.121.3";
|
|
27
|
-
/**
|
|
28
|
-
* PostHog analytics key.
|
|
29
|
-
* Only populated during production builds via PROMPTFOO_POSTHOG_KEY env var.
|
|
30
|
-
* Empty string in development/test.
|
|
31
|
-
*/
|
|
32
|
-
const POSTHOG_KEY = "phc_E5n5uHnDo2eREJL1uqX1cIlbkoRby4yFWt3V94HqRRg";
|
|
33
21
|
function getShareApiBaseUrl() {
|
|
34
22
|
return getEnvString("PROMPTFOO_REMOTE_API_BASE_URL") || "https://api.promptfoo.app";
|
|
35
23
|
}
|
|
@@ -45,6 +33,220 @@ const CONSENT_ENDPOINT = "https://api.promptfoo.dev/consent";
|
|
|
45
33
|
const EVENTS_ENDPOINT = "https://a.promptfoo.app";
|
|
46
34
|
const R_ENDPOINT = "https://r.promptfoo.app/";
|
|
47
35
|
//#endregion
|
|
36
|
+
//#region src/globalConfig/globalConfig.ts
|
|
37
|
+
/**
|
|
38
|
+
* Functions for manipulating the global configuration file, which lives at
|
|
39
|
+
* ~/.promptfoo/promptfoo.yaml by default.
|
|
40
|
+
*/
|
|
41
|
+
function writeGlobalConfig(config) {
|
|
42
|
+
fs$2.writeFileSync(path$1.join(getConfigDirectoryPath(true), "promptfoo.yaml"), yaml.dump(config));
|
|
43
|
+
}
|
|
44
|
+
function readGlobalConfig() {
|
|
45
|
+
const configDir = getConfigDirectoryPath();
|
|
46
|
+
const configFilePath = path$1.join(configDir, "promptfoo.yaml");
|
|
47
|
+
let globalConfig = { id: crypto.randomUUID() };
|
|
48
|
+
if (fs$2.existsSync(configFilePath)) {
|
|
49
|
+
globalConfig = yaml.load(fs$2.readFileSync(configFilePath, "utf-8")) || {};
|
|
50
|
+
if (!globalConfig?.id) {
|
|
51
|
+
globalConfig = {
|
|
52
|
+
...globalConfig,
|
|
53
|
+
id: crypto.randomUUID()
|
|
54
|
+
};
|
|
55
|
+
writeGlobalConfig(globalConfig);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
if (!fs$2.existsSync(configDir)) fs$2.mkdirSync(configDir, { recursive: true });
|
|
59
|
+
fs$2.writeFileSync(configFilePath, yaml.dump(globalConfig));
|
|
60
|
+
}
|
|
61
|
+
return globalConfig;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Merges the top-level keys into existing config.
|
|
65
|
+
* @param partialConfig New keys to merge into the existing config.
|
|
66
|
+
*/
|
|
67
|
+
function writeGlobalConfigPartial(partialConfig) {
|
|
68
|
+
const updatedConfig = { ...readGlobalConfig() };
|
|
69
|
+
Object.entries(partialConfig).forEach(([key, value]) => {
|
|
70
|
+
if (value !== void 0 && value !== null) updatedConfig[key] = value;
|
|
71
|
+
else delete updatedConfig[key];
|
|
72
|
+
});
|
|
73
|
+
writeGlobalConfig(updatedConfig);
|
|
74
|
+
}
|
|
75
|
+
const API_HOST = getEnvString("API_HOST", "https://api.promptfoo.app");
|
|
76
|
+
const SHARING_CUTOFF_DATE = /* @__PURE__ */ new Date("2026-03-09T00:00:00Z");
|
|
77
|
+
var CloudConfig = class {
|
|
78
|
+
config;
|
|
79
|
+
constructor() {
|
|
80
|
+
const savedConfig = readGlobalConfig()?.cloud || {};
|
|
81
|
+
this.config = {
|
|
82
|
+
appUrl: savedConfig.appUrl || "https://www.promptfoo.app",
|
|
83
|
+
apiHost: savedConfig.apiHost,
|
|
84
|
+
apiKey: savedConfig.apiKey,
|
|
85
|
+
sharing: savedConfig.sharing,
|
|
86
|
+
currentOrganizationId: savedConfig.currentOrganizationId,
|
|
87
|
+
currentTeamId: savedConfig.currentTeamId,
|
|
88
|
+
teams: savedConfig.teams
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the API key from config file or PROMPTFOO_API_KEY environment variable.
|
|
93
|
+
* Config file takes precedence over environment variable.
|
|
94
|
+
*/
|
|
95
|
+
resolveApiKey() {
|
|
96
|
+
return this.config.apiKey || process.env.PROMPTFOO_API_KEY;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the API host from config file, PROMPTFOO_CLOUD_API_URL environment variable,
|
|
100
|
+
* or defaults to the standard cloud API host.
|
|
101
|
+
* Config file takes precedence over environment variable.
|
|
102
|
+
*/
|
|
103
|
+
resolveApiHost() {
|
|
104
|
+
return this.config.apiHost || process.env.PROMPTFOO_CLOUD_API_URL || API_HOST;
|
|
105
|
+
}
|
|
106
|
+
isEnabled() {
|
|
107
|
+
return !!this.resolveApiKey();
|
|
108
|
+
}
|
|
109
|
+
setApiHost(apiHost) {
|
|
110
|
+
this.config.apiHost = apiHost;
|
|
111
|
+
this.saveConfig();
|
|
112
|
+
}
|
|
113
|
+
setApiKey(apiKey) {
|
|
114
|
+
this.config.apiKey = apiKey;
|
|
115
|
+
this.saveConfig();
|
|
116
|
+
}
|
|
117
|
+
getApiKey() {
|
|
118
|
+
return this.resolveApiKey();
|
|
119
|
+
}
|
|
120
|
+
getApiHost() {
|
|
121
|
+
return this.resolveApiHost();
|
|
122
|
+
}
|
|
123
|
+
setAppUrl(appUrl) {
|
|
124
|
+
this.config.appUrl = appUrl;
|
|
125
|
+
this.saveConfig();
|
|
126
|
+
}
|
|
127
|
+
getAppUrl() {
|
|
128
|
+
return this.config.appUrl;
|
|
129
|
+
}
|
|
130
|
+
getSharing() {
|
|
131
|
+
return this.config.sharing;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Sets the sharing preference. Note: this value is only updated at authentication time
|
|
135
|
+
* (via `validateAndSetApiToken`) and may become stale if the user's license status
|
|
136
|
+
* changes between re-authentications.
|
|
137
|
+
*/
|
|
138
|
+
setSharing(sharing) {
|
|
139
|
+
this.config.sharing = sharing;
|
|
140
|
+
this.saveConfig();
|
|
141
|
+
}
|
|
142
|
+
delete() {
|
|
143
|
+
writeGlobalConfigPartial({ cloud: {} });
|
|
144
|
+
this.reload();
|
|
145
|
+
}
|
|
146
|
+
saveConfig() {
|
|
147
|
+
writeGlobalConfigPartial({ cloud: this.config });
|
|
148
|
+
this.reload();
|
|
149
|
+
}
|
|
150
|
+
reload() {
|
|
151
|
+
const savedConfig = readGlobalConfig()?.cloud || {};
|
|
152
|
+
this.config = {
|
|
153
|
+
appUrl: savedConfig.appUrl || "https://www.promptfoo.app",
|
|
154
|
+
apiHost: savedConfig.apiHost,
|
|
155
|
+
apiKey: savedConfig.apiKey,
|
|
156
|
+
sharing: savedConfig.sharing,
|
|
157
|
+
currentOrganizationId: savedConfig.currentOrganizationId,
|
|
158
|
+
currentTeamId: savedConfig.currentTeamId,
|
|
159
|
+
teams: savedConfig.teams
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
saveValidatedApiToken(token, apiHost, user, app, hasActiveLicense) {
|
|
163
|
+
this.setApiKey(token);
|
|
164
|
+
this.setApiHost(apiHost);
|
|
165
|
+
this.setAppUrl(app.url);
|
|
166
|
+
if (typeof hasActiveLicense === "boolean") {
|
|
167
|
+
const createdAt = user?.createdAt ? new Date(user.createdAt) : null;
|
|
168
|
+
const isGrandfathered = createdAt != null && createdAt < SHARING_CUTOFF_DATE;
|
|
169
|
+
this.setSharing(hasActiveLicense || isGrandfathered);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async validateApiToken(token, apiHost) {
|
|
173
|
+
try {
|
|
174
|
+
const { fetchWithProxy } = await Promise.resolve().then(() => fetch_exports);
|
|
175
|
+
const response = await fetchWithProxy(`${apiHost}/api/v1/users/me`, { headers: { Authorization: `Bearer ${token}` } });
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
const errorMessage = await response.text();
|
|
178
|
+
logger.error(`[Cloud] Failed to validate API token: ${errorMessage}. HTTP Status: ${response.status} - ${response.statusText}.`);
|
|
179
|
+
throw new Error("Failed to validate API token: " + response.statusText);
|
|
180
|
+
}
|
|
181
|
+
const { user, organization, app, hasActiveLicense } = await response.json();
|
|
182
|
+
return {
|
|
183
|
+
user,
|
|
184
|
+
organization,
|
|
185
|
+
app,
|
|
186
|
+
...typeof hasActiveLicense === "boolean" ? { hasActiveLicense } : {}
|
|
187
|
+
};
|
|
188
|
+
} catch (err) {
|
|
189
|
+
const error = err;
|
|
190
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
191
|
+
logger.error(`[Cloud] Failed to validate API token with host ${apiHost}: ${errorMessage}`);
|
|
192
|
+
if (error.cause) logger.error(`Cause: ${error.cause}`);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async validateAndSetApiToken(token, apiHost) {
|
|
197
|
+
const { user, organization, app, hasActiveLicense } = await this.validateApiToken(token, apiHost);
|
|
198
|
+
this.saveValidatedApiToken(token, apiHost, user, app, hasActiveLicense);
|
|
199
|
+
return {
|
|
200
|
+
user,
|
|
201
|
+
organization,
|
|
202
|
+
app,
|
|
203
|
+
hasActiveLicense: typeof hasActiveLicense === "boolean" ? hasActiveLicense : false
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
getCurrentOrganizationId() {
|
|
207
|
+
return this.config.currentOrganizationId;
|
|
208
|
+
}
|
|
209
|
+
setCurrentOrganization(organizationId) {
|
|
210
|
+
this.config.currentOrganizationId = organizationId;
|
|
211
|
+
this.saveConfig();
|
|
212
|
+
}
|
|
213
|
+
getCurrentTeamId(organizationId) {
|
|
214
|
+
if (organizationId) return this.config.teams?.[organizationId]?.currentTeamId;
|
|
215
|
+
return this.config.currentTeamId;
|
|
216
|
+
}
|
|
217
|
+
setCurrentTeamId(teamId, organizationId) {
|
|
218
|
+
if (organizationId) {
|
|
219
|
+
if (!this.config.teams) this.config.teams = {};
|
|
220
|
+
if (!this.config.teams[organizationId]) this.config.teams[organizationId] = {};
|
|
221
|
+
this.config.teams[organizationId].currentTeamId = teamId;
|
|
222
|
+
} else this.config.currentTeamId = teamId;
|
|
223
|
+
this.saveConfig();
|
|
224
|
+
}
|
|
225
|
+
clearCurrentTeamId(organizationId) {
|
|
226
|
+
if (organizationId) {
|
|
227
|
+
if (this.config.teams?.[organizationId]) delete this.config.teams[organizationId].currentTeamId;
|
|
228
|
+
} else delete this.config.currentTeamId;
|
|
229
|
+
this.saveConfig();
|
|
230
|
+
}
|
|
231
|
+
cacheTeams(teams, organizationId) {
|
|
232
|
+
if (organizationId) {
|
|
233
|
+
if (!this.config.teams) this.config.teams = {};
|
|
234
|
+
if (!this.config.teams[organizationId]) this.config.teams[organizationId] = {};
|
|
235
|
+
this.config.teams[organizationId].cache = teams.map((t) => ({
|
|
236
|
+
id: t.id,
|
|
237
|
+
name: t.name,
|
|
238
|
+
slug: t.slug,
|
|
239
|
+
lastFetched: (/* @__PURE__ */ new Date()).toISOString()
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
this.saveConfig();
|
|
243
|
+
}
|
|
244
|
+
getCachedTeams(organizationId) {
|
|
245
|
+
if (organizationId) return this.config.teams?.[organizationId]?.cache;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const cloudConfig = new CloudConfig();
|
|
249
|
+
//#endregion
|
|
48
250
|
//#region src/providers/shared.ts
|
|
49
251
|
/**
|
|
50
252
|
* The default timeout for API requests in milliseconds.
|
|
@@ -69,8 +271,9 @@ function calculateCost(modelName, config, promptTokens, completionTokens, models
|
|
|
69
271
|
if (!Number.isFinite(promptTokens) || !Number.isFinite(completionTokens) || typeof promptTokens === "undefined" || typeof completionTokens === "undefined") return;
|
|
70
272
|
const model = models.find((m) => m.id === modelName);
|
|
71
273
|
if (!model || !model.cost) return;
|
|
72
|
-
const
|
|
73
|
-
const
|
|
274
|
+
const longContextCost = model.cost.longContext && promptTokens > model.cost.longContext.threshold ? model.cost.longContext : void 0;
|
|
275
|
+
const inputCost = config.cost ?? longContextCost?.input ?? model.cost.input;
|
|
276
|
+
const outputCost = config.cost ?? longContextCost?.output ?? model.cost.output;
|
|
74
277
|
return inputCost * promptTokens + outputCost * completionTokens;
|
|
75
278
|
}
|
|
76
279
|
/**
|
|
@@ -147,7 +350,7 @@ function isOpenAIToolChoice(obj) {
|
|
|
147
350
|
function openaiToolChoiceToAnthropic(choice) {
|
|
148
351
|
if (typeof choice === "string") switch (choice) {
|
|
149
352
|
case "auto": return { type: "auto" };
|
|
150
|
-
case "none": return { type: "
|
|
353
|
+
case "none": return { type: "none" };
|
|
151
354
|
case "required": return { type: "any" };
|
|
152
355
|
}
|
|
153
356
|
return {
|
|
@@ -283,213 +486,160 @@ function transformTools(tools, format) {
|
|
|
283
486
|
}
|
|
284
487
|
}
|
|
285
488
|
//#endregion
|
|
286
|
-
//#region src/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
489
|
+
//#region src/scheduler/headerParser.ts
|
|
490
|
+
const OPENAI_HEADERS = {
|
|
491
|
+
remainingRequests: "x-ratelimit-remaining-requests",
|
|
492
|
+
remainingTokens: "x-ratelimit-remaining-tokens",
|
|
493
|
+
limitRequests: "x-ratelimit-limit-requests",
|
|
494
|
+
limitTokens: "x-ratelimit-limit-tokens",
|
|
495
|
+
resetRequests: "x-ratelimit-reset-requests",
|
|
496
|
+
resetTokens: "x-ratelimit-reset-tokens"
|
|
497
|
+
};
|
|
498
|
+
const ANTHROPIC_HEADERS = {
|
|
499
|
+
remainingRequests: "anthropic-ratelimit-requests-remaining",
|
|
500
|
+
remainingTokens: "anthropic-ratelimit-tokens-remaining",
|
|
501
|
+
limitRequests: "anthropic-ratelimit-requests-limit",
|
|
502
|
+
limitTokens: "anthropic-ratelimit-tokens-limit",
|
|
503
|
+
reset: "anthropic-ratelimit-requests-reset"
|
|
504
|
+
};
|
|
505
|
+
const STANDARD_HEADERS = {
|
|
506
|
+
remaining: "ratelimit-remaining",
|
|
507
|
+
limit: "ratelimit-limit",
|
|
508
|
+
reset: "ratelimit-reset",
|
|
509
|
+
remainingAlt: "x-ratelimit-remaining",
|
|
510
|
+
limitAlt: "x-ratelimit-limit",
|
|
511
|
+
resetAlt: "x-ratelimit-reset"
|
|
512
|
+
};
|
|
293
513
|
/**
|
|
294
|
-
*
|
|
295
|
-
* ~/.promptfoo/promptfoo.yaml by default.
|
|
514
|
+
* Parse rate limit headers from response.
|
|
296
515
|
*/
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
516
|
+
function parseRateLimitHeaders(headers) {
|
|
517
|
+
const result = {};
|
|
518
|
+
const h = lowercaseKeys(headers);
|
|
519
|
+
result.remainingRequests = parseFirstMatch(h, [
|
|
520
|
+
OPENAI_HEADERS.remainingRequests,
|
|
521
|
+
ANTHROPIC_HEADERS.remainingRequests,
|
|
522
|
+
STANDARD_HEADERS.remainingAlt,
|
|
523
|
+
STANDARD_HEADERS.remaining
|
|
524
|
+
]);
|
|
525
|
+
result.remainingTokens = parseFirstMatch(h, [OPENAI_HEADERS.remainingTokens, ANTHROPIC_HEADERS.remainingTokens]);
|
|
526
|
+
result.limitRequests = parseFirstMatch(h, [
|
|
527
|
+
OPENAI_HEADERS.limitRequests,
|
|
528
|
+
ANTHROPIC_HEADERS.limitRequests,
|
|
529
|
+
STANDARD_HEADERS.limitAlt,
|
|
530
|
+
STANDARD_HEADERS.limit
|
|
531
|
+
]);
|
|
532
|
+
result.limitTokens = parseFirstMatch(h, [OPENAI_HEADERS.limitTokens, ANTHROPIC_HEADERS.limitTokens]);
|
|
533
|
+
for (const name of [
|
|
534
|
+
OPENAI_HEADERS.resetRequests,
|
|
535
|
+
OPENAI_HEADERS.resetTokens,
|
|
536
|
+
ANTHROPIC_HEADERS.reset,
|
|
537
|
+
STANDARD_HEADERS.resetAlt,
|
|
538
|
+
STANDARD_HEADERS.reset
|
|
539
|
+
]) if (h[name] !== void 0) {
|
|
540
|
+
const parsed = parseResetTime(h[name]);
|
|
541
|
+
if (parsed !== null) {
|
|
542
|
+
result.resetAt = parsed;
|
|
543
|
+
break;
|
|
312
544
|
}
|
|
313
|
-
} else {
|
|
314
|
-
if (!fs$1.existsSync(configDir)) fs$1.mkdirSync(configDir, { recursive: true });
|
|
315
|
-
fs$1.writeFileSync(configFilePath, yaml.dump(globalConfig));
|
|
316
545
|
}
|
|
317
|
-
|
|
546
|
+
if (h["retry-after-ms"] !== void 0) {
|
|
547
|
+
const ms = parseInt(h["retry-after-ms"], 10);
|
|
548
|
+
if (!isNaN(ms) && ms >= 0) {
|
|
549
|
+
result.retryAfterMs = ms;
|
|
550
|
+
if (result.resetAt === void 0) result.resetAt = Date.now() + ms;
|
|
551
|
+
}
|
|
552
|
+
} else if (h["retry-after"] !== void 0) {
|
|
553
|
+
const parsed = parseRetryAfter(h["retry-after"]);
|
|
554
|
+
if (parsed !== null) {
|
|
555
|
+
result.retryAfterMs = parsed;
|
|
556
|
+
if (result.resetAt === void 0) result.resetAt = Date.now() + parsed;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return result;
|
|
318
560
|
}
|
|
319
561
|
/**
|
|
320
|
-
*
|
|
321
|
-
*
|
|
562
|
+
* Parse Retry-After header value.
|
|
563
|
+
* Returns duration in milliseconds.
|
|
564
|
+
* Exported for integration use.
|
|
322
565
|
*/
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const savedConfig = readGlobalConfig()?.cloud || {};
|
|
337
|
-
this.config = {
|
|
338
|
-
appUrl: savedConfig.appUrl || "https://www.promptfoo.app",
|
|
339
|
-
apiHost: savedConfig.apiHost,
|
|
340
|
-
apiKey: savedConfig.apiKey,
|
|
341
|
-
sharing: savedConfig.sharing,
|
|
342
|
-
currentOrganizationId: savedConfig.currentOrganizationId,
|
|
343
|
-
currentTeamId: savedConfig.currentTeamId,
|
|
344
|
-
teams: savedConfig.teams
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Returns the API key from config file or PROMPTFOO_API_KEY environment variable.
|
|
349
|
-
* Config file takes precedence over environment variable.
|
|
350
|
-
*/
|
|
351
|
-
resolveApiKey() {
|
|
352
|
-
return this.config.apiKey || process.env.PROMPTFOO_API_KEY;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Returns the API host from config file, PROMPTFOO_CLOUD_API_URL environment variable,
|
|
356
|
-
* or defaults to the standard cloud API host.
|
|
357
|
-
* Config file takes precedence over environment variable.
|
|
358
|
-
*/
|
|
359
|
-
resolveApiHost() {
|
|
360
|
-
return this.config.apiHost || process.env.PROMPTFOO_CLOUD_API_URL || API_HOST;
|
|
361
|
-
}
|
|
362
|
-
isEnabled() {
|
|
363
|
-
return !!this.resolveApiKey();
|
|
364
|
-
}
|
|
365
|
-
setApiHost(apiHost) {
|
|
366
|
-
this.config.apiHost = apiHost;
|
|
367
|
-
this.saveConfig();
|
|
368
|
-
}
|
|
369
|
-
setApiKey(apiKey) {
|
|
370
|
-
this.config.apiKey = apiKey;
|
|
371
|
-
this.saveConfig();
|
|
372
|
-
}
|
|
373
|
-
getApiKey() {
|
|
374
|
-
return this.resolveApiKey();
|
|
375
|
-
}
|
|
376
|
-
getApiHost() {
|
|
377
|
-
return this.resolveApiHost();
|
|
378
|
-
}
|
|
379
|
-
setAppUrl(appUrl) {
|
|
380
|
-
this.config.appUrl = appUrl;
|
|
381
|
-
this.saveConfig();
|
|
382
|
-
}
|
|
383
|
-
getAppUrl() {
|
|
384
|
-
return this.config.appUrl;
|
|
385
|
-
}
|
|
386
|
-
getSharing() {
|
|
387
|
-
return this.config.sharing;
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Sets the sharing preference. Note: this value is only updated at authentication time
|
|
391
|
-
* (via `validateAndSetApiToken`) and may become stale if the user's license status
|
|
392
|
-
* changes between re-authentications.
|
|
393
|
-
*/
|
|
394
|
-
setSharing(sharing) {
|
|
395
|
-
this.config.sharing = sharing;
|
|
396
|
-
this.saveConfig();
|
|
397
|
-
}
|
|
398
|
-
delete() {
|
|
399
|
-
writeGlobalConfigPartial({ cloud: {} });
|
|
400
|
-
this.reload();
|
|
401
|
-
}
|
|
402
|
-
saveConfig() {
|
|
403
|
-
writeGlobalConfigPartial({ cloud: this.config });
|
|
404
|
-
this.reload();
|
|
405
|
-
}
|
|
406
|
-
reload() {
|
|
407
|
-
const savedConfig = readGlobalConfig()?.cloud || {};
|
|
408
|
-
this.config = {
|
|
409
|
-
appUrl: savedConfig.appUrl || "https://www.promptfoo.app",
|
|
410
|
-
apiHost: savedConfig.apiHost,
|
|
411
|
-
apiKey: savedConfig.apiKey,
|
|
412
|
-
sharing: savedConfig.sharing,
|
|
413
|
-
currentOrganizationId: savedConfig.currentOrganizationId,
|
|
414
|
-
currentTeamId: savedConfig.currentTeamId,
|
|
415
|
-
teams: savedConfig.teams
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
async validateAndSetApiToken(token, apiHost) {
|
|
419
|
-
try {
|
|
420
|
-
const { fetchWithProxy } = await Promise.resolve().then(() => fetch_exports);
|
|
421
|
-
const response = await fetchWithProxy(`${apiHost}/api/v1/users/me`, { headers: { Authorization: `Bearer ${token}` } });
|
|
422
|
-
if (!response.ok) {
|
|
423
|
-
const errorMessage = await response.text();
|
|
424
|
-
logger.error(`[Cloud] Failed to validate API token: ${errorMessage}. HTTP Status: ${response.status} - ${response.statusText}.`);
|
|
425
|
-
throw new Error("Failed to validate API token: " + response.statusText);
|
|
426
|
-
}
|
|
427
|
-
const { user, organization, app, hasActiveLicense } = await response.json();
|
|
428
|
-
this.setApiKey(token);
|
|
429
|
-
this.setApiHost(apiHost);
|
|
430
|
-
this.setAppUrl(app.url);
|
|
431
|
-
if (typeof hasActiveLicense === "boolean") {
|
|
432
|
-
const createdAt = user?.createdAt ? new Date(user.createdAt) : null;
|
|
433
|
-
const isGrandfathered = createdAt != null && createdAt < SHARING_CUTOFF_DATE;
|
|
434
|
-
this.setSharing(hasActiveLicense || isGrandfathered);
|
|
435
|
-
}
|
|
436
|
-
return {
|
|
437
|
-
user,
|
|
438
|
-
organization,
|
|
439
|
-
app,
|
|
440
|
-
hasActiveLicense: typeof hasActiveLicense === "boolean" ? hasActiveLicense : false
|
|
441
|
-
};
|
|
442
|
-
} catch (err) {
|
|
443
|
-
const error = err;
|
|
444
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
445
|
-
logger.error(`[Cloud] Failed to validate API token with host ${apiHost}: ${errorMessage}`);
|
|
446
|
-
if (error.cause) logger.error(`Cause: ${error.cause}`);
|
|
447
|
-
throw error;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
getCurrentOrganizationId() {
|
|
451
|
-
return this.config.currentOrganizationId;
|
|
452
|
-
}
|
|
453
|
-
setCurrentOrganization(organizationId) {
|
|
454
|
-
this.config.currentOrganizationId = organizationId;
|
|
455
|
-
this.saveConfig();
|
|
456
|
-
}
|
|
457
|
-
getCurrentTeamId(organizationId) {
|
|
458
|
-
if (organizationId) return this.config.teams?.[organizationId]?.currentTeamId;
|
|
459
|
-
return this.config.currentTeamId;
|
|
460
|
-
}
|
|
461
|
-
setCurrentTeamId(teamId, organizationId) {
|
|
462
|
-
if (organizationId) {
|
|
463
|
-
if (!this.config.teams) this.config.teams = {};
|
|
464
|
-
if (!this.config.teams[organizationId]) this.config.teams[organizationId] = {};
|
|
465
|
-
this.config.teams[organizationId].currentTeamId = teamId;
|
|
466
|
-
} else this.config.currentTeamId = teamId;
|
|
467
|
-
this.saveConfig();
|
|
468
|
-
}
|
|
469
|
-
clearCurrentTeamId(organizationId) {
|
|
470
|
-
if (organizationId) {
|
|
471
|
-
if (this.config.teams?.[organizationId]) delete this.config.teams[organizationId].currentTeamId;
|
|
472
|
-
} else delete this.config.currentTeamId;
|
|
473
|
-
this.saveConfig();
|
|
474
|
-
}
|
|
475
|
-
cacheTeams(teams, organizationId) {
|
|
476
|
-
if (organizationId) {
|
|
477
|
-
if (!this.config.teams) this.config.teams = {};
|
|
478
|
-
if (!this.config.teams[organizationId]) this.config.teams[organizationId] = {};
|
|
479
|
-
this.config.teams[organizationId].cache = teams.map((t) => ({
|
|
480
|
-
id: t.id,
|
|
481
|
-
name: t.name,
|
|
482
|
-
slug: t.slug,
|
|
483
|
-
lastFetched: (/* @__PURE__ */ new Date()).toISOString()
|
|
484
|
-
}));
|
|
566
|
+
function parseRetryAfter(value) {
|
|
567
|
+
const seconds = parseInt(value, 10);
|
|
568
|
+
if (!isNaN(seconds) && seconds >= 0 && String(seconds) === value.trim()) return seconds * 1e3;
|
|
569
|
+
const httpDate = parseHttpDate(value);
|
|
570
|
+
if (httpDate !== null) return Math.max(0, httpDate - Date.now());
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
function parseFirstMatch(headers, names) {
|
|
574
|
+
for (const name of names) {
|
|
575
|
+
const value = headers[name];
|
|
576
|
+
if (value !== void 0) {
|
|
577
|
+
const num = parseInt(value, 10);
|
|
578
|
+
if (!isNaN(num) && num >= 0) return num;
|
|
485
579
|
}
|
|
486
|
-
this.saveConfig();
|
|
487
580
|
}
|
|
488
|
-
|
|
489
|
-
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Parse reset time from various formats.
|
|
584
|
+
* Returns absolute Unix timestamp in milliseconds.
|
|
585
|
+
*/
|
|
586
|
+
function parseResetTime(value) {
|
|
587
|
+
const durationMs = parseDuration(value);
|
|
588
|
+
if (durationMs !== null) return Date.now() + durationMs;
|
|
589
|
+
const num = parseFloat(value);
|
|
590
|
+
if (!isNaN(num)) if (num < 1e9) return Date.now() + num * 1e3;
|
|
591
|
+
else if (num < 1e10) return num * 1e3;
|
|
592
|
+
else return num;
|
|
593
|
+
const httpDate = parseHttpDate(value);
|
|
594
|
+
if (httpDate !== null) return httpDate;
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Parse HTTP-date format (RFC 7231).
|
|
599
|
+
*/
|
|
600
|
+
function parseHttpDate(value) {
|
|
601
|
+
const timestamp = Date.parse(value);
|
|
602
|
+
if (!isNaN(timestamp)) {
|
|
603
|
+
const now = Date.now();
|
|
604
|
+
const oneYearMs = 365 * 24 * 60 * 60 * 1e3;
|
|
605
|
+
if (timestamp > now - oneYearMs && timestamp < now + oneYearMs) return timestamp;
|
|
490
606
|
}
|
|
491
|
-
|
|
492
|
-
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Parse duration strings like "1s", "100ms", "1m30s", "1h30s", "2h15m30s".
|
|
611
|
+
*
|
|
612
|
+
* Supported formats:
|
|
613
|
+
* - Xms (milliseconds)
|
|
614
|
+
* - Xs or X.Xs (seconds)
|
|
615
|
+
* - Xm or XmYs (minutes with optional seconds)
|
|
616
|
+
* - Xh or XhYm or XhYs or XhYmZs (hours with optional minutes/seconds)
|
|
617
|
+
*/
|
|
618
|
+
function parseDuration(value) {
|
|
619
|
+
const match = value.match(/^(?:(\d+)h)?(?:(\d+)m(?!s))?(?:(\d+(?:\.\d+)?)(ms|s))?$/);
|
|
620
|
+
if (!match) return null;
|
|
621
|
+
const [, hours, minutes, secondsValue, secondsUnit] = match;
|
|
622
|
+
if (!hours && !minutes && !secondsValue) return null;
|
|
623
|
+
let ms = 0;
|
|
624
|
+
if (hours) ms += parseInt(hours, 10) * 36e5;
|
|
625
|
+
if (minutes) ms += parseInt(minutes, 10) * 6e4;
|
|
626
|
+
if (secondsValue) {
|
|
627
|
+
const num = parseFloat(secondsValue);
|
|
628
|
+
ms += secondsUnit === "ms" ? num : num * 1e3;
|
|
629
|
+
}
|
|
630
|
+
return ms;
|
|
631
|
+
}
|
|
632
|
+
function lowercaseKeys(obj) {
|
|
633
|
+
const result = {};
|
|
634
|
+
for (const [key, value] of Object.entries(obj)) result[key.toLowerCase()] = value;
|
|
635
|
+
return result;
|
|
636
|
+
}
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/util/time.ts
|
|
639
|
+
function getCurrentTimestamp() {
|
|
640
|
+
return Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
641
|
+
}
|
|
642
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
493
643
|
//#endregion
|
|
494
644
|
//#region src/util/fetch/monkeyPatchFetch.ts
|
|
495
645
|
const gzipAsync = promisify(gzip);
|
|
@@ -561,9 +711,8 @@ var fetch_exports = /* @__PURE__ */ __exportAll({
|
|
|
561
711
|
isRateLimited: () => isRateLimited,
|
|
562
712
|
isTransientError: () => isTransientError
|
|
563
713
|
});
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
let cachedProxyAgents = /* @__PURE__ */ new Map();
|
|
714
|
+
const cachedAgents = /* @__PURE__ */ new Map();
|
|
715
|
+
const cachedProxyAgents = /* @__PURE__ */ new Map();
|
|
567
716
|
/**
|
|
568
717
|
* Get the connection pool size for HTTP agents.
|
|
569
718
|
* Priority: PROMPTFOO_FETCH_CONNECTIONS env var > CLI -j flag > DEFAULT_MAX_CONCURRENCY (4).
|
|
@@ -580,36 +729,37 @@ function getConnectionPoolSize() {
|
|
|
580
729
|
}
|
|
581
730
|
function getOrCreateAgent(tlsOptions) {
|
|
582
731
|
const concurrency = getConnectionPoolSize();
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
return cachedAgent;
|
|
732
|
+
const existing = cachedAgents.get(concurrency);
|
|
733
|
+
if (existing) return existing;
|
|
734
|
+
const agent = new Agent({
|
|
735
|
+
headersTimeout: REQUEST_TIMEOUT_MS,
|
|
736
|
+
keepAliveTimeout: 3e4,
|
|
737
|
+
keepAliveMaxTimeout: 6e4,
|
|
738
|
+
connections: concurrency,
|
|
739
|
+
connect: tlsOptions
|
|
740
|
+
});
|
|
741
|
+
cachedAgents.set(concurrency, agent);
|
|
742
|
+
return agent;
|
|
743
|
+
}
|
|
744
|
+
function getProxyAgentCacheKey(proxyUrl, concurrency) {
|
|
745
|
+
return `${proxyUrl}::${concurrency}`;
|
|
598
746
|
}
|
|
599
747
|
function getOrCreateProxyAgent(proxyUrl, tlsOptions) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
748
|
+
const concurrency = getConnectionPoolSize();
|
|
749
|
+
const cacheKey = getProxyAgentCacheKey(proxyUrl, concurrency);
|
|
750
|
+
const existing = cachedProxyAgents.get(cacheKey);
|
|
751
|
+
if (existing) return existing;
|
|
752
|
+
const agent = new ProxyAgent({
|
|
753
|
+
uri: proxyUrl,
|
|
754
|
+
proxyTls: tlsOptions,
|
|
755
|
+
requestTls: tlsOptions,
|
|
756
|
+
headersTimeout: REQUEST_TIMEOUT_MS,
|
|
757
|
+
keepAliveTimeout: 3e4,
|
|
758
|
+
keepAliveMaxTimeout: 6e4,
|
|
759
|
+
connections: concurrency
|
|
760
|
+
});
|
|
761
|
+
cachedProxyAgents.set(cacheKey, agent);
|
|
762
|
+
return agent;
|
|
613
763
|
}
|
|
614
764
|
async function fetchWithProxy(url, options = {}, abortSignal) {
|
|
615
765
|
let finalUrl = url;
|
|
@@ -711,12 +861,14 @@ async function handleRateLimit(response) {
|
|
|
711
861
|
const retryAfter = response.headers.get("Retry-After");
|
|
712
862
|
const openaiReset = response.headers.get("x-ratelimit-reset-requests") || response.headers.get("x-ratelimit-reset-tokens");
|
|
713
863
|
let waitTime = 6e4;
|
|
714
|
-
if (openaiReset)
|
|
715
|
-
|
|
864
|
+
if (openaiReset) {
|
|
865
|
+
const parsedHeaders = parseRateLimitHeaders(Object.fromEntries(response.headers.entries()));
|
|
866
|
+
if (parsedHeaders.resetAt !== void 0) waitTime = Math.max(parsedHeaders.resetAt - Date.now(), 0);
|
|
867
|
+
} else if (rateLimitReset) {
|
|
716
868
|
const resetTime = /* @__PURE__ */ new Date(Number.parseInt(rateLimitReset) * 1e3);
|
|
717
869
|
const now = /* @__PURE__ */ new Date();
|
|
718
870
|
waitTime = Math.max(resetTime.getTime() - now.getTime() + 1e3, 0);
|
|
719
|
-
} else if (retryAfter) waitTime =
|
|
871
|
+
} else if (retryAfter) waitTime = parseRetryAfter(retryAfter) ?? waitTime;
|
|
720
872
|
logger.debug(`Rate limited, waiting ${waitTime}ms before retry`);
|
|
721
873
|
await sleep(waitTime);
|
|
722
874
|
}
|
|
@@ -772,6 +924,6 @@ async function fetchWithRetries(url, options = {}, timeout, maxRetries) {
|
|
|
772
924
|
throw new Error(`Request failed after ${maxRetries} retries: ${lastErrorMessage}`);
|
|
773
925
|
}
|
|
774
926
|
//#endregion
|
|
775
|
-
export {
|
|
927
|
+
export { TERMINAL_MAX_WIDTH as A, readGlobalConfig as C, CONSENT_ENDPOINT as D, CLOUD_PROVIDER_PREFIX as E, HUMAN_ASSERTION_TYPE as F, getShareApiBaseUrl as M, getShareViewBaseUrl as N, EVENTS_ENDPOINT as O, FILE_METADATA_KEY as P, cloudConfig as S, writeGlobalConfigPartial as T, parseChatPrompt as _, getCurrentTimestamp as a, transformTools as b, parseRetryAfter as c, calculateCost as d, isOpenAIToolArray as f, openaiToolsToBedrock as g, openaiToolChoiceToBedrock as h, fetch_exports as i, getDefaultShareViewBaseUrl as j, R_ENDPOINT as k, LONG_RUNNING_MODEL_TIMEOUT_MS as l, isPromptfooSampleTarget as m, fetchWithRetries as n, sleep as o, isOpenAIToolChoice as p, fetchWithTimeout as r, parseRateLimitHeaders as s, fetchWithProxy as t, REQUEST_TIMEOUT_MS as u, toTitleCase as v, writeGlobalConfig as w, CloudConfig as x, transformToolChoice as y };
|
|
776
928
|
|
|
777
|
-
//# sourceMappingURL=fetch-
|
|
929
|
+
//# sourceMappingURL=fetch-D9xxyC1p.js.map
|