promptfoo 0.121.3 → 0.121.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/README.md +1 -1
  2. package/dist/src/{ListApp-Du7YVwj5.js → ListApp-BRUsT43Y.js} +1 -1
  3. package/dist/src/{accounts-BPyfpSeU.cjs → accounts-BIFntVWB.cjs} +5 -5
  4. package/dist/src/{accounts-CFLK3mnD.js → accounts-CLJHCDDb.js} +6 -6
  5. package/dist/src/{accounts-B2XmGjty.js → accounts-CaLNYnf7.js} +5 -5
  6. package/dist/src/{accounts-Xatc0RYb.js → accounts-bnyHT7Ju.js} +5 -5
  7. package/dist/src/{agentic-utils-36epdqwB.js → agentic-utils-B5krlibj.js} +3 -3
  8. package/dist/src/{agentic-utils-DIYAAYE7.js → agentic-utils-Ba67xmgs.js} +3 -3
  9. package/dist/src/{agentic-utils-D8yXo5Lm.js → agentic-utils-BclbiXiq.js} +4 -4
  10. package/dist/src/{agentic-utils-DAVsChuB.cjs → agentic-utils-D2x0wGhB.cjs} +3 -3
  11. package/dist/src/{agents-CLQ-P15P.js → agents-BGqaTDnr.js} +5 -7
  12. package/dist/src/{agents-wg3ohknq.js → agents-BV9yFpXX.js} +6 -7
  13. package/dist/src/{agents-CgBniSlI.js → agents-BYdMl1UE.js} +5 -9
  14. package/dist/src/{agents-Bqgfdokm.js → agents-DhxWMCtH.js} +35 -14
  15. package/dist/src/{agents-BBWxKSM0.cjs → agents-DiWmQYH9.cjs} +5 -7
  16. package/dist/src/{agents-CAYbM7qD.cjs → agents-WULPVjbH.cjs} +34 -12
  17. package/dist/src/{agents-DSSTV4bv.js → agents-emVcx3yh.js} +35 -13
  18. package/dist/src/{agents-BBVJCIYr.js → agents-n6vPqV3i.js} +35 -13
  19. package/dist/src/{aimlapi-BwGC1TtS.js → aimlapi-BxqK9HF_.js} +8 -14
  20. package/dist/src/{aimlapi-Bv8Fmc-b.cjs → aimlapi-BzLjZI_m.cjs} +8 -15
  21. package/dist/src/{aimlapi-MgSLdvy7.js → aimlapi-DR4pgeiC.js} +7 -14
  22. package/dist/src/{aimlapi-DaC3qZ-o.js → aimlapi-uPGp0Zdo.js} +7 -16
  23. package/dist/src/app/app/tsconfig.app.tsbuildinfo +1 -0
  24. package/dist/src/app/assets/Report-vjzrbgce.js +1 -0
  25. package/dist/src/app/assets/index-B3NQ8HTd.js +385 -0
  26. package/dist/src/app/assets/index-Cli2yAXv.css +1 -0
  27. package/dist/src/app/assets/rolldown-runtime-COnpUsM8.js +1 -0
  28. package/dist/src/app/assets/scroll-timeline-D9IT_e8Z.js +1 -0
  29. package/dist/src/app/assets/sync-IjzpWrOE.js +4 -0
  30. package/dist/src/app/assets/vendor-charts-BNdH8TCw.js +36 -0
  31. package/dist/src/app/assets/vendor-markdown-Ch00wnNI.js +29 -0
  32. package/dist/src/app/assets/vendor-react-CVvmk1UB.js +9 -0
  33. package/dist/src/app/assets/vendor-utils-BnEYbx2Q.js +37 -0
  34. package/dist/src/app/index.html +32 -7
  35. package/dist/src/{audio-Bn44pQxv.js → audio-BvpTOArF.js} +4 -4
  36. package/dist/src/{audio-DVFjQ67_.cjs → audio-C0vDeS0j.cjs} +4 -4
  37. package/dist/src/{audio-DjU9GswO.js → audio-CScmnmEB.js} +4 -5
  38. package/dist/src/{audio-DDA5WHdx.js → audio-Da8U9IS5.js} +4 -4
  39. package/dist/src/{base-CKjwebIH.js → base-BOMaNEes.js} +3 -3
  40. package/dist/src/{base-CqzQ4K8j.js → base-BTux96b1.js} +3 -3
  41. package/dist/src/{base-BboXIF_0.cjs → base-Tw6uhH8K.cjs} +3 -3
  42. package/dist/src/{base-Cz2ZC_iA.js → base-dYsl2hmL.js} +3 -3
  43. package/dist/src/{blobs-C6j0bvFz.cjs → blobs-B95F_7vE.cjs} +3 -3
  44. package/dist/src/{blobs-DXTl6J3H.js → blobs-BW4U31ue.js} +3 -3
  45. package/dist/src/{blobs-BUWmKWzo.js → blobs-D_gg8nbm.js} +4 -4
  46. package/dist/src/{blobs-B1JriOyi.js → blobs-DjLby-uP.js} +4 -4
  47. package/dist/src/cache-BI5BY7ey.js +280 -0
  48. package/dist/src/cache-BRkhlH3k.cjs +3 -0
  49. package/dist/src/cache-BlC6aeJ0.js +3 -0
  50. package/dist/src/cache-Bzttsk0X.js +310 -0
  51. package/dist/src/cache-Cr-qWIbP.js +310 -0
  52. package/dist/src/cache-DGg-yTZG.cjs +376 -0
  53. package/dist/src/{chat-BEwdgGEg.js → chat-BLOdH60v.js} +63 -37
  54. package/dist/src/{chat-B0iaWhoh.js → chat-Cx_LkwvZ.js} +63 -37
  55. package/dist/src/{chat-DK1U-eZ-.js → chat-D9nudO9b.js} +5 -14
  56. package/dist/src/{chat-pxmiVpWe.js → chat-DChSH_Es.js} +63 -37
  57. package/dist/src/{chat-B-52XYI1.js → chat-DG2LkwLq.js} +3 -13
  58. package/dist/src/{chat-BtIKkLKx.cjs → chat-DH97tVV9.cjs} +3 -13
  59. package/dist/src/{chat-BE0qTA8e.js → chat-aMQZw6R7.js} +4 -16
  60. package/dist/src/{chat-CM8qWR3_.cjs → chat-vYqqv1gP.cjs} +64 -38
  61. package/dist/src/{chatkit-_8eJqKcD.js → chatkit-B8X34dQc.js} +4 -4
  62. package/dist/src/{chatkit-BYGQlHlV.js → chatkit-BXu42Qwt.js} +4 -4
  63. package/dist/src/{chatkit-a2D6mY6s.js → chatkit-CbMRoeYw.js} +4 -4
  64. package/dist/src/{chatkit-Cx174XI3.cjs → chatkit-D44VyUyB.cjs} +4 -4
  65. package/dist/src/{claude-agent-sdk-8ddRp1L2.cjs → claude-agent-sdk-BRq0bbIK.cjs} +23 -18
  66. package/dist/src/{claude-agent-sdk-CMjh4LFH.js → claude-agent-sdk-BjriSVRZ.js} +20 -15
  67. package/dist/src/{claude-agent-sdk-HgbFioFw.js → claude-agent-sdk-BzNZeZ0N.js} +20 -15
  68. package/dist/src/{claude-agent-sdk-Bq5EArsX.js → claude-agent-sdk-DYv_AJ8u.js} +21 -17
  69. package/dist/src/cloud-CoD5OacT.js +3 -0
  70. package/dist/src/{cloud-z8KZpUoa.js → cloud-Da0bofJd.js} +25 -13
  71. package/dist/src/{cloudflare-ai-Bbp26N0L.js → cloudflare-ai-CXC4b1EU.js} +5 -14
  72. package/dist/src/{cloudflare-ai-BGyXlpXJ.js → cloudflare-ai-CyBoIs1Q.js} +7 -15
  73. package/dist/src/{cloudflare-ai-DdKP9TKT.js → cloudflare-ai-DGOwgexC.js} +6 -17
  74. package/dist/src/{cloudflare-ai-C62x6MQG.cjs → cloudflare-ai-DJv5qnyb.cjs} +6 -15
  75. package/dist/src/{cloudflare-gateway-DXhtXDRb.js → cloudflare-gateway-1sAoOyft.js} +6 -16
  76. package/dist/src/{cloudflare-gateway-D-e9i1Sn.js → cloudflare-gateway-D-dnkzCF.js} +5 -18
  77. package/dist/src/{cloudflare-gateway-Dx36ftqF.cjs → cloudflare-gateway-DKVjkDav.cjs} +4 -15
  78. package/dist/src/{cloudflare-gateway-BwAaUgeW.js → cloudflare-gateway-TJkVrZlB.js} +4 -15
  79. package/dist/src/codex-app-server-CCLjqCh9.js +1915 -0
  80. package/dist/src/codex-app-server-CCe0TiDc.js +1915 -0
  81. package/dist/src/codex-app-server-CPW1LFwh.js +1916 -0
  82. package/dist/src/codex-app-server-VMRnjZ68.cjs +1920 -0
  83. package/dist/src/codex-sdk-1jm_qPHf.js +3 -0
  84. package/dist/src/codex-sdk-Bd8UbO9q.cjs +1172 -0
  85. package/dist/src/codex-sdk-BgEFQ70r.js +1164 -0
  86. package/dist/src/codex-sdk-Bzb_TqX9.js +1165 -0
  87. package/dist/src/codex-sdk-Danroptg.cjs +2 -0
  88. package/dist/src/codex-sdk-DfvDTN33.js +1165 -0
  89. package/dist/src/{cometapi-BDyV-NNm.js → cometapi-B5ImDlSm.js} +9 -15
  90. package/dist/src/{cometapi-C3hOlM7-.cjs → cometapi-BgAkuYCw.cjs} +9 -16
  91. package/dist/src/{cometapi-hhL4TAh3.js → cometapi-CC7hWxmX.js} +8 -15
  92. package/dist/src/{cometapi-sp7sJpBD.js → cometapi-CCbpHkuF.js} +8 -17
  93. package/dist/src/{completion-DoYy49ti.js → completion-2iuYVxwi.js} +8 -57
  94. package/dist/src/{completion-BCimtq-h.js → completion-CrD6MQ93.js} +8 -57
  95. package/dist/src/{completion-DlXUhj5c.cjs → completion-DtQ72Bm3.cjs} +7 -62
  96. package/dist/src/{completion-DCjv7RZ3.js → completion-Vq_ad618.js} +8 -57
  97. package/dist/src/{createHash-CTQmL3G2.js → createHash-4gFQpDDv.js} +3 -3
  98. package/dist/src/{createHash-Da8fMwqB.js → createHash-DPpsZgFF.js} +3 -3
  99. package/dist/src/{createHash-DmPQkvBh.js → createHash-Un4Q_huE.js} +3 -3
  100. package/dist/src/{createHash-BYwImsYv.cjs → createHash-VvBIc-AW.cjs} +4 -4
  101. package/dist/src/{docker-CxCkwMzc.js → docker--3qzPa-6.js} +6 -14
  102. package/dist/src/{docker-Cqj2-QVi.cjs → docker-D3AY-5F5.cjs} +7 -15
  103. package/dist/src/{docker-FeBni2dw.js → docker-DCsCDvwM.js} +7 -14
  104. package/dist/src/{docker-DpguQj-w.js → docker-Dorv4_Dg.js} +6 -16
  105. package/dist/src/embedding-BXhN5lCH.cjs +63 -0
  106. package/dist/src/embedding-ChS1ivFS.js +58 -0
  107. package/dist/src/embedding-DNRvZwRN.js +59 -0
  108. package/dist/src/embedding-D_bI4NDq.js +58 -0
  109. package/dist/src/entrypoint.js +69 -6
  110. package/dist/src/{errors-P6ll7XSJ.js → errors-DFHe4L-n.js} +1 -1
  111. package/dist/src/{esm-SUNIX1x3.js → esm-B6whoAcf.js} +15 -6
  112. package/dist/src/{esm-CKWP3u_P.js → esm-BRkfNsYs.js} +16 -7
  113. package/dist/src/{esm-7UIl0pPM.js → esm-BX8fwlAO.js} +27 -18
  114. package/dist/src/{esm-CipptfDu.cjs → esm-B_rGuPTo.cjs} +15 -6
  115. package/dist/src/eval-BQPLBJbw.js +3 -0
  116. package/dist/src/{eval-BTqTn7lb.js → eval-DJ_4A-tr.js} +50 -21
  117. package/dist/src/evalResult-BBJAHAtw.cjs +2 -0
  118. package/dist/src/evalResult-BBK58h2B.js +3 -0
  119. package/dist/src/{evalResult-DpARzUCb.cjs → evalResult-Cx-8OWkb.cjs} +29 -11
  120. package/dist/src/{evalResult-DUDShQrm.js → evalResult-D6P5I5il.js} +29 -11
  121. package/dist/src/{evalResult-BkIhRdTe.js → evalResult-pSvGWFMo.js} +29 -11
  122. package/dist/src/evalResult-spPqh1G_.js +2 -0
  123. package/dist/src/{evaluator-BcvOGaam.js → evaluator-D-UIbbYq.js} +3975 -2152
  124. package/dist/src/evaluator-DgLKaZk8.js +3 -0
  125. package/dist/src/{extractor-D_wd8jxt.js → extractor-BM3jRERL.js} +6 -6
  126. package/dist/src/{extractor-DG3sSfXE.cjs → extractor-Dxr2J_wK.cjs} +6 -6
  127. package/dist/src/{extractor-CAZ2G3Kh.js → extractor-DxyiFhPk.js} +6 -6
  128. package/dist/src/{extractor-C8XwivI9.js → extractor-YlZbUMsL.js} +6 -6
  129. package/dist/src/fetch-8viavNv8.js +3 -0
  130. package/dist/src/{fetch-DoVRJZhJ.js → fetch-B6ch2nU2.js} +199 -60
  131. package/dist/src/{fetch-CVAtKnI3.js → fetch-D9xxyC1p.js} +404 -252
  132. package/dist/src/{fetch-BnR9wSnm.cjs → fetch-NuqXW1Xb.cjs} +415 -263
  133. package/dist/src/{fetch-BiYv2BZc.js → fetch-Y5qX_kST.js} +222 -70
  134. package/dist/src/{fileExtensions-LcDYkU4v.js → fileExtensions-8CjoL7vB.js} +1 -1
  135. package/dist/src/{fileExtensions-DnqA1y9x.js → fileExtensions-BGh-W-HT.js} +1 -1
  136. package/dist/src/{fileExtensions-bYh77CN8.cjs → fileExtensions-D9h-8Wxg.cjs} +1 -1
  137. package/dist/src/{fileExtensions-Ds-foDzt.js → fileExtensions-DysCsxNG.js} +1 -1
  138. package/dist/src/{formatDuration-DgBVMN65.js → formatDuration-Ch4A7G3o.js} +1 -1
  139. package/dist/src/{genaiTracer-BfxrvSUb.cjs → genaiTracer-BokHC-MW.cjs} +7 -3
  140. package/dist/src/{genaiTracer-C1rxGO8Q.js → genaiTracer-C3ZPQU60.js} +6 -2
  141. package/dist/src/{genaiTracer-70Z8BIuV.js → genaiTracer-CFny3gOy.js} +6 -2
  142. package/dist/src/{genaiTracer-D3fD9dNV.js → genaiTracer-DxODqT9e.js} +6 -2
  143. package/dist/src/golang/wrapper.go +1 -1
  144. package/dist/src/{graders-DG7mhg-b.js → graders-BoUqsCEm.js} +7402 -5699
  145. package/dist/src/{graders-BElhu9ZY.cjs → graders-Bw1wk_21.cjs} +5220 -3437
  146. package/dist/src/graders-C84JI-m5.js +2 -0
  147. package/dist/src/graders-CBbd0K0Q.cjs +2 -0
  148. package/dist/src/graders-CbQqpHSN.js +3 -0
  149. package/dist/src/{graders-RjHF8VfG.js → graders-CgPn32yp.js} +7400 -5697
  150. package/dist/src/{graders-BXAJ0sbS.js → graders-CwrbifOo.js} +6136 -4433
  151. package/dist/src/graders-DS42d3ZG.js +2 -0
  152. package/dist/src/{image-6WQXK8m8.js → image-BeWaInPF.js} +4 -4
  153. package/dist/src/{image-PoF6DN3x.js → image-BmilRNqO.js} +8 -8
  154. package/dist/src/{image--F58eEIn.cjs → image-CxJoa3aW.cjs} +8 -8
  155. package/dist/src/{image-fza3zuKs.cjs → image-D10dNAav.cjs} +4 -4
  156. package/dist/src/{image-DO0RYnjH.js → image-Dr_3I3nK.js} +4 -5
  157. package/dist/src/{image-B8b6f36E.js → image-DsGRlkh7.js} +8 -8
  158. package/dist/src/{image-CoxZp9PZ.js → image-a_SGUobh.js} +8 -8
  159. package/dist/src/{image-xNbw5ph2.js → image-qjO6FWPs.js} +4 -4
  160. package/dist/src/index.cjs +4835 -2582
  161. package/dist/src/index.d.cts +2782 -31
  162. package/dist/src/index.d.ts +2783 -32
  163. package/dist/src/index.js +4817 -2564
  164. package/dist/src/{interactiveCheck-BnMYOjMu.js → interactiveCheck-CCICw2cy.js} +2 -2
  165. package/dist/src/{invariant-BtWWVVhl.js → invariant-B2Rf6avk.js} +1 -1
  166. package/dist/src/{invariant-vgHWClmd.js → invariant-DIYf9sP1.js} +1 -1
  167. package/dist/src/{knowledgeBase-Bi7CmDbx.js → knowledgeBase-BBETc5-S.js} +6 -8
  168. package/dist/src/{knowledgeBase-DqrLX8fy.cjs → knowledgeBase-C8qOo26M.cjs} +6 -8
  169. package/dist/src/{knowledgeBase-DFRXPZl_.js → knowledgeBase-CzAi2rUI.js} +7 -8
  170. package/dist/src/{knowledgeBase-Ce3ofVan.js → knowledgeBase-Dr3Kib7F.js} +6 -10
  171. package/dist/src/{litellm-CKiAxnoM.js → litellm-BLSiANhk.js} +6 -14
  172. package/dist/src/{litellm-CnHI69aj.cjs → litellm-CaUmV7Mk.cjs} +6 -15
  173. package/dist/src/{litellm-Tc294Jhj.js → litellm-DQGo_juI.js} +5 -14
  174. package/dist/src/{litellm-Bo2gQXpo.js → litellm-DRc4qWfc.js} +5 -16
  175. package/dist/src/{logger-BcJBzSSA.js → logger-BbY6ypFL.js} +41 -12
  176. package/dist/src/{logger-D5iKBpu_.cjs → logger-COuQb2xB.cjs} +51 -10
  177. package/dist/src/{logger-DO8_zM18.js → logger-Ct2S6Yx-.js} +40 -11
  178. package/dist/src/{logger-BnkjG2jt.js → logger-KD8JjCRJ.js} +41 -12
  179. package/dist/src/{luma-ray-C9q8rdQe.js → luma-ray-B-tNZzqW.js} +6 -10
  180. package/dist/src/{luma-ray-DP0QA9qn.js → luma-ray-CtS3OlGq.js} +6 -10
  181. package/dist/src/{luma-ray-0ehMPt5N.js → luma-ray-PJJgUjOc.js} +6 -11
  182. package/dist/src/{luma-ray-m9Ku2meV.cjs → luma-ray-if-Ml4R9.cjs} +6 -10
  183. package/dist/src/main.d.ts +1 -26
  184. package/dist/src/main.js +1188 -679
  185. package/dist/src/messages-B9dSjrNf.js +544 -0
  186. package/dist/src/messages-BnsVHUnm.cjs +558 -0
  187. package/dist/src/messages-CI69Lasb.js +543 -0
  188. package/dist/src/messages-CewuNcNS.js +543 -0
  189. package/dist/src/{meteor-DLZZ3osF.cjs → meteor-BBGcGeCa.cjs} +1 -1
  190. package/dist/src/{meteor-DUiCJRC-.js → meteor-BKTM-7KS.js} +1 -1
  191. package/dist/src/{meteor-44VjEACX.js → meteor-CeGo0Lu2.js} +2 -2
  192. package/dist/src/{meteor-D-SotUw9.js → meteor-Wc_aUVvu.js} +2 -2
  193. package/dist/src/{modelslab-B5J-ZM5c.js → modelslab-BCLOtfek.js} +8 -10
  194. package/dist/src/{modelslab-IQbNg-r7.cjs → modelslab-BkapYJhh.cjs} +7 -10
  195. package/dist/src/{modelslab-BTOT8FUO.js → modelslab-D73OnKSx.js} +7 -10
  196. package/dist/src/{modelslab-BI458moT.js → modelslab-zpz9JcK0.js} +7 -12
  197. package/dist/src/{nova-reel-BZ9y-Y5s.js → nova-reel-B8F_TK5w.js} +7 -10
  198. package/dist/src/{nova-reel-Xw1SXLpg.js → nova-reel-Bx0NFV2f.js} +6 -10
  199. package/dist/src/{nova-reel-DEeQlnOJ.js → nova-reel-CNGJTLtG.js} +6 -12
  200. package/dist/src/{nova-reel-CE5etkv9.cjs → nova-reel-DkT7tnoB.cjs} +6 -10
  201. package/dist/src/{nova-sonic-Ogqf-csn.js → nova-sonic-BaXRN1cr.js} +5 -7
  202. package/dist/src/{nova-sonic-DXTLpi-r.js → nova-sonic-BeTRaFOh.js} +4 -7
  203. package/dist/src/{nova-sonic-DWswpN1E.js → nova-sonic-CL7Zqv0G.js} +4 -9
  204. package/dist/src/{nova-sonic-N0yCm0vb.cjs → nova-sonic-YT426juD.cjs} +4 -7
  205. package/dist/src/{openai-BcB5KlTk.js → openai-BMHD2Huo.js} +6 -3
  206. package/dist/src/{openai-BMcwgD5C.js → openai-BT-JvDse.js} +6 -3
  207. package/dist/src/{openai-CoxGAQwn.cjs → openai-Cy1XLs0c.cjs} +6 -3
  208. package/dist/src/{openai-D6wITiVn.js → openai-D4fxGvRx.js} +6 -3
  209. package/dist/src/openclaw-Bq7RVR3k.js +1200 -0
  210. package/dist/src/openclaw-DA8U4DsD.js +1201 -0
  211. package/dist/src/openclaw-DObVgpjC.js +1200 -0
  212. package/dist/src/openclaw-DUBZP3GL.cjs +1206 -0
  213. package/dist/src/{opencode-sdk-CHCs7dEb.js → opencode-sdk-BB40Wir1.js} +6 -8
  214. package/dist/src/{opencode-sdk-DDxj4QqH.js → opencode-sdk-BM1UAIv1.js} +6 -8
  215. package/dist/src/{opencode-sdk-WWJhnbKr.cjs → opencode-sdk-CeqiOcOU.cjs} +7 -9
  216. package/dist/src/{opencode-sdk-C71Z0ehR.js → opencode-sdk-ChdK7F7z.js} +6 -9
  217. package/dist/src/{otlpReceiver-CZL48YfC.js → otlpReceiver-C6thJRXi.js} +154 -98
  218. package/dist/src/{otlpReceiver-C9KlUtxh.js → otlpReceiver-CcdIikOu.js} +154 -98
  219. package/dist/src/{otlpReceiver-DHKqJlsz.cjs → otlpReceiver-DNSQj6bf.cjs} +154 -98
  220. package/dist/src/{otlpReceiver-CavGAA6k.js → otlpReceiver-UYMQx3sy.js} +154 -98
  221. package/dist/src/{providerRegistry-BkzVH5Ba.js → providerRegistry-1gB5vtzQ.js} +2 -2
  222. package/dist/src/{providerRegistry-BTDgfV5h.cjs → providerRegistry-BESeALrr.cjs} +2 -2
  223. package/dist/src/{providerRegistry-CUWki5mQ.js → providerRegistry-DoACwqhD.js} +2 -2
  224. package/dist/src/{providerRegistry-B9lh-_tx.js → providerRegistry-PMsleEzs.js} +2 -2
  225. package/dist/src/providers-BuyzKt7C.js +2 -0
  226. package/dist/src/providers-C7lNVBjX.cjs +3 -0
  227. package/dist/src/providers-CCE2COJi2.js +2 -0
  228. package/dist/src/{providers-Cn73d5sr.js → providers-CJh7iriU.js} +17180 -16823
  229. package/dist/src/providers-Ctcc592x.js +3 -0
  230. package/dist/src/{providers-DvddrgxL.js → providers-DRrerKra.js} +1052 -695
  231. package/dist/src/{providers-Ch6Mr0gn.js → providers-DT-GtF2t.js} +16716 -16359
  232. package/dist/src/{providers-CScd1wN6.cjs → providers-eDShy16E.cjs} +19893 -19506
  233. package/dist/src/python/persistent_wrapper.py +0 -5
  234. package/dist/src/{pythonUtils-Cpo0Ez1p.js → pythonUtils-C4tltmIn.js} +4 -4
  235. package/dist/src/{pythonUtils-dAVigVK-.cjs → pythonUtils-CoLaCwNY.cjs} +4 -4
  236. package/dist/src/{pythonUtils-Bzwbgpbg.js → pythonUtils-DMO68Jg7.js} +3 -3
  237. package/dist/src/{pythonUtils-wIqk7zAf.js → pythonUtils-DNqbnRdx.js} +3 -3
  238. package/dist/src/{quiverai-BeofbLVc.js → quiverai-BSS9a7wV.js} +4 -4
  239. package/dist/src/{quiverai-DVSEqJiq.js → quiverai-Bk1KrvL6.js} +4 -4
  240. package/dist/src/{quiverai-CcUhPIBg.cjs → quiverai-Bpx6MZ7T.cjs} +4 -4
  241. package/dist/src/{quiverai-CCQn73lq.js → quiverai-CPKhWgaT.js} +4 -5
  242. package/dist/src/render-7uNJ2V14.js +135 -0
  243. package/dist/src/render-DlscvAUJ.js +135 -0
  244. package/dist/src/render-eui5p5mL.js +136 -0
  245. package/dist/src/{render-BHl6QVq9.js → render-nj-UaPdn.js} +2 -3
  246. package/dist/src/render-tG6ir9_g.cjs +165 -0
  247. package/dist/src/{responses-CgNyTPsY.js → responses-1ztiVYsx.js} +56 -17
  248. package/dist/src/{responses-BKP_WYis.js → responses-B8haB-mD.js} +56 -17
  249. package/dist/src/{responses-CQb1Tj69.js → responses-BiaBguAu.js} +56 -17
  250. package/dist/src/{responses-mo0KQDbu.cjs → responses-CF-ayauu.cjs} +56 -17
  251. package/dist/src/rubyUtils-4hjGxvju.js +3 -0
  252. package/dist/src/{rubyUtils-DECSbsfY.js → rubyUtils-BI0p46eZ.js} +3 -3
  253. package/dist/src/{rubyUtils-CiVfln3g.js → rubyUtils-CIQFnVz4.js} +3 -3
  254. package/dist/src/rubyUtils-CO-tuszQ.cjs +2 -0
  255. package/dist/src/{rubyUtils-PgU-gHmx.js → rubyUtils-DGnoCYL2.js} +4 -4
  256. package/dist/src/{rubyUtils-CGeUtCfW.cjs → rubyUtils-DoifqkiA.cjs} +5 -4
  257. package/dist/src/{sagemaker-CqeASYE5.js → sagemaker-BDLeW29y.js} +14 -18
  258. package/dist/src/{sagemaker-MUbD5V3v.js → sagemaker-C5T60MKf.js} +14 -19
  259. package/dist/src/{sagemaker-CVv8W7so.js → sagemaker-ClS_NB07.js} +14 -18
  260. package/dist/src/{sagemaker-jiw1wQa-.cjs → sagemaker-ljtY12VM.cjs} +14 -18
  261. package/dist/src/{scanner-DVDeUz1r.js → scanner-nOCWNIXa.js} +130 -35
  262. package/dist/src/server/golang/wrapper.go +1 -1
  263. package/dist/src/server/index.js +4829 -2529
  264. package/dist/src/server/python/persistent_wrapper.py +0 -5
  265. package/dist/src/{server-BtoCXeXI.cjs → server-BEECpeGG.cjs} +140 -6
  266. package/dist/src/{server-DZ9MtCn0.js → server-ByiF3qlg.js} +129 -9
  267. package/dist/src/{server-Cns05F1j.js → server-ByxbqAcQ.js} +128 -8
  268. package/dist/src/server-C0XKRNB_.cjs +2 -0
  269. package/dist/src/server-C_15p79-.js +3 -0
  270. package/dist/src/{server-CP9qKM40.js → server-gyd6d4Hc.js} +126 -7
  271. package/dist/src/{signal-C3ZTsUgi.js → signal-DTtUuU3l.js} +3 -3
  272. package/dist/src/{slack-DCEV-vWP.js → slack-4zZX1OKP.js} +2 -2
  273. package/dist/src/{slack-94iG3T0s.cjs → slack-BLlsDpfG.cjs} +2 -2
  274. package/dist/src/{slack-BR0HtO3K.js → slack-BPYLQLgb.js} +2 -2
  275. package/dist/src/{slack-2sdpGzbt.js → slack-Bamy_7te.js} +2 -2
  276. package/dist/src/{store-CLyU7AtI.cjs → store-2K0kDi80.cjs} +3 -3
  277. package/dist/src/{store-VB0GP46K.js → store-2OXm_eBY.js} +3 -3
  278. package/dist/src/store-BELqNwvz.js +3 -0
  279. package/dist/src/{store-Cj258DgL.js → store-BPkzEyFM.js} +3 -3
  280. package/dist/src/{store-P8OKm19S.js → store-CPh25336.js} +3 -3
  281. package/dist/src/store-uQZ4AjPe.cjs +2 -0
  282. package/dist/src/{tables-BEIFz2tM.js → tables-BMSOS2Gg.js} +3 -3
  283. package/dist/src/{tables-BdZQEpRz.cjs → tables-CXbaZ9y1.cjs} +3 -3
  284. package/dist/src/{tables-DmzvLbeZ.js → tables-NlvH23ky.js} +3 -3
  285. package/dist/src/{tables-kC7R5kiK.js → tables-WgdUZ8Ck.js} +3 -3
  286. package/dist/src/{telemetry-DPXLd7UE.js → telemetry--iqaGyaS.js} +5 -4
  287. package/dist/src/{telemetry-re627Lre.cjs → telemetry-CEQxGnMZ.cjs} +8 -7
  288. package/dist/src/{telemetry-BugWqKiu.js → telemetry-CgdVGV8N.js} +5 -4
  289. package/dist/src/{telemetry-BnH5VJAU.js → telemetry-DWdGHvEf.js} +5 -4
  290. package/dist/src/telemetry-DjNoC_n3.cjs +2 -0
  291. package/dist/src/telemetry-ZdPZc0fm.js +3 -0
  292. package/dist/src/{text-CW1cyrwj.cjs → text-BiNME7QG.cjs} +1 -1
  293. package/dist/src/{text-Db-Wt2u2.js → text-D4lz-Jg_.js} +1 -1
  294. package/dist/src/{text-TIv0QYnd.js → text-DDQP0tuQ.js} +1 -1
  295. package/dist/src/{text-B_UCRPp2.js → text-NWvfMfkF.js} +1 -1
  296. package/dist/src/{tokenUsageUtils-DflFMjS0.js → tokenUsageUtils-2wIvAhB3.js} +7 -3
  297. package/dist/src/{tokenUsageUtils-BDGe-iyI.js → tokenUsageUtils-4c780gFd.js} +7 -3
  298. package/dist/src/{tokenUsageUtils-NYT-WKS6.js → tokenUsageUtils-BjVkdk18.js} +7 -3
  299. package/dist/src/{tokenUsageUtils-bVa1ga6f.cjs → tokenUsageUtils-C9odhsbW.cjs} +7 -3
  300. package/dist/src/{transcription-CaMivnjG.js → transcription-84t4ALo2.js} +7 -11
  301. package/dist/src/{transcription-Hb3VnC4M.js → transcription-Bm2emLmJ.js} +8 -11
  302. package/dist/src/{transcription-BvtsrzRG.cjs → transcription-CZ4LG5hQ.cjs} +9 -13
  303. package/dist/src/{transcription-DOMMTu01.js → transcription-D7Q0vJsh.js} +7 -13
  304. package/dist/src/{transform-DrleutM3.js → transform-B-b6Cq-q.js} +8 -6
  305. package/dist/src/transform-BQt0BeAW.js +3 -0
  306. package/dist/src/transform-Bq5oqC0s.cjs +2 -0
  307. package/dist/src/{transform-ZrG2dvlo.cjs → transform-C9izGX54.cjs} +5 -5
  308. package/dist/src/{transform-BzK09Q_9.js → transform-CwbAZ84V.js} +5 -5
  309. package/dist/src/{transform-0BwoBsvO.cjs → transform-Dg4LcO1Y.cjs} +18 -10
  310. package/dist/src/{transform-B2-jIv68.js → transform-DtooZqYY.js} +8 -6
  311. package/dist/src/{transform-ljLYHEPh.js → transform-DzCF-wqV.js} +5 -5
  312. package/dist/src/{transform-DyDAwEpE.js → transform-_DpNB4qp.js} +9 -7
  313. package/dist/src/{transform-BqPkNPYm.js → transform-eGiUAv86.js} +5 -5
  314. package/dist/src/{transformersAvailability-DKoRtQLy.cjs → transformersAvailability-B22swDxr.cjs} +1 -1
  315. package/dist/src/{transformersAvailability-BGkzavwb.js → transformersAvailability-lvCCvuPT.js} +1 -1
  316. package/dist/src/{transformersAvailability-D6c6ROpT.js → transformersAvailability-rJGPccjr.js} +1 -1
  317. package/dist/src/{types-Cd3ygw8W.js → types-BDjGOq4E.js} +354 -24
  318. package/dist/src/{types-CIhFeUC4.js → types-BVH9hjgW.js} +364 -23
  319. package/dist/src/{types-D8cGDZbL.cjs → types-CgG2rKiW.cjs} +534 -167
  320. package/dist/src/{types-q8GXGF65.js → types-DNRZVOue.js} +498 -167
  321. package/dist/src/{util-BLvy9qfE.js → util-3pBZZb_H.js} +151 -149
  322. package/dist/src/{util-CFj4YKIn.cjs → util-A5_ZsQUn.cjs} +66 -44
  323. package/dist/src/{util-BtoGs5Cb.js → util-B9CNhyac.js} +66 -44
  324. package/dist/src/{util-Bm3E9jpK.js → util-BQOCAHQC.js} +692 -690
  325. package/dist/src/{util-vNmDL5DT.js → util-BVXcTwXu.js} +138 -36
  326. package/dist/src/{util-CgDCK4KI.js → util-BlFVL0UF.js} +66 -44
  327. package/dist/src/{util-DM2rTn_6.js → util-C-kmRosx.js} +66 -44
  328. package/dist/src/{util-DbVG-yZU.js → util-DFPeFkiV.js} +138 -36
  329. package/dist/src/{util-DMFeUvLz.js → util-DN0-b81k.js} +138 -36
  330. package/dist/src/{util--9u9UVCt.cjs → util-Dpmm_dAI.cjs} +143 -35
  331. package/dist/src/{util-CMMkIxfU.js → util-Dub0f_ej.js} +693 -691
  332. package/dist/src/{util-CuLo2pMR.cjs → util-DvpHnLt0.cjs} +714 -719
  333. package/dist/src/{utils-DOjD4dTC.js → utils-BUMN8orw.js} +6 -4
  334. package/dist/src/{utils-DKw8mrgr.cjs → utils-DkVeShIB.cjs} +6 -4
  335. package/dist/src/{utils-DEuL4VNB.js → utils-kt7lv30R.js} +6 -4
  336. package/dist/src/{utils-CFxO9KGo.js → utils-o8S5huU2.js} +6 -4
  337. package/dist/src/version-0frU0UTr.js +16 -0
  338. package/dist/src/version-CbpiUINz.js +17 -0
  339. package/dist/src/version-CbuBKu2U.js +16 -0
  340. package/dist/src/version-D9zu9FWB.cjs +27 -0
  341. package/dist/tsconfig.tsbuildinfo +1 -1
  342. package/package.json +57 -46
  343. package/dist/src/app/assets/index-B6l9CVVb.js +0 -439
  344. package/dist/src/app/assets/index-DyZ0Ep37.css +0 -1
  345. package/dist/src/app/assets/scroll-timeline-BdJZVXlz.js +0 -1
  346. package/dist/src/app/assets/sync-CStkzc6u.js +0 -4
  347. package/dist/src/app/assets/vendor-charts-BnDWwBlI.js +0 -36
  348. package/dist/src/app/assets/vendor-markdown-Bz7N-ca6.js +0 -29
  349. package/dist/src/app/assets/vendor-react-AtKqiNEf.js +0 -4
  350. package/dist/src/app/assets/vendor-syntax-D06x6TQF.js +0 -2
  351. package/dist/src/app/assets/vendor-utils-BvMHZmO7.js +0 -37
  352. package/dist/src/cache-C5yFZ4gC.cjs +0 -816
  353. package/dist/src/cache-CaT5tPgo.js +0 -756
  354. package/dist/src/cache-CyCanoMu.js +0 -6
  355. package/dist/src/cache-DSqR6ezl.js +0 -726
  356. package/dist/src/cache-Df_QFDNu.cjs +0 -5
  357. package/dist/src/cache-HP0NP4k3.js +0 -756
  358. package/dist/src/cloud-DE3t1-ZI.js +0 -4
  359. package/dist/src/codex-sdk-BQEw16R_.js +0 -834
  360. package/dist/src/codex-sdk-C_07GuVS.js +0 -834
  361. package/dist/src/codex-sdk-DE5G18dx.js +0 -835
  362. package/dist/src/codex-sdk-ZLKfDjqP.cjs +0 -838
  363. package/dist/src/eval-7aEqoMs3.js +0 -15
  364. package/dist/src/evalResult-CYNHkk5A.js +0 -12
  365. package/dist/src/evalResult-CuvJeNiM.js +0 -10
  366. package/dist/src/evalResult-tGdilrWt.cjs +0 -10
  367. package/dist/src/evaluator-BBUqRhz1.js +0 -36
  368. package/dist/src/fetch-UWU706qb.js +0 -5
  369. package/dist/src/graders-BxfEguVY.js +0 -32
  370. package/dist/src/graders-CzVMbEnv.js +0 -34
  371. package/dist/src/graders-DjCXfj0l.cjs +0 -32
  372. package/dist/src/graders-kHzIWOKu.js +0 -32
  373. package/dist/src/messages-DJNo37Ko.js +0 -246
  374. package/dist/src/messages-Dy9QecMs.js +0 -245
  375. package/dist/src/messages-HJsyEh4o.cjs +0 -257
  376. package/dist/src/messages-biC_ex-p.js +0 -245
  377. package/dist/src/openclaw-0Sv7AK3O.js +0 -580
  378. package/dist/src/openclaw-CXxbKgDH.cjs +0 -586
  379. package/dist/src/openclaw-D1FSCps-.js +0 -580
  380. package/dist/src/openclaw-D2ENvu7a.js +0 -582
  381. package/dist/src/providers-BSLEaIQG.js +0 -32
  382. package/dist/src/providers-D-FnDg8k.cjs +0 -31
  383. package/dist/src/providers-DEYiFVAo.js +0 -30
  384. package/dist/src/providers-sS2WI8YD.js +0 -30
  385. package/dist/src/rubyUtils-B1HXG4ej.cjs +0 -4
  386. package/dist/src/rubyUtils-Rt6pKA96.js +0 -5
  387. package/dist/src/server-B0Xh1Gx-.js +0 -7
  388. package/dist/src/server-DJTKu9IR.cjs +0 -5
  389. package/dist/src/store-C5u6MgC8.js +0 -6
  390. package/dist/src/store-CNHk-De4.cjs +0 -5
  391. package/dist/src/telemetry-Yig0Tino.js +0 -7
  392. package/dist/src/telemetry-p8Pwqm1i.cjs +0 -5
  393. package/dist/src/transform-ChNIpHz7.js +0 -6
  394. package/dist/src/transform-PtQ6rAE3.cjs +0 -5
