promptfoo 0.121.2 → 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 +2 -0
- package/dist/src/{ListApp-Du7YVwj5.js → ListApp-DQkFNqE9.js} +1 -1
- package/dist/src/{accounts-B0pgC1oV.js → accounts-DdJ2pHMI.js} +5 -5
- package/dist/src/{accounts-CiBLOnA7.js → accounts-DhMYUUbu.js} +5 -5
- package/dist/src/{accounts-gtkH-5KX.cjs → accounts-Dy17bs4D.cjs} +5 -5
- package/dist/src/{accounts-Bm2D8Db9.js → accounts-F9d_5sMC.js} +6 -6
- package/dist/src/{cometapi-C4xSqeID.cjs → agentic-utils-BpX5b23w.cjs} +24 -62
- package/dist/src/{cometapi-CUQq3H_a.js → agentic-utils-P172hM8B.js} +4 -61
- package/dist/src/agentic-utils-qFlm6zes.js +153 -0
- package/dist/src/{agentic-utils-DS1g3GLF.js → agentic-utils-w68v6_Dz.js} +3 -3
- package/dist/src/{agents-CmvBq8LV.js → agents-8FDnTriG.js} +6 -7
- package/dist/src/{agents-DbRtpYxR.cjs → agents-BahDpe5G.cjs} +255 -20
- package/dist/src/{agents-DgF2zDag.js → agents-C-R_jfzI.js} +255 -20
- package/dist/src/{agents-9qiOy0ho.js → agents-CgaMXvLM.js} +5 -7
- package/dist/src/{agents-Di9DKPzn.cjs → agents-D7-HGxUj.cjs} +5 -7
- package/dist/src/{agents-CBr9A01V.js → agents-DJ35I3Nt.js} +255 -20
- package/dist/src/{agents-cLXA8a_8.js → agents-aYPQLf8W.js} +5 -9
- package/dist/src/{agents-D__IdAlg.js → agents-pQeBEXMm.js} +255 -21
- package/dist/src/{aimlapi-B4rcnZgv.js → aimlapi-BCq3MHeL.js} +8 -14
- package/dist/src/{aimlapi-DHJU_kcV.js → aimlapi-BD6J9oKt.js} +7 -14
- package/dist/src/{aimlapi-BvlNH0gr.cjs → aimlapi-qcK4OT55.cjs} +8 -15
- package/dist/src/{aimlapi-CnkC2HqE.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-Dz3z7s3J.js → audio-B7izf48x.js} +4 -5
- package/dist/src/{audio-CGMyULza.cjs → audio-BQtNuYBj.cjs} +4 -4
- package/dist/src/{audio-Bkv46et0.js → audio-COrn8rM6.js} +4 -4
- package/dist/src/{audio-ClI_AFre.js → audio-DcVKoInv.js} +4 -4
- package/dist/src/{base-CGrhspbK.cjs → base-D-670DX8.cjs} +3 -3
- package/dist/src/{base-CpjcHe4e.js → base-PYJvBE1i.js} +3 -3
- package/dist/src/{base-Dy1V8--Z.js → base-fZ9wgg50.js} +3 -3
- package/dist/src/{base-DLKtKMFh.js → base-yrI1Yal4.js} +3 -3
- package/dist/src/{blobs-BDbfYdrJ.js → blobs-BCZavS8s.js} +4 -4
- package/dist/src/{blobs-CMHN0Qcz.js → blobs-BQWqnnvL.js} +4 -4
- package/dist/src/{blobs-CBO20krR.js → blobs-C-F78Kfn.js} +3 -3
- package/dist/src/{blobs-D23XLin-.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-C2jrdPMx.js → chat-0bwXjVP0.js} +3 -13
- package/dist/src/{chat-C1Qst7jL.cjs → chat-BPXSW8Bv.cjs} +3 -13
- package/dist/src/{chat-DJIw17u0.js → chat-BfPaS15_.js} +68 -42
- package/dist/src/{chat-CgF-J-Jj.cjs → chat-CclRbxGf.cjs} +68 -42
- package/dist/src/{chat-BiKyneZl.js → chat-Dr3DUQ0D.js} +68 -42
- package/dist/src/{chat-DqxYYtWA.js → chat-I9izLm49.js} +67 -41
- package/dist/src/{chat-CzkrVDfz.js → chat-MKxMnZJZ.js} +3 -13
- package/dist/src/{chat-qmatte1u.js → chat-mW0ORo8G.js} +3 -14
- package/dist/src/{chatkit-DKyPi1Gs.cjs → chatkit-BoWoSgXl.cjs} +4 -4
- package/dist/src/{chatkit-65VXf5SR.js → chatkit-CJnHRRMM.js} +4 -4
- package/dist/src/{chatkit-Be-Q-a9F.js → chatkit-Cv6AhukM.js} +4 -4
- package/dist/src/{chatkit-BxFvW8KY.js → chatkit-zUIVoDos.js} +4 -4
- package/dist/src/{claude-agent-sdk-Apiy0iaz.js → claude-agent-sdk-BQNuLaAK.js} +41 -18
- package/dist/src/{claude-agent-sdk-D9Z5Pr9X.cjs → claude-agent-sdk-CPJo3dBQ.cjs} +45 -22
- package/dist/src/{claude-agent-sdk-D2bJee9S.js → claude-agent-sdk-Dtq_L-Sc.js} +40 -17
- package/dist/src/{claude-agent-sdk-DfCoW0E6.js → claude-agent-sdk-nfAIcxNf.js} +42 -20
- package/dist/src/{cloud-C0dlstV_.js → cloud-DQZ5sVjW.js} +25 -13
- package/dist/src/cloud-Hphvo8kr.js +3 -0
- package/dist/src/{cloudflare-ai-8TDxHR0x.js → cloudflare-ai-BIB567w6.js} +5 -14
- package/dist/src/{cloudflare-ai-g7PB6VHR.js → cloudflare-ai-DGLte7Py.js} +5 -14
- package/dist/src/{cloudflare-ai-CknbZ5LJ.cjs → cloudflare-ai-Dl3N9OVD.cjs} +6 -15
- package/dist/src/{cloudflare-ai-BxAGvfju.js → cloudflare-ai-DlKr0rY7.js} +5 -15
- package/dist/src/{cloudflare-gateway-B9HWA5wf.js → cloudflare-gateway-BDZrYydE.js} +4 -16
- package/dist/src/{cloudflare-gateway-BSnDmHYo.cjs → cloudflare-gateway-BYDp495F.cjs} +4 -15
- package/dist/src/{cloudflare-gateway-CKDb4dJ8.js → cloudflare-gateway-CiIZHU0Q.js} +5 -164
- package/dist/src/{cloudflare-gateway-CP9QEWYS.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-BL9yvj_f.js → cometapi-BUlt_ELa.js} +8 -15
- package/dist/src/{cometapi-DFNiKmSz.js → cometapi-CtJ-mS8R.js} +8 -16
- package/dist/src/cometapi-DT-jlVCB.js +55 -0
- package/dist/src/cometapi-UVOryo4W.cjs +55 -0
- package/dist/src/{completion-CM6oK8PS.cjs → completion-BozdoXba.cjs} +7 -62
- package/dist/src/{completion-5MzrpJxT.js → completion-Dnxn7E-j.js} +8 -57
- package/dist/src/{completion-qRoZAYRB.js → completion-HUe8wDhZ.js} +8 -57
- package/dist/src/{completion-DZ083F31.js → completion-x0a_c2y1.js} +8 -57
- package/dist/src/{createHash-CTQmL3G2.js → createHash-4gFQpDDv.js} +3 -3
- package/dist/src/{createHash-CfZSc0b4.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-ExVyLp0S.js → docker-CQmlA2NU.js} +7 -14
- package/dist/src/{docker-Bb5dcxr8.js → docker-ClnmCf1Z.js} +6 -14
- package/dist/src/{docker-BvfL2BrW.js → docker-DCgsveLD.js} +6 -16
- package/dist/src/{docker-DcF2pRrj.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-CaIwzWR5.js → esm-C7PnfdF8.js} +16 -7
- package/dist/src/{esm-CnNt7sI4.cjs → esm-CtEPLdAj.cjs} +15 -6
- package/dist/src/{esm-Cd1AjG1D.js → esm-Dh4dOLlt.js} +15 -6
- package/dist/src/{esm-C03C-mv3.js → esm-tVgYPY-f.js} +27 -18
- package/dist/src/eval-CzJFfFO9.js +3 -0
- package/dist/src/{eval-Dg2nG4v2.js → eval-u4UVafl6.js} +49 -20
- package/dist/src/{evalResult-BDMqrapS.js → evalResult-Bgm9ZH31.js} +7 -7
- package/dist/src/{evalResult-BBRNtX4I.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-fuaI8HkH.cjs → evalResult-KZqXl4XP.cjs} +7 -7
- package/dist/src/evaluator-CVessDWe.js +3 -0
- package/dist/src/{evaluator-BhoWwp5b.js → evaluator-IvuDYSvQ.js} +3080 -1254
- package/dist/src/{extractor-D25qpmGX.js → extractor-CAfTSraf.js} +6 -6
- package/dist/src/{extractor-DReVID0K.js → extractor-DNSeBVOJ.js} +6 -6
- package/dist/src/{extractor-C0EVHewb.js → extractor-Dk6bRWkv.js} +6 -6
- package/dist/src/{extractor-pYLLi3wS.cjs → extractor-WVPOrH43.cjs} +6 -6
- package/dist/src/{fetch-HaqdX7U1.js → fetch-B0Z3Oe4k.js} +218 -55
- package/dist/src/{fetch-Dxpd4_sr.js → fetch-BEWnXrrG.js} +195 -45
- package/dist/src/fetch-C7bGKDlQ.js +3 -0
- package/dist/src/{fetch-BPkYtG8K.cjs → fetch-CJU5ELPa.cjs} +223 -48
- package/dist/src/{fetch-Cwxnd8zz.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-D3fD9dNV.js → genaiTracer-COYDi-tC.js} +6 -2
- package/dist/src/{genaiTracer-C1rxGO8Q.js → genaiTracer-DWdZ28hY.js} +6 -2
- package/dist/src/{genaiTracer-70Z8BIuV.js → genaiTracer-XnrcgDCe.js} +6 -2
- package/dist/src/{genaiTracer-DN4dQywX.cjs → genaiTracer-yRuxj9-L.cjs} +7 -3
- package/dist/src/golang/wrapper.go +1 -1
- package/dist/src/{graders-DU49_J8Y.cjs → graders--zknU_uk.cjs} +5747 -3206
- 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-BTeBGqjJ.js → graders-Zy3x0zqX.js} +5727 -3218
- package/dist/src/{graders-Bj_Odv7c.js → graders-eIHhRqoC.js} +5719 -3210
- package/dist/src/{graders-DP7KFFo-.js → graders-pvbReLLn.js} +5728 -3219
- package/dist/src/{image-B0h9VEMc.js → image-9302QVqR.js} +4 -4
- package/dist/src/{image-CHfWvljl.js → image-B5Mv-Z3h.js} +8 -8
- package/dist/src/{image-DS-o-0ph.js → image-DVz2RiMF.js} +8 -8
- package/dist/src/{image-C1madmKh.cjs → image-De2FBmYV.cjs} +4 -4
- package/dist/src/{image-B02ogr_b.js → image-dnoUgPrC.js} +4 -5
- package/dist/src/{image-Dpxa1Jt6.js → image-qUpPvmNZ.js} +8 -8
- package/dist/src/{image-Bb4vWQLM.js → image-u7-rKnYU.js} +4 -4
- package/dist/src/{image-BLmROtN3.cjs → image-x6KqLQl4.cjs} +8 -8
- package/dist/src/index.cjs +3728 -1482
- package/dist/src/index.d.cts +3232 -79
- package/dist/src/index.d.ts +3232 -79
- package/dist/src/index.js +3735 -1490
- package/dist/src/{interactiveCheck-BgLZUIt3.js → interactiveCheck-CLERUB0c.js} +2 -2
- package/dist/src/{knowledgeBase-DOO_BM9b.cjs → knowledgeBase-Bpoe_nLu.cjs} +6 -8
- package/dist/src/{knowledgeBase-D33Ty2l6.js → knowledgeBase-Dgc7CBWF.js} +6 -8
- package/dist/src/{knowledgeBase-B3OoKIej.js → knowledgeBase-RhFPGWDc.js} +6 -8
- package/dist/src/{knowledgeBase-CYTLHOt1.js → knowledgeBase-lm9RXSAm.js} +6 -9
- package/dist/src/{litellm-NbjknEh6.js → litellm-C2kqjxqp.js} +6 -14
- package/dist/src/{litellm-I_hbp_dc.cjs → litellm-CoyI4IAl.cjs} +6 -15
- package/dist/src/{litellm-TrljxD9G.js → litellm-DRjpcSa7.js} +5 -14
- package/dist/src/{litellm-AaeZcZQF.js → litellm-p37R1dzQ.js} +5 -16
- package/dist/src/{logger-DLcq4dWf.js → logger-B88EkIn6.js} +48 -23
- package/dist/src/{logger-Cp1GPUjj.cjs → logger-COuQb2xB.cjs} +77 -22
- package/dist/src/{logger-CT3IKMKA.js → logger-Ct2S6Yx-.js} +48 -23
- package/dist/src/{logger-KkObSCzq.js → logger-DksKw1Qc.js} +48 -23
- package/dist/src/{luma-ray-f6I2fft-.js → luma-ray-B863CmuZ.js} +6 -10
- package/dist/src/{luma-ray-DDsjcgZZ.js → luma-ray-BTTLtqQ8.js} +7 -10
- package/dist/src/{luma-ray-Due0n7di.cjs → luma-ray-BxVKaW2a.cjs} +6 -10
- package/dist/src/{luma-ray-BS2_tY8L.js → luma-ray-KgTCXrZC.js} +6 -12
- package/dist/src/main.d.ts +1 -26
- package/dist/src/main.js +1011 -548
- package/dist/src/{messages-Bs1kC7P4.cjs → messages-811uVVW5.cjs} +74 -19
- package/dist/src/{messages-BS17jdMx.js → messages-BTQz42fn.js} +74 -19
- package/dist/src/{messages-ZJk778GH.js → messages-MYTQ2TWp.js} +74 -19
- package/dist/src/{messages-D0lx5qK7.js → messages-zWbkLLHz.js} +74 -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-Bmni6skY.js → modelslab-D0erNWKe.js} +7 -10
- package/dist/src/{modelslab-DRb74SP4.js → modelslab-DIq-6y7x.js} +7 -10
- package/dist/src/{modelslab-CoUX6Jc_.cjs → modelslab-Dk1JAtVo.cjs} +7 -10
- package/dist/src/{modelslab-Bx9IrZfS.js → modelslab-wu9yi5GE.js} +7 -11
- package/dist/src/{nova-reel-BfPq-0Yk.js → nova-reel-CCFRfeRb.js} +7 -10
- package/dist/src/{nova-reel-C_QM18Xn.cjs → nova-reel-CrLXVKQf.cjs} +6 -10
- package/dist/src/{nova-reel-bgjxilYW.js → nova-reel-DQrm74ng.js} +6 -10
- package/dist/src/{nova-reel-D_W1tjMH.js → nova-reel-gr11WG7f.js} +6 -12
- package/dist/src/{nova-sonic-DIGQNR07.js → nova-sonic-BYdp-QLs.js} +5 -7
- package/dist/src/{nova-sonic-CFb5GYhg.js → nova-sonic-B_ZXcUJB.js} +4 -7
- package/dist/src/{nova-sonic-De1HW5fD.js → nova-sonic-TDgrlTk7.js} +4 -9
- package/dist/src/{nova-sonic-zfcljeRp.cjs → nova-sonic-i5tUvXKn.cjs} +4 -7
- package/dist/src/{openai-DElQ-fPX.js → openai-DhVEmgeZ.js} +6 -3
- package/dist/src/{openai-DhbB7eWK.js → openai-Qsvz25mV.js} +6 -3
- package/dist/src/{openai-Cuif0GEt.cjs → openai-URNyItar.cjs} +6 -3
- package/dist/src/{openai-j-sE2O7r.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-B3CWY9h_.js → opencode-sdk-BUu5Nevv.js} +12 -14
- package/dist/src/{opencode-sdk-BL764Jdi.cjs → opencode-sdk-BZ2idgYA.cjs} +16 -18
- package/dist/src/{opencode-sdk-0j6rTWNb.js → opencode-sdk-BxD8vXp_.js} +12 -15
- package/dist/src/{opencode-sdk-C2y6UkP2.js → opencode-sdk-GI2KaAXq.js} +12 -14
- package/dist/src/{otlpReceiver-C99PPb48.js → otlpReceiver-B2z58l4e.js} +154 -98
- package/dist/src/{otlpReceiver-CGq6LspY.cjs → otlpReceiver-BfcVq2Nq.cjs} +154 -98
- package/dist/src/{otlpReceiver-D89fR-rC.js → otlpReceiver-BntK801g.js} +154 -98
- package/dist/src/{otlpReceiver-CdNBdbsk.js → otlpReceiver-DmVulbhC.js} +154 -98
- package/dist/src/{providerRegistry-CD8MEar9.js → providerRegistry-Bvh8mv85.js} +2 -2
- package/dist/src/{providerRegistry-DM8rZYol.js → providerRegistry-CPQ_CmVO.js} +2 -2
- package/dist/src/{providerRegistry-Civky8Ar.cjs → providerRegistry-CQMdTmHP.cjs} +2 -2
- package/dist/src/{providerRegistry-B0RUOLI_.js → providerRegistry-CWoPjKFZ.js} +2 -2
- package/dist/src/{providers-CgKOSgTR.cjs → providers-1eKkXBKp.cjs} +1435 -930
- package/dist/src/{providers-BlqUifFg.js → providers-BV_KMZje.js} +1419 -944
- package/dist/src/providers-Bp4S-FvO.js +2 -0
- package/dist/src/providers-DV3ax9e_.cjs +3 -0
- package/dist/src/{providers-D8lF1sqW.js → providers-Domz_llv.js} +1427 -952
- package/dist/src/{providers-Dk_6ocUX.js → providers-DruaQfwu.js} +1424 -949
- 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-D6fwaDSg.js → pythonUtils-C2UQ30Rz.js} +4 -4
- package/dist/src/{pythonUtils-D5nxkQ0P.js → pythonUtils-Cldx7huE.js} +4 -4
- package/dist/src/{pythonUtils-C3py6GC1.js → pythonUtils-CnndUbW-.js} +3 -3
- package/dist/src/{pythonUtils-CTU3Y3lw.cjs → pythonUtils-tAJvvpS-.cjs} +3 -3
- package/dist/src/{quiverai-CIaELU_m.js → quiverai-CtWi6x_g.js} +4 -4
- package/dist/src/{quiverai-PdShCPox.cjs → quiverai-DFotyafY.cjs} +4 -4
- package/dist/src/{quiverai-BbOUOn2L.js → quiverai-DR0SnIQV.js} +4 -4
- package/dist/src/{quiverai-uH-dcTIr.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-Drod8m7K.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-DIR9Ud3j.js → responses--OsX2aYW.js} +23 -14
- package/dist/src/{responses-D8SBTL64.cjs → responses-Bi9vBuW_.cjs} +24 -15
- package/dist/src/{responses-CB2jwoAr.js → responses-C-flexAY.js} +24 -15
- package/dist/src/{responses-WNGNYe3K.js → responses-DL9m8CyY.js} +24 -15
- package/dist/src/{rubyUtils-DhCAlxZr.cjs → rubyUtils-B6eljPuh.cjs} +3 -3
- package/dist/src/{rubyUtils-BcuGX77l.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-BUVePouc.js → rubyUtils-DVLeA2jg.js} +3 -3
- package/dist/src/{rubyUtils-Boc4HZzX.js → rubyUtils-DsGrTx8R.js} +3 -3
- package/dist/src/{sagemaker-CNBxx5CJ.js → sagemaker-BVkaG2-l.js} +14 -18
- package/dist/src/{sagemaker-CemTFp2h.js → sagemaker-BveBvuxm.js} +14 -18
- package/dist/src/{sagemaker-YSyBXQQh.js → sagemaker-D67yzMzs.js} +14 -19
- package/dist/src/{sagemaker-Cl28mZU2.cjs → sagemaker-XnfhheQv.cjs} +14 -18
- package/dist/src/{scanner-BsBlNXNn.js → scanner-1DqWi1Ej.js} +130 -35
- package/dist/src/server/golang/wrapper.go +1 -1
- package/dist/src/server/index.js +3757 -1511
- package/dist/src/server/python/persistent_wrapper.py +0 -5
- package/dist/src/{server-CqzrVGpF.js → server-BNYztJkh.js} +128 -9
- package/dist/src/{server-CuxBbeSY.js → server-BSB45Nt9.js} +127 -8
- package/dist/src/{server-VWgWb00X.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-C_7Ax-hA.cjs → server-Dx2TyCH2.cjs} +140 -6
- package/dist/src/{signal-4U3mfRvL.js → signal-CE5G3a7x.js} +3 -3
- package/dist/src/{slack-BmVAVGaK.cjs → slack-1Rhq0EoV.cjs} +2 -2
- package/dist/src/{slack-DCUPTzS2.js → slack-D5Wpy8LM.js} +2 -2
- package/dist/src/{slack-DXMKtA-f.js → slack-DDUe-5MC.js} +2 -2
- package/dist/src/{slack-DOdy_kyv.js → slack-acRb0IqQ.js} +2 -2
- package/dist/src/store-CWOSz6D_.cjs +2 -0
- package/dist/src/{store-Dim__MDd.js → store-CYEy5J2D.js} +17 -5
- package/dist/src/{store-DLlFCC4h.cjs → store-DAAyxcy6.cjs} +17 -5
- package/dist/src/store-DCDBhv7B.js +3 -0
- package/dist/src/{store-CXGFv4aR.js → store-Dn9HUkdW.js} +17 -5
- package/dist/src/{store-DXilxTl-.js → store-M0b1WfYb.js} +17 -5
- package/dist/src/{tables-gftXzE9I.js → tables-C4CH3zRr.js} +3 -3
- package/dist/src/{tables-DLJPUdUE.js → tables-CsWou1Bx.js} +3 -3
- package/dist/src/{tables-6YKwjN9-.js → tables-DQ4WU5tX.js} +3 -3
- package/dist/src/{tables-DPi7wKeM.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-CMrFgtPB.js → telemetry-CQPez_Jp.js} +4 -4
- package/dist/src/{telemetry-DaX14Chu.cjs → telemetry-Dsw_faFj.cjs} +4 -4
- package/dist/src/{telemetry-Dthj_BbD.js → telemetry-Dvqxv3YC.js} +4 -4
- package/dist/src/{telemetry-Cps3mIU-.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-NYT-WKS6.js → tokenUsageUtils-C-bmyHoE.js} +7 -3
- package/dist/src/{tokenUsageUtils-DflFMjS0.js → tokenUsageUtils-CXrvO-wA.js} +7 -3
- package/dist/src/{transcription-NLVG9MT1.cjs → transcription-BvjmiYB1.cjs} +12 -16
- package/dist/src/{transcription-BNYURcXg.js → transcription-CJspiD2c.js} +11 -14
- package/dist/src/{transcription-B_OdaHp7.js → transcription-DuWDupG7.js} +10 -14
- package/dist/src/{transcription-s6A-bNrZ.js → transcription-V2HaAmy2.js} +10 -16
- package/dist/src/{transform-DECvGmzp.js → transform-Bbg6A8Jk.js} +4 -4
- package/dist/src/{transform-vNucnNr0.js → transform-CG0ehZNG.js} +11 -7
- package/dist/src/{transform-DuHvhZpj.cjs → transform-CTeuTR3S.cjs} +31 -9
- package/dist/src/{transform-CzK1Q0zl.cjs → transform-CUnzlsbn.cjs} +4 -4
- package/dist/src/{transform-aa6tmVpZ.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-DilY9wbS.js → transform-UN5UGu8U.js} +5 -5
- package/dist/src/{transform-uAytVuyX.js → transform-lQrDE1BQ.js} +11 -7
- package/dist/src/{transform-D5HsjduX.js → transform-zDhMmzwX.js} +11 -7
- package/dist/src/{transformersAvailability-CEVM2GNQ.js → transformersAvailability-CcHusyhw.js} +1 -1
- package/dist/src/{transformersAvailability-CwayUSlh.cjs → transformersAvailability-Cju9mHgR.cjs} +1 -1
- package/dist/src/{transformersAvailability-D6c6ROpT.js → transformersAvailability-DLlROWhg.js} +1 -1
- package/dist/src/{types-DmyIJ-sR.js → types-BGQDAP8i.js} +357 -22
- package/dist/src/{types-CzW2QFyi.js → types-Bgh5SOn6.js} +358 -24
- package/dist/src/{types-C_7nyzr1.cjs → types-CeaeaZdP.cjs} +393 -22
- package/dist/src/{types-Cbd8uOMq.js → types-Dm9JM6Vb.js} +368 -23
- package/dist/src/{util-BHGHw5G1.js → util-BYvQUPp7.js} +138 -36
- package/dist/src/{util-B9vlHIIh.cjs → util-Bxn8emtE.cjs} +15 -168
- package/dist/src/{util-ZzmqNPlg.js → util-C8e5uydV.js} +19 -142
- package/dist/src/{util-CMy69ZgQ.js → util-C9J8ahRn.js} +18 -4
- package/dist/src/{util-BzMcevZc.cjs → util-CN3SrLT4.cjs} +18 -4
- package/dist/src/{util-BV4XUC0n.js → util-D3q0WQ-0.js} +18 -4
- package/dist/src/{util-Dnmk2mBQ.js → util-D9TisOyk.js} +18 -4
- package/dist/src/{util-B3xGByQh.js → util-DDs-7g6-.js} +138 -36
- package/dist/src/{util-Bv6uGDfH.js → util-DvU2Pw8c.js} +138 -36
- package/dist/src/{util-C1CeHl-P.js → util-DxWpWjhc.js} +13 -136
- package/dist/src/{util-BRYkYPTd.js → util-oGMLA7vc.js} +17 -140
- package/dist/src/{util-DGNOS1db.cjs → util-olYL5C6N.cjs} +143 -35
- package/dist/src/{utils-Cz9qXqII.cjs → utils-B05gLxER.cjs} +6 -4
- package/dist/src/{utils-f2-Moju7.js → utils-BLJKfv0y.js} +6 -4
- package/dist/src/{utils-dLokC-eR.js → utils-DJfvjyMj.js} +6 -4
- package/dist/src/{utils-XiOAgly5.js → utils-hXtCYanr.js} +6 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -57
- package/dist/src/app/assets/index-4LKxG2CG.js +0 -439
- package/dist/src/app/assets/index-C3zcsZFQ.css +0 -1
- package/dist/src/app/assets/scroll-timeline-BdJZVXlz.js +0 -1
- package/dist/src/app/assets/sync-9qqYcY-B.js +0 -4
- package/dist/src/app/assets/vendor-charts-BnDWwBlI.js +0 -36
- package/dist/src/app/assets/vendor-markdown-0tekx3KX.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/app/tsconfig.app.tsbuildinfo +0 -1
- package/dist/src/cache-BVeDlD87.js +0 -726
- package/dist/src/cache-C4Nxf52C.js +0 -756
- package/dist/src/cache-CeUpFm3M.cjs +0 -5
- package/dist/src/cache-Dh5WtQps.cjs +0 -816
- package/dist/src/cache-i1P6crbO.js +0 -756
- package/dist/src/cache-n-RCJ-hL.js +0 -6
- package/dist/src/cloud-BBh91EUK.js +0 -4
- package/dist/src/codex-sdk-C6UMlxwV.js +0 -665
- package/dist/src/codex-sdk-DUwKWezN.js +0 -665
- package/dist/src/codex-sdk-GGAw0qbD.js +0 -666
- package/dist/src/codex-sdk-fAO0c3yA.cjs +0 -669
- package/dist/src/eval-B3r2CVXr.js +0 -15
- package/dist/src/evalResult-5xwYnECe.js +0 -12
- package/dist/src/evalResult-71lY93Kj.cjs +0 -10
- package/dist/src/evalResult-Dx5P5cIv.js +0 -10
- package/dist/src/evaluator-Jx6bRZV6.js +0 -36
- package/dist/src/fetch-BxNb_Lp3.js +0 -5
- package/dist/src/graders-B_pgMLS2.js +0 -34
- package/dist/src/graders-DErokPDO.cjs +0 -32
- package/dist/src/graders-DR_uNe54.js +0 -32
- package/dist/src/graders-w3176Wz-.js +0 -32
- package/dist/src/openclaw-CSugPYAr.cjs +0 -586
- package/dist/src/openclaw-DiSz3I5L.js +0 -582
- package/dist/src/openclaw-DuvJKEW5.js +0 -580
- package/dist/src/openclaw-tiVYRtr-.js +0 -580
- package/dist/src/providers-B7V0njNs.js +0 -32
- package/dist/src/providers-BEwbhv0X.js +0 -30
- package/dist/src/providers-CH3C7zf7.js +0 -30
- package/dist/src/providers-zyB6k_38.cjs +0 -31
- package/dist/src/rubyUtils-BUHu6PhO.js +0 -5
- package/dist/src/rubyUtils-CP42kMvq.cjs +0 -4
- package/dist/src/server-DA4Cyrrq.js +0 -7
- package/dist/src/server-Dulb-4-K.cjs +0 -5
- package/dist/src/store-CXS-Q_91.js +0 -6
- package/dist/src/store-eYkaKMwq.cjs +0 -5
- package/dist/src/telemetry-BpMfhthR.cjs +0 -5
- package/dist/src/telemetry-Dw38hanS.js +0 -7
- package/dist/src/tokenUsageUtils-BDGe-iyI.js +0 -138
- package/dist/src/transform-DTGDnAzW.js +0 -6
- package/dist/src/transform-m3qNw4KP.cjs +0 -5
|
@@ -1,665 +0,0 @@
|
|
|
1
|
-
import { b as getEnvString, i as logger, w as state } from "./logger-CT3IKMKA.js";
|
|
2
|
-
import { i as resolvePackageEntryPoint, r as importModule } from "./esm-Cd1AjG1D.js";
|
|
3
|
-
import { n as withGenAISpan, t as getTraceparent } from "./genaiTracer-D3fD9dNV.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
|
-
/**
|
|
11
|
-
* Helper to load the OpenAI Codex SDK ESM module
|
|
12
|
-
* Uses resolvePackageEntryPoint to handle ESM-only packages with restrictive exports
|
|
13
|
-
*/
|
|
14
|
-
async function loadCodexSDK() {
|
|
15
|
-
const codexPath = resolvePackageEntryPoint("@openai/codex-sdk", state.basePath && path.isAbsolute(state.basePath) ? state.basePath : process.cwd());
|
|
16
|
-
if (!codexPath) throw new Error(dedent`The @openai/codex-sdk package is required but not installed.
|
|
17
|
-
|
|
18
|
-
To use the OpenAI Codex SDK provider, install it with:
|
|
19
|
-
npm install @openai/codex-sdk
|
|
20
|
-
|
|
21
|
-
Requires Node.js 18+.
|
|
22
|
-
|
|
23
|
-
For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
|
|
24
|
-
try {
|
|
25
|
-
return await importModule(codexPath);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
logger.error(`Failed to load OpenAI Codex SDK: ${err}`);
|
|
28
|
-
if (err.stack) logger.error(err.stack);
|
|
29
|
-
throw new Error(dedent`Failed to load @openai/codex-sdk.
|
|
30
|
-
|
|
31
|
-
The package was found but could not be loaded. This may be due to:
|
|
32
|
-
- Incompatible Node.js version (requires Node.js 18+)
|
|
33
|
-
- Corrupted installation
|
|
34
|
-
|
|
35
|
-
Try reinstalling:
|
|
36
|
-
npm install @openai/codex-sdk
|
|
37
|
-
|
|
38
|
-
For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const CODEX_MODEL_PRICING = {
|
|
42
|
-
"gpt-5.4": {
|
|
43
|
-
input: 2.5,
|
|
44
|
-
output: 15,
|
|
45
|
-
cache_read: .25
|
|
46
|
-
},
|
|
47
|
-
"gpt-5.4-pro": {
|
|
48
|
-
input: 30,
|
|
49
|
-
output: 180,
|
|
50
|
-
cache_read: 30
|
|
51
|
-
},
|
|
52
|
-
"gpt-5.3-codex": {
|
|
53
|
-
input: 1.75,
|
|
54
|
-
output: 14,
|
|
55
|
-
cache_read: .175
|
|
56
|
-
},
|
|
57
|
-
"gpt-5.3-codex-spark": {
|
|
58
|
-
input: .5,
|
|
59
|
-
output: 4,
|
|
60
|
-
cache_read: .05
|
|
61
|
-
},
|
|
62
|
-
"gpt-5.2": {
|
|
63
|
-
input: 1.75,
|
|
64
|
-
output: 14,
|
|
65
|
-
cache_read: .175
|
|
66
|
-
},
|
|
67
|
-
"gpt-5.2-codex": {
|
|
68
|
-
input: 1.75,
|
|
69
|
-
output: 14,
|
|
70
|
-
cache_read: .175
|
|
71
|
-
},
|
|
72
|
-
"gpt-5.1-codex": {
|
|
73
|
-
input: 2,
|
|
74
|
-
output: 8,
|
|
75
|
-
cache_read: .2
|
|
76
|
-
},
|
|
77
|
-
"gpt-5.1-codex-max": {
|
|
78
|
-
input: 3,
|
|
79
|
-
output: 12,
|
|
80
|
-
cache_read: .3
|
|
81
|
-
},
|
|
82
|
-
"gpt-5.1-codex-mini": {
|
|
83
|
-
input: .5,
|
|
84
|
-
output: 2,
|
|
85
|
-
cache_read: .05
|
|
86
|
-
},
|
|
87
|
-
"gpt-5-codex": {
|
|
88
|
-
input: 2,
|
|
89
|
-
output: 8,
|
|
90
|
-
cache_read: .2
|
|
91
|
-
},
|
|
92
|
-
"gpt-5-codex-mini": {
|
|
93
|
-
input: .5,
|
|
94
|
-
output: 2,
|
|
95
|
-
cache_read: .05
|
|
96
|
-
},
|
|
97
|
-
"gpt-5": {
|
|
98
|
-
input: 2,
|
|
99
|
-
output: 8,
|
|
100
|
-
cache_read: .2
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
var OpenAICodexSDKProvider = class OpenAICodexSDKProvider {
|
|
104
|
-
static OPENAI_MODELS = [
|
|
105
|
-
"gpt-5.4",
|
|
106
|
-
"gpt-5.4-pro",
|
|
107
|
-
"gpt-5.3-codex",
|
|
108
|
-
"gpt-5.3-codex-spark",
|
|
109
|
-
"gpt-5.2",
|
|
110
|
-
"gpt-5.2-codex",
|
|
111
|
-
"gpt-5.1-codex",
|
|
112
|
-
"gpt-5.1-codex-max",
|
|
113
|
-
"gpt-5.1-codex-mini",
|
|
114
|
-
"gpt-5-codex",
|
|
115
|
-
"gpt-5-codex-mini",
|
|
116
|
-
"gpt-5"
|
|
117
|
-
];
|
|
118
|
-
config;
|
|
119
|
-
env;
|
|
120
|
-
apiKey;
|
|
121
|
-
providerId = "openai:codex-sdk";
|
|
122
|
-
codexModule;
|
|
123
|
-
codexInstance;
|
|
124
|
-
codexInstanceEnvHash;
|
|
125
|
-
threads = /* @__PURE__ */ new Map();
|
|
126
|
-
deepTracingWarningShown = false;
|
|
127
|
-
constructor(options = {}) {
|
|
128
|
-
const { config, env, id } = options;
|
|
129
|
-
this.config = config ?? {};
|
|
130
|
-
this.env = env;
|
|
131
|
-
this.apiKey = this.getApiKey();
|
|
132
|
-
this.providerId = id ?? this.providerId;
|
|
133
|
-
if (this.config.model && !OpenAICodexSDKProvider.OPENAI_MODELS.includes(this.config.model)) logger.warn(`Using unknown model for OpenAI Codex SDK: ${this.config.model}`);
|
|
134
|
-
}
|
|
135
|
-
id() {
|
|
136
|
-
return this.providerId;
|
|
137
|
-
}
|
|
138
|
-
getApiKey() {
|
|
139
|
-
return this.config?.apiKey || this.env?.OPENAI_API_KEY || this.env?.CODEX_API_KEY || getEnvString("OPENAI_API_KEY") || getEnvString("CODEX_API_KEY");
|
|
140
|
-
}
|
|
141
|
-
toString() {
|
|
142
|
-
return "[OpenAI Codex SDK Provider]";
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Safely tear down a Codex instance by calling its cleanup method
|
|
146
|
-
* (destroy, cleanup, or close -- whichever is available).
|
|
147
|
-
*/
|
|
148
|
-
async destroyInstance(instance) {
|
|
149
|
-
if (typeof instance.destroy === "function") await instance.destroy();
|
|
150
|
-
else if (typeof instance.cleanup === "function") await instance.cleanup();
|
|
151
|
-
else if (typeof instance.close === "function") await instance.close();
|
|
152
|
-
}
|
|
153
|
-
async cleanup() {
|
|
154
|
-
this.threads.clear();
|
|
155
|
-
if (this.codexInstance) {
|
|
156
|
-
try {
|
|
157
|
-
await this.destroyInstance(this.codexInstance);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
logger.warn("[CodexSDK] Error during cleanup", { error });
|
|
160
|
-
}
|
|
161
|
-
this.codexInstance = void 0;
|
|
162
|
-
this.codexInstanceEnvHash = void 0;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
prepareEnvironment(config, traceparent) {
|
|
166
|
-
const env = config.cli_env ? { ...config.cli_env } : { ...process.env };
|
|
167
|
-
const sortedEnv = {};
|
|
168
|
-
for (const key of Object.keys(env).sort()) if (env[key] !== void 0) sortedEnv[key] = env[key];
|
|
169
|
-
if (this.apiKey) {
|
|
170
|
-
sortedEnv.OPENAI_API_KEY = this.apiKey;
|
|
171
|
-
sortedEnv.CODEX_API_KEY = this.apiKey;
|
|
172
|
-
}
|
|
173
|
-
if (this.env) for (const key of Object.keys(this.env).sort()) {
|
|
174
|
-
const value = this.env[key];
|
|
175
|
-
if (value !== void 0) sortedEnv[key] = value;
|
|
176
|
-
}
|
|
177
|
-
if (config.deep_tracing) {
|
|
178
|
-
if (!sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT) sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT = "http://127.0.0.1:4318";
|
|
179
|
-
if (!sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL) sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL = "http/json";
|
|
180
|
-
if (!sortedEnv.OTEL_SERVICE_NAME) sortedEnv.OTEL_SERVICE_NAME = "codex-cli";
|
|
181
|
-
if (!sortedEnv.OTEL_TRACES_EXPORTER) sortedEnv.OTEL_TRACES_EXPORTER = "otlp";
|
|
182
|
-
if (traceparent) sortedEnv.TRACEPARENT = traceparent;
|
|
183
|
-
logger.debug("[CodexSDK] Injecting OTEL config for deep tracing", {
|
|
184
|
-
traceparent: traceparent || "(none - CLI will start own trace)",
|
|
185
|
-
endpoint: sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
186
|
-
userConfigured: {
|
|
187
|
-
endpoint: !!env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
188
|
-
protocol: !!env.OTEL_EXPORTER_OTLP_PROTOCOL,
|
|
189
|
-
serviceName: !!env.OTEL_SERVICE_NAME
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
} else delete sortedEnv.TRACEPARENT;
|
|
193
|
-
return sortedEnv;
|
|
194
|
-
}
|
|
195
|
-
validateWorkingDirectory(workingDir, skipGitCheck = false) {
|
|
196
|
-
let stats;
|
|
197
|
-
try {
|
|
198
|
-
stats = fs.statSync(workingDir);
|
|
199
|
-
} catch (err) {
|
|
200
|
-
throw new Error(`Working directory ${workingDir} does not exist or isn't accessible: ${err.message}`);
|
|
201
|
-
}
|
|
202
|
-
if (!stats.isDirectory()) throw new Error(`Working directory ${workingDir} is not a directory`);
|
|
203
|
-
if (!skipGitCheck) {
|
|
204
|
-
const gitDir = path.join(workingDir, ".git");
|
|
205
|
-
if (!fs.existsSync(gitDir)) throw new Error(dedent`Working directory ${workingDir} is not a Git repository.
|
|
206
|
-
|
|
207
|
-
Codex requires a Git repository by default to prevent unrecoverable errors.
|
|
208
|
-
|
|
209
|
-
To bypass this check, set skip_git_repo_check: true in your provider config.`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Build Codex constructor options from provider config.
|
|
214
|
-
* Used when creating both local (deep-tracing) and cached instances.
|
|
215
|
-
*/
|
|
216
|
-
buildCodexOptions(env, config) {
|
|
217
|
-
return {
|
|
218
|
-
env,
|
|
219
|
-
...this.apiKey ? { apiKey: this.apiKey } : {},
|
|
220
|
-
...config.codex_path_override ? { codexPathOverride: config.codex_path_override } : {},
|
|
221
|
-
...config.base_url ? { baseUrl: config.base_url } : {},
|
|
222
|
-
...config.cli_config ? { config: config.cli_config } : {}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
buildThreadOptions(config) {
|
|
226
|
-
return {
|
|
227
|
-
workingDirectory: config.working_dir,
|
|
228
|
-
skipGitRepoCheck: config.skip_git_repo_check ?? false,
|
|
229
|
-
...config.model ? { model: config.model } : {},
|
|
230
|
-
...config.additional_directories?.length ? { additionalDirectories: config.additional_directories } : {},
|
|
231
|
-
...config.sandbox_mode ? { sandboxMode: config.sandbox_mode } : {},
|
|
232
|
-
...config.model_reasoning_effort ? { modelReasoningEffort: config.model_reasoning_effort } : {},
|
|
233
|
-
...config.network_access_enabled !== void 0 ? { networkAccessEnabled: config.network_access_enabled } : {},
|
|
234
|
-
...config.web_search_mode ? { webSearchMode: config.web_search_mode } : {},
|
|
235
|
-
...config.web_search_enabled !== void 0 && !config.web_search_mode ? { webSearchEnabled: config.web_search_enabled } : {},
|
|
236
|
-
...config.approval_policy ? { approvalPolicy: config.approval_policy } : {}
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
async getOrCreateThread(config, cacheKey, instance) {
|
|
240
|
-
const threadOptions = this.buildThreadOptions(config);
|
|
241
|
-
if (config.deep_tracing) return instance.startThread(threadOptions);
|
|
242
|
-
if (config.thread_id) {
|
|
243
|
-
const cached = this.threads.get(config.thread_id);
|
|
244
|
-
if (cached) return cached;
|
|
245
|
-
const thread = instance.resumeThread(config.thread_id, threadOptions);
|
|
246
|
-
if (config.persist_threads) this.threads.set(config.thread_id, thread);
|
|
247
|
-
return thread;
|
|
248
|
-
}
|
|
249
|
-
if (config.persist_threads && cacheKey) {
|
|
250
|
-
const cached = this.threads.get(cacheKey);
|
|
251
|
-
if (cached) return cached;
|
|
252
|
-
const poolSize = config.thread_pool_size ?? 1;
|
|
253
|
-
if (this.threads.size >= poolSize) {
|
|
254
|
-
const oldestKey = this.threads.keys().next().value;
|
|
255
|
-
if (oldestKey) this.threads.delete(oldestKey);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
const thread = instance.startThread(threadOptions);
|
|
259
|
-
if (config.persist_threads && cacheKey) this.threads.set(cacheKey, thread);
|
|
260
|
-
return thread;
|
|
261
|
-
}
|
|
262
|
-
async runStreaming(thread, prompt, runOptions, callOptions) {
|
|
263
|
-
const { events } = await thread.runStreamed(prompt, runOptions);
|
|
264
|
-
const items = [];
|
|
265
|
-
let usage = void 0;
|
|
266
|
-
const tracer = trace.getTracer("promptfoo.codex-sdk");
|
|
267
|
-
const activeSpans = /* @__PURE__ */ new Map();
|
|
268
|
-
const itemStartTimes = /* @__PURE__ */ new Map();
|
|
269
|
-
let lastEventTime = Date.now();
|
|
270
|
-
const reasoningTexts = [];
|
|
271
|
-
const conversationMessages = [];
|
|
272
|
-
conversationMessages.push({
|
|
273
|
-
role: "user",
|
|
274
|
-
content: prompt
|
|
275
|
-
});
|
|
276
|
-
try {
|
|
277
|
-
for await (const event of events) {
|
|
278
|
-
const eventTime = Date.now();
|
|
279
|
-
if (callOptions?.abortSignal?.aborted) {
|
|
280
|
-
const abortError = /* @__PURE__ */ new Error("AbortError");
|
|
281
|
-
abortError.name = "AbortError";
|
|
282
|
-
throw abortError;
|
|
283
|
-
}
|
|
284
|
-
switch (event.type) {
|
|
285
|
-
case "item.started": {
|
|
286
|
-
const item = event.item;
|
|
287
|
-
if (!item) {
|
|
288
|
-
logger.warn("Codex item.started event missing item", { event });
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
if (!item.id) {
|
|
292
|
-
logger.debug("Codex item.started without id, will create span at completion", { type: item.type });
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
const itemId = String(item.id);
|
|
296
|
-
const spanName = this.getSpanNameForItem(item);
|
|
297
|
-
const span = tracer.startSpan(spanName, {
|
|
298
|
-
kind: SpanKind.INTERNAL,
|
|
299
|
-
attributes: {
|
|
300
|
-
"codex.item.id": itemId,
|
|
301
|
-
"codex.item.type": item.type,
|
|
302
|
-
...this.getAttributesForItem(item)
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
activeSpans.set(itemId, span);
|
|
306
|
-
itemStartTimes.set(itemId, eventTime);
|
|
307
|
-
logger.debug("Codex item started", {
|
|
308
|
-
itemId,
|
|
309
|
-
type: item.type
|
|
310
|
-
});
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
case "item.completed": {
|
|
314
|
-
const item = event.item;
|
|
315
|
-
if (!item) {
|
|
316
|
-
logger.warn("Codex item.completed event missing item", { event });
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
const itemId = item.id ? String(item.id) : crypto.randomUUID();
|
|
320
|
-
items.push(item);
|
|
321
|
-
if (item.type === "reasoning" && typeof item.text === "string") reasoningTexts.push(item.text);
|
|
322
|
-
if (item.type === "agent_message" && typeof item.text === "string") conversationMessages.push({
|
|
323
|
-
role: "assistant",
|
|
324
|
-
content: item.text
|
|
325
|
-
});
|
|
326
|
-
let span = activeSpans.get(itemId);
|
|
327
|
-
const hadStartEvent = span !== void 0;
|
|
328
|
-
if (!span) {
|
|
329
|
-
const spanName = this.getSpanNameForItem(item);
|
|
330
|
-
span = tracer.startSpan(spanName, {
|
|
331
|
-
kind: SpanKind.INTERNAL,
|
|
332
|
-
startTime: lastEventTime,
|
|
333
|
-
attributes: {
|
|
334
|
-
"codex.item.id": itemId,
|
|
335
|
-
"codex.item.type": item.type,
|
|
336
|
-
"codex.timing.estimated": true,
|
|
337
|
-
...this.getAttributesForItem(item)
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
const completionAttrs = this.getCompletionAttributesForItem(item);
|
|
342
|
-
for (const [key, value] of Object.entries(completionAttrs)) span.setAttribute(key, value);
|
|
343
|
-
const durationMs = eventTime - (itemStartTimes.get(itemId) || lastEventTime);
|
|
344
|
-
span.setAttribute("codex.duration_ms", durationMs);
|
|
345
|
-
span.setAttribute("codex.had_start_event", hadStartEvent);
|
|
346
|
-
if (item.type === "reasoning" && typeof item.text === "string") span.addEvent("reasoning", { "codex.reasoning.text": item.text });
|
|
347
|
-
if (item.type === "agent_message" && typeof item.text === "string") span.addEvent("message", { "codex.message.text": item.text });
|
|
348
|
-
if (item.type === "command_execution" && typeof item.aggregated_output === "string") span.addEvent("output", { "codex.command.output": item.aggregated_output });
|
|
349
|
-
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({
|
|
350
|
-
code: SpanStatusCode.ERROR,
|
|
351
|
-
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"
|
|
352
|
-
});
|
|
353
|
-
else span.setStatus({ code: SpanStatusCode.OK });
|
|
354
|
-
span.end();
|
|
355
|
-
activeSpans.delete(itemId);
|
|
356
|
-
itemStartTimes.delete(itemId);
|
|
357
|
-
logger.debug("Codex item completed", {
|
|
358
|
-
itemId,
|
|
359
|
-
type: item.type,
|
|
360
|
-
durationMs
|
|
361
|
-
});
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
case "item.updated": {
|
|
365
|
-
const item = event.item;
|
|
366
|
-
if (item?.id) {
|
|
367
|
-
const itemId = String(item.id);
|
|
368
|
-
const span = activeSpans.get(itemId);
|
|
369
|
-
if (span) {
|
|
370
|
-
const updatedAttrs = this.getCompletionAttributesForItem(item);
|
|
371
|
-
for (const [key, value] of Object.entries(updatedAttrs)) span.setAttribute(key, value);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
logger.debug("Codex item updated", {
|
|
375
|
-
itemId: item?.id,
|
|
376
|
-
type: item?.type
|
|
377
|
-
});
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
case "turn.completed":
|
|
381
|
-
usage = event.usage;
|
|
382
|
-
logger.debug("Codex turn completed", { usage });
|
|
383
|
-
break;
|
|
384
|
-
case "turn.failed": {
|
|
385
|
-
const errorMsg = event.error?.message || "Turn failed";
|
|
386
|
-
logger.error("Codex turn failed", { error: errorMsg });
|
|
387
|
-
throw new Error(`Codex turn failed: ${errorMsg}`);
|
|
388
|
-
}
|
|
389
|
-
default: logger.debug("Codex unknown event type", { type: event.type });
|
|
390
|
-
}
|
|
391
|
-
lastEventTime = eventTime;
|
|
392
|
-
}
|
|
393
|
-
} finally {
|
|
394
|
-
for (const [itemId, span] of activeSpans) {
|
|
395
|
-
logger.warn("Codex item span not properly closed", { itemId });
|
|
396
|
-
span.setStatus({
|
|
397
|
-
code: SpanStatusCode.ERROR,
|
|
398
|
-
message: "Span not properly closed"
|
|
399
|
-
});
|
|
400
|
-
span.end();
|
|
401
|
-
}
|
|
402
|
-
activeSpans.clear();
|
|
403
|
-
itemStartTimes.clear();
|
|
404
|
-
}
|
|
405
|
-
const agentMessages = items.filter((i) => i.type === "agent_message");
|
|
406
|
-
return {
|
|
407
|
-
finalResponse: agentMessages.length > 0 ? agentMessages.map((i) => i.text).join("\n") : "",
|
|
408
|
-
items,
|
|
409
|
-
usage,
|
|
410
|
-
reasoningTexts,
|
|
411
|
-
conversationMessages
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Get a descriptive span name for a Codex item
|
|
416
|
-
*/
|
|
417
|
-
getSpanNameForItem(item) {
|
|
418
|
-
switch (item.type) {
|
|
419
|
-
case "command_execution": return `exec ${typeof item.command === "string" ? item.command.split(" ")[0] || "command" : "command"}`;
|
|
420
|
-
case "file_change": return `file ${item.changes?.[0]?.kind || "change"}`;
|
|
421
|
-
case "mcp_tool_call": return `mcp ${typeof item.server === "string" ? item.server : "unknown"}/${typeof item.tool === "string" ? item.tool : "unknown"}`;
|
|
422
|
-
case "agent_message": return "agent response";
|
|
423
|
-
case "reasoning": return "reasoning";
|
|
424
|
-
case "web_search": return `search "${typeof item.query === "string" ? item.query.slice(0, 30) : ""}"`;
|
|
425
|
-
case "todo_list": return "todo update";
|
|
426
|
-
case "error": return "error";
|
|
427
|
-
case "collaboration_tool_call": return `collab ${typeof item.tool === "string" ? item.tool : "unknown"}`;
|
|
428
|
-
case "spawn_agent": return `spawn ${typeof item.role === "string" ? item.role : "agent"}`;
|
|
429
|
-
case "send_input": return "send input";
|
|
430
|
-
case "agent_wait": return "wait";
|
|
431
|
-
default: return `codex.${item.type || "unknown"}`;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Get attributes for a Codex item at start
|
|
436
|
-
*/
|
|
437
|
-
getAttributesForItem(item) {
|
|
438
|
-
const attrs = {};
|
|
439
|
-
switch (item.type) {
|
|
440
|
-
case "command_execution":
|
|
441
|
-
if (typeof item.command === "string") attrs["codex.command"] = item.command;
|
|
442
|
-
break;
|
|
443
|
-
case "mcp_tool_call":
|
|
444
|
-
if (typeof item.server === "string") attrs["codex.mcp.server"] = item.server;
|
|
445
|
-
if (typeof item.tool === "string") attrs["codex.mcp.tool"] = item.tool;
|
|
446
|
-
break;
|
|
447
|
-
case "web_search":
|
|
448
|
-
if (typeof item.query === "string") attrs["codex.search.query"] = item.query;
|
|
449
|
-
break;
|
|
450
|
-
case "collaboration_tool_call":
|
|
451
|
-
if (typeof item.tool === "string") attrs["codex.collab.tool"] = item.tool;
|
|
452
|
-
if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
|
|
453
|
-
break;
|
|
454
|
-
case "spawn_agent":
|
|
455
|
-
if (typeof item.role === "string") attrs["codex.collab.role"] = item.role;
|
|
456
|
-
if (typeof item.thread_id === "string") attrs["codex.collab.spawned_thread"] = item.thread_id;
|
|
457
|
-
break;
|
|
458
|
-
case "send_input":
|
|
459
|
-
if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
return attrs;
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Get attributes for a Codex item at completion
|
|
466
|
-
*/
|
|
467
|
-
getCompletionAttributesForItem(item) {
|
|
468
|
-
const attrs = {};
|
|
469
|
-
switch (item.type) {
|
|
470
|
-
case "command_execution":
|
|
471
|
-
if (typeof item.exit_code === "number") attrs["codex.exit_code"] = item.exit_code;
|
|
472
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
473
|
-
if (typeof item.aggregated_output === "string") attrs["codex.output"] = item.aggregated_output;
|
|
474
|
-
break;
|
|
475
|
-
case "file_change":
|
|
476
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
477
|
-
if (Array.isArray(item.changes) && item.changes.length) {
|
|
478
|
-
attrs["codex.files_changed"] = item.changes.length;
|
|
479
|
-
attrs["codex.files"] = item.changes.map((c) => typeof c?.path === "string" ? c.path : "").filter(Boolean).join(", ");
|
|
480
|
-
}
|
|
481
|
-
break;
|
|
482
|
-
case "mcp_tool_call":
|
|
483
|
-
if (typeof item.status === "string") attrs["codex.status"] = item.status;
|
|
484
|
-
if (typeof item.error?.message === "string") attrs["codex.error"] = item.error.message;
|
|
485
|
-
break;
|
|
486
|
-
case "agent_message":
|
|
487
|
-
if (typeof item.text === "string") attrs["codex.message"] = item.text;
|
|
488
|
-
break;
|
|
489
|
-
case "reasoning":
|
|
490
|
-
if (typeof item.text === "string") attrs["codex.reasoning"] = item.text;
|
|
491
|
-
break;
|
|
492
|
-
case "error":
|
|
493
|
-
if (typeof item.message === "string") attrs["codex.error"] = item.message;
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
return attrs;
|
|
497
|
-
}
|
|
498
|
-
generateCacheKey(config, prompt) {
|
|
499
|
-
const keyData = {
|
|
500
|
-
working_dir: config.working_dir,
|
|
501
|
-
additional_directories: config.additional_directories,
|
|
502
|
-
model: config.model,
|
|
503
|
-
output_schema: config.output_schema,
|
|
504
|
-
sandbox_mode: config.sandbox_mode,
|
|
505
|
-
model_reasoning_effort: config.model_reasoning_effort,
|
|
506
|
-
network_access_enabled: config.network_access_enabled,
|
|
507
|
-
web_search_enabled: config.web_search_enabled,
|
|
508
|
-
web_search_mode: config.web_search_mode,
|
|
509
|
-
approval_policy: config.approval_policy,
|
|
510
|
-
prompt
|
|
511
|
-
};
|
|
512
|
-
return `openai:codex-sdk:${crypto.createHash("sha256").update(JSON.stringify(keyData)).digest("hex")}`;
|
|
513
|
-
}
|
|
514
|
-
async callApi(prompt, context, callOptions) {
|
|
515
|
-
const config = {
|
|
516
|
-
...this.config,
|
|
517
|
-
...context?.prompt?.config
|
|
518
|
-
};
|
|
519
|
-
const modelName = config.model || "codex";
|
|
520
|
-
const spanContext = {
|
|
521
|
-
system: "openai",
|
|
522
|
-
operationName: "chat",
|
|
523
|
-
model: modelName,
|
|
524
|
-
providerId: this.id(),
|
|
525
|
-
evalId: context?.evaluationId || context?.test?.metadata?.evaluationId,
|
|
526
|
-
testIndex: typeof context?.test?.vars?.__testIdx === "number" ? context.test.vars.__testIdx : void 0,
|
|
527
|
-
promptLabel: context?.prompt?.label,
|
|
528
|
-
traceparent: context?.traceparent,
|
|
529
|
-
requestBody: prompt
|
|
530
|
-
};
|
|
531
|
-
const resultExtractor = (response) => {
|
|
532
|
-
const result = {};
|
|
533
|
-
if (response.tokenUsage) result.tokenUsage = response.tokenUsage;
|
|
534
|
-
if (response.sessionId) result.responseId = response.sessionId;
|
|
535
|
-
if (response.cached !== void 0) result.cacheHit = response.cached;
|
|
536
|
-
result.responseModel = modelName;
|
|
537
|
-
if (response.output !== void 0) try {
|
|
538
|
-
result.responseBody = typeof response.output === "string" ? response.output : JSON.stringify(response.output);
|
|
539
|
-
} catch {
|
|
540
|
-
result.responseBody = "[unable to serialize output]";
|
|
541
|
-
}
|
|
542
|
-
if (response.raw) try {
|
|
543
|
-
const rawData = typeof response.raw === "string" ? JSON.parse(response.raw) : response.raw;
|
|
544
|
-
if (rawData.reasoningTexts?.length > 0) result.additionalAttributes = {
|
|
545
|
-
"codex.reasoning.count": rawData.reasoningTexts.length,
|
|
546
|
-
"codex.reasoning.summary": rawData.reasoningTexts.join("\n---\n").slice(0, 2e3)
|
|
547
|
-
};
|
|
548
|
-
if (rawData.conversationMessages?.length > 0) result.additionalAttributes = {
|
|
549
|
-
...result.additionalAttributes,
|
|
550
|
-
"codex.conversation.message_count": rawData.conversationMessages.length
|
|
551
|
-
};
|
|
552
|
-
if (rawData.items?.length > 0) {
|
|
553
|
-
const itemCounts = {};
|
|
554
|
-
for (const item of rawData.items) itemCounts[item.type] = (itemCounts[item.type] || 0) + 1;
|
|
555
|
-
result.additionalAttributes = {
|
|
556
|
-
...result.additionalAttributes,
|
|
557
|
-
"codex.items.total": rawData.items.length,
|
|
558
|
-
"codex.items.breakdown": JSON.stringify(itemCounts)
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
} catch {}
|
|
562
|
-
return result;
|
|
563
|
-
};
|
|
564
|
-
return withGenAISpan(spanContext, () => this.callApiInternal(prompt, context, callOptions, config), resultExtractor);
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Internal implementation of callApi without tracing wrapper.
|
|
568
|
-
* Context is available for future use (e.g., _context?.vars for template rendering,
|
|
569
|
-
* _context?.bustCache for cache control, _context?.debug for debug mode).
|
|
570
|
-
*/
|
|
571
|
-
async callApiInternal(prompt, _context, callOptions, config) {
|
|
572
|
-
const currentTraceparent = getTraceparent();
|
|
573
|
-
const env = this.prepareEnvironment(config, currentTraceparent);
|
|
574
|
-
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.");
|
|
575
|
-
if (config.working_dir) this.validateWorkingDirectory(config.working_dir, config.skip_git_repo_check);
|
|
576
|
-
if (callOptions?.abortSignal?.aborted) return { error: "OpenAI Codex SDK call aborted before it started" };
|
|
577
|
-
if (!this.codexModule) this.codexModule = await loadCodexSDK();
|
|
578
|
-
let localInstance = void 0;
|
|
579
|
-
const useLocalInstance = config.deep_tracing;
|
|
580
|
-
if (useLocalInstance) {
|
|
581
|
-
if ((config.persist_threads || config.thread_id || (config.thread_pool_size ?? 0) > 1) && !this.deepTracingWarningShown) {
|
|
582
|
-
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.");
|
|
583
|
-
this.deepTracingWarningShown = true;
|
|
584
|
-
}
|
|
585
|
-
localInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
|
|
586
|
-
} else {
|
|
587
|
-
const stableEnv = { ...env };
|
|
588
|
-
delete stableEnv.TRACEPARENT;
|
|
589
|
-
const envHash = crypto.createHash("sha256").update(JSON.stringify(stableEnv)).digest("hex");
|
|
590
|
-
const envChanged = this.codexInstanceEnvHash !== envHash;
|
|
591
|
-
if (!this.codexInstance || envChanged) {
|
|
592
|
-
if (envChanged && this.codexInstance) {
|
|
593
|
-
logger.debug("[CodexSDK] Recreating instance due to configuration change");
|
|
594
|
-
try {
|
|
595
|
-
await this.destroyInstance(this.codexInstance);
|
|
596
|
-
} catch (cleanupError) {
|
|
597
|
-
logger.warn("[CodexSDK] Error cleaning up old instance", { error: cleanupError });
|
|
598
|
-
}
|
|
599
|
-
this.threads.clear();
|
|
600
|
-
}
|
|
601
|
-
this.codexInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
|
|
602
|
-
this.codexInstanceEnvHash = envHash;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
const activeInstance = useLocalInstance ? localInstance : this.codexInstance;
|
|
606
|
-
if (!activeInstance) throw new Error("Failed to create Codex instance - SDK module may have failed to load");
|
|
607
|
-
const cacheKey = this.generateCacheKey(config, prompt);
|
|
608
|
-
const thread = await this.getOrCreateThread(config, cacheKey, activeInstance);
|
|
609
|
-
const runOptions = {};
|
|
610
|
-
if (config.output_schema) runOptions.outputSchema = config.output_schema;
|
|
611
|
-
if (callOptions?.abortSignal) runOptions.signal = callOptions.abortSignal;
|
|
612
|
-
try {
|
|
613
|
-
const turn = config.enable_streaming ? await this.runStreaming(thread, prompt, runOptions, callOptions) : await thread.run(prompt, runOptions);
|
|
614
|
-
const output = turn.finalResponse || "";
|
|
615
|
-
const raw = JSON.stringify(turn);
|
|
616
|
-
const tokenUsage = turn.usage ? {
|
|
617
|
-
prompt: turn.usage.input_tokens,
|
|
618
|
-
completion: turn.usage.output_tokens,
|
|
619
|
-
total: turn.usage.input_tokens + turn.usage.output_tokens,
|
|
620
|
-
cached: turn.usage.cached_input_tokens || 0
|
|
621
|
-
} : void 0;
|
|
622
|
-
let cost = 0;
|
|
623
|
-
if (tokenUsage && config.model) {
|
|
624
|
-
const pricing = CODEX_MODEL_PRICING[config.model];
|
|
625
|
-
if (pricing) {
|
|
626
|
-
const cachedTokens = tokenUsage.cached || 0;
|
|
627
|
-
const inputCost = ((tokenUsage.prompt || 0) - cachedTokens) * (pricing.input / 1e6);
|
|
628
|
-
const cacheReadCost = cachedTokens * (pricing.cache_read / 1e6);
|
|
629
|
-
const outputCost = (tokenUsage.completion || 0) * (pricing.output / 1e6);
|
|
630
|
-
cost = inputCost + cacheReadCost + outputCost;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
logger.debug("OpenAI Codex SDK response", {
|
|
634
|
-
output,
|
|
635
|
-
usage: turn.usage
|
|
636
|
-
});
|
|
637
|
-
return {
|
|
638
|
-
output,
|
|
639
|
-
tokenUsage,
|
|
640
|
-
cost,
|
|
641
|
-
raw,
|
|
642
|
-
sessionId: thread.id || "unknown"
|
|
643
|
-
};
|
|
644
|
-
} catch (error) {
|
|
645
|
-
if (error instanceof Error && error.name === "AbortError" || callOptions?.abortSignal?.aborted) {
|
|
646
|
-
logger.warn("OpenAI Codex SDK call aborted");
|
|
647
|
-
return { error: "OpenAI Codex SDK call aborted" };
|
|
648
|
-
}
|
|
649
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
650
|
-
logger.error("Error calling OpenAI Codex SDK", { error: errorMessage });
|
|
651
|
-
return { error: `Error calling OpenAI Codex SDK: ${errorMessage}` };
|
|
652
|
-
} finally {
|
|
653
|
-
if (!config.deep_tracing && !config.persist_threads && !config.thread_id && cacheKey) this.threads.delete(cacheKey);
|
|
654
|
-
if (useLocalInstance && localInstance) try {
|
|
655
|
-
await this.destroyInstance(localInstance);
|
|
656
|
-
} catch (cleanupError) {
|
|
657
|
-
logger.debug("[CodexSDK] Error cleaning up local instance", { error: cleanupError });
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
//#endregion
|
|
663
|
-
export { OpenAICodexSDKProvider };
|
|
664
|
-
|
|
665
|
-
//# sourceMappingURL=codex-sdk-C6UMlxwV.js.map
|