promptfoo 0.121.3 → 0.121.4
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-DQkFNqE9.js} +1 -1
- package/dist/src/{accounts-Xatc0RYb.js → accounts-DdJ2pHMI.js} +5 -5
- package/dist/src/{accounts-B2XmGjty.js → accounts-DhMYUUbu.js} +5 -5
- package/dist/src/{accounts-BPyfpSeU.cjs → accounts-Dy17bs4D.cjs} +5 -5
- package/dist/src/{accounts-CFLK3mnD.js → accounts-F9d_5sMC.js} +6 -6
- package/dist/src/{agentic-utils-DAVsChuB.cjs → agentic-utils-BpX5b23w.cjs} +3 -3
- package/dist/src/{agentic-utils-DIYAAYE7.js → agentic-utils-P172hM8B.js} +3 -3
- package/dist/src/{agentic-utils-D8yXo5Lm.js → agentic-utils-qFlm6zes.js} +4 -4
- package/dist/src/{agentic-utils-36epdqwB.js → agentic-utils-w68v6_Dz.js} +3 -3
- package/dist/src/{agents-CLQ-P15P.js → agents-8FDnTriG.js} +6 -7
- package/dist/src/{agents-CAYbM7qD.cjs → agents-BahDpe5G.cjs} +34 -12
- package/dist/src/{agents-DSSTV4bv.js → agents-C-R_jfzI.js} +35 -13
- package/dist/src/{agents-wg3ohknq.js → agents-CgaMXvLM.js} +5 -7
- package/dist/src/{agents-BBWxKSM0.cjs → agents-D7-HGxUj.cjs} +5 -7
- package/dist/src/{agents-BBVJCIYr.js → agents-DJ35I3Nt.js} +35 -13
- package/dist/src/{agents-CgBniSlI.js → agents-aYPQLf8W.js} +5 -9
- package/dist/src/{agents-Bqgfdokm.js → agents-pQeBEXMm.js} +35 -14
- package/dist/src/{aimlapi-BwGC1TtS.js → aimlapi-BCq3MHeL.js} +8 -14
- package/dist/src/{aimlapi-MgSLdvy7.js → aimlapi-BD6J9oKt.js} +7 -14
- package/dist/src/{aimlapi-Bv8Fmc-b.cjs → aimlapi-qcK4OT55.cjs} +8 -15
- package/dist/src/{aimlapi-DaC3qZ-o.js → aimlapi-sgYnkE54.js} +7 -16
- package/dist/src/app/app/tsconfig.app.tsbuildinfo +1 -0
- package/dist/src/app/assets/Report-CQYFezYu.js +1 -0
- package/dist/src/app/assets/index-BXGkeMwh.css +1 -0
- package/dist/src/app/assets/index-BzJt18Jz.js +385 -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 +7 -7
- package/dist/src/{audio-DjU9GswO.js → audio-B7izf48x.js} +4 -5
- package/dist/src/{audio-DVFjQ67_.cjs → audio-BQtNuYBj.cjs} +4 -4
- package/dist/src/{audio-Bn44pQxv.js → audio-COrn8rM6.js} +4 -4
- package/dist/src/{audio-DDA5WHdx.js → audio-DcVKoInv.js} +4 -4
- package/dist/src/{base-BboXIF_0.cjs → base-D-670DX8.cjs} +3 -3
- package/dist/src/{base-CqzQ4K8j.js → base-PYJvBE1i.js} +3 -3
- package/dist/src/{base-CKjwebIH.js → base-fZ9wgg50.js} +3 -3
- package/dist/src/{base-Cz2ZC_iA.js → base-yrI1Yal4.js} +3 -3
- package/dist/src/{blobs-BUWmKWzo.js → blobs-BCZavS8s.js} +4 -4
- package/dist/src/{blobs-B1JriOyi.js → blobs-BQWqnnvL.js} +4 -4
- package/dist/src/{blobs-DXTl6J3H.js → blobs-C-F78Kfn.js} +3 -3
- package/dist/src/{blobs-C6j0bvFz.cjs → blobs-D2FAd1Q5.cjs} +3 -3
- package/dist/src/cache-BIyPcp5v.cjs +376 -0
- package/dist/src/cache-C4Xb-hNb.js +310 -0
- package/dist/src/cache-Cr9oLMUa.js +3 -0
- package/dist/src/cache-D5NZmMiT.js +310 -0
- package/dist/src/cache-DbLsVWB2.cjs +3 -0
- package/dist/src/cache-mb7c8hbp.js +280 -0
- package/dist/src/{chat-DK1U-eZ-.js → chat-0bwXjVP0.js} +3 -13
- package/dist/src/{chat-BtIKkLKx.cjs → chat-BPXSW8Bv.cjs} +3 -13
- package/dist/src/{chat-B0iaWhoh.js → chat-BfPaS15_.js} +63 -37
- package/dist/src/{chat-CM8qWR3_.cjs → chat-CclRbxGf.cjs} +63 -37
- package/dist/src/{chat-BEwdgGEg.js → chat-Dr3DUQ0D.js} +63 -37
- package/dist/src/{chat-pxmiVpWe.js → chat-I9izLm49.js} +62 -36
- package/dist/src/{chat-B-52XYI1.js → chat-MKxMnZJZ.js} +3 -13
- package/dist/src/{chat-BE0qTA8e.js → chat-mW0ORo8G.js} +3 -14
- package/dist/src/{chatkit-Cx174XI3.cjs → chatkit-BoWoSgXl.cjs} +4 -4
- package/dist/src/{chatkit-BYGQlHlV.js → chatkit-CJnHRRMM.js} +4 -4
- package/dist/src/{chatkit-a2D6mY6s.js → chatkit-Cv6AhukM.js} +4 -4
- package/dist/src/{chatkit-_8eJqKcD.js → chatkit-zUIVoDos.js} +4 -4
- package/dist/src/{claude-agent-sdk-CMjh4LFH.js → claude-agent-sdk-BQNuLaAK.js} +19 -14
- package/dist/src/{claude-agent-sdk-8ddRp1L2.cjs → claude-agent-sdk-CPJo3dBQ.cjs} +21 -16
- package/dist/src/{claude-agent-sdk-HgbFioFw.js → claude-agent-sdk-Dtq_L-Sc.js} +20 -15
- package/dist/src/{claude-agent-sdk-Bq5EArsX.js → claude-agent-sdk-nfAIcxNf.js} +21 -17
- package/dist/src/{cloud-z8KZpUoa.js → cloud-DQZ5sVjW.js} +25 -13
- package/dist/src/cloud-Hphvo8kr.js +3 -0
- package/dist/src/{cloudflare-ai-Bbp26N0L.js → cloudflare-ai-BIB567w6.js} +5 -14
- package/dist/src/{cloudflare-ai-BGyXlpXJ.js → cloudflare-ai-DGLte7Py.js} +5 -14
- package/dist/src/{cloudflare-ai-C62x6MQG.cjs → cloudflare-ai-Dl3N9OVD.cjs} +6 -15
- package/dist/src/{cloudflare-ai-DdKP9TKT.js → cloudflare-ai-DlKr0rY7.js} +5 -15
- package/dist/src/{cloudflare-gateway-D-e9i1Sn.js → cloudflare-gateway-BDZrYydE.js} +4 -16
- package/dist/src/{cloudflare-gateway-Dx36ftqF.cjs → cloudflare-gateway-BYDp495F.cjs} +4 -15
- package/dist/src/{cloudflare-gateway-DXhtXDRb.js → cloudflare-gateway-CiIZHU0Q.js} +4 -15
- package/dist/src/{cloudflare-gateway-BwAaUgeW.js → cloudflare-gateway-DI1HNP5F.js} +4 -15
- package/dist/src/codex-sdk-BAmYE7qy.js +3 -0
- package/dist/src/codex-sdk-C2_M2pl_.cjs +1172 -0
- package/dist/src/codex-sdk-CErXn7qh.js +1165 -0
- package/dist/src/codex-sdk-CWEnH70W.cjs +2 -0
- package/dist/src/codex-sdk-CpqiOqDO.js +1164 -0
- package/dist/src/codex-sdk-Rtky3M4I.js +1165 -0
- package/dist/src/{cometapi-BDyV-NNm.js → cometapi-BUlt_ELa.js} +8 -15
- package/dist/src/{cometapi-hhL4TAh3.js → cometapi-CtJ-mS8R.js} +9 -15
- package/dist/src/{cometapi-sp7sJpBD.js → cometapi-DT-jlVCB.js} +8 -17
- package/dist/src/{cometapi-C3hOlM7-.cjs → cometapi-UVOryo4W.cjs} +9 -16
- package/dist/src/{completion-DlXUhj5c.cjs → completion-BozdoXba.cjs} +7 -62
- package/dist/src/{completion-BCimtq-h.js → completion-Dnxn7E-j.js} +8 -57
- package/dist/src/{completion-DCjv7RZ3.js → completion-HUe8wDhZ.js} +8 -57
- package/dist/src/{completion-DoYy49ti.js → completion-x0a_c2y1.js} +8 -57
- package/dist/src/{createHash-CTQmL3G2.js → createHash-4gFQpDDv.js} +3 -3
- package/dist/src/{createHash-BYwImsYv.cjs → createHash-B7KvgoOD.cjs} +4 -4
- package/dist/src/{createHash-Da8fMwqB.js → createHash-ChI45QR1.js} +3 -3
- package/dist/src/{createHash-DmPQkvBh.js → createHash-CwDVU5xr.js} +3 -3
- package/dist/src/{docker-FeBni2dw.js → docker-CQmlA2NU.js} +7 -14
- package/dist/src/{docker-CxCkwMzc.js → docker-ClnmCf1Z.js} +6 -14
- package/dist/src/{docker-DpguQj-w.js → docker-DCgsveLD.js} +6 -16
- package/dist/src/{docker-Cqj2-QVi.cjs → docker-DS4_Osau.cjs} +7 -15
- package/dist/src/embedding-D3xTseo7.js +59 -0
- package/dist/src/embedding-DD9wa3ae.js +58 -0
- package/dist/src/embedding-I45KG3o7.cjs +63 -0
- package/dist/src/embedding-nFbumxcv.js +58 -0
- package/dist/src/entrypoint.js +69 -6
- package/dist/src/{errors-P6ll7XSJ.js → errors-Cw810C93.js} +1 -1
- package/dist/src/{esm-SUNIX1x3.js → esm-C7PnfdF8.js} +15 -6
- package/dist/src/{esm-CipptfDu.cjs → esm-CtEPLdAj.cjs} +15 -6
- package/dist/src/{esm-CKWP3u_P.js → esm-Dh4dOLlt.js} +16 -7
- package/dist/src/{esm-7UIl0pPM.js → esm-tVgYPY-f.js} +27 -18
- package/dist/src/eval-CzJFfFO9.js +3 -0
- package/dist/src/{eval-BTqTn7lb.js → eval-u4UVafl6.js} +49 -20
- package/dist/src/{evalResult-BkIhRdTe.js → evalResult-Bgm9ZH31.js} +7 -7
- package/dist/src/{evalResult-DUDShQrm.js → evalResult-D3hVYFis.js} +7 -7
- package/dist/src/evalResult-D8MT9p0s.js +3 -0
- package/dist/src/evalResult-DElBuddX.js +2 -0
- package/dist/src/evalResult-Dvc-iucu.cjs +2 -0
- package/dist/src/{evalResult-DpARzUCb.cjs → evalResult-KZqXl4XP.cjs} +7 -7
- package/dist/src/evaluator-CVessDWe.js +3 -0
- package/dist/src/{evaluator-BcvOGaam.js → evaluator-IvuDYSvQ.js} +3178 -2102
- package/dist/src/{extractor-C8XwivI9.js → extractor-CAfTSraf.js} +6 -6
- package/dist/src/{extractor-CAZ2G3Kh.js → extractor-DNSeBVOJ.js} +6 -6
- package/dist/src/{extractor-D_wd8jxt.js → extractor-Dk6bRWkv.js} +6 -6
- package/dist/src/{extractor-DG3sSfXE.cjs → extractor-WVPOrH43.cjs} +6 -6
- package/dist/src/{fetch-BiYv2BZc.js → fetch-B0Z3Oe4k.js} +218 -55
- package/dist/src/{fetch-DoVRJZhJ.js → fetch-BEWnXrrG.js} +195 -45
- package/dist/src/fetch-C7bGKDlQ.js +3 -0
- package/dist/src/{fetch-BnR9wSnm.cjs → fetch-CJU5ELPa.cjs} +223 -48
- package/dist/src/{fetch-CVAtKnI3.js → fetch-Di00EQrc.js} +218 -55
- package/dist/src/{fileExtensions-Ds-foDzt.js → fileExtensions-AWa2ZML4.js} +1 -1
- package/dist/src/{fileExtensions-LcDYkU4v.js → fileExtensions-BArZuxsI.js} +1 -1
- package/dist/src/{formatDuration-DgBVMN65.js → formatDuration-DZzPsexs.js} +1 -1
- package/dist/src/{genaiTracer-70Z8BIuV.js → genaiTracer-COYDi-tC.js} +6 -2
- package/dist/src/{genaiTracer-C1rxGO8Q.js → genaiTracer-DWdZ28hY.js} +6 -2
- package/dist/src/{genaiTracer-D3fD9dNV.js → genaiTracer-XnrcgDCe.js} +6 -2
- package/dist/src/{genaiTracer-BfxrvSUb.cjs → genaiTracer-yRuxj9-L.cjs} +7 -3
- package/dist/src/golang/wrapper.go +1 -1
- package/dist/src/{graders-BElhu9ZY.cjs → graders--zknU_uk.cjs} +3772 -1302
- package/dist/src/graders-BOAzQEUe.cjs +2 -0
- package/dist/src/graders-D4BTsZdG2.js +3 -0
- package/dist/src/graders-DOJK1XpV.js +2 -0
- package/dist/src/graders-NAv9LcBn.js +2 -0
- package/dist/src/{graders-DG7mhg-b.js → graders-Zy3x0zqX.js} +5691 -3247
- package/dist/src/{graders-RjHF8VfG.js → graders-eIHhRqoC.js} +5683 -3239
- package/dist/src/{graders-BXAJ0sbS.js → graders-pvbReLLn.js} +5692 -3248
- package/dist/src/{image-6WQXK8m8.js → image-9302QVqR.js} +4 -4
- package/dist/src/{image-B8b6f36E.js → image-B5Mv-Z3h.js} +8 -8
- package/dist/src/{image-PoF6DN3x.js → image-DVz2RiMF.js} +8 -8
- package/dist/src/{image-fza3zuKs.cjs → image-De2FBmYV.cjs} +4 -4
- package/dist/src/{image-DO0RYnjH.js → image-dnoUgPrC.js} +4 -5
- package/dist/src/{image-CoxZp9PZ.js → image-qUpPvmNZ.js} +8 -8
- package/dist/src/{image-xNbw5ph2.js → image-u7-rKnYU.js} +4 -4
- package/dist/src/{image--F58eEIn.cjs → image-x6KqLQl4.cjs} +8 -8
- package/dist/src/index.cjs +3641 -2144
- package/dist/src/index.d.cts +2660 -20
- package/dist/src/index.d.ts +2660 -20
- package/dist/src/index.js +3649 -2152
- package/dist/src/{interactiveCheck-BnMYOjMu.js → interactiveCheck-CLERUB0c.js} +2 -2
- package/dist/src/{knowledgeBase-DqrLX8fy.cjs → knowledgeBase-Bpoe_nLu.cjs} +6 -8
- package/dist/src/{knowledgeBase-Bi7CmDbx.js → knowledgeBase-Dgc7CBWF.js} +6 -8
- package/dist/src/{knowledgeBase-DFRXPZl_.js → knowledgeBase-RhFPGWDc.js} +6 -8
- package/dist/src/{knowledgeBase-Ce3ofVan.js → knowledgeBase-lm9RXSAm.js} +6 -9
- package/dist/src/{litellm-CKiAxnoM.js → litellm-C2kqjxqp.js} +6 -14
- package/dist/src/{litellm-CnHI69aj.cjs → litellm-CoyI4IAl.cjs} +6 -15
- package/dist/src/{litellm-Tc294Jhj.js → litellm-DRjpcSa7.js} +5 -14
- package/dist/src/{litellm-Bo2gQXpo.js → litellm-p37R1dzQ.js} +5 -16
- package/dist/src/{logger-BnkjG2jt.js → logger-B88EkIn6.js} +40 -11
- 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-BcJBzSSA.js → logger-DksKw1Qc.js} +40 -11
- package/dist/src/{luma-ray-C9q8rdQe.js → luma-ray-B863CmuZ.js} +6 -10
- package/dist/src/{luma-ray-DP0QA9qn.js → luma-ray-BTTLtqQ8.js} +7 -10
- package/dist/src/{luma-ray-m9Ku2meV.cjs → luma-ray-BxVKaW2a.cjs} +6 -10
- package/dist/src/{luma-ray-0ehMPt5N.js → luma-ray-KgTCXrZC.js} +6 -12
- package/dist/src/main.d.ts +1 -26
- package/dist/src/main.js +985 -520
- package/dist/src/{messages-HJsyEh4o.cjs → messages-811uVVW5.cjs} +69 -19
- package/dist/src/{messages-Dy9QecMs.js → messages-BTQz42fn.js} +69 -19
- package/dist/src/{messages-biC_ex-p.js → messages-MYTQ2TWp.js} +69 -19
- package/dist/src/{messages-DJNo37Ko.js → messages-zWbkLLHz.js} +69 -19
- package/dist/src/{meteor-D-SotUw9.js → meteor-CU5UAE-H.js} +1 -1
- package/dist/src/{meteor-DLZZ3osF.cjs → meteor-Co1VQ1u5.cjs} +1 -1
- package/dist/src/{meteor-44VjEACX.js → meteor-DHdzY1Ss.js} +1 -1
- package/dist/src/{meteor-DUiCJRC-.js → meteor-DuAFv6gF.js} +1 -1
- package/dist/src/{modelslab-B5J-ZM5c.js → modelslab-D0erNWKe.js} +7 -10
- package/dist/src/{modelslab-BTOT8FUO.js → modelslab-DIq-6y7x.js} +7 -10
- package/dist/src/{modelslab-IQbNg-r7.cjs → modelslab-Dk1JAtVo.cjs} +7 -10
- package/dist/src/{modelslab-BI458moT.js → modelslab-wu9yi5GE.js} +7 -11
- package/dist/src/{nova-reel-BZ9y-Y5s.js → nova-reel-CCFRfeRb.js} +7 -10
- package/dist/src/{nova-reel-CE5etkv9.cjs → nova-reel-CrLXVKQf.cjs} +6 -10
- package/dist/src/{nova-reel-Xw1SXLpg.js → nova-reel-DQrm74ng.js} +6 -10
- package/dist/src/{nova-reel-DEeQlnOJ.js → nova-reel-gr11WG7f.js} +6 -12
- package/dist/src/{nova-sonic-Ogqf-csn.js → nova-sonic-BYdp-QLs.js} +5 -7
- package/dist/src/{nova-sonic-DXTLpi-r.js → nova-sonic-B_ZXcUJB.js} +4 -7
- package/dist/src/{nova-sonic-DWswpN1E.js → nova-sonic-TDgrlTk7.js} +4 -9
- package/dist/src/{nova-sonic-N0yCm0vb.cjs → nova-sonic-i5tUvXKn.cjs} +4 -7
- package/dist/src/{openai-BcB5KlTk.js → openai-DhVEmgeZ.js} +6 -3
- package/dist/src/{openai-BMcwgD5C.js → openai-Qsvz25mV.js} +6 -3
- package/dist/src/{openai-CoxGAQwn.cjs → openai-URNyItar.cjs} +6 -3
- package/dist/src/{openai-D6wITiVn.js → openai-iYtrXzOX.js} +6 -3
- package/dist/src/openclaw-CLWrW03k.js +1200 -0
- package/dist/src/openclaw-CnQ363Wi.js +1199 -0
- package/dist/src/openclaw-CwzlQSQX.js +1199 -0
- package/dist/src/openclaw-wX9rtfke.cjs +1205 -0
- package/dist/src/{opencode-sdk-CHCs7dEb.js → opencode-sdk-BUu5Nevv.js} +6 -8
- package/dist/src/{opencode-sdk-WWJhnbKr.cjs → opencode-sdk-BZ2idgYA.cjs} +6 -8
- package/dist/src/{opencode-sdk-DDxj4QqH.js → opencode-sdk-BxD8vXp_.js} +7 -8
- package/dist/src/{opencode-sdk-C71Z0ehR.js → opencode-sdk-GI2KaAXq.js} +6 -10
- package/dist/src/{otlpReceiver-CZL48YfC.js → otlpReceiver-B2z58l4e.js} +154 -98
- package/dist/src/{otlpReceiver-DHKqJlsz.cjs → otlpReceiver-BfcVq2Nq.cjs} +154 -98
- package/dist/src/{otlpReceiver-CavGAA6k.js → otlpReceiver-BntK801g.js} +154 -98
- package/dist/src/{otlpReceiver-C9KlUtxh.js → otlpReceiver-DmVulbhC.js} +154 -98
- package/dist/src/{providerRegistry-BkzVH5Ba.js → providerRegistry-Bvh8mv85.js} +2 -2
- package/dist/src/{providerRegistry-CUWki5mQ.js → providerRegistry-CPQ_CmVO.js} +2 -2
- package/dist/src/{providerRegistry-BTDgfV5h.cjs → providerRegistry-CQMdTmHP.cjs} +2 -2
- package/dist/src/{providerRegistry-B9lh-_tx.js → providerRegistry-CWoPjKFZ.js} +2 -2
- package/dist/src/{providers-CScd1wN6.cjs → providers-1eKkXBKp.cjs} +792 -556
- package/dist/src/{providers-Ch6Mr0gn.js → providers-BV_KMZje.js} +699 -493
- package/dist/src/providers-Bp4S-FvO.js +2 -0
- package/dist/src/providers-DV3ax9e_.cjs +3 -0
- package/dist/src/{providers-DvddrgxL.js → providers-Domz_llv.js} +707 -501
- package/dist/src/{providers-Cn73d5sr.js → providers-DruaQfwu.js} +704 -498
- package/dist/src/providers-iUt5fbAN.js +3 -0
- package/dist/src/providers-u9Enmfok.js +2 -0
- package/dist/src/python/persistent_wrapper.py +0 -5
- package/dist/src/{pythonUtils-Cpo0Ez1p.js → pythonUtils-C2UQ30Rz.js} +3 -3
- package/dist/src/{pythonUtils-Bzwbgpbg.js → pythonUtils-Cldx7huE.js} +3 -3
- package/dist/src/{pythonUtils-wIqk7zAf.js → pythonUtils-CnndUbW-.js} +3 -3
- package/dist/src/{pythonUtils-dAVigVK-.cjs → pythonUtils-tAJvvpS-.cjs} +3 -3
- package/dist/src/{quiverai-BeofbLVc.js → quiverai-CtWi6x_g.js} +4 -4
- package/dist/src/{quiverai-CcUhPIBg.cjs → quiverai-DFotyafY.cjs} +4 -4
- package/dist/src/{quiverai-DVSEqJiq.js → quiverai-DR0SnIQV.js} +4 -4
- package/dist/src/{quiverai-CCQn73lq.js → quiverai-aPPvXOgn.js} +4 -5
- package/dist/src/render-CH-62LbA.js +135 -0
- package/dist/src/render-CMEpfLaO.js +136 -0
- package/dist/src/{render-BHl6QVq9.js → render-CgVDrJmM.js} +2 -3
- package/dist/src/render-DHIZ6_k8.js +135 -0
- package/dist/src/render-DfQSFxGE.cjs +165 -0
- package/dist/src/{responses-CQb1Tj69.js → responses--OsX2aYW.js} +17 -12
- package/dist/src/{responses-mo0KQDbu.cjs → responses-Bi9vBuW_.cjs} +18 -13
- package/dist/src/{responses-CgNyTPsY.js → responses-C-flexAY.js} +18 -13
- package/dist/src/{responses-BKP_WYis.js → responses-DL9m8CyY.js} +18 -13
- package/dist/src/{rubyUtils-CGeUtCfW.cjs → rubyUtils-B6eljPuh.cjs} +3 -3
- package/dist/src/{rubyUtils-DECSbsfY.js → rubyUtils-CYSQEG4a.js} +3 -3
- package/dist/src/rubyUtils-D1L2d3jb.js +3 -0
- package/dist/src/rubyUtils-DUbq4tff.cjs +2 -0
- package/dist/src/{rubyUtils-PgU-gHmx.js → rubyUtils-DVLeA2jg.js} +3 -3
- package/dist/src/{rubyUtils-CiVfln3g.js → rubyUtils-DsGrTx8R.js} +3 -3
- package/dist/src/{sagemaker-CqeASYE5.js → sagemaker-BVkaG2-l.js} +14 -18
- package/dist/src/{sagemaker-CVv8W7so.js → sagemaker-BveBvuxm.js} +14 -18
- package/dist/src/{sagemaker-MUbD5V3v.js → sagemaker-D67yzMzs.js} +14 -19
- package/dist/src/{sagemaker-jiw1wQa-.cjs → sagemaker-XnfhheQv.cjs} +14 -18
- package/dist/src/{scanner-DVDeUz1r.js → scanner-1DqWi1Ej.js} +130 -35
- package/dist/src/server/golang/wrapper.go +1 -1
- package/dist/src/server/index.js +3596 -2098
- package/dist/src/server/python/persistent_wrapper.py +0 -5
- package/dist/src/{server-DZ9MtCn0.js → server-BNYztJkh.js} +128 -9
- package/dist/src/{server-Cns05F1j.js → server-BSB45Nt9.js} +127 -8
- package/dist/src/{server-CP9qKM40.js → server-D6Il2Sob.js} +126 -7
- package/dist/src/server-DCtHUqlp.js +3 -0
- package/dist/src/server-DaA2eR26.cjs +2 -0
- package/dist/src/{server-BtoCXeXI.cjs → server-Dx2TyCH2.cjs} +140 -6
- package/dist/src/{signal-C3ZTsUgi.js → signal-CE5G3a7x.js} +3 -3
- package/dist/src/{slack-94iG3T0s.cjs → slack-1Rhq0EoV.cjs} +2 -2
- package/dist/src/{slack-BR0HtO3K.js → slack-D5Wpy8LM.js} +2 -2
- package/dist/src/{slack-DCEV-vWP.js → slack-DDUe-5MC.js} +2 -2
- package/dist/src/{slack-2sdpGzbt.js → slack-acRb0IqQ.js} +2 -2
- package/dist/src/store-CWOSz6D_.cjs +2 -0
- package/dist/src/{store-P8OKm19S.js → store-CYEy5J2D.js} +3 -3
- package/dist/src/{store-CLyU7AtI.cjs → store-DAAyxcy6.cjs} +3 -3
- package/dist/src/store-DCDBhv7B.js +3 -0
- package/dist/src/{store-VB0GP46K.js → store-Dn9HUkdW.js} +3 -3
- package/dist/src/{store-Cj258DgL.js → store-M0b1WfYb.js} +3 -3
- package/dist/src/{tables-DmzvLbeZ.js → tables-C4CH3zRr.js} +3 -3
- package/dist/src/{tables-BEIFz2tM.js → tables-CsWou1Bx.js} +3 -3
- package/dist/src/{tables-kC7R5kiK.js → tables-DQ4WU5tX.js} +3 -3
- package/dist/src/{tables-BdZQEpRz.cjs → tables-DUfh1F7Z.cjs} +3 -3
- package/dist/src/telemetry-C1IqxcdW.js +3 -0
- package/dist/src/telemetry-C4ZEa_es.cjs +2 -0
- package/dist/src/{telemetry-BnH5VJAU.js → telemetry-CQPez_Jp.js} +4 -4
- package/dist/src/{telemetry-re627Lre.cjs → telemetry-Dsw_faFj.cjs} +4 -4
- package/dist/src/{telemetry-BugWqKiu.js → telemetry-Dvqxv3YC.js} +4 -4
- package/dist/src/{telemetry-DPXLd7UE.js → telemetry-dbaJ0E98.js} +4 -4
- package/dist/src/{text-CW1cyrwj.cjs → text-BVi-cLPJ.cjs} +1 -1
- package/dist/src/{text-B_UCRPp2.js → text-CZr46tp_.js} +1 -1
- package/dist/src/{text-TIv0QYnd.js → text-DHxdyQqT.js} +1 -1
- package/dist/src/{text-Db-Wt2u2.js → text-KvuD2Iko.js} +1 -1
- package/dist/src/{tokenUsageUtils-bVa1ga6f.cjs → tokenUsageUtils-Bb7DkZPz.cjs} +7 -3
- package/dist/src/{tokenUsageUtils-BDGe-iyI.js → tokenUsageUtils-C-bmyHoE.js} +7 -3
- package/dist/src/{tokenUsageUtils-DflFMjS0.js → tokenUsageUtils-CXrvO-wA.js} +7 -3
- package/dist/src/{transcription-BvtsrzRG.cjs → transcription-BvjmiYB1.cjs} +9 -13
- package/dist/src/{transcription-Hb3VnC4M.js → transcription-CJspiD2c.js} +8 -11
- package/dist/src/{transcription-CaMivnjG.js → transcription-DuWDupG7.js} +7 -11
- package/dist/src/{transcription-DOMMTu01.js → transcription-V2HaAmy2.js} +7 -13
- package/dist/src/{transform-BqPkNPYm.js → transform-Bbg6A8Jk.js} +4 -4
- package/dist/src/{transform-DrleutM3.js → transform-CG0ehZNG.js} +9 -8
- package/dist/src/{transform-0BwoBsvO.cjs → transform-CTeuTR3S.cjs} +16 -8
- package/dist/src/{transform-ZrG2dvlo.cjs → transform-CUnzlsbn.cjs} +4 -4
- package/dist/src/{transform-BzK09Q_9.js → transform-DYX1_Xnh.js} +5 -5
- package/dist/src/transform-DgKlRr73.cjs +2 -0
- package/dist/src/transform-M6ITAESf.js +3 -0
- package/dist/src/{transform-ljLYHEPh.js → transform-UN5UGu8U.js} +5 -5
- package/dist/src/{transform-B2-jIv68.js → transform-lQrDE1BQ.js} +8 -6
- package/dist/src/{transform-DyDAwEpE.js → transform-zDhMmzwX.js} +10 -7
- package/dist/src/{transformersAvailability-BGkzavwb.js → transformersAvailability-CcHusyhw.js} +1 -1
- package/dist/src/{transformersAvailability-DKoRtQLy.cjs → transformersAvailability-Cju9mHgR.cjs} +1 -1
- package/dist/src/{transformersAvailability-D6c6ROpT.js → transformersAvailability-DLlROWhg.js} +1 -1
- package/dist/src/{types-q8GXGF65.js → types-BGQDAP8i.js} +351 -22
- package/dist/src/{types-Cd3ygw8W.js → types-Bgh5SOn6.js} +352 -24
- package/dist/src/{types-D8cGDZbL.cjs → types-CeaeaZdP.cjs} +387 -22
- package/dist/src/{types-CIhFeUC4.js → types-Dm9JM6Vb.js} +362 -23
- package/dist/src/{util-vNmDL5DT.js → util-BYvQUPp7.js} +138 -36
- package/dist/src/{util-CuLo2pMR.cjs → util-Bxn8emtE.cjs} +14 -167
- package/dist/src/{util-BLvy9qfE.js → util-C8e5uydV.js} +18 -141
- package/dist/src/{util-DM2rTn_6.js → util-C9J8ahRn.js} +4 -4
- package/dist/src/{util-CFj4YKIn.cjs → util-CN3SrLT4.cjs} +4 -4
- package/dist/src/{util-BtoGs5Cb.js → util-D3q0WQ-0.js} +4 -4
- package/dist/src/{util-CgDCK4KI.js → util-D9TisOyk.js} +4 -4
- package/dist/src/{util-DMFeUvLz.js → util-DDs-7g6-.js} +138 -36
- package/dist/src/{util-DbVG-yZU.js → util-DvU2Pw8c.js} +138 -36
- package/dist/src/{util-Bm3E9jpK.js → util-DxWpWjhc.js} +12 -135
- package/dist/src/{util-CMMkIxfU.js → util-oGMLA7vc.js} +16 -139
- package/dist/src/{util--9u9UVCt.cjs → util-olYL5C6N.cjs} +143 -35
- package/dist/src/{utils-DKw8mrgr.cjs → utils-B05gLxER.cjs} +6 -4
- package/dist/src/{utils-DEuL4VNB.js → utils-BLJKfv0y.js} +6 -4
- package/dist/src/{utils-DOjD4dTC.js → utils-DJfvjyMj.js} +6 -4
- package/dist/src/{utils-CFxO9KGo.js → utils-hXtCYanr.js} +6 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -42
- 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/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/tokenUsageUtils-NYT-WKS6.js +0 -138
- package/dist/src/transform-ChNIpHz7.js +0 -6
- package/dist/src/transform-PtQ6rAE3.cjs +0 -5
|
@@ -1,834 +0,0 @@
|
|
|
1
|
-
import { C as getEnvString, D as state, a as logger, c as REDACTED, l as normalizeFieldName, u as sanitizeObject } from "./logger-BnkjG2jt.js";
|
|
2
|
-
import { i as resolvePackageEntryPoint, r as importModule } from "./esm-CKWP3u_P.js";
|
|
3
|
-
import { n as withGenAISpan, t as getTraceparent } from "./genaiTracer-70Z8BIuV.js";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import dedent from "dedent";
|
|
7
|
-
import crypto from "crypto";
|
|
8
|
-
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
|
-
//#region src/providers/openai/codex-sdk.ts
|
|
10
|
-
const MINIMAL_CLI_ENV_KEYS = [
|
|
11
|
-
"PATH",
|
|
12
|
-
"Path",
|
|
13
|
-
"HOME",
|
|
14
|
-
"USER",
|
|
15
|
-
"USERNAME",
|
|
16
|
-
"USERPROFILE",
|
|
17
|
-
"TMPDIR",
|
|
18
|
-
"TMP",
|
|
19
|
-
"TEMP",
|
|
20
|
-
"SHELL",
|
|
21
|
-
"COMSPEC",
|
|
22
|
-
"SystemRoot",
|
|
23
|
-
"PATHEXT",
|
|
24
|
-
"LANG",
|
|
25
|
-
"LC_ALL",
|
|
26
|
-
"TERM"
|
|
27
|
-
];
|
|
28
|
-
function getMinimalProcessEnv() {
|
|
29
|
-
const env = {};
|
|
30
|
-
for (const key of MINIMAL_CLI_ENV_KEYS) {
|
|
31
|
-
const value = process.env[key];
|
|
32
|
-
if (typeof value === "string" && value.length > 0) env[key] = value;
|
|
33
|
-
}
|
|
34
|
-
return env;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Helper to load the OpenAI Codex SDK ESM module
|
|
38
|
-
* Uses resolvePackageEntryPoint to handle ESM-only packages with restrictive exports
|
|
39
|
-
*/
|
|
40
|
-
async function loadCodexSDK() {
|
|
41
|
-
const basePaths = [state.basePath && path.isAbsolute(state.basePath) ? state.basePath : void 0, process.cwd()].filter((candidate) => Boolean(candidate));
|
|
42
|
-
let codexPath = null;
|
|
43
|
-
for (const basePath of new Set(basePaths)) {
|
|
44
|
-
codexPath = resolvePackageEntryPoint("@openai/codex-sdk", basePath);
|
|
45
|
-
if (codexPath) break;
|
|
46
|
-
}
|
|
47
|
-
if (!codexPath) throw new Error(dedent`The @openai/codex-sdk package is required but not installed.
|
|
48
|
-
|
|
49
|
-
To use the OpenAI Codex SDK provider, install it with:
|
|
50
|
-
npm install @openai/codex-sdk
|
|
51
|
-
|
|
52
|
-
Requires Node.js 18+.
|
|
53
|
-
|
|
54
|
-
For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
|
|
55
|
-
try {
|
|
56
|
-
return await importModule(codexPath);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
logger.error(`Failed to load OpenAI Codex SDK: ${err}`);
|
|
59
|
-
if (err.stack) logger.error(err.stack);
|
|
60
|
-
throw new Error(dedent`Failed to load @openai/codex-sdk.
|
|
61
|
-
|
|
62
|
-
The package was found but could not be loaded. This may be due to:
|
|
63
|
-
- Incompatible Node.js version (requires Node.js 18+)
|
|
64
|
-
- Corrupted installation
|
|
65
|
-
|
|
66
|
-
Try reinstalling:
|
|
67
|
-
npm install @openai/codex-sdk
|
|
68
|
-
|
|
69
|
-
For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const CODEX_MODEL_PRICING = {
|
|
73
|
-
"gpt-5.4": {
|
|
74
|
-
input: 2.5,
|
|
75
|
-
output: 15,
|
|
76
|
-
cache_read: .25
|
|
77
|
-
},
|
|
78
|
-
"gpt-5.4-pro": {
|
|
79
|
-
input: 30,
|
|
80
|
-
output: 180,
|
|
81
|
-
cache_read: 30
|
|
82
|
-
},
|
|
83
|
-
"gpt-5.3-codex": {
|
|
84
|
-
input: 1.75,
|
|
85
|
-
output: 14,
|
|
86
|
-
cache_read: .175
|
|
87
|
-
},
|
|
88
|
-
"gpt-5.3-codex-spark": {
|
|
89
|
-
input: .5,
|
|
90
|
-
output: 4,
|
|
91
|
-
cache_read: .05
|
|
92
|
-
},
|
|
93
|
-
"gpt-5.2": {
|
|
94
|
-
input: 1.75,
|
|
95
|
-
output: 14,
|
|
96
|
-
cache_read: .175
|
|
97
|
-
},
|
|
98
|
-
"gpt-5.2-codex": {
|
|
99
|
-
input: 1.75,
|
|
100
|
-
output: 14,
|
|
101
|
-
cache_read: .175
|
|
102
|
-
},
|
|
103
|
-
"gpt-5.1-codex": {
|
|
104
|
-
input: 2,
|
|
105
|
-
output: 8,
|
|
106
|
-
cache_read: .2
|
|
107
|
-
},
|
|
108
|
-
"gpt-5.1-codex-max": {
|
|
109
|
-
input: 3,
|
|
110
|
-
output: 12,
|
|
111
|
-
cache_read: .3
|
|
112
|
-
},
|
|
113
|
-
"gpt-5.1-codex-mini": {
|
|
114
|
-
input: .5,
|
|
115
|
-
output: 2,
|
|
116
|
-
cache_read: .05
|
|
117
|
-
},
|
|
118
|
-
"gpt-5-codex": {
|
|
119
|
-
input: 2,
|
|
120
|
-
output: 8,
|
|
121
|
-
cache_read: .2
|
|
122
|
-
},
|
|
123
|
-
"gpt-5-codex-mini": {
|
|
124
|
-
input: .5,
|
|
125
|
-
output: 2,
|
|
126
|
-
cache_read: .05
|
|
127
|
-
},
|
|
128
|
-
"gpt-5": {
|
|
129
|
-
input: 2,
|
|
130
|
-
output: 8,
|
|
131
|
-
cache_read: .2
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
var OpenAICodexSDKProvider = class OpenAICodexSDKProvider {
|
|
135
|
-
static OPENAI_MODELS = [
|
|
136
|
-
"gpt-5.4",
|
|
137
|
-
"gpt-5.4-pro",
|
|
138
|
-
"gpt-5.3-codex",
|
|
139
|
-
"gpt-5.3-codex-spark",
|
|
140
|
-
"gpt-5.2",
|
|
141
|
-
"gpt-5.2-codex",
|
|
142
|
-
"gpt-5.1-codex",
|
|
143
|
-
"gpt-5.1-codex-max",
|
|
144
|
-
"gpt-5.1-codex-mini",
|
|
145
|
-
"gpt-5-codex",
|
|
146
|
-
"gpt-5-codex-mini",
|
|
147
|
-
"gpt-5"
|
|
148
|
-
];
|
|
149
|
-
config;
|
|
150
|
-
env;
|
|
151
|
-
apiKey;
|
|
152
|
-
providerId = "openai:codex-sdk";
|
|
153
|
-
codexModule;
|
|
154
|
-
codexInstance;
|
|
155
|
-
codexInstanceEnvHash;
|
|
156
|
-
threads = /* @__PURE__ */ new Map();
|
|
157
|
-
deepTracingWarningShown = false;
|
|
158
|
-
constructor(options = {}) {
|
|
159
|
-
const { config, env, id } = options;
|
|
160
|
-
this.config = config ?? {};
|
|
161
|
-
this.env = env;
|
|
162
|
-
this.apiKey = this.getApiKey();
|
|
163
|
-
this.providerId = id ?? this.providerId;
|
|
164
|
-
if (this.config.model && !OpenAICodexSDKProvider.OPENAI_MODELS.includes(this.config.model)) logger.warn(`Using unknown model for OpenAI Codex SDK: ${this.config.model}`);
|
|
165
|
-
}
|
|
166
|
-
id() {
|
|
167
|
-
return this.providerId;
|
|
168
|
-
}
|
|
169
|
-
getApiKey() {
|
|
170
|
-
return this.config?.apiKey || this.env?.OPENAI_API_KEY || this.env?.CODEX_API_KEY || getEnvString("OPENAI_API_KEY") || getEnvString("CODEX_API_KEY");
|
|
171
|
-
}
|
|
172
|
-
toString() {
|
|
173
|
-
return "[OpenAI Codex SDK Provider]";
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Safely tear down a Codex instance by calling its cleanup method
|
|
177
|
-
* (destroy, cleanup, or close -- whichever is available).
|
|
178
|
-
*/
|
|
179
|
-
async destroyInstance(instance) {
|
|
180
|
-
if (typeof instance.destroy === "function") await instance.destroy();
|
|
181
|
-
else if (typeof instance.cleanup === "function") await instance.cleanup();
|
|
182
|
-
else if (typeof instance.close === "function") await instance.close();
|
|
183
|
-
}
|
|
184
|
-
async cleanup() {
|
|
185
|
-
this.threads.clear();
|
|
186
|
-
if (this.codexInstance) {
|
|
187
|
-
try {
|
|
188
|
-
await this.destroyInstance(this.codexInstance);
|
|
189
|
-
} catch (error) {
|
|
190
|
-
logger.warn("[CodexSDK] Error during cleanup", { error });
|
|
191
|
-
}
|
|
192
|
-
this.codexInstance = void 0;
|
|
193
|
-
this.codexInstanceEnvHash = void 0;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
prepareEnvironment(config, traceparent) {
|
|
197
|
-
const env = {
|
|
198
|
-
...config.cli_env === void 0 || config.inherit_process_env === true ? process.env : getMinimalProcessEnv(),
|
|
199
|
-
...config.cli_env ?? {}
|
|
200
|
-
};
|
|
201
|
-
const sortedEnv = {};
|
|
202
|
-
for (const key of Object.keys(env).sort()) if (env[key] !== void 0) sortedEnv[key] = env[key];
|
|
203
|
-
if (this.apiKey) {
|
|
204
|
-
sortedEnv.OPENAI_API_KEY = this.apiKey;
|
|
205
|
-
sortedEnv.CODEX_API_KEY = this.apiKey;
|
|
206
|
-
}
|
|
207
|
-
if (this.env) for (const key of Object.keys(this.env).sort()) {
|
|
208
|
-
const value = this.env[key];
|
|
209
|
-
if (value !== void 0) sortedEnv[key] = value;
|
|
210
|
-
}
|
|
211
|
-
if (config.deep_tracing) {
|
|
212
|
-
if (!sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT) sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT = "http://127.0.0.1:4318";
|
|
213
|
-
if (!sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL) sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL = "http/json";
|
|
214
|
-
if (!sortedEnv.OTEL_SERVICE_NAME) sortedEnv.OTEL_SERVICE_NAME = "codex-cli";
|
|
215
|
-
if (!sortedEnv.OTEL_TRACES_EXPORTER) sortedEnv.OTEL_TRACES_EXPORTER = "otlp";
|
|
216
|
-
if (traceparent) sortedEnv.TRACEPARENT = traceparent;
|
|
217
|
-
logger.debug("[CodexSDK] Injecting OTEL config for deep tracing", {
|
|
218
|
-
traceparent: traceparent || "(none - CLI will start own trace)",
|
|
219
|
-
endpoint: sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
220
|
-
userConfigured: {
|
|
221
|
-
endpoint: !!env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
222
|
-
protocol: !!env.OTEL_EXPORTER_OTLP_PROTOCOL,
|
|
223
|
-
serviceName: !!env.OTEL_SERVICE_NAME
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
} else delete sortedEnv.TRACEPARENT;
|
|
227
|
-
return sortedEnv;
|
|
228
|
-
}
|
|
229
|
-
getSkillRootPrefixes(env) {
|
|
230
|
-
const prefixes = /* @__PURE__ */ new Set();
|
|
231
|
-
const addPrefix = (candidate) => {
|
|
232
|
-
if (!candidate) return;
|
|
233
|
-
const normalized = candidate.replace(/\\/g, "/").replace(/\/+$/g, "");
|
|
234
|
-
if (normalized) prefixes.add(normalized);
|
|
235
|
-
};
|
|
236
|
-
addPrefix(env.CODEX_HOME);
|
|
237
|
-
addPrefix("/etc/codex");
|
|
238
|
-
const homeDir = env.HOME || process.env.HOME;
|
|
239
|
-
if (homeDir) addPrefix(path.posix.join(homeDir.replace(/\\/g, "/"), ".codex"));
|
|
240
|
-
return Array.from(prefixes);
|
|
241
|
-
}
|
|
242
|
-
isValidCodexSkillName(name) {
|
|
243
|
-
return /^[A-Za-z0-9._:-]+$/.test(name);
|
|
244
|
-
}
|
|
245
|
-
extractSkillPathCandidates(text, skillRootPrefixes = []) {
|
|
246
|
-
const matches = /* @__PURE__ */ new Map();
|
|
247
|
-
for (const rawToken of text.split(/\s+/)) {
|
|
248
|
-
const token = rawToken.replace(/^[`"'([{<]+|[`"',;:)\]}>]+$/g, "").trim();
|
|
249
|
-
if (!token) continue;
|
|
250
|
-
const normalizedPath = token.replace(/\\/g, "/");
|
|
251
|
-
const repoMatch = normalizedPath.match(/^\.agents\/skills\/([^/\s]+)\/SKILL\.md$/);
|
|
252
|
-
if (repoMatch) {
|
|
253
|
-
if (this.isValidCodexSkillName(repoMatch[1])) matches.set(normalizedPath, {
|
|
254
|
-
name: repoMatch[1],
|
|
255
|
-
path: normalizedPath
|
|
256
|
-
});
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
const matchingRoot = skillRootPrefixes.find((prefix) => normalizedPath.startsWith(`${prefix}/skills/`));
|
|
260
|
-
if (!matchingRoot) continue;
|
|
261
|
-
const customRootMatch = normalizedPath.slice(matchingRoot.length + 1).match(/^skills\/([^/\s]+)\/SKILL\.md$/);
|
|
262
|
-
if (customRootMatch && this.isValidCodexSkillName(customRootMatch[1])) matches.set(normalizedPath, {
|
|
263
|
-
name: customRootMatch[1],
|
|
264
|
-
path: normalizedPath
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return Array.from(matches.values());
|
|
268
|
-
}
|
|
269
|
-
extractSkillCallsFromItems(items, skillRootPrefixes = [], options = {}) {
|
|
270
|
-
const skillCalls = /* @__PURE__ */ new Map();
|
|
271
|
-
for (const item of items) {
|
|
272
|
-
if (item?.type !== "command_execution") continue;
|
|
273
|
-
if (options.requireSuccessfulCommand && !this.isSuccessfulCommandExecution(item)) continue;
|
|
274
|
-
const command = typeof item.command === "string" && item.command.trim() ? item.command : void 0;
|
|
275
|
-
if (!command) continue;
|
|
276
|
-
for (const skillPath of this.extractSkillPathCandidates(command, skillRootPrefixes)) {
|
|
277
|
-
const existing = skillCalls.get(skillPath.path) ?? {
|
|
278
|
-
name: skillPath.name,
|
|
279
|
-
path: skillPath.path
|
|
280
|
-
};
|
|
281
|
-
skillCalls.set(skillPath.path, existing);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return Array.from(skillCalls.values()).map((skillCall) => ({
|
|
285
|
-
name: skillCall.name,
|
|
286
|
-
path: skillCall.path,
|
|
287
|
-
source: "heuristic"
|
|
288
|
-
}));
|
|
289
|
-
}
|
|
290
|
-
buildSkillMetadata(items, skillRootPrefixes = []) {
|
|
291
|
-
if (!Array.isArray(items) || items.length === 0) return;
|
|
292
|
-
const attemptedSkillCalls = this.extractSkillCallsFromItems(items, skillRootPrefixes);
|
|
293
|
-
const skillCalls = this.extractSkillCallsFromItems(items, skillRootPrefixes, { requireSuccessfulCommand: true });
|
|
294
|
-
if (skillCalls.length === 0 && attemptedSkillCalls.length <= skillCalls.length) return;
|
|
295
|
-
return {
|
|
296
|
-
attemptedSkillCalls,
|
|
297
|
-
skillCalls
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
isSuccessfulCommandExecution(item) {
|
|
301
|
-
if (item?.type !== "command_execution") return false;
|
|
302
|
-
if (typeof item.status === "string" && item.status !== "completed") return false;
|
|
303
|
-
if (typeof item.exit_code === "number" && item.exit_code !== 0) return false;
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
validateWorkingDirectory(workingDir, skipGitCheck = false) {
|
|
307
|
-
let stats;
|
|
308
|
-
try {
|
|
309
|
-
stats = fs.statSync(workingDir);
|
|
310
|
-
} catch (err) {
|
|
311
|
-
throw new Error(`Working directory ${workingDir} does not exist or isn't accessible: ${err.message}`);
|
|
312
|
-
}
|
|
313
|
-
if (!stats.isDirectory()) throw new Error(`Working directory ${workingDir} is not a directory`);
|
|
314
|
-
if (!skipGitCheck) {
|
|
315
|
-
const gitDir = path.join(workingDir, ".git");
|
|
316
|
-
if (!fs.existsSync(gitDir)) throw new Error(dedent`Working directory ${workingDir} is not a Git repository.
|
|
317
|
-
|
|
318
|
-
Codex requires a Git repository by default to prevent unrecoverable errors.
|
|
319
|
-
|
|
320
|
-
To bypass this check, set skip_git_repo_check: true in your provider config.`);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Build Codex constructor options from provider config.
|
|
325
|
-
* Used when creating both local (deep-tracing) and cached instances.
|
|
326
|
-
*/
|
|
327
|
-
buildCodexOptions(env, config) {
|
|
328
|
-
return {
|
|
329
|
-
env,
|
|
330
|
-
...this.apiKey ? { apiKey: this.apiKey } : {},
|
|
331
|
-
...config.codex_path_override ? { codexPathOverride: config.codex_path_override } : {},
|
|
332
|
-
...config.base_url ? { baseUrl: config.base_url } : {},
|
|
333
|
-
...config.cli_config ? { config: config.cli_config } : {}
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
buildThreadOptions(config) {
|
|
337
|
-
return {
|
|
338
|
-
workingDirectory: config.working_dir,
|
|
339
|
-
skipGitRepoCheck: config.skip_git_repo_check ?? false,
|
|
340
|
-
...config.model ? { model: config.model } : {},
|
|
341
|
-
...config.additional_directories?.length ? { additionalDirectories: config.additional_directories } : {},
|
|
342
|
-
...config.sandbox_mode ? { sandboxMode: config.sandbox_mode } : {},
|
|
343
|
-
...config.model_reasoning_effort ? { modelReasoningEffort: config.model_reasoning_effort } : {},
|
|
344
|
-
...config.network_access_enabled === void 0 ? {} : { networkAccessEnabled: config.network_access_enabled },
|
|
345
|
-
...config.web_search_mode ? { webSearchMode: config.web_search_mode } : {},
|
|
346
|
-
...config.web_search_enabled !== void 0 && !config.web_search_mode ? { webSearchEnabled: config.web_search_enabled } : {},
|
|
347
|
-
...config.approval_policy ? { approvalPolicy: config.approval_policy } : {}
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
async getOrCreateThread(config, cacheKey, instance) {
|
|
351
|
-
const threadOptions = this.buildThreadOptions(config);
|
|
352
|
-
if (config.deep_tracing) return instance.startThread(threadOptions);
|
|
353
|
-
if (config.thread_id) {
|
|
354
|
-
const cached = this.threads.get(config.thread_id);
|
|
355
|
-
if (cached) return cached;
|
|
356
|
-
const thread = instance.resumeThread(config.thread_id, threadOptions);
|
|
357
|
-
if (config.persist_threads) this.threads.set(config.thread_id, thread);
|
|
358
|
-
return thread;
|
|
359
|
-
}
|
|
360
|
-
if (config.persist_threads && cacheKey) {
|
|
361
|
-
const cached = this.threads.get(cacheKey);
|
|
362
|
-
if (cached) return cached;
|
|
363
|
-
const poolSize = config.thread_pool_size ?? 1;
|
|
364
|
-
if (this.threads.size >= poolSize) {
|
|
365
|
-
const oldestKey = this.threads.keys().next().value;
|
|
366
|
-
if (oldestKey) this.threads.delete(oldestKey);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
const thread = instance.startThread(threadOptions);
|
|
370
|
-
if (config.persist_threads && cacheKey) this.threads.set(cacheKey, thread);
|
|
371
|
-
return thread;
|
|
372
|
-
}
|
|
373
|
-
async runStreaming(thread, prompt, runOptions, callOptions, skillRootPrefixes = []) {
|
|
374
|
-
const { events } = await thread.runStreamed(prompt, runOptions);
|
|
375
|
-
const items = [];
|
|
376
|
-
let usage = void 0;
|
|
377
|
-
const tracer = trace.getTracer("promptfoo.codex-sdk");
|
|
378
|
-
const activeSpans = /* @__PURE__ */ new Map();
|
|
379
|
-
const itemStartTimes = /* @__PURE__ */ new Map();
|
|
380
|
-
let lastEventTime = Date.now();
|
|
381
|
-
const reasoningTexts = [];
|
|
382
|
-
const conversationMessages = [];
|
|
383
|
-
conversationMessages.push({
|
|
384
|
-
role: "user",
|
|
385
|
-
content: prompt
|
|
386
|
-
});
|
|
387
|
-
try {
|
|
388
|
-
for await (const event of events) {
|
|
389
|
-
const eventTime = Date.now();
|
|
390
|
-
if (callOptions?.abortSignal?.aborted) {
|
|
391
|
-
const abortError = /* @__PURE__ */ new Error("AbortError");
|
|
392
|
-
abortError.name = "AbortError";
|
|
393
|
-
throw abortError;
|
|
394
|
-
}
|
|
395
|
-
switch (event.type) {
|
|
396
|
-
case "item.started": {
|
|
397
|
-
const item = event.item;
|
|
398
|
-
if (!item) {
|
|
399
|
-
logger.warn("Codex item.started event missing item", { event });
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
if (!item.id) {
|
|
403
|
-
logger.debug("Codex item.started without id, will create span at completion", { type: item.type });
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
const itemId = String(item.id);
|
|
407
|
-
const spanName = this.getSpanNameForItem(item);
|
|
408
|
-
const span = tracer.startSpan(spanName, {
|
|
409
|
-
kind: SpanKind.INTERNAL,
|
|
410
|
-
attributes: {
|
|
411
|
-
"codex.item.id": itemId,
|
|
412
|
-
"codex.item.type": item.type,
|
|
413
|
-
...this.getAttributesForItem(item)
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
activeSpans.set(itemId, span);
|
|
417
|
-
itemStartTimes.set(itemId, eventTime);
|
|
418
|
-
logger.debug("Codex item started", {
|
|
419
|
-
itemId,
|
|
420
|
-
type: item.type
|
|
421
|
-
});
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
case "item.completed": {
|
|
425
|
-
const item = event.item;
|
|
426
|
-
if (!item) {
|
|
427
|
-
logger.warn("Codex item.completed event missing item", { event });
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
const itemId = item.id ? String(item.id) : crypto.randomUUID();
|
|
431
|
-
items.push(item);
|
|
432
|
-
if (item.type === "reasoning" && typeof item.text === "string") reasoningTexts.push(item.text);
|
|
433
|
-
if (item.type === "agent_message" && typeof item.text === "string") conversationMessages.push({
|
|
434
|
-
role: "assistant",
|
|
435
|
-
content: item.text
|
|
436
|
-
});
|
|
437
|
-
let span = activeSpans.get(itemId);
|
|
438
|
-
const hadStartEvent = span !== void 0;
|
|
439
|
-
if (!span) {
|
|
440
|
-
const spanName = this.getSpanNameForItem(item);
|
|
441
|
-
span = tracer.startSpan(spanName, {
|
|
442
|
-
kind: SpanKind.INTERNAL,
|
|
443
|
-
startTime: lastEventTime,
|
|
444
|
-
attributes: {
|
|
445
|
-
"codex.item.id": itemId,
|
|
446
|
-
"codex.item.type": item.type,
|
|
447
|
-
"codex.timing.estimated": true,
|
|
448
|
-
...this.getAttributesForItem(item)
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
const completionAttrs = this.getCompletionAttributesForItem(item, skillRootPrefixes);
|
|
453
|
-
for (const [key, value] of Object.entries(completionAttrs)) span.setAttribute(key, value);
|
|
454
|
-
const durationMs = eventTime - (itemStartTimes.get(itemId) || lastEventTime);
|
|
455
|
-
span.setAttribute("codex.duration_ms", durationMs);
|
|
456
|
-
span.setAttribute("codex.had_start_event", hadStartEvent);
|
|
457
|
-
if (item.type === "reasoning" && typeof item.text === "string") span.addEvent("reasoning", { "codex.reasoning.text": item.text });
|
|
458
|
-
if (item.type === "agent_message" && typeof item.text === "string") span.addEvent("message", { "codex.message.text": item.text });
|
|
459
|
-
if (item.type === "command_execution" && typeof item.aggregated_output === "string") span.addEvent("output", { "codex.command.output": item.aggregated_output });
|
|
460
|
-
if (item.status === "failed" || item.type === "error" || item.error !== void 0 || item.type === "command_execution" && typeof item.exit_code === "number" && item.exit_code !== 0) span.setStatus({
|
|
461
|
-
code: SpanStatusCode.ERROR,
|
|
462
|
-
message: (typeof item.message === "string" ? item.message : null) || (typeof item.error?.message === "string" ? item.error.message : null) || (item.type === "command_execution" && item.exit_code !== 0 ? `Command exited with code ${item.exit_code}` : null) || "Item failed"
|
|
463
|
-
});
|
|
464
|
-
else span.setStatus({ code: SpanStatusCode.OK });
|
|
465
|
-
span.end();
|
|
466
|
-
activeSpans.delete(itemId);
|
|
467
|
-
itemStartTimes.delete(itemId);
|
|
468
|
-
logger.debug("Codex item completed", {
|
|
469
|
-
itemId,
|
|
470
|
-
type: item.type,
|
|
471
|
-
durationMs
|
|
472
|
-
});
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
case "item.updated": {
|
|
476
|
-
const item = event.item;
|
|
477
|
-
if (item?.id) {
|
|
478
|
-
const itemId = String(item.id);
|
|
479
|
-
const span = activeSpans.get(itemId);
|
|
480
|
-
if (span) {
|
|
481
|
-
const updatedAttrs = this.getCompletionAttributesForItem(item, skillRootPrefixes);
|
|
482
|
-
for (const [key, value] of Object.entries(updatedAttrs)) span.setAttribute(key, value);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
logger.debug("Codex item updated", {
|
|
486
|
-
itemId: item?.id,
|
|
487
|
-
type: item?.type
|
|
488
|
-
});
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
case "turn.completed":
|
|
492
|
-
usage = event.usage;
|
|
493
|
-
logger.debug("Codex turn completed", { usage });
|
|
494
|
-
break;
|
|
495
|
-
case "turn.failed": {
|
|
496
|
-
const errorMsg = event.error?.message || "Turn failed";
|
|
497
|
-
logger.error("Codex turn failed", { error: errorMsg });
|
|
498
|
-
throw new Error(`Codex turn failed: ${errorMsg}`);
|
|
499
|
-
}
|
|
500
|
-
default: logger.debug("Codex unknown event type", { type: event.type });
|
|
501
|
-
}
|
|
502
|
-
lastEventTime = eventTime;
|
|
503
|
-
}
|
|
504
|
-
} finally {
|
|
505
|
-
for (const [itemId, span] of activeSpans) {
|
|
506
|
-
logger.warn("Codex item span not properly closed", { itemId });
|
|
507
|
-
span.setStatus({
|
|
508
|
-
code: SpanStatusCode.ERROR,
|
|
509
|
-
message: "Span not properly closed"
|
|
510
|
-
});
|
|
511
|
-
span.end();
|
|
512
|
-
}
|
|
513
|
-
activeSpans.clear();
|
|
514
|
-
itemStartTimes.clear();
|
|
515
|
-
}
|
|
516
|
-
const agentMessages = items.filter((i) => i.type === "agent_message");
|
|
517
|
-
return {
|
|
518
|
-
finalResponse: agentMessages.length > 0 ? agentMessages.map((i) => i.text).join("\n") : "",
|
|
519
|
-
items,
|
|
520
|
-
usage,
|
|
521
|
-
reasoningTexts,
|
|
522
|
-
conversationMessages
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Get a descriptive span name for a Codex item
|
|
527
|
-
*/
|
|
528
|
-
getSpanNameForItem(item) {
|
|
529
|
-
switch (item.type) {
|
|
530
|
-
case "command_execution": return `exec ${typeof item.command === "string" ? item.command.split(" ")[0] || "command" : "command"}`;
|
|
531
|
-
case "file_change": return `file ${item.changes?.[0]?.kind || "change"}`;
|
|
532
|
-
case "mcp_tool_call": return `mcp ${typeof item.server === "string" ? item.server : "unknown"}/${typeof item.tool === "string" ? item.tool : "unknown"}`;
|
|
533
|
-
case "agent_message": return "agent response";
|
|
534
|
-
case "reasoning": return "reasoning";
|
|
535
|
-
case "web_search": return `search "${typeof item.query === "string" ? item.query.slice(0, 30) : ""}"`;
|
|
536
|
-
case "todo_list": return "todo update";
|
|
537
|
-
case "error": return "error";
|
|
538
|
-
case "collaboration_tool_call": return `collab ${typeof item.tool === "string" ? item.tool : "unknown"}`;
|
|
539
|
-
case "spawn_agent": return `spawn ${typeof item.role === "string" ? item.role : "agent"}`;
|
|
540
|
-
case "send_input": return "send input";
|
|
541
|
-
case "agent_wait": return "wait";
|
|
542
|
-
default: return `codex.${item.type || "unknown"}`;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Get attributes for a Codex item at start
|
|
547
|
-
*/
|
|
548
|
-
getSkillTraceAttributes(item, skillRootPrefixes = [], options = {}) {
|
|
549
|
-
if (item?.type !== "command_execution") return {};
|
|
550
|
-
if (options.requireSuccessfulCommand && !this.isSuccessfulCommandExecution(item)) return {};
|
|
551
|
-
const command = typeof item.command === "string" && item.command.trim() ? item.command : void 0;
|
|
552
|
-
const skillCandidates = /* @__PURE__ */ new Map();
|
|
553
|
-
if (command) for (const skill of this.extractSkillPathCandidates(command, skillRootPrefixes)) skillCandidates.set(skill.path, skill);
|
|
554
|
-
if (skillCandidates.size === 0) return {};
|
|
555
|
-
const skills = Array.from(skillCandidates.values());
|
|
556
|
-
const attrs = {
|
|
557
|
-
"promptfoo.skill.count": skills.length,
|
|
558
|
-
"promptfoo.skill.names": skills.map((skill) => skill.name).join(","),
|
|
559
|
-
"promptfoo.skill.paths": skills.map((skill) => skill.path).join(",")
|
|
560
|
-
};
|
|
561
|
-
if (skills.length === 1) {
|
|
562
|
-
attrs["promptfoo.skill.name"] = skills[0].name;
|
|
563
|
-
attrs["promptfoo.skill.path"] = skills[0].path;
|
|
564
|
-
}
|
|
565
|
-
return attrs;
|
|
566
|
-
}
|
|
567
|
-
getAttributesForItem(item) {
|
|
568
|
-
const attrs = {};
|
|
569
|
-
switch (item.type) {
|
|
570
|
-
case "command_execution":
|
|
571
|
-
if (typeof item.command === "string") attrs["codex.command"] = item.command;
|
|
572
|
-
break;
|
|
573
|
-
case "mcp_tool_call":
|
|
574
|
-
if (typeof item.server === "string") attrs["codex.mcp.server"] = item.server;
|
|
575
|
-
if (typeof item.tool === "string") attrs["codex.mcp.tool"] = item.tool;
|
|
576
|
-
{
|
|
577
|
-
const serializedArgs = this.serializeItemValue(item.arguments ?? item.args ?? item.input);
|
|
578
|
-
if (serializedArgs) attrs["codex.mcp.input"] = serializedArgs;
|
|
579
|
-
}
|
|
580
|
-
break;
|
|
581
|
-
case "web_search":
|
|
582
|
-
if (typeof item.query === "string") attrs["codex.search.query"] = item.query;
|
|
583
|
-
break;
|
|
584
|
-
case "collaboration_tool_call":
|
|
585
|
-
if (typeof item.tool === "string") attrs["codex.collab.tool"] = item.tool;
|
|
586
|
-
if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
|
|
587
|
-
break;
|
|
588
|
-
case "spawn_agent":
|
|
589
|
-
if (typeof item.role === "string") attrs["codex.collab.role"] = item.role;
|
|
590
|
-
if (typeof item.thread_id === "string") attrs["codex.collab.spawned_thread"] = item.thread_id;
|
|
591
|
-
break;
|
|
592
|
-
case "send_input":
|
|
593
|
-
if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
|
|
594
|
-
break;
|
|
595
|
-
}
|
|
596
|
-
return attrs;
|
|
597
|
-
}
|
|
598
|
-
serializeItemValue(value) {
|
|
599
|
-
if (typeof value === "string") {
|
|
600
|
-
const trimmed = value.trim();
|
|
601
|
-
if (!trimmed) return;
|
|
602
|
-
try {
|
|
603
|
-
return JSON.stringify(this.redactTracePii(sanitizeObject(JSON.parse(trimmed))));
|
|
604
|
-
} catch {
|
|
605
|
-
return this.redactTracePii(sanitizeObject(trimmed, { context: "Codex MCP trace input" }));
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
if (value === void 0 || value === null) return;
|
|
609
|
-
try {
|
|
610
|
-
return JSON.stringify(this.redactTracePii(sanitizeObject(value, { context: "Codex MCP trace input" })));
|
|
611
|
-
} catch {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
redactTracePii(value) {
|
|
616
|
-
if (typeof value === "string" && /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i.test(value)) return REDACTED;
|
|
617
|
-
if (Array.isArray(value)) return value.map((item) => this.redactTracePii(item));
|
|
618
|
-
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [key, normalizeFieldName(key).includes("email") ? REDACTED : this.redactTracePii(entryValue)]));
|
|
619
|
-
return value;
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Get attributes for a Codex item at completion
|
|
623
|
-
*/
|
|
624
|
-
getCompletionAttributesForItem(item, skillRootPrefixes = []) {
|
|
625
|
-
const attrs = {};
|
|
626
|
-
switch (item.type) {
|
|
627
|
-
case "command_execution":
|
|
628
|
-
if (typeof item.exit_code === "number") attrs["codex.exit_code"] = item.exit_code;
|
|
629
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
630
|
-
if (typeof item.aggregated_output === "string") attrs["codex.output"] = item.aggregated_output;
|
|
631
|
-
Object.assign(attrs, this.getSkillTraceAttributes(item, skillRootPrefixes, { requireSuccessfulCommand: true }));
|
|
632
|
-
break;
|
|
633
|
-
case "file_change":
|
|
634
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
635
|
-
if (Array.isArray(item.changes) && item.changes.length) {
|
|
636
|
-
attrs["codex.files_changed"] = item.changes.length;
|
|
637
|
-
attrs["codex.files"] = item.changes.map((c) => typeof c?.path === "string" ? c.path : "").filter(Boolean).join(", ");
|
|
638
|
-
}
|
|
639
|
-
break;
|
|
640
|
-
case "mcp_tool_call":
|
|
641
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
642
|
-
if (typeof item.error?.message === "string") attrs["codex.error"] = item.error.message;
|
|
643
|
-
{
|
|
644
|
-
const serializedArgs = this.serializeItemValue(item.arguments ?? item.args ?? item.input);
|
|
645
|
-
if (serializedArgs) attrs["codex.mcp.input"] = serializedArgs;
|
|
646
|
-
}
|
|
647
|
-
break;
|
|
648
|
-
case "agent_message":
|
|
649
|
-
if (typeof item.text === "string") attrs["codex.message"] = item.text;
|
|
650
|
-
break;
|
|
651
|
-
case "reasoning":
|
|
652
|
-
if (typeof item.text === "string") attrs["codex.reasoning"] = item.text;
|
|
653
|
-
break;
|
|
654
|
-
case "error":
|
|
655
|
-
if (typeof item.message === "string") attrs["codex.error"] = item.message;
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
return attrs;
|
|
659
|
-
}
|
|
660
|
-
generateCacheKey(config, prompt) {
|
|
661
|
-
const keyData = {
|
|
662
|
-
working_dir: config.working_dir,
|
|
663
|
-
additional_directories: config.additional_directories,
|
|
664
|
-
model: config.model,
|
|
665
|
-
output_schema: config.output_schema,
|
|
666
|
-
sandbox_mode: config.sandbox_mode,
|
|
667
|
-
model_reasoning_effort: config.model_reasoning_effort,
|
|
668
|
-
network_access_enabled: config.network_access_enabled,
|
|
669
|
-
web_search_enabled: config.web_search_enabled,
|
|
670
|
-
web_search_mode: config.web_search_mode,
|
|
671
|
-
approval_policy: config.approval_policy,
|
|
672
|
-
prompt
|
|
673
|
-
};
|
|
674
|
-
return `openai:codex-sdk:${crypto.createHash("sha256").update(JSON.stringify(keyData)).digest("hex")}`;
|
|
675
|
-
}
|
|
676
|
-
async callApi(prompt, context, callOptions) {
|
|
677
|
-
const config = {
|
|
678
|
-
...this.config,
|
|
679
|
-
...context?.prompt?.config
|
|
680
|
-
};
|
|
681
|
-
const modelName = config.model || "codex";
|
|
682
|
-
const spanContext = {
|
|
683
|
-
system: "openai",
|
|
684
|
-
operationName: "chat",
|
|
685
|
-
model: modelName,
|
|
686
|
-
providerId: this.id(),
|
|
687
|
-
evalId: context?.evaluationId || context?.test?.metadata?.evaluationId,
|
|
688
|
-
testIndex: typeof context?.test?.vars?.__testIdx === "number" ? context.test.vars.__testIdx : void 0,
|
|
689
|
-
promptLabel: context?.prompt?.label,
|
|
690
|
-
traceparent: context?.traceparent,
|
|
691
|
-
requestBody: prompt
|
|
692
|
-
};
|
|
693
|
-
const resultExtractor = (response) => {
|
|
694
|
-
const result = {};
|
|
695
|
-
if (response.tokenUsage) result.tokenUsage = response.tokenUsage;
|
|
696
|
-
if (response.sessionId) result.responseId = response.sessionId;
|
|
697
|
-
if (response.cached !== void 0) result.cacheHit = response.cached;
|
|
698
|
-
result.responseModel = modelName;
|
|
699
|
-
if (response.output !== void 0) try {
|
|
700
|
-
result.responseBody = typeof response.output === "string" ? response.output : JSON.stringify(response.output);
|
|
701
|
-
} catch {
|
|
702
|
-
result.responseBody = "[unable to serialize output]";
|
|
703
|
-
}
|
|
704
|
-
if (response.raw) try {
|
|
705
|
-
const rawData = typeof response.raw === "string" ? JSON.parse(response.raw) : response.raw;
|
|
706
|
-
if (rawData.reasoningTexts?.length > 0) result.additionalAttributes = {
|
|
707
|
-
"codex.reasoning.count": rawData.reasoningTexts.length,
|
|
708
|
-
"codex.reasoning.summary": rawData.reasoningTexts.join("\n---\n").slice(0, 2e3)
|
|
709
|
-
};
|
|
710
|
-
if (rawData.conversationMessages?.length > 0) result.additionalAttributes = {
|
|
711
|
-
...result.additionalAttributes,
|
|
712
|
-
"codex.conversation.message_count": rawData.conversationMessages.length
|
|
713
|
-
};
|
|
714
|
-
if (rawData.items?.length > 0) {
|
|
715
|
-
const itemCounts = {};
|
|
716
|
-
for (const item of rawData.items) itemCounts[item.type] = (itemCounts[item.type] || 0) + 1;
|
|
717
|
-
result.additionalAttributes = {
|
|
718
|
-
...result.additionalAttributes,
|
|
719
|
-
"codex.items.total": rawData.items.length,
|
|
720
|
-
"codex.items.breakdown": JSON.stringify(itemCounts)
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
} catch {}
|
|
724
|
-
return result;
|
|
725
|
-
};
|
|
726
|
-
return withGenAISpan(spanContext, () => this.callApiInternal(prompt, context, callOptions, config), resultExtractor);
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Internal implementation of callApi without tracing wrapper.
|
|
730
|
-
* Context is available for future use (e.g., _context?.vars for template rendering,
|
|
731
|
-
* _context?.bustCache for cache control, _context?.debug for debug mode).
|
|
732
|
-
*/
|
|
733
|
-
async callApiInternal(prompt, _context, callOptions, config) {
|
|
734
|
-
const currentTraceparent = getTraceparent();
|
|
735
|
-
const env = this.prepareEnvironment(config, currentTraceparent);
|
|
736
|
-
const skillRootPrefixes = this.getSkillRootPrefixes(env);
|
|
737
|
-
if (!this.apiKey && !env.OPENAI_API_KEY && !env.CODEX_API_KEY) throw new Error("OpenAI API key is not set. Set OPENAI_API_KEY or CODEX_API_KEY environment variable or add \"apiKey\" to provider config.");
|
|
738
|
-
if (config.working_dir) this.validateWorkingDirectory(config.working_dir, config.skip_git_repo_check);
|
|
739
|
-
if (callOptions?.abortSignal?.aborted) return { error: "OpenAI Codex SDK call aborted before it started" };
|
|
740
|
-
if (!this.codexModule) this.codexModule = await loadCodexSDK();
|
|
741
|
-
let localInstance = void 0;
|
|
742
|
-
const useLocalInstance = config.deep_tracing;
|
|
743
|
-
if (useLocalInstance) {
|
|
744
|
-
if ((config.persist_threads || config.thread_id || (config.thread_pool_size ?? 0) > 1) && !this.deepTracingWarningShown) {
|
|
745
|
-
logger.warn("[CodexSDK] deep_tracing is incompatible with thread persistence. Thread options (persist_threads, thread_id, thread_pool_size) are ignored when deep_tracing is enabled.");
|
|
746
|
-
this.deepTracingWarningShown = true;
|
|
747
|
-
}
|
|
748
|
-
localInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
|
|
749
|
-
} else {
|
|
750
|
-
const stableEnv = { ...env };
|
|
751
|
-
delete stableEnv.TRACEPARENT;
|
|
752
|
-
const envHash = crypto.createHash("sha256").update(JSON.stringify(stableEnv)).digest("hex");
|
|
753
|
-
const envChanged = this.codexInstanceEnvHash !== envHash;
|
|
754
|
-
if (!this.codexInstance || envChanged) {
|
|
755
|
-
if (envChanged && this.codexInstance) {
|
|
756
|
-
logger.debug("[CodexSDK] Recreating instance due to configuration change");
|
|
757
|
-
try {
|
|
758
|
-
await this.destroyInstance(this.codexInstance);
|
|
759
|
-
} catch (cleanupError) {
|
|
760
|
-
logger.warn("[CodexSDK] Error cleaning up old instance", { error: cleanupError });
|
|
761
|
-
}
|
|
762
|
-
this.threads.clear();
|
|
763
|
-
}
|
|
764
|
-
this.codexInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
|
|
765
|
-
this.codexInstanceEnvHash = envHash;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
const activeInstance = useLocalInstance ? localInstance : this.codexInstance;
|
|
769
|
-
if (!activeInstance) throw new Error("Failed to create Codex instance - SDK module may have failed to load");
|
|
770
|
-
const cacheKey = this.generateCacheKey(config, prompt);
|
|
771
|
-
const thread = await this.getOrCreateThread(config, cacheKey, activeInstance);
|
|
772
|
-
const runOptions = {};
|
|
773
|
-
if (config.output_schema) runOptions.outputSchema = config.output_schema;
|
|
774
|
-
if (callOptions?.abortSignal) runOptions.signal = callOptions.abortSignal;
|
|
775
|
-
try {
|
|
776
|
-
const turn = config.enable_streaming ? await this.runStreaming(thread, prompt, runOptions, callOptions, skillRootPrefixes) : await thread.run(prompt, runOptions);
|
|
777
|
-
const output = turn.finalResponse || "";
|
|
778
|
-
const raw = JSON.stringify(turn);
|
|
779
|
-
const skillMetadata = this.buildSkillMetadata(turn.items, skillRootPrefixes);
|
|
780
|
-
const metadata = skillMetadata ? {
|
|
781
|
-
...skillMetadata.skillCalls.length > 0 ? { skillCalls: skillMetadata.skillCalls } : {},
|
|
782
|
-
...skillMetadata.attemptedSkillCalls.length > skillMetadata.skillCalls.length ? { attemptedSkillCalls: skillMetadata.attemptedSkillCalls } : {}
|
|
783
|
-
} : void 0;
|
|
784
|
-
const tokenUsage = turn.usage ? {
|
|
785
|
-
prompt: turn.usage.input_tokens,
|
|
786
|
-
completion: turn.usage.output_tokens,
|
|
787
|
-
total: turn.usage.input_tokens + turn.usage.output_tokens,
|
|
788
|
-
cached: turn.usage.cached_input_tokens || 0
|
|
789
|
-
} : void 0;
|
|
790
|
-
let cost = 0;
|
|
791
|
-
if (tokenUsage && config.model) {
|
|
792
|
-
const pricing = CODEX_MODEL_PRICING[config.model];
|
|
793
|
-
if (pricing) {
|
|
794
|
-
const cachedTokens = tokenUsage.cached || 0;
|
|
795
|
-
const inputCost = ((tokenUsage.prompt || 0) - cachedTokens) * (pricing.input / 1e6);
|
|
796
|
-
const cacheReadCost = cachedTokens * (pricing.cache_read / 1e6);
|
|
797
|
-
const outputCost = (tokenUsage.completion || 0) * (pricing.output / 1e6);
|
|
798
|
-
cost = inputCost + cacheReadCost + outputCost;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
logger.debug("OpenAI Codex SDK response", {
|
|
802
|
-
output,
|
|
803
|
-
usage: turn.usage
|
|
804
|
-
});
|
|
805
|
-
return {
|
|
806
|
-
output,
|
|
807
|
-
tokenUsage,
|
|
808
|
-
cost,
|
|
809
|
-
metadata,
|
|
810
|
-
raw,
|
|
811
|
-
sessionId: thread.id || "unknown"
|
|
812
|
-
};
|
|
813
|
-
} catch (error) {
|
|
814
|
-
if (error instanceof Error && error.name === "AbortError" || callOptions?.abortSignal?.aborted) {
|
|
815
|
-
logger.warn("OpenAI Codex SDK call aborted");
|
|
816
|
-
return { error: "OpenAI Codex SDK call aborted" };
|
|
817
|
-
}
|
|
818
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
819
|
-
logger.error("Error calling OpenAI Codex SDK", { error: errorMessage });
|
|
820
|
-
return { error: `Error calling OpenAI Codex SDK: ${errorMessage}` };
|
|
821
|
-
} finally {
|
|
822
|
-
if (!config.deep_tracing && !config.persist_threads && !config.thread_id && cacheKey) this.threads.delete(cacheKey);
|
|
823
|
-
if (useLocalInstance && localInstance) try {
|
|
824
|
-
await this.destroyInstance(localInstance);
|
|
825
|
-
} catch (cleanupError) {
|
|
826
|
-
logger.debug("[CodexSDK] Error cleaning up local instance", { error: cleanupError });
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
|
-
//#endregion
|
|
832
|
-
export { OpenAICodexSDKProvider };
|
|
833
|
-
|
|
834
|
-
//# sourceMappingURL=codex-sdk-BQEw16R_.js.map
|