@@ -1,838 +0,0 @@
1
- const require_logger = require("./logger-D5iKBpu_.cjs");
2
- const require_esm = require("./esm-CipptfDu.cjs");
3
- const require_genaiTracer = require("./genaiTracer-BfxrvSUb.cjs");
4
- let fs = require("fs");
5
- fs = require_logger.__toESM(fs);
6
- let path = require("path");
7
- path = require_logger.__toESM(path);
8
- let dedent = require("dedent");
9
- dedent = require_logger.__toESM(dedent);
10
- let crypto = require("crypto");
11
- crypto = require_logger.__toESM(crypto);
12
- let _opentelemetry_api = require("@opentelemetry/api");
13
- //#region src/providers/openai/codex-sdk.ts
14
- const MINIMAL_CLI_ENV_KEYS = [
15
- "PATH",
16
- "Path",
17
- "HOME",
18
- "USER",
19
- "USERNAME",
20
- "USERPROFILE",
21
- "TMPDIR",
22
- "TMP",
23
- "TEMP",
24
- "SHELL",
25
- "COMSPEC",
26
- "SystemRoot",
27
- "PATHEXT",
28
- "LANG",
29
- "LC_ALL",
30
- "TERM"
31
- ];
32
- function getMinimalProcessEnv() {
33
- const env = {};
34
- for (const key of MINIMAL_CLI_ENV_KEYS) {
35
- const value = process.env[key];
36
- if (typeof value === "string" && value.length > 0) env[key] = value;
37
- }
38
- return env;
39
- }
40
- /**
41
- * Helper to load the OpenAI Codex SDK ESM module
42
- * Uses resolvePackageEntryPoint to handle ESM-only packages with restrictive exports
43
- */
44
- async function loadCodexSDK() {
45
- const basePaths = [require_logger.state.basePath && path.default.isAbsolute(require_logger.state.basePath) ? require_logger.state.basePath : void 0, process.cwd()].filter((candidate) => Boolean(candidate));
46
- let codexPath = null;
47
- for (const basePath of new Set(basePaths)) {
48
- codexPath = require_esm.resolvePackageEntryPoint("@openai/codex-sdk", basePath);
49
- if (codexPath) break;
50
- }
51
- if (!codexPath) throw new Error(dedent.default`The @openai/codex-sdk package is required but not installed.
52
-
53
- To use the OpenAI Codex SDK provider, install it with:
54
- npm install @openai/codex-sdk
55
-
56
- Requires Node.js 18+.
57
-
58
- For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
59
- try {
60
- return await require_esm.importModule(codexPath);
61
- } catch (err) {
62
- require_logger.logger.error(`Failed to load OpenAI Codex SDK: ${err}`);
63
- if (err.stack) require_logger.logger.error(err.stack);
64
- throw new Error(dedent.default`Failed to load @openai/codex-sdk.
65
-
66
- The package was found but could not be loaded. This may be due to:
67
- - Incompatible Node.js version (requires Node.js 18+)
68
- - Corrupted installation
69
-
70
- Try reinstalling:
71
- npm install @openai/codex-sdk
72
-
73
- For more information, see: https://www.promptfoo.dev/docs/providers/openai-codex-sdk/`);
74
- }
75
- }
76
- const CODEX_MODEL_PRICING = {
77
- "gpt-5.4": {
78
- input: 2.5,
79
- output: 15,
80
- cache_read: .25
81
- },
82
- "gpt-5.4-pro": {
83
- input: 30,
84
- output: 180,
85
- cache_read: 30
86
- },
87
- "gpt-5.3-codex": {
88
- input: 1.75,
89
- output: 14,
90
- cache_read: .175
91
- },
92
- "gpt-5.3-codex-spark": {
93
- input: .5,
94
- output: 4,
95
- cache_read: .05
96
- },
97
- "gpt-5.2": {
98
- input: 1.75,
99
- output: 14,
100
- cache_read: .175
101
- },
102
- "gpt-5.2-codex": {
103
- input: 1.75,
104
- output: 14,
105
- cache_read: .175
106
- },
107
- "gpt-5.1-codex": {
108
- input: 2,
109
- output: 8,
110
- cache_read: .2
111
- },
112
- "gpt-5.1-codex-max": {
113
- input: 3,
114
- output: 12,
115
- cache_read: .3
116
- },
117
- "gpt-5.1-codex-mini": {
118
- input: .5,
119
- output: 2,
120
- cache_read: .05
121
- },
122
- "gpt-5-codex": {
123
- input: 2,
124
- output: 8,
125
- cache_read: .2
126
- },
127
- "gpt-5-codex-mini": {
128
- input: .5,
129
- output: 2,
130
- cache_read: .05
131
- },
132
- "gpt-5": {
133
- input: 2,
134
- output: 8,
135
- cache_read: .2
136
- }
137
- };
138
- var OpenAICodexSDKProvider = class OpenAICodexSDKProvider {
139
- static OPENAI_MODELS = [
140
- "gpt-5.4",
141
- "gpt-5.4-pro",
142
- "gpt-5.3-codex",
143
- "gpt-5.3-codex-spark",
144
- "gpt-5.2",
145
- "gpt-5.2-codex",
146
- "gpt-5.1-codex",
147
- "gpt-5.1-codex-max",
148
- "gpt-5.1-codex-mini",
149
- "gpt-5-codex",
150
- "gpt-5-codex-mini",
151
- "gpt-5"
152
- ];
153
- config;
154
- env;
155
- apiKey;
156
- providerId = "openai:codex-sdk";
157
- codexModule;
158
- codexInstance;
159
- codexInstanceEnvHash;
160
- threads = /* @__PURE__ */ new Map();
161
- deepTracingWarningShown = false;
162
- constructor(options = {}) {
163
- const { config, env, id } = options;
164
- this.config = config ?? {};
165
- this.env = env;
166
- this.apiKey = this.getApiKey();
167
- this.providerId = id ?? this.providerId;
168
- if (this.config.model && !OpenAICodexSDKProvider.OPENAI_MODELS.includes(this.config.model)) require_logger.logger.warn(`Using unknown model for OpenAI Codex SDK: ${this.config.model}`);
169
- }
170
- id() {
171
- return this.providerId;
172
- }
173
- getApiKey() {
174
- return this.config?.apiKey || this.env?.OPENAI_API_KEY || this.env?.CODEX_API_KEY || require_logger.getEnvString("OPENAI_API_KEY") || require_logger.getEnvString("CODEX_API_KEY");
175
- }
176
- toString() {
177
- return "[OpenAI Codex SDK Provider]";
178
- }
179
- /**
180
- * Safely tear down a Codex instance by calling its cleanup method
181
- * (destroy, cleanup, or close -- whichever is available).
182
- */
183
- async destroyInstance(instance) {
184
- if (typeof instance.destroy === "function") await instance.destroy();
185
- else if (typeof instance.cleanup === "function") await instance.cleanup();
186
- else if (typeof instance.close === "function") await instance.close();
187
- }
188
- async cleanup() {
189
- this.threads.clear();
190
- if (this.codexInstance) {
191
- try {
192
- await this.destroyInstance(this.codexInstance);
193
- } catch (error) {
194
- require_logger.logger.warn("[CodexSDK] Error during cleanup", { error });
195
- }
196
- this.codexInstance = void 0;
197
- this.codexInstanceEnvHash = void 0;
198
- }
199
- }
200
- prepareEnvironment(config, traceparent) {
201
- const env = {
202
- ...config.cli_env === void 0 || config.inherit_process_env === true ? process.env : getMinimalProcessEnv(),
203
- ...config.cli_env ?? {}
204
- };
205
- const sortedEnv = {};
206
- for (const key of Object.keys(env).sort()) if (env[key] !== void 0) sortedEnv[key] = env[key];
207
- if (this.apiKey) {
208
- sortedEnv.OPENAI_API_KEY = this.apiKey;
209
- sortedEnv.CODEX_API_KEY = this.apiKey;
210
- }
211
- if (this.env) for (const key of Object.keys(this.env).sort()) {
212
- const value = this.env[key];
213
- if (value !== void 0) sortedEnv[key] = value;
214
- }
215
- if (config.deep_tracing) {
216
- if (!sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT) sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT = "http://127.0.0.1:4318";
217
- if (!sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL) sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL = "http/json";
218
- if (!sortedEnv.OTEL_SERVICE_NAME) sortedEnv.OTEL_SERVICE_NAME = "codex-cli";
219
- if (!sortedEnv.OTEL_TRACES_EXPORTER) sortedEnv.OTEL_TRACES_EXPORTER = "otlp";
220
- if (traceparent) sortedEnv.TRACEPARENT = traceparent;
221
- require_logger.logger.debug("[CodexSDK] Injecting OTEL config for deep tracing", {
222
- traceparent: traceparent || "(none - CLI will start own trace)",
223
- endpoint: sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
224
- userConfigured: {
225
- endpoint: !!env.OTEL_EXPORTER_OTLP_ENDPOINT,
226
- protocol: !!env.OTEL_EXPORTER_OTLP_PROTOCOL,
227
- serviceName: !!env.OTEL_SERVICE_NAME
228
- }
229
- });
230
- } else delete sortedEnv.TRACEPARENT;
231
- return sortedEnv;
232
- }
233
- getSkillRootPrefixes(env) {
234
- const prefixes = /* @__PURE__ */ new Set();
235
- const addPrefix = (candidate) => {
236
- if (!candidate) return;
237
- const normalized = candidate.replace(/\\/g, "/").replace(/\/+$/g, "");
238
- if (normalized) prefixes.add(normalized);
239
- };
240
- addPrefix(env.CODEX_HOME);
241
- addPrefix("/etc/codex");
242
- const homeDir = env.HOME || process.env.HOME;
243
- if (homeDir) addPrefix(path.default.posix.join(homeDir.replace(/\\/g, "/"), ".codex"));
244
- return Array.from(prefixes);
245
- }
246
- isValidCodexSkillName(name) {
247
- return /^[A-Za-z0-9._:-]+$/.test(name);
248
- }
249
- extractSkillPathCandidates(text, skillRootPrefixes = []) {
250
- const matches = /* @__PURE__ */ new Map();
251
- for (const rawToken of text.split(/\s+/)) {
252
- const token = rawToken.replace(/^[`"'([{<]+|[`"',;:)\]}>]+$/g, "").trim();
253
- if (!token) continue;
254
- const normalizedPath = token.replace(/\\/g, "/");
255
- const repoMatch = normalizedPath.match(/^\.agents\/skills\/([^/\s]+)\/SKILL\.md$/);
256
- if (repoMatch) {
257
- if (this.isValidCodexSkillName(repoMatch[1])) matches.set(normalizedPath, {
258
- name: repoMatch[1],
259
- path: normalizedPath
260
- });
261
- continue;
262
- }
263
- const matchingRoot = skillRootPrefixes.find((prefix) => normalizedPath.startsWith(`${prefix}/skills/`));
264
- if (!matchingRoot) continue;
265
- const customRootMatch = normalizedPath.slice(matchingRoot.length + 1).match(/^skills\/([^/\s]+)\/SKILL\.md$/);
266
- if (customRootMatch && this.isValidCodexSkillName(customRootMatch[1])) matches.set(normalizedPath, {
267
- name: customRootMatch[1],
268
- path: normalizedPath
269
- });
270
- }
271
- return Array.from(matches.values());
272
- }
273
- extractSkillCallsFromItems(items, skillRootPrefixes = [], options = {}) {
274
- const skillCalls = /* @__PURE__ */ new Map();
275
- for (const item of items) {
276
- if (item?.type !== "command_execution") continue;
277
- if (options.requireSuccessfulCommand && !this.isSuccessfulCommandExecution(item)) continue;
278
- const command = typeof item.command === "string" && item.command.trim() ? item.command : void 0;
279
- if (!command) continue;
280
- for (const skillPath of this.extractSkillPathCandidates(command, skillRootPrefixes)) {
281
- const existing = skillCalls.get(skillPath.path) ?? {
282
- name: skillPath.name,
283
- path: skillPath.path
284
- };
285
- skillCalls.set(skillPath.path, existing);
286
- }
287
- }
288
- return Array.from(skillCalls.values()).map((skillCall) => ({
289
- name: skillCall.name,
290
- path: skillCall.path,
291
- source: "heuristic"
292
- }));
293
- }
294
- buildSkillMetadata(items, skillRootPrefixes = []) {
295
- if (!Array.isArray(items) || items.length === 0) return;
296
- const attemptedSkillCalls = this.extractSkillCallsFromItems(items, skillRootPrefixes);
297
- const skillCalls = this.extractSkillCallsFromItems(items, skillRootPrefixes, { requireSuccessfulCommand: true });
298
- if (skillCalls.length === 0 && attemptedSkillCalls.length <= skillCalls.length) return;
299
- return {
300
- attemptedSkillCalls,
301
- skillCalls
302
- };
303
- }
304
- isSuccessfulCommandExecution(item) {
305
- if (item?.type !== "command_execution") return false;
306
- if (typeof item.status === "string" && item.status !== "completed") return false;
307
- if (typeof item.exit_code === "number" && item.exit_code !== 0) return false;
308
- return true;
309
- }
310
- validateWorkingDirectory(workingDir, skipGitCheck = false) {
311
- let stats;
312
- try {
313
- stats = fs.default.statSync(workingDir);
314
- } catch (err) {
315
- throw new Error(`Working directory ${workingDir} does not exist or isn't accessible: ${err.message}`);
316
- }
317
- if (!stats.isDirectory()) throw new Error(`Working directory ${workingDir} is not a directory`);
318
- if (!skipGitCheck) {
319
- const gitDir = path.default.join(workingDir, ".git");
320
- if (!fs.default.existsSync(gitDir)) throw new Error(dedent.default`Working directory ${workingDir} is not a Git repository.
321
-
322
- Codex requires a Git repository by default to prevent unrecoverable errors.
323
-
324
- To bypass this check, set skip_git_repo_check: true in your provider config.`);
325
- }
326
- }
327
- /**
328
- * Build Codex constructor options from provider config.
329
- * Used when creating both local (deep-tracing) and cached instances.
330
- */
331
- buildCodexOptions(env, config) {
332
- return {
333
- env,
334
- ...this.apiKey ? { apiKey: this.apiKey } : {},
335
- ...config.codex_path_override ? { codexPathOverride: config.codex_path_override } : {},
336
- ...config.base_url ? { baseUrl: config.base_url } : {},
337
- ...config.cli_config ? { config: config.cli_config } : {}
338
- };
339
- }
340
- buildThreadOptions(config) {
341
- return {
342
- workingDirectory: config.working_dir,
343
- skipGitRepoCheck: config.skip_git_repo_check ?? false,
344
- ...config.model ? { model: config.model } : {},
345
- ...config.additional_directories?.length ? { additionalDirectories: config.additional_directories } : {},
346
- ...config.sandbox_mode ? { sandboxMode: config.sandbox_mode } : {},
347
- ...config.model_reasoning_effort ? { modelReasoningEffort: config.model_reasoning_effort } : {},
348
- ...config.network_access_enabled === void 0 ? {} : { networkAccessEnabled: config.network_access_enabled },
349
- ...config.web_search_mode ? { webSearchMode: config.web_search_mode } : {},
350
- ...config.web_search_enabled !== void 0 && !config.web_search_mode ? { webSearchEnabled: config.web_search_enabled } : {},
351
- ...config.approval_policy ? { approvalPolicy: config.approval_policy } : {}
352
- };
353
- }
354
- async getOrCreateThread(config, cacheKey, instance) {
355
- const threadOptions = this.buildThreadOptions(config);
356
- if (config.deep_tracing) return instance.startThread(threadOptions);
357
- if (config.thread_id) {
358
- const cached = this.threads.get(config.thread_id);
359
- if (cached) return cached;
360
- const thread = instance.resumeThread(config.thread_id, threadOptions);
361
- if (config.persist_threads) this.threads.set(config.thread_id, thread);
362
- return thread;
363
- }
364
- if (config.persist_threads && cacheKey) {
365
- const cached = this.threads.get(cacheKey);
366
- if (cached) return cached;
367
- const poolSize = config.thread_pool_size ?? 1;
368
- if (this.threads.size >= poolSize) {
369
- const oldestKey = this.threads.keys().next().value;
370
- if (oldestKey) this.threads.delete(oldestKey);
371
- }
372
- }
373
- const thread = instance.startThread(threadOptions);
374
- if (config.persist_threads && cacheKey) this.threads.set(cacheKey, thread);
375
- return thread;
376
- }
377
- async runStreaming(thread, prompt, runOptions, callOptions, skillRootPrefixes = []) {
378
- const { events } = await thread.runStreamed(prompt, runOptions);
379
- const items = [];
380
- let usage = void 0;
381
- const tracer = _opentelemetry_api.trace.getTracer("promptfoo.codex-sdk");
382
- const activeSpans = /* @__PURE__ */ new Map();
383
- const itemStartTimes = /* @__PURE__ */ new Map();
384
- let lastEventTime = Date.now();
385
- const reasoningTexts = [];
386
- const conversationMessages = [];
387
- conversationMessages.push({
388
- role: "user",
389
- content: prompt
390
- });
391
- try {
392
- for await (const event of events) {
393
- const eventTime = Date.now();
394
- if (callOptions?.abortSignal?.aborted) {
395
- const abortError = /* @__PURE__ */ new Error("AbortError");
396
- abortError.name = "AbortError";
397
- throw abortError;
398
- }
399
- switch (event.type) {
400
- case "item.started": {
401
- const item = event.item;
402
- if (!item) {
403
- require_logger.logger.warn("Codex item.started event missing item", { event });
404
- break;
405
- }
406
- if (!item.id) {
407
- require_logger.logger.debug("Codex item.started without id, will create span at completion", { type: item.type });
408
- break;
409
- }
410
- const itemId = String(item.id);
411
- const spanName = this.getSpanNameForItem(item);
412
- const span = tracer.startSpan(spanName, {
413
- kind: _opentelemetry_api.SpanKind.INTERNAL,
414
- attributes: {
415
- "codex.item.id": itemId,
416
- "codex.item.type": item.type,
417
- ...this.getAttributesForItem(item)
418
- }
419
- });
420
- activeSpans.set(itemId, span);
421
- itemStartTimes.set(itemId, eventTime);
422
- require_logger.logger.debug("Codex item started", {
423
- itemId,
424
- type: item.type
425
- });
426
- break;
427
- }
428
- case "item.completed": {
429
- const item = event.item;
430
- if (!item) {
431
- require_logger.logger.warn("Codex item.completed event missing item", { event });
432
- break;
433
- }
434
- const itemId = item.id ? String(item.id) : crypto.default.randomUUID();
435
- items.push(item);
436
- if (item.type === "reasoning" && typeof item.text === "string") reasoningTexts.push(item.text);
437
- if (item.type === "agent_message" && typeof item.text === "string") conversationMessages.push({
438
- role: "assistant",
439
- content: item.text
440
- });
441
- let span = activeSpans.get(itemId);
442
- const hadStartEvent = span !== void 0;
443
- if (!span) {
444
- const spanName = this.getSpanNameForItem(item);
445
- span = tracer.startSpan(spanName, {
446
- kind: _opentelemetry_api.SpanKind.INTERNAL,
447
- startTime: lastEventTime,
448
- attributes: {
449
- "codex.item.id": itemId,
450
- "codex.item.type": item.type,
451
- "codex.timing.estimated": true,
452
- ...this.getAttributesForItem(item)
453
- }
454
- });
455
- }
456
- const completionAttrs = this.getCompletionAttributesForItem(item, skillRootPrefixes);
457
- for (const [key, value] of Object.entries(completionAttrs)) span.setAttribute(key, value);
458
- const durationMs = eventTime - (itemStartTimes.get(itemId) || lastEventTime);
459
- span.setAttribute("codex.duration_ms", durationMs);
460
- span.setAttribute("codex.had_start_event", hadStartEvent);
461
- if (item.type === "reasoning" && typeof item.text === "string") span.addEvent("reasoning", { "codex.reasoning.text": item.text });
462
- if (item.type === "agent_message" && typeof item.text === "string") span.addEvent("message", { "codex.message.text": item.text });
463
- if (item.type === "command_execution" && typeof item.aggregated_output === "string") span.addEvent("output", { "codex.command.output": item.aggregated_output });
464
- 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({
465
- code: _opentelemetry_api.SpanStatusCode.ERROR,
466
- 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"
467
- });
468
- else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
469
- span.end();
470
- activeSpans.delete(itemId);
471
- itemStartTimes.delete(itemId);
472
- require_logger.logger.debug("Codex item completed", {
473
- itemId,
474
- type: item.type,
475
- durationMs
476
- });
477
- break;
478
- }
479
- case "item.updated": {
480
- const item = event.item;
481
- if (item?.id) {
482
- const itemId = String(item.id);
483
- const span = activeSpans.get(itemId);
484
- if (span) {
485
- const updatedAttrs = this.getCompletionAttributesForItem(item, skillRootPrefixes);
486
- for (const [key, value] of Object.entries(updatedAttrs)) span.setAttribute(key, value);
487
- }
488
- }
489
- require_logger.logger.debug("Codex item updated", {
490
- itemId: item?.id,
491
- type: item?.type
492
- });
493
- break;
494
- }
495
- case "turn.completed":
496
- usage = event.usage;
497
- require_logger.logger.debug("Codex turn completed", { usage });
498
- break;
499
- case "turn.failed": {
500
- const errorMsg = event.error?.message || "Turn failed";
501
- require_logger.logger.error("Codex turn failed", { error: errorMsg });
502
- throw new Error(`Codex turn failed: ${errorMsg}`);
503
- }
504
- default: require_logger.logger.debug("Codex unknown event type", { type: event.type });
505
- }
506
- lastEventTime = eventTime;
507
- }
508
- } finally {
509
- for (const [itemId, span] of activeSpans) {
510
- require_logger.logger.warn("Codex item span not properly closed", { itemId });
511
- span.setStatus({
512
- code: _opentelemetry_api.SpanStatusCode.ERROR,
513
- message: "Span not properly closed"
514
- });
515
- span.end();
516
- }
517
- activeSpans.clear();
518
- itemStartTimes.clear();
519
- }
520
- const agentMessages = items.filter((i) => i.type === "agent_message");
521
- return {
522
- finalResponse: agentMessages.length > 0 ? agentMessages.map((i) => i.text).join("\n") : "",
523
- items,
524
- usage,
525
- reasoningTexts,
526
- conversationMessages
527
- };
528
- }
529
- /**
530
- * Get a descriptive span name for a Codex item
531
- */
532
- getSpanNameForItem(item) {
533
- switch (item.type) {
534
- case "command_execution": return `exec ${typeof item.command === "string" ? item.command.split(" ")[0] || "command" : "command"}`;
535
- case "file_change": return `file ${item.changes?.[0]?.kind || "change"}`;
536
- case "mcp_tool_call": return `mcp ${typeof item.server === "string" ? item.server : "unknown"}/${typeof item.tool === "string" ? item.tool : "unknown"}`;
537
- case "agent_message": return "agent response";
538
- case "reasoning": return "reasoning";
539
- case "web_search": return `search "${typeof item.query === "string" ? item.query.slice(0, 30) : ""}"`;
540
- case "todo_list": return "todo update";
541
- case "error": return "error";
542
- case "collaboration_tool_call": return `collab ${typeof item.tool === "string" ? item.tool : "unknown"}`;
543
- case "spawn_agent": return `spawn ${typeof item.role === "string" ? item.role : "agent"}`;
544
- case "send_input": return "send input";
545
- case "agent_wait": return "wait";
546
- default: return `codex.${item.type || "unknown"}`;
547
- }
548
- }
549
- /**
550
- * Get attributes for a Codex item at start
551
- */
552
- getSkillTraceAttributes(item, skillRootPrefixes = [], options = {}) {
553
- if (item?.type !== "command_execution") return {};
554
- if (options.requireSuccessfulCommand && !this.isSuccessfulCommandExecution(item)) return {};
555
- const command = typeof item.command === "string" && item.command.trim() ? item.command : void 0;
556
- const skillCandidates = /* @__PURE__ */ new Map();
557
- if (command) for (const skill of this.extractSkillPathCandidates(command, skillRootPrefixes)) skillCandidates.set(skill.path, skill);
558
- if (skillCandidates.size === 0) return {};
559
- const skills = Array.from(skillCandidates.values());
560
- const attrs = {
561
- "promptfoo.skill.count": skills.length,
562
- "promptfoo.skill.names": skills.map((skill) => skill.name).join(","),
563
- "promptfoo.skill.paths": skills.map((skill) => skill.path).join(",")
564
- };
565
- if (skills.length === 1) {
566
- attrs["promptfoo.skill.name"] = skills[0].name;
567
- attrs["promptfoo.skill.path"] = skills[0].path;
568
- }
569
- return attrs;
570
- }
571
- getAttributesForItem(item) {
572
- const attrs = {};
573
- switch (item.type) {
574
- case "command_execution":
575
- if (typeof item.command === "string") attrs["codex.command"] = item.command;
576
- break;
577
- case "mcp_tool_call":
578
- if (typeof item.server === "string") attrs["codex.mcp.server"] = item.server;
579
- if (typeof item.tool === "string") attrs["codex.mcp.tool"] = item.tool;
580
- {
581
- const serializedArgs = this.serializeItemValue(item.arguments ?? item.args ?? item.input);
582
- if (serializedArgs) attrs["codex.mcp.input"] = serializedArgs;
583
- }
584
- break;
585
- case "web_search":
586
- if (typeof item.query === "string") attrs["codex.search.query"] = item.query;
587
- break;
588
- case "collaboration_tool_call":
589
- if (typeof item.tool === "string") attrs["codex.collab.tool"] = item.tool;
590
- if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
591
- break;
592
- case "spawn_agent":
593
- if (typeof item.role === "string") attrs["codex.collab.role"] = item.role;
594
- if (typeof item.thread_id === "string") attrs["codex.collab.spawned_thread"] = item.thread_id;
595
- break;
596
- case "send_input":
597
- if (typeof item.target_thread_id === "string") attrs["codex.collab.target_thread"] = item.target_thread_id;
598
- break;
599
- }
600
- return attrs;
601
- }
602
- serializeItemValue(value) {
603
- if (typeof value === "string") {
604
- const trimmed = value.trim();
605
- if (!trimmed) return;
606
- try {
607
- return JSON.stringify(this.redactTracePii(require_logger.sanitizeObject(JSON.parse(trimmed))));
608
- } catch {
609
- return this.redactTracePii(require_logger.sanitizeObject(trimmed, { context: "Codex MCP trace input" }));
610
- }
611
- }
612
- if (value === void 0 || value === null) return;
613
- try {
614
- return JSON.stringify(this.redactTracePii(require_logger.sanitizeObject(value, { context: "Codex MCP trace input" })));
615
- } catch {
616
- return;
617
- }
618
- }
619
- redactTracePii(value) {
620
- if (typeof value === "string" && /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i.test(value)) return require_logger.REDACTED;
621
- if (Array.isArray(value)) return value.map((item) => this.redactTracePii(item));
622
- if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [key, require_logger.normalizeFieldName(key).includes("email") ? require_logger.REDACTED : this.redactTracePii(entryValue)]));
623
- return value;
624
- }
625
- /**
626
- * Get attributes for a Codex item at completion
627
- */
628
- getCompletionAttributesForItem(item, skillRootPrefixes = []) {
629
- const attrs = {};
630
- switch (item.type) {
631
- case "command_execution":
632
- if (typeof item.exit_code === "number") attrs["codex.exit_code"] = item.exit_code;
633
- if (typeof item.status === "string") attrs["codex.status"] = item.status;
634
- if (typeof item.aggregated_output === "string") attrs["codex.output"] = item.aggregated_output;
635
- Object.assign(attrs, this.getSkillTraceAttributes(item, skillRootPrefixes, { requireSuccessfulCommand: true }));
636
- break;
637
- case "file_change":
638
- if (typeof item.status === "string") attrs["codex.status"] = item.status;
639
- if (Array.isArray(item.changes) && item.changes.length) {
640
- attrs["codex.files_changed"] = item.changes.length;
641
- attrs["codex.files"] = item.changes.map((c) => typeof c?.path === "string" ? c.path : "").filter(Boolean).join(", ");
642
- }
643
- break;
644
- case "mcp_tool_call":
645
- if (typeof item.status === "string") attrs["codex.status"] = item.status;
646
- if (typeof item.error?.message === "string") attrs["codex.error"] = item.error.message;
647
- {
648
- const serializedArgs = this.serializeItemValue(item.arguments ?? item.args ?? item.input);
649
- if (serializedArgs) attrs["codex.mcp.input"] = serializedArgs;
650
- }
651
- break;
652
- case "agent_message":
653
- if (typeof item.text === "string") attrs["codex.message"] = item.text;
654
- break;
655
- case "reasoning":
656
- if (typeof item.text === "string") attrs["codex.reasoning"] = item.text;
657
- break;
658
- case "error":
659
- if (typeof item.message === "string") attrs["codex.error"] = item.message;
660
- break;
661
- }
662
- return attrs;
663
- }
664
- generateCacheKey(config, prompt) {
665
- const keyData = {
666
- working_dir: config.working_dir,
667
- additional_directories: config.additional_directories,
668
- model: config.model,
669
- output_schema: config.output_schema,
670
- sandbox_mode: config.sandbox_mode,
671
- model_reasoning_effort: config.model_reasoning_effort,
672
- network_access_enabled: config.network_access_enabled,
673
- web_search_enabled: config.web_search_enabled,
674
- web_search_mode: config.web_search_mode,
675
- approval_policy: config.approval_policy,
676
- prompt
677
- };
678
- return `openai:codex-sdk:${crypto.default.createHash("sha256").update(JSON.stringify(keyData)).digest("hex")}`;
679
- }
680
- async callApi(prompt, context, callOptions) {
681
- const config = {
682
- ...this.config,
683
- ...context?.prompt?.config
684
- };
685
- const modelName = config.model || "codex";
686
- const spanContext = {
687
- system: "openai",
688
- operationName: "chat",
689
- model: modelName,
690
- providerId: this.id(),
691
- evalId: context?.evaluationId || context?.test?.metadata?.evaluationId,
692
- testIndex: typeof context?.test?.vars?.__testIdx === "number" ? context.test.vars.__testIdx : void 0,
693
- promptLabel: context?.prompt?.label,
694
- traceparent: context?.traceparent,
695
- requestBody: prompt
696
- };
697
- const resultExtractor = (response) => {
698
- const result = {};
699
- if (response.tokenUsage) result.tokenUsage = response.tokenUsage;
700
- if (response.sessionId) result.responseId = response.sessionId;
701
- if (response.cached !== void 0) result.cacheHit = response.cached;
702
- result.responseModel = modelName;
703
- if (response.output !== void 0) try {
704
- result.responseBody = typeof response.output === "string" ? response.output : JSON.stringify(response.output);
705
- } catch {
706
- result.responseBody = "[unable to serialize output]";
707
- }
708
- if (response.raw) try {
709
- const rawData = typeof response.raw === "string" ? JSON.parse(response.raw) : response.raw;
710
- if (rawData.reasoningTexts?.length > 0) result.additionalAttributes = {
711
- "codex.reasoning.count": rawData.reasoningTexts.length,
712
- "codex.reasoning.summary": rawData.reasoningTexts.join("\n---\n").slice(0, 2e3)
713
- };
714
- if (rawData.conversationMessages?.length > 0) result.additionalAttributes = {
715
- ...result.additionalAttributes,
716
- "codex.conversation.message_count": rawData.conversationMessages.length
717
- };
718
- if (rawData.items?.length > 0) {
719
- const itemCounts = {};
720
- for (const item of rawData.items) itemCounts[item.type] = (itemCounts[item.type] || 0) + 1;
721
- result.additionalAttributes = {
722
- ...result.additionalAttributes,
723
- "codex.items.total": rawData.items.length,
724
- "codex.items.breakdown": JSON.stringify(itemCounts)
725
- };
726
- }
727
- } catch {}
728
- return result;
729
- };
730
- return require_genaiTracer.withGenAISpan(spanContext, () => this.callApiInternal(prompt, context, callOptions, config), resultExtractor);
731
- }
732
- /**
733
- * Internal implementation of callApi without tracing wrapper.
734
- * Context is available for future use (e.g., _context?.vars for template rendering,
735
- * _context?.bustCache for cache control, _context?.debug for debug mode).
736
- */
737
- async callApiInternal(prompt, _context, callOptions, config) {
738
- const currentTraceparent = require_genaiTracer.getTraceparent();
739
- const env = this.prepareEnvironment(config, currentTraceparent);
740
- const skillRootPrefixes = this.getSkillRootPrefixes(env);
741
- 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.");
742
- if (config.working_dir) this.validateWorkingDirectory(config.working_dir, config.skip_git_repo_check);
743
- if (callOptions?.abortSignal?.aborted) return { error: "OpenAI Codex SDK call aborted before it started" };
744
- if (!this.codexModule) this.codexModule = await loadCodexSDK();
745
- let localInstance = void 0;
746
- const useLocalInstance = config.deep_tracing;
747
- if (useLocalInstance) {
748
- if ((config.persist_threads || config.thread_id || (config.thread_pool_size ?? 0) > 1) && !this.deepTracingWarningShown) {
749
- require_logger.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.");
750
- this.deepTracingWarningShown = true;
751
- }
752
- localInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
753
- } else {
754
- const stableEnv = { ...env };
755
- delete stableEnv.TRACEPARENT;
756
- const envHash = crypto.default.createHash("sha256").update(JSON.stringify(stableEnv)).digest("hex");
757
- const envChanged = this.codexInstanceEnvHash !== envHash;
758
- if (!this.codexInstance || envChanged) {
759
- if (envChanged && this.codexInstance) {
760
- require_logger.logger.debug("[CodexSDK] Recreating instance due to configuration change");
761
- try {
762
- await this.destroyInstance(this.codexInstance);
763
- } catch (cleanupError) {
764
- require_logger.logger.warn("[CodexSDK] Error cleaning up old instance", { error: cleanupError });
765
- }
766
- this.threads.clear();
767
- }
768
- this.codexInstance = new this.codexModule.Codex(this.buildCodexOptions(env, config));
769
- this.codexInstanceEnvHash = envHash;
770
- }
771
- }
772
- const activeInstance = useLocalInstance ? localInstance : this.codexInstance;
773
- if (!activeInstance) throw new Error("Failed to create Codex instance - SDK module may have failed to load");
774
- const cacheKey = this.generateCacheKey(config, prompt);
775
- const thread = await this.getOrCreateThread(config, cacheKey, activeInstance);
776
- const runOptions = {};
777
- if (config.output_schema) runOptions.outputSchema = config.output_schema;
778
- if (callOptions?.abortSignal) runOptions.signal = callOptions.abortSignal;
779
- try {
780
- const turn = config.enable_streaming ? await this.runStreaming(thread, prompt, runOptions, callOptions, skillRootPrefixes) : await thread.run(prompt, runOptions);
781
- const output = turn.finalResponse || "";
782
- const raw = JSON.stringify(turn);
783
- const skillMetadata = this.buildSkillMetadata(turn.items, skillRootPrefixes);
784
- const metadata = skillMetadata ? {
785
- ...skillMetadata.skillCalls.length > 0 ? { skillCalls: skillMetadata.skillCalls } : {},
786
- ...skillMetadata.attemptedSkillCalls.length > skillMetadata.skillCalls.length ? { attemptedSkillCalls: skillMetadata.attemptedSkillCalls } : {}
787
- } : void 0;
788
- const tokenUsage = turn.usage ? {
789
- prompt: turn.usage.input_tokens,
790
- completion: turn.usage.output_tokens,
791
- total: turn.usage.input_tokens + turn.usage.output_tokens,
792
- cached: turn.usage.cached_input_tokens || 0
793
- } : void 0;
794
- let cost = 0;
795
- if (tokenUsage && config.model) {
796
- const pricing = CODEX_MODEL_PRICING[config.model];
797
- if (pricing) {
798
- const cachedTokens = tokenUsage.cached || 0;
799
- const inputCost = ((tokenUsage.prompt || 0) - cachedTokens) * (pricing.input / 1e6);
800
- const cacheReadCost = cachedTokens * (pricing.cache_read / 1e6);
801
- const outputCost = (tokenUsage.completion || 0) * (pricing.output / 1e6);
802
- cost = inputCost + cacheReadCost + outputCost;
803
- }
804
- }
805
- require_logger.logger.debug("OpenAI Codex SDK response", {
806
- output,
807
- usage: turn.usage
808
- });
809
- return {
810
- output,
811
- tokenUsage,
812
- cost,
813
- metadata,
814
- raw,
815
- sessionId: thread.id || "unknown"
816
- };
817
- } catch (error) {
818
- if (error instanceof Error && error.name === "AbortError" || callOptions?.abortSignal?.aborted) {
819
- require_logger.logger.warn("OpenAI Codex SDK call aborted");
820
- return { error: "OpenAI Codex SDK call aborted" };
821
- }
822
- const errorMessage = error instanceof Error ? error.message : String(error);
823
- require_logger.logger.error("Error calling OpenAI Codex SDK", { error: errorMessage });
824
- return { error: `Error calling OpenAI Codex SDK: ${errorMessage}` };
825
- } finally {
826
- if (!config.deep_tracing && !config.persist_threads && !config.thread_id && cacheKey) this.threads.delete(cacheKey);
827
- if (useLocalInstance && localInstance) try {
828
- await this.destroyInstance(localInstance);
829
- } catch (cleanupError) {
830
- require_logger.logger.debug("[CodexSDK] Error cleaning up local instance", { error: cleanupError });
831
- }
832
- }
833
- }
834
- };
835
- //#endregion
836
- exports.OpenAICodexSDKProvider = OpenAICodexSDKProvider;
837
-
838
- //# sourceMappingURL=codex-sdk-ZLKfDjqP.cjs.map