promptfoo 0.125.0 → 0.125.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (869) hide show
  1. package/README.md +3 -3
  2. package/dist/src/accounts-BOxNYxVN.js +229 -0
  3. package/dist/src/accounts-BezXLdAW.cjs +276 -0
  4. package/dist/src/accounts-CPISMNlh.js +227 -0
  5. package/dist/src/accounts-vJBPs89d.js +222 -0
  6. package/dist/src/agentWorkspace-Bom7SpF2.js +592 -0
  7. package/dist/src/agentWorkspace-CEomAcws.cjs +619 -0
  8. package/dist/src/agentWorkspace-DPtMLrlI.js +593 -0
  9. package/dist/src/agentWorkspace-DkAeEYLz.js +592 -0
  10. package/dist/src/agentic-utils-121v7mJo.js +197 -0
  11. package/dist/src/agentic-utils-CBWD_rcd.cjs +237 -0
  12. package/dist/src/agentic-utils-D8wyQwPG.js +198 -0
  13. package/dist/src/agentic-utils-EP1QkQCs.js +197 -0
  14. package/dist/src/agents-Br3ah8iA.js +778 -0
  15. package/dist/src/agents-C5wj_UTv.js +777 -0
  16. package/dist/src/agents-C9Efp4mC.js +266 -0
  17. package/dist/src/agents-CQYwaVCO.js +267 -0
  18. package/dist/src/agents-CjCd4Vo8.js +777 -0
  19. package/dist/src/agents-DRWiCHYz.js +266 -0
  20. package/dist/src/agents-F2rhx0iL.cjs +266 -0
  21. package/dist/src/agents-RTYyy69h.cjs +777 -0
  22. package/dist/src/agents-api-CY72O86e.js +711 -0
  23. package/dist/src/agents-api-CsSsC21b.js +710 -0
  24. package/dist/src/agents-api-DN-ibDc8.js +710 -0
  25. package/dist/src/agents-api-cNDsCCv1.cjs +710 -0
  26. package/dist/src/ai.studio-Bj6Dyi6o.js +2 -0
  27. package/dist/src/ai.studio-C-e0LzyW.js +369 -0
  28. package/dist/src/ai.studio-CR8M6Aqf.cjs +391 -0
  29. package/dist/src/ai.studio-YKk7F0tv.js +374 -0
  30. package/dist/src/aimlapi-BGunsuTu.js +30 -0
  31. package/dist/src/aimlapi-BkzcfBsL.js +29 -0
  32. package/dist/src/aimlapi-DXFcEdP8.js +28 -0
  33. package/dist/src/aimlapi-r-8iCcAw.cjs +29 -0
  34. package/dist/src/anthropicMessages-7-YNRgQR.js +114 -0
  35. package/dist/src/anthropicMessages-C8m9Whrd.cjs +114 -0
  36. package/dist/src/anthropicMessages-DS1vXD0f.js +115 -0
  37. package/dist/src/anthropicMessages-DmvGkz-0.js +114 -0
  38. package/dist/src/app/assets/index-CrdXWTXm.js +392 -0
  39. package/dist/src/app/browser-inventory.json +4 -4
  40. package/dist/src/app/index.html +1 -1
  41. package/dist/src/audio-BLgFgyw-.cjs +104 -0
  42. package/dist/src/audio-C2sibT7Q.js +104 -0
  43. package/dist/src/audio-DXEXb03H.js +104 -0
  44. package/dist/src/audio-TkvojpwO.js +105 -0
  45. package/dist/src/authoritativeMarkupInjection-BAT9B-Wj.js +79 -0
  46. package/dist/src/authoritativeMarkupInjection-B_yHETKT.js +78 -0
  47. package/dist/src/authoritativeMarkupInjection-BfjecQ3Q.cjs +78 -0
  48. package/dist/src/authoritativeMarkupInjection-D-hDKrhD.js +78 -0
  49. package/dist/src/aws-B_9unI_-.js +1149 -0
  50. package/dist/src/aws-D0FY3qkc.js +2433 -0
  51. package/dist/src/aws-Dh1-a90n.js +2433 -0
  52. package/dist/src/aws-qskKGczY.cjs +2454 -0
  53. package/dist/src/base-CaWlBkVz.js +462 -0
  54. package/dist/src/base-CcViNwVs.js +255 -0
  55. package/dist/src/base-CsVbPJkU.cjs +467 -0
  56. package/dist/src/base-DNK9py25.js +255 -0
  57. package/dist/src/base-DlH5tjEZ.js +463 -0
  58. package/dist/src/base-DyLOZ_iX.js +256 -0
  59. package/dist/src/base-RRYXfG7l.cjs +305 -0
  60. package/dist/src/base-oXVgvtVn.js +462 -0
  61. package/dist/src/bedrock-BP17ZXbR.cjs +2 -0
  62. package/dist/src/bedrock-CsjM1dOt.js +1300 -0
  63. package/dist/src/bedrock-CzPwj8GO.js +1 -0
  64. package/dist/src/bedrock-eGXZw8oh.js +1 -0
  65. package/dist/src/bedrock-tSWjmXdj.js +2 -0
  66. package/dist/src/bestOfN-BQ93nUKV.js +160 -0
  67. package/dist/src/bestOfN-ByGGwlcb.cjs +161 -0
  68. package/dist/src/bestOfN-CbP7csHr.js +159 -0
  69. package/dist/src/bestOfN-xn6i2Xs2.js +159 -0
  70. package/dist/src/cache-CHq9hPz9.js +2 -0
  71. package/dist/src/cache-D-9eZN3I.js +754 -0
  72. package/dist/src/cache-DSm6t1MZ.js +741 -0
  73. package/dist/src/cache-DeF5zIEN.js +782 -0
  74. package/dist/src/cache-iG87oYan.cjs +856 -0
  75. package/dist/src/cerebras-CTtM4yMH.js +98 -0
  76. package/dist/src/cerebras-CogcJ3ce.cjs +97 -0
  77. package/dist/src/cerebras-DmkRypTh.js +97 -0
  78. package/dist/src/cerebras-GUp0B8JY.js +97 -0
  79. package/dist/src/chat-B4ihd3fw.js +226 -0
  80. package/dist/src/chat-B9cAQ_rS.js +227 -0
  81. package/dist/src/chat-BU7EB4R-.cjs +76 -0
  82. package/dist/src/chat-C8yxJ2-s.cjs +226 -0
  83. package/dist/src/chat-ClTFM3qq.js +934 -0
  84. package/dist/src/chat-Cnq0Is68.js +123 -0
  85. package/dist/src/chat-CwrurR57.cjs +987 -0
  86. package/dist/src/chat-D0lsojPv.js +124 -0
  87. package/dist/src/chat-D7_8yFIx.js +76 -0
  88. package/dist/src/chat-DCoETlLG.js +226 -0
  89. package/dist/src/chat-DHE7xaTR.js +76 -0
  90. package/dist/src/chat-DmhT6rz2.cjs +123 -0
  91. package/dist/src/chat-DvfMe8KI.js +123 -0
  92. package/dist/src/chat-DwP5kVnl.js +935 -0
  93. package/dist/src/chat-MB7U-QE2.js +77 -0
  94. package/dist/src/chat-zCWuBKAj.js +934 -0
  95. package/dist/src/claude-agent-sdk-23bIVI75.js +999 -0
  96. package/dist/src/claude-agent-sdk-BACpnIJi.cjs +1005 -0
  97. package/dist/src/claude-agent-sdk-BlYlmcEr.js +999 -0
  98. package/dist/src/claude-agent-sdk-Cr-jqJZl.js +1000 -0
  99. package/dist/src/client-BktbiPx9.cjs +357 -0
  100. package/dist/src/client-CjztEBmW.js +351 -0
  101. package/dist/src/client-mRs2UvH9.js +351 -0
  102. package/dist/src/client-uCz0ydjC.js +352 -0
  103. package/dist/src/cloud-BtYF555L.js +2 -0
  104. package/dist/src/cloud-CVSUEmAy.js +287 -0
  105. package/dist/src/cloud-D7Ifb-Fl.js +599 -0
  106. package/dist/src/cloud-DB5oK5NX.cjs +666 -0
  107. package/dist/src/cloud-ecu989Em.js +657 -0
  108. package/dist/src/cloud-ramjGURF.js +599 -0
  109. package/dist/src/cloudflare-ai-BfDkIjO8.js +133 -0
  110. package/dist/src/cloudflare-ai-D9HaXz1M.js +134 -0
  111. package/dist/src/cloudflare-ai-HrD5WUK8.js +132 -0
  112. package/dist/src/cloudflare-ai-Qdj8aKP2.cjs +133 -0
  113. package/dist/src/cloudflare-gateway-C81uKETQ.js +276 -0
  114. package/dist/src/cloudflare-gateway-CX5Z9X0k.js +276 -0
  115. package/dist/src/cloudflare-gateway-DW-og8gb.js +277 -0
  116. package/dist/src/cloudflare-gateway-iRyXo9n2.cjs +276 -0
  117. package/dist/src/codex-app-server-BFIrSgdy.js +2155 -0
  118. package/dist/src/codex-app-server-By1eDVD4.js +2 -0
  119. package/dist/src/codex-app-server-DKsF4qmY.js +2156 -0
  120. package/dist/src/codex-app-server-n7n4uZzC.cjs +2162 -0
  121. package/dist/src/codex-app-server-xAoELVxu.js +2155 -0
  122. package/dist/src/codex-sdk-C2ZLxa6r.js +1552 -0
  123. package/dist/src/codex-sdk-CzG02tQt.cjs +1588 -0
  124. package/dist/src/codex-sdk-DNxAOhiV.js +2 -0
  125. package/dist/src/codex-sdk-DT3aQezK.js +1557 -0
  126. package/dist/src/codex-sdk-pw9DpcJP.js +1557 -0
  127. package/dist/src/codex-security-B0bLmXJF.js +406 -0
  128. package/dist/src/codex-security-BhYs-3iY.js +406 -0
  129. package/dist/src/codex-security-DQcOfxYW.js +407 -0
  130. package/dist/src/codex-security-DsCWr6GZ.cjs +411 -0
  131. package/dist/src/cometapi-B16asPLX.cjs +55 -0
  132. package/dist/src/cometapi-MgTbZA_H.js +53 -0
  133. package/dist/src/cometapi-i33vKzPV.js +55 -0
  134. package/dist/src/cometapi-wK2UWK0X.js +56 -0
  135. package/dist/src/compatible-COj8ZCy9.js +24 -0
  136. package/dist/src/compatible-CRSsIUGb.cjs +24 -0
  137. package/dist/src/compatible-Dy1vCcNF.js +25 -0
  138. package/dist/src/compatible-aUItQrpk.js +24 -0
  139. package/dist/src/completion-Bn7COFMk.js +119 -0
  140. package/dist/src/completion-Bub2N48b.js +118 -0
  141. package/dist/src/completion-Cf2G9OlM.cjs +123 -0
  142. package/dist/src/conversationScoring-BiTYJ9MD.js +374 -0
  143. package/dist/src/conversationScoring-CKL47uIu.js +373 -0
  144. package/dist/src/conversationScoring-DCvQKp6k.cjs +398 -0
  145. package/dist/src/conversationScoring-DLNJtDZI.js +373 -0
  146. package/dist/src/crescendo-5iLk9WiJ.cjs +734 -0
  147. package/dist/src/crescendo-B5ylG7kW.js +733 -0
  148. package/dist/src/crescendo-BD7k6TIx.js +730 -0
  149. package/dist/src/crescendo-DqO2Ch0P.js +732 -0
  150. package/dist/src/custom-8rv_aG2K.js +617 -0
  151. package/dist/src/custom-BOtrIHFN.js +619 -0
  152. package/dist/src/custom-BvN8seCs.cjs +620 -0
  153. package/dist/src/custom-Cld9v_Y4.js +618 -0
  154. package/dist/src/dataUrl-BdHUey2l.cjs +3187 -0
  155. package/dist/src/dataUrl-DBMifX6C.js +3133 -0
  156. package/dist/src/dataUrl-DUSr-ZvI.js +2868 -0
  157. package/dist/src/decisions-CLazADTw.js +516 -0
  158. package/dist/src/decisions-D5X93awq.js +515 -0
  159. package/dist/src/decisions-DmaeArEn.js +515 -0
  160. package/dist/src/decisions-DyQJyHJz.cjs +514 -0
  161. package/dist/src/docker-C9NYQFeu.js +94 -0
  162. package/dist/src/docker-CGq3mMol.cjs +94 -0
  163. package/dist/src/docker-DOm7nmpl.js +95 -0
  164. package/dist/src/docker-skFN-Kfo.js +93 -0
  165. package/dist/src/embedding-0UbzkTk9.js +82 -0
  166. package/dist/src/embedding-DTrSDt7k.cjs +86 -0
  167. package/dist/src/embedding-j2ORNl5H.js +81 -0
  168. package/dist/src/envoy-BvS8XTQO.js +60 -0
  169. package/dist/src/envoy-Cn6Hzw0e.js +60 -0
  170. package/dist/src/envoy-DC3KWcUY.cjs +60 -0
  171. package/dist/src/envoy-DetHjo5B.js +61 -0
  172. package/dist/src/eval-Cer9dPe9.js +1920 -0
  173. package/dist/src/eval-CytYmI2Z.js +2 -0
  174. package/dist/src/evalResult-DzOq5wt9.js +1300 -0
  175. package/dist/src/evaluator-BxCmvGtv.js +10578 -0
  176. package/dist/src/evaluator-Ct7YDELm.js +2 -0
  177. package/dist/src/evaluatorHelpers-B_AwIrsl.js +600 -0
  178. package/dist/src/evaluatorHelpers-D1Tpc7gd.js +601 -0
  179. package/dist/src/evaluatorHelpers-DRR3rLq0.cjs +622 -0
  180. package/dist/src/fetch-B5KxZuKu.js +1559 -0
  181. package/dist/src/fetch-BG_Jl7ty.js +1556 -0
  182. package/dist/src/fetch-BKlgUg08.cjs +1853 -0
  183. package/dist/src/fetch-C9Fsja0R.js +2 -0
  184. package/dist/src/fetch-CM7P8KWA.cjs +14 -0
  185. package/dist/src/fetch-D0FkIB3G.js +9 -0
  186. package/dist/src/fetch-RXHsZF-J.js +1280 -0
  187. package/dist/src/fetch-rSECy8jR.js +10 -0
  188. package/dist/src/functionCallbackUtils-BB9tmf6a.cjs +262 -0
  189. package/dist/src/functionCallbackUtils-BXk2iY01.js +246 -0
  190. package/dist/src/functionCallbackUtils-B_cYp7P5.js +245 -0
  191. package/dist/src/functionCallbackUtils-BfXnPo0o.js +245 -0
  192. package/dist/src/gemini-image-BXLMADDz.js +471 -0
  193. package/dist/src/gemini-image-BYUZyEUx.js +472 -0
  194. package/dist/src/gemini-image-DSt1QubZ.cjs +471 -0
  195. package/dist/src/gemini-image-DdNDMiZ_.js +471 -0
  196. package/dist/src/goat-9b-uU_k6.js +514 -0
  197. package/dist/src/goat-BCJuiDd0.js +515 -0
  198. package/dist/src/goat-CmAHbemm.js +512 -0
  199. package/dist/src/goat-DdOTdyoS.cjs +515 -0
  200. package/dist/src/goblin-Bp5C5lyb.js +22 -0
  201. package/dist/src/goblin-Dmr7GItI.js +23 -0
  202. package/dist/src/goblin-DpM8wxlf.cjs +22 -0
  203. package/dist/src/goblin-cJyH6Pq-.js +22 -0
  204. package/dist/src/google-B6eaPAbE.js +142 -0
  205. package/dist/src/google-D-FStdN6.cjs +142 -0
  206. package/dist/src/google-DAC7BsCW.js +142 -0
  207. package/dist/src/google-Id18H0Va.js +143 -0
  208. package/dist/src/graders-BjNQWkaB.js +2 -0
  209. package/dist/src/graders-CqdIp_vl.js +15470 -0
  210. package/dist/src/hydra-6Ouh74DE.js +610 -0
  211. package/dist/src/hydra-BHjhZnLB.cjs +612 -0
  212. package/dist/src/hydra-BL6k2REV.js +2 -0
  213. package/dist/src/hydra-BWUc0o67.js +613 -0
  214. package/dist/src/hydra-CUkEOLKw.js +612 -0
  215. package/dist/src/image-B6hG_xhb.js +481 -0
  216. package/dist/src/image-BFaq7Krd.cjs +209 -0
  217. package/dist/src/image-Bql5C0N9.cjs +504 -0
  218. package/dist/src/image-BtZfI2pT.js +163 -0
  219. package/dist/src/image-CIM4oN7Z.cjs +163 -0
  220. package/dist/src/image-CbAl7Jpu.js +209 -0
  221. package/dist/src/image-CiYm_yFw.js +209 -0
  222. package/dist/src/image-DCMNvBiV.js +163 -0
  223. package/dist/src/image-DL7pIuUZ.js +210 -0
  224. package/dist/src/image-ey0kxF8o.js +164 -0
  225. package/dist/src/image-smgIk3rE.js +482 -0
  226. package/dist/src/index.cjs +27 -27
  227. package/dist/src/index.d.cts +8 -8
  228. package/dist/src/index.js +27 -27
  229. package/dist/src/indirectWebPwn-B_-UpWY5.js +285 -0
  230. package/dist/src/indirectWebPwn-Cz3SLiEq.js +434 -0
  231. package/dist/src/indirectWebPwn-D2s8zGiM.cjs +463 -0
  232. package/dist/src/indirectWebPwn-DXbj2wGu.cjs +285 -0
  233. package/dist/src/indirectWebPwn-D_4H44E6.js +285 -0
  234. package/dist/src/indirectWebPwn-L044SrpV.js +434 -0
  235. package/dist/src/indirectWebPwn-cnmvdavH.js +435 -0
  236. package/dist/src/indirectWebPwn-zUBzsqTt.js +286 -0
  237. package/dist/src/interactions-Bu3oVQ-j.js +850 -0
  238. package/dist/src/interactions-CND010Lh.cjs +850 -0
  239. package/dist/src/interactions-DAx7tqUz.js +851 -0
  240. package/dist/src/interactions-DPkIumeh.js +850 -0
  241. package/dist/src/iterative-BO4JRnpG.js +545 -0
  242. package/dist/src/iterative-CAK-k9rz.js +548 -0
  243. package/dist/src/iterative-CDgHc0xO.cjs +549 -0
  244. package/dist/src/iterative-CXJlHLl9.js +547 -0
  245. package/dist/src/iterativeImage-BEdGKSmh.cjs +419 -0
  246. package/dist/src/iterativeImage-BfL0QZw5.js +417 -0
  247. package/dist/src/iterativeImage-C9KhnibC.js +417 -0
  248. package/dist/src/iterativeImage-btjkOfWG.js +418 -0
  249. package/dist/src/iterativeMeta-B5Bdw6QA.js +437 -0
  250. package/dist/src/iterativeMeta-C3mI4gpT.js +440 -0
  251. package/dist/src/iterativeMeta-Co2BKyqS.cjs +439 -0
  252. package/dist/src/iterativeMeta-DD8ihRWD.js +439 -0
  253. package/dist/src/iterativeTree-AMi4GV2O.js +878 -0
  254. package/dist/src/iterativeTree-C8FJOEje.cjs +879 -0
  255. package/dist/src/iterativeTree-CvrY1f2Z.js +877 -0
  256. package/dist/src/iterativeTree-bPtESmaD.js +876 -0
  257. package/dist/src/knowledgeBase-Cf5871e3.js +163 -0
  258. package/dist/src/knowledgeBase-D2PQhqLH.js +164 -0
  259. package/dist/src/knowledgeBase-DpoMw1IH.cjs +163 -0
  260. package/dist/src/knowledgeBase-npGFl763.js +163 -0
  261. package/dist/src/litellm-BBB5DQdt.cjs +146 -0
  262. package/dist/src/litellm-Bo43ow7r.js +145 -0
  263. package/dist/src/litellm-CaU8CMLS.js +146 -0
  264. package/dist/src/litellm-wY7Unh8o.js +147 -0
  265. package/dist/src/live-5g2w-M-E.js +891 -0
  266. package/dist/src/live-BfaXsDyD.cjs +891 -0
  267. package/dist/src/live-C1xewnGD.js +2 -0
  268. package/dist/src/live-DaF7nYy5.js +892 -0
  269. package/dist/src/live-lp3urLUw.js +891 -0
  270. package/dist/src/luma-ray-B7zvKGVG.js +309 -0
  271. package/dist/src/luma-ray-DCf5fnrz.cjs +309 -0
  272. package/dist/src/luma-ray-DepBcn6z.js +309 -0
  273. package/dist/src/luma-ray-XQC4M1pt.js +310 -0
  274. package/dist/src/main.js +26 -26
  275. package/dist/src/mantleChat-7xm95vSV.js +154 -0
  276. package/dist/src/mantleChat-CXhAs5RD.js +155 -0
  277. package/dist/src/mantleChat-CcE-zjfj.cjs +154 -0
  278. package/dist/src/mantleChat-Cpefl7Zm.js +154 -0
  279. package/dist/src/mcp-B0V0ikdM.js +84 -0
  280. package/dist/src/mcp-CV2k2gwj.js +85 -0
  281. package/dist/src/memoryPoisoning-BC5FQQWZ.js +111 -0
  282. package/dist/src/memoryPoisoning-BDwrtZKX.js +111 -0
  283. package/dist/src/memoryPoisoning-BFemS_FF.js +112 -0
  284. package/dist/src/memoryPoisoning-DRs2rbVV.cjs +111 -0
  285. package/dist/src/messages-Bc5oZoAJ.js +1128 -0
  286. package/dist/src/messages-BkaH8fRW.js +1127 -0
  287. package/dist/src/messages-CoHlziS5.js +1127 -0
  288. package/dist/src/messages-Cv_m6kYs.cjs +1161 -0
  289. package/dist/src/mischievousUser-BcyFxrqJ.js +51 -0
  290. package/dist/src/mischievousUser-BlhOQSd2.js +52 -0
  291. package/dist/src/mischievousUser-BuQiKE8D.js +51 -0
  292. package/dist/src/mischievousUser-ChIOk6cT.cjs +51 -0
  293. package/dist/src/modelslab-BXIWBTgX.js +171 -0
  294. package/dist/src/modelslab-ChVsUiaJ.js +170 -0
  295. package/dist/src/modelslab-DZ6BFlDv.js +170 -0
  296. package/dist/src/modelslab-DhRr-vyo.cjs +170 -0
  297. package/dist/src/nova-reel-BL8DrN4_.js +272 -0
  298. package/dist/src/nova-reel-BiOMUm5q.cjs +272 -0
  299. package/dist/src/nova-reel-CTsya1hV.js +273 -0
  300. package/dist/src/nova-reel-kgBY4Svd.js +272 -0
  301. package/dist/src/nova-sonic-CaSSA3Jq.cjs +374 -0
  302. package/dist/src/nova-sonic-DLpmoGsR.js +375 -0
  303. package/dist/src/nova-sonic-DwWc4SoN.js +374 -0
  304. package/dist/src/nova-sonic-qnReTaXm.js +374 -0
  305. package/dist/src/novita-B5mAt3Ui.js +114 -0
  306. package/dist/src/novita-D57vCjDD.js +116 -0
  307. package/dist/src/novita-ITRtG8IJ.js +115 -0
  308. package/dist/src/novita-Rh3T13YO.cjs +115 -0
  309. package/dist/src/nscale-8V7iZ_pI.js +210 -0
  310. package/dist/src/nscale-BQnMv4pH.cjs +209 -0
  311. package/dist/src/nscale-BWZXHZVF.js +209 -0
  312. package/dist/src/nscale-BqrHiUqU.js +207 -0
  313. package/dist/src/openaiResponses-BMtGTu8R.js +317 -0
  314. package/dist/src/openaiResponses-CvcI_viE.js +318 -0
  315. package/dist/src/openaiResponses-DYPZEMX1.cjs +318 -0
  316. package/dist/src/openaiResponses-DZTg1-kb.js +319 -0
  317. package/dist/src/openclaw-BeKuig4g.js +1338 -0
  318. package/dist/src/openclaw-COkdQ83y.js +1337 -0
  319. package/dist/src/openclaw-CSoX_HQ5.cjs +1344 -0
  320. package/dist/src/openclaw-DJlhPGCb.js +1336 -0
  321. package/dist/src/opencode-sdk-BEJftEs6.cjs +1018 -0
  322. package/dist/src/opencode-sdk-DMvBB3V7.js +1013 -0
  323. package/dist/src/opencode-sdk-Df7hMjLO.js +1012 -0
  324. package/dist/src/opencode-sdk-bQp5Xf3W.js +1012 -0
  325. package/dist/src/openinterpreter-B3GgVZjK.js +431 -0
  326. package/dist/src/openinterpreter-BiGcU-HN.cjs +435 -0
  327. package/dist/src/openinterpreter-Buj2l3Eh.js +432 -0
  328. package/dist/src/openinterpreter-C3_Cg5b_.js +431 -0
  329. package/dist/src/pricing-0Pampf0q.cjs +999 -0
  330. package/dist/src/pricing-B8VdhEhY.js +976 -0
  331. package/dist/src/pricing-CtLA-rKA.js +976 -0
  332. package/dist/src/promptfoo-4OkHtH9P.cjs +341 -0
  333. package/dist/src/promptfoo-Bhpm7sH6.js +286 -0
  334. package/dist/src/promptfoo-BqV8ogVA.js +285 -0
  335. package/dist/src/promptfoo-S1Q9OHk_.js +286 -0
  336. package/dist/src/providers-B5zs1ZRv.js +24437 -0
  337. package/dist/src/providers-Cd6CJh6m.js +2 -0
  338. package/dist/src/providers-CpJlgHET.js +24039 -0
  339. package/dist/src/providers-CzvLvK6G.cjs +24180 -0
  340. package/dist/src/quiverai-1E_IvLHn.js +325 -0
  341. package/dist/src/quiverai-BXH004Vv.js +325 -0
  342. package/dist/src/quiverai-Ccya2z8Y.cjs +325 -0
  343. package/dist/src/quiverai-Cez57oe-.js +326 -0
  344. package/dist/src/registry-3zX_M9Ik.js +131 -0
  345. package/dist/src/registry-AuCrKTvS.js +132 -0
  346. package/dist/src/registry-CxXWKtQG.js +131 -0
  347. package/dist/src/registry-DG3o66JQ.cjs +131 -0
  348. package/dist/src/remoteGeneration-CAtvamG6.js +370 -0
  349. package/dist/src/remoteGeneration-CF225pDl.cjs +482 -0
  350. package/dist/src/remoteGeneration-DtnqocnL.js +370 -0
  351. package/dist/src/remoteGeneration-g3KvW-sP.js +371 -0
  352. package/dist/src/responses-BMbaUXQI.js +1098 -0
  353. package/dist/src/responses-B_TOSof-.js +1099 -0
  354. package/dist/src/responses-v-yANwTA.cjs +1109 -0
  355. package/dist/src/runtimeTransform-BBZv-oUZ.js +156 -0
  356. package/dist/src/runtimeTransform-DT2v5ovW.js +156 -0
  357. package/dist/src/runtimeTransform-GXXEIXdS.cjs +161 -0
  358. package/dist/src/runtimeTransform-JTwBQc-P.js +157 -0
  359. package/dist/src/sagemaker-B8D0L4rj.cjs +716 -0
  360. package/dist/src/sagemaker-CR2_AGdB.js +713 -0
  361. package/dist/src/sagemaker-Cd9qSQUV.js +714 -0
  362. package/dist/src/sagemaker-mKlltN4p.js +713 -0
  363. package/dist/src/scanner-PG_8lh8r.js +1971 -0
  364. package/dist/src/server/index.js +55 -55
  365. package/dist/src/server-Bmh7sd9F.js +155 -0
  366. package/dist/src/server-C7b8z6aC.js +63 -0
  367. package/dist/src/server-CAcovgtL.js +2 -0
  368. package/dist/src/server-CuuMfKlh.cjs +74 -0
  369. package/dist/src/server-DMPCj9jy.js +189 -0
  370. package/dist/src/session-BksXvRH_.cjs +69 -0
  371. package/dist/src/session-DOxUjqGQ.js +63 -0
  372. package/dist/src/session-Dujsc-b9.js +62 -0
  373. package/dist/src/session-VjtIxREd.js +62 -0
  374. package/dist/src/shared-Bkyz_7e5.cjs +2185 -0
  375. package/dist/src/shared-DDJg8ycC.js +1929 -0
  376. package/dist/src/shared-Dh3yfRBd.js +1927 -0
  377. package/dist/src/shared-tfPT8Tna.js +1928 -0
  378. package/dist/src/simulatedUser-6JdkyL3k.cjs +252 -0
  379. package/dist/src/simulatedUser-CFr2mr3M.js +248 -0
  380. package/dist/src/simulatedUser-DjwwUqx-.js +247 -0
  381. package/dist/src/slack-C_gIYiUs.js +144 -0
  382. package/dist/src/slack-DhNbz9CM.cjs +144 -0
  383. package/dist/src/slack-Dm2iI1zu.js +145 -0
  384. package/dist/src/strategies-BIY-bNul.js +2248 -0
  385. package/dist/src/strategies-C1KQQj9G.cjs +2420 -0
  386. package/dist/src/strategies-DM_3mReG.js +2385 -0
  387. package/dist/src/telemetry-BhMTibZO.js +2 -0
  388. package/dist/src/telemetry-C04d25BM.cjs +216 -0
  389. package/dist/src/telemetry-CIqy4fSC.js +201 -0
  390. package/dist/src/telemetry-CXozp_6C.js +205 -0
  391. package/dist/src/telemetry-g7PkBxmY.js +205 -0
  392. package/dist/src/togetherai-BvCim68-.js +50 -0
  393. package/dist/src/togetherai-CWyDCA9m.cjs +49 -0
  394. package/dist/src/togetherai-CeSE31vK.js +49 -0
  395. package/dist/src/togetherai-_2W0URf8.js +48 -0
  396. package/dist/src/traceContext-Brw3Oe41.js +1016 -0
  397. package/dist/src/traceContext-DpAYv27G.js +1015 -0
  398. package/dist/src/traceContext-KSqhzZI2.cjs +1032 -0
  399. package/dist/src/transcription-BySopazW.js +175 -0
  400. package/dist/src/transcription-DO4UPkRI.cjs +178 -0
  401. package/dist/src/transcription-RJGBa-pC.js +176 -0
  402. package/dist/src/transcription-fZenF3G5.js +175 -0
  403. package/dist/src/transform-BzhRc5z2.js +125 -0
  404. package/dist/src/transform-CPQu05u6.cjs +154 -0
  405. package/dist/src/transform-DAED8imp.js +126 -0
  406. package/dist/src/transform-DIOIQDmM.js +125 -0
  407. package/dist/src/typesafe-ByE0Kxfg.js +253 -0
  408. package/dist/src/typesafe-CFqGFY34.js +253 -0
  409. package/dist/src/typesafe-DCWIw-CP.cjs +253 -0
  410. package/dist/src/typesafe-DyHFV5Qk.js +254 -0
  411. package/dist/src/util-BHkj9joz.js +2049 -0
  412. package/dist/src/util-CICwIpmu.cjs +934 -0
  413. package/dist/src/util-CePiY2xZ.js +286 -0
  414. package/dist/src/util-CgT3uf4p.js +743 -0
  415. package/dist/src/util-Cj9drvOY.js +1770 -0
  416. package/dist/src/util-ClJRjlQA.cjs +357 -0
  417. package/dist/src/util-Cxf8VF2M.js +395 -0
  418. package/dist/src/util-D7RdV7rS.js +395 -0
  419. package/dist/src/util-DMNFhk47.js +351 -0
  420. package/dist/src/util-DNzh3M0z.js +396 -0
  421. package/dist/src/util-Df7rfMGb.cjs +2305 -0
  422. package/dist/src/util-Kf0KnG_6.js +2051 -0
  423. package/dist/src/util-LEbeiYw_.js +743 -0
  424. package/dist/src/util-WH8CgVs4.js +352 -0
  425. package/dist/src/util-cx6Xw8Lw.cjs +478 -0
  426. package/dist/src/util-qzBqirBH.js +2050 -0
  427. package/dist/src/vertex-CBAMfRz3.js +854 -0
  428. package/dist/src/vertex-CMP2IpN9.js +2 -0
  429. package/dist/src/vertex-CZ5YOotT.js +848 -0
  430. package/dist/src/vertex-DNsh1F1M.cjs +871 -0
  431. package/dist/src/vertexLive-BTXYj3-F.js +55 -0
  432. package/dist/src/vertexLive-Ba_LAqEF.cjs +55 -0
  433. package/dist/src/vertexLive-DM4sFaaj.js +56 -0
  434. package/dist/src/vertexLive-JqZOw7HC.js +55 -0
  435. package/dist/src/video-BY7Q2Gii.cjs +706 -0
  436. package/dist/src/video-CYElP-CK.js +703 -0
  437. package/dist/src/video-C_AdEDH0.js +702 -0
  438. package/dist/src/video-DGvjQ_4j.js +702 -0
  439. package/package.json +1 -1
  440. package/dist/src/accounts-Dpb43yde.cjs +0 -276
  441. package/dist/src/accounts-GKrO1olH.js +0 -229
  442. package/dist/src/accounts-e4FGOsji.js +0 -227
  443. package/dist/src/accounts-sUiEJfkB.js +0 -222
  444. package/dist/src/agentWorkspace-B8A_wuMR.cjs +0 -619
  445. package/dist/src/agentWorkspace-DSPIscXR.js +0 -593
  446. package/dist/src/agentWorkspace-DxUqd-XK.js +0 -592
  447. package/dist/src/agentWorkspace-n0uOJXhD.js +0 -592
  448. package/dist/src/agentic-utils-9bCj4twQ.js +0 -197
  449. package/dist/src/agentic-utils-CyCLuLoj.js +0 -197
  450. package/dist/src/agentic-utils-D23qtOlx.cjs +0 -237
  451. package/dist/src/agentic-utils-DuBMMNCw.js +0 -198
  452. package/dist/src/agents-6hDRNoYD.js +0 -777
  453. package/dist/src/agents-B8w2o7Sc.cjs +0 -777
  454. package/dist/src/agents-Ck0NXl7v.js +0 -777
  455. package/dist/src/agents-CwT3B1qB.js +0 -778
  456. package/dist/src/agents-DOLjfOEq.js +0 -266
  457. package/dist/src/agents-OcF9hq--.js +0 -267
  458. package/dist/src/agents-api-CnZZt8bn.cjs +0 -710
  459. package/dist/src/agents-api-D04u3bmL.js +0 -711
  460. package/dist/src/agents-api-DWw0_Vio.js +0 -710
  461. package/dist/src/agents-api-IWHEwp8i.js +0 -710
  462. package/dist/src/agents-mHt2Mh9O.cjs +0 -266
  463. package/dist/src/agents-sICccZCA.js +0 -266
  464. package/dist/src/ai.studio-Ci4rypDT.js +0 -2
  465. package/dist/src/ai.studio-KkQ6KaHa.js +0 -369
  466. package/dist/src/ai.studio-gSXK2cGI.js +0 -374
  467. package/dist/src/ai.studio-nQF_B4DH.cjs +0 -391
  468. package/dist/src/aimlapi-BeSk5BDV.js +0 -30
  469. package/dist/src/aimlapi-CzNUhdKu.cjs +0 -29
  470. package/dist/src/aimlapi-DCkazDPI.js +0 -29
  471. package/dist/src/aimlapi-WeH5B6K1.js +0 -28
  472. package/dist/src/anthropicMessages-AcNWTpYO.js +0 -115
  473. package/dist/src/anthropicMessages-BUtvzbpL.js +0 -114
  474. package/dist/src/anthropicMessages-DTWhZDCd.js +0 -114
  475. package/dist/src/anthropicMessages-lGVnSgyx.cjs +0 -114
  476. package/dist/src/app/assets/index-CyEI5aDN.js +0 -392
  477. package/dist/src/audio-BE_Duiu1.js +0 -104
  478. package/dist/src/audio-CiUd00k2.cjs +0 -104
  479. package/dist/src/audio-Dop6omna.js +0 -105
  480. package/dist/src/audio-EZNTInr_.js +0 -104
  481. package/dist/src/authoritativeMarkupInjection-BUqH6hNk.js +0 -78
  482. package/dist/src/authoritativeMarkupInjection-BmbJdJO0.cjs +0 -78
  483. package/dist/src/authoritativeMarkupInjection-Cpz12Y3w.js +0 -78
  484. package/dist/src/authoritativeMarkupInjection-W4XfcH91.js +0 -79
  485. package/dist/src/aws-B2Jqbnet.js +0 -2433
  486. package/dist/src/aws-DHtuUIzQ.js +0 -1149
  487. package/dist/src/aws-DLqXP6wY.js +0 -2433
  488. package/dist/src/aws-DfduhmwL.cjs +0 -2454
  489. package/dist/src/base-B9L2Xvpc.js +0 -255
  490. package/dist/src/base-BTZnIsuH.cjs +0 -305
  491. package/dist/src/base-BhaWNQPJ.js +0 -462
  492. package/dist/src/base-Br-G_Xou.js +0 -256
  493. package/dist/src/base-Bzo8hiUS.cjs +0 -467
  494. package/dist/src/base-C82fd2jq.js +0 -463
  495. package/dist/src/base-CRdQwC1W.js +0 -462
  496. package/dist/src/base-CjGwZNOQ.js +0 -255
  497. package/dist/src/bedrock-BdMru_ro.js +0 -1300
  498. package/dist/src/bedrock-CBUmfLX1.cjs +0 -2
  499. package/dist/src/bedrock-DBDxBaF9.js +0 -2
  500. package/dist/src/bedrock-DDrECM21.js +0 -1
  501. package/dist/src/bedrock-DVwkgvRS.js +0 -1
  502. package/dist/src/bestOfN-AKF5beq4.js +0 -159
  503. package/dist/src/bestOfN-C1UIVGJV.js +0 -160
  504. package/dist/src/bestOfN-DlkETbXy.cjs +0 -161
  505. package/dist/src/bestOfN-XIfEgU-g.js +0 -159
  506. package/dist/src/cache-BZaVoKaA.js +0 -2
  507. package/dist/src/cache-CEYhFUsH.js +0 -741
  508. package/dist/src/cache-Cbw1zH6q.js +0 -782
  509. package/dist/src/cache-CdaZNb75.js +0 -754
  510. package/dist/src/cache-DpuIzPxh.cjs +0 -856
  511. package/dist/src/cerebras-Bpn6FPkJ.js +0 -97
  512. package/dist/src/cerebras-CqJ0BRCJ.cjs +0 -97
  513. package/dist/src/cerebras-D4ILa_TY.js +0 -97
  514. package/dist/src/cerebras-DR8uc7ee.js +0 -98
  515. package/dist/src/chat-B7PZfaYp.cjs +0 -987
  516. package/dist/src/chat-BVuSjdEb.js +0 -227
  517. package/dist/src/chat-BsaZRjXN.js +0 -76
  518. package/dist/src/chat-C5liqe3Y.js +0 -226
  519. package/dist/src/chat-C9hyHf5B.js +0 -124
  520. package/dist/src/chat-CFLalAck.js +0 -226
  521. package/dist/src/chat-CN8JGrHu.js +0 -76
  522. package/dist/src/chat-CaHBBpCb.js +0 -123
  523. package/dist/src/chat-CcbLSghx.js +0 -123
  524. package/dist/src/chat-CoSN6sr2.js +0 -934
  525. package/dist/src/chat-CsJRFX8a.cjs +0 -226
  526. package/dist/src/chat-DFoZLvO_.js +0 -934
  527. package/dist/src/chat-DiLQvL7r.js +0 -77
  528. package/dist/src/chat-F6qVSDk3.cjs +0 -123
  529. package/dist/src/chat-Oq4FaJgI.cjs +0 -76
  530. package/dist/src/chat-knMfQUKz.js +0 -935
  531. package/dist/src/claude-agent-sdk-CJkOLpnI.js +0 -999
  532. package/dist/src/claude-agent-sdk-Ckn76PRD.js +0 -999
  533. package/dist/src/claude-agent-sdk-DX0gTr11.cjs +0 -1005
  534. package/dist/src/claude-agent-sdk-LMeikxoR.js +0 -1000
  535. package/dist/src/client-BFf1r6Z8.js +0 -352
  536. package/dist/src/client-CdXyDdDi.js +0 -351
  537. package/dist/src/client-DV8XMu7i.js +0 -351
  538. package/dist/src/client-iEXtOBKW.cjs +0 -357
  539. package/dist/src/cloud-B02qcpjf.js +0 -2
  540. package/dist/src/cloud-BlHP-g1v.cjs +0 -666
  541. package/dist/src/cloud-C9BI4isF.js +0 -287
  542. package/dist/src/cloud-CTTLNdvj.js +0 -657
  543. package/dist/src/cloud-D5X5yQ_d.js +0 -599
  544. package/dist/src/cloud-QxPkpsHA.js +0 -599
  545. package/dist/src/cloudflare-ai-DRTRT1fc.js +0 -132
  546. package/dist/src/cloudflare-ai-DgaXapAV.cjs +0 -133
  547. package/dist/src/cloudflare-ai-DkuJXijS.js +0 -134
  548. package/dist/src/cloudflare-ai-wy9QCHku.js +0 -133
  549. package/dist/src/cloudflare-gateway-9cAN8g29.cjs +0 -276
  550. package/dist/src/cloudflare-gateway-BVFMD292.js +0 -277
  551. package/dist/src/cloudflare-gateway-BuUI4p6I.js +0 -276
  552. package/dist/src/cloudflare-gateway-TlYHizbW.js +0 -276
  553. package/dist/src/codex-app-server-BPz_feug.cjs +0 -2162
  554. package/dist/src/codex-app-server-C9noXM9C.js +0 -2155
  555. package/dist/src/codex-app-server-CEmD-Y5U.js +0 -2
  556. package/dist/src/codex-app-server-DZolc18r.js +0 -2156
  557. package/dist/src/codex-app-server-Dd0A37nO.js +0 -2155
  558. package/dist/src/codex-sdk-BbxjBvBk.cjs +0 -1588
  559. package/dist/src/codex-sdk-BpXeIs-_.js +0 -1557
  560. package/dist/src/codex-sdk-BtQp5X0f.js +0 -1552
  561. package/dist/src/codex-sdk-CH0v9Bk1.js +0 -2
  562. package/dist/src/codex-sdk-CgrN7JB8.js +0 -1557
  563. package/dist/src/codex-security-B5fENNUr.js +0 -406
  564. package/dist/src/codex-security-C6uuJx-y.cjs +0 -411
  565. package/dist/src/codex-security-CifWtZR_.js +0 -407
  566. package/dist/src/codex-security-Kg2bOEKy.js +0 -406
  567. package/dist/src/cometapi-BFpIDLIx.js +0 -55
  568. package/dist/src/cometapi-C6O2PIrN.js +0 -56
  569. package/dist/src/cometapi-D5Yupc6F.js +0 -53
  570. package/dist/src/cometapi-DzgIwJzJ.cjs +0 -55
  571. package/dist/src/compatible-0jhmVfOp.js +0 -25
  572. package/dist/src/compatible-DdtwWdJi.cjs +0 -24
  573. package/dist/src/compatible-Di4nR3sU.js +0 -24
  574. package/dist/src/compatible-iJKLWdnf.js +0 -24
  575. package/dist/src/completion-B0_hVUDG.js +0 -119
  576. package/dist/src/completion-BdI6v0-Q.cjs +0 -123
  577. package/dist/src/completion-CWcJscwv.js +0 -118
  578. package/dist/src/conversationScoring-99EOPJRa.js +0 -373
  579. package/dist/src/conversationScoring-BIq4J0Cq.js +0 -374
  580. package/dist/src/conversationScoring-DARyeATr.cjs +0 -398
  581. package/dist/src/conversationScoring-DS48t4Hb.js +0 -373
  582. package/dist/src/crescendo-CebvXIu4.js +0 -730
  583. package/dist/src/crescendo-CxrLS0oo.js +0 -732
  584. package/dist/src/crescendo-DZQXBSkj.js +0 -733
  585. package/dist/src/crescendo-wjEx68uD.cjs +0 -734
  586. package/dist/src/custom-BiQ-aUNw.cjs +0 -620
  587. package/dist/src/custom-ByyB5Z93.js +0 -619
  588. package/dist/src/custom-C5jOevNb.js +0 -617
  589. package/dist/src/custom-CCrsCz8o.js +0 -618
  590. package/dist/src/dataUrl-C9J7wz9H.js +0 -3133
  591. package/dist/src/dataUrl-CGsBT7UZ.cjs +0 -3187
  592. package/dist/src/dataUrl-CzKvvWNO.js +0 -2868
  593. package/dist/src/decisions-BTusXCUx.cjs +0 -514
  594. package/dist/src/decisions-BYtL9edD.js +0 -515
  595. package/dist/src/decisions-jYix_gCF.js +0 -515
  596. package/dist/src/decisions-nxxfHRAN.js +0 -516
  597. package/dist/src/docker-DDIv4zkg.js +0 -93
  598. package/dist/src/docker-DVLp_5OG.js +0 -94
  599. package/dist/src/docker-INm9w0SY.cjs +0 -94
  600. package/dist/src/docker-sGuoCul_.js +0 -95
  601. package/dist/src/embedding-CAhqLLrR.js +0 -82
  602. package/dist/src/embedding-D94GAsti.cjs +0 -86
  603. package/dist/src/embedding-zb4MAzQy.js +0 -81
  604. package/dist/src/envoy-BMPszwEa.cjs +0 -60
  605. package/dist/src/envoy-Bp-s39_8.js +0 -60
  606. package/dist/src/envoy-BswDt-Ou.js +0 -61
  607. package/dist/src/envoy-rVbYcV80.js +0 -60
  608. package/dist/src/eval-B1-XfrC7.js +0 -2
  609. package/dist/src/eval-pC4qCvLw.js +0 -1920
  610. package/dist/src/evalResult-CzjCb5bd.js +0 -1300
  611. package/dist/src/evaluator-CNq2K7J_.js +0 -10578
  612. package/dist/src/evaluator-LtfxdxEu.js +0 -2
  613. package/dist/src/evaluatorHelpers-C5J0NYpQ.js +0 -601
  614. package/dist/src/evaluatorHelpers-DcdCglCs.cjs +0 -622
  615. package/dist/src/evaluatorHelpers-Rvb88W6B.js +0 -600
  616. package/dist/src/fetch-5HtnNhHg.js +0 -1556
  617. package/dist/src/fetch-BCwjoIFd.js +0 -1559
  618. package/dist/src/fetch-BhfUnKen.js +0 -1280
  619. package/dist/src/fetch-C08w4vVl.js +0 -9
  620. package/dist/src/fetch-DBxy8Tlb.cjs +0 -14
  621. package/dist/src/fetch-DYte6oQX.cjs +0 -1853
  622. package/dist/src/fetch-ElpfcAVG.js +0 -10
  623. package/dist/src/fetch-lM1OIaSt.js +0 -2
  624. package/dist/src/functionCallbackUtils-BCAdWfHO.js +0 -246
  625. package/dist/src/functionCallbackUtils-BYq9qOhG.js +0 -245
  626. package/dist/src/functionCallbackUtils-ByWkmVud.cjs +0 -262
  627. package/dist/src/functionCallbackUtils-D_C_JaFd.js +0 -245
  628. package/dist/src/gemini-image-CAlwaJhZ.js +0 -471
  629. package/dist/src/gemini-image-DJoVoOnZ.cjs +0 -471
  630. package/dist/src/gemini-image-Waio-9Xx.js +0 -472
  631. package/dist/src/gemini-image-vbY6Ftbf.js +0 -471
  632. package/dist/src/goat-BWbtyY9c.js +0 -512
  633. package/dist/src/goat-CXzzeCOQ.cjs +0 -515
  634. package/dist/src/goat-CfgvzSgZ.js +0 -514
  635. package/dist/src/goat-DLeoIHBp.js +0 -515
  636. package/dist/src/goblin-CmfCfwqk.cjs +0 -22
  637. package/dist/src/goblin-CtcaORRH.js +0 -22
  638. package/dist/src/goblin-DF6DDhM-.js +0 -22
  639. package/dist/src/goblin-Nai0xxBV.js +0 -23
  640. package/dist/src/google-ClpkLtKL.cjs +0 -142
  641. package/dist/src/google-CrFgKu9k.js +0 -143
  642. package/dist/src/google-Dj_EIBqS.js +0 -142
  643. package/dist/src/google-e4-vARv6.js +0 -142
  644. package/dist/src/graders-BN1IIa71.js +0 -15470
  645. package/dist/src/graders-C5sCfSP5.js +0 -2
  646. package/dist/src/hydra-B7RfXVBK.js +0 -2
  647. package/dist/src/hydra-C1cFN-Jg.js +0 -613
  648. package/dist/src/hydra-CK6Uc1ia.js +0 -612
  649. package/dist/src/hydra-Dg65rAP_.js +0 -610
  650. package/dist/src/hydra-Fqx8l_Xu.cjs +0 -612
  651. package/dist/src/image-BdlUDAtp.js +0 -163
  652. package/dist/src/image-C-KwEhwt.cjs +0 -163
  653. package/dist/src/image-C76fp6NK.cjs +0 -209
  654. package/dist/src/image-D75ehv3D.js +0 -482
  655. package/dist/src/image-DKtc5v5W.js +0 -209
  656. package/dist/src/image-DT_xOkJY.js +0 -163
  657. package/dist/src/image-DVpdllEE.js +0 -209
  658. package/dist/src/image-DXZ8AzMf.js +0 -481
  659. package/dist/src/image-DZl_1mvy.js +0 -164
  660. package/dist/src/image-DcTD7Ak0.cjs +0 -504
  661. package/dist/src/image-ndxEvBKB.js +0 -210
  662. package/dist/src/indirectWebPwn-70WA5x_q.js +0 -435
  663. package/dist/src/indirectWebPwn-BRVyd3qV.cjs +0 -463
  664. package/dist/src/indirectWebPwn-BsJVsu0q.js +0 -285
  665. package/dist/src/indirectWebPwn-Cw6yJu0i.js +0 -285
  666. package/dist/src/indirectWebPwn-D-PhJzo4.js +0 -286
  667. package/dist/src/indirectWebPwn-DRPHt2I8.js +0 -434
  668. package/dist/src/indirectWebPwn-DXtfFhd9.cjs +0 -285
  669. package/dist/src/indirectWebPwn-DvpNouzc.js +0 -434
  670. package/dist/src/interactions-5ixfW7Cl.js +0 -850
  671. package/dist/src/interactions-BOUzfmg1.cjs +0 -850
  672. package/dist/src/interactions-CSSXcGNc.js +0 -851
  673. package/dist/src/interactions-WB_sgkN0.js +0 -850
  674. package/dist/src/iterative-BShRNqjC.cjs +0 -549
  675. package/dist/src/iterative-BcW_ELtB.js +0 -548
  676. package/dist/src/iterative-BpHbHz8B.js +0 -547
  677. package/dist/src/iterative-YcchP12d.js +0 -545
  678. package/dist/src/iterativeImage-BMFE5Hl7.cjs +0 -419
  679. package/dist/src/iterativeImage-CkSaYLMY.js +0 -417
  680. package/dist/src/iterativeImage-DAEUlQX_.js +0 -418
  681. package/dist/src/iterativeImage-DeUSkEnj.js +0 -417
  682. package/dist/src/iterativeMeta-DbdaKdEO.cjs +0 -439
  683. package/dist/src/iterativeMeta-DcF9JWEK.js +0 -437
  684. package/dist/src/iterativeMeta-DkfPqWIC.js +0 -439
  685. package/dist/src/iterativeMeta-DkrpnVSs.js +0 -440
  686. package/dist/src/iterativeTree-CEMY1FhE.cjs +0 -879
  687. package/dist/src/iterativeTree-Cv5W4tX9.js +0 -877
  688. package/dist/src/iterativeTree-DGvomd3M.js +0 -876
  689. package/dist/src/iterativeTree-KbtC2Mkz.js +0 -878
  690. package/dist/src/knowledgeBase-AYRXn4wO.js +0 -163
  691. package/dist/src/knowledgeBase-BNqQfx01.js +0 -163
  692. package/dist/src/knowledgeBase-C0IaCCVs.js +0 -164
  693. package/dist/src/knowledgeBase-C2uj6wK4.cjs +0 -163
  694. package/dist/src/litellm-CN1ScAwZ.js +0 -147
  695. package/dist/src/litellm-CTjwiKSa.js +0 -146
  696. package/dist/src/litellm-Cd4Nj5ue.js +0 -145
  697. package/dist/src/litellm-DMqLpEBg.cjs +0 -146
  698. package/dist/src/live-Bt50-InO.cjs +0 -891
  699. package/dist/src/live-Bu2ujadG.js +0 -2
  700. package/dist/src/live-C3M52i3p.js +0 -891
  701. package/dist/src/live-CRfHMO3B.js +0 -892
  702. package/dist/src/live-iCIpO14m.js +0 -891
  703. package/dist/src/luma-ray-B8eHC4c8.cjs +0 -309
  704. package/dist/src/luma-ray-BIvkPw0s.js +0 -309
  705. package/dist/src/luma-ray-ChsiBxMA.js +0 -309
  706. package/dist/src/luma-ray-DAvKrInz.js +0 -310
  707. package/dist/src/mantleChat-5YeEXAZI.js +0 -154
  708. package/dist/src/mantleChat-D--mW3hl.js +0 -154
  709. package/dist/src/mantleChat-DHP3siNg.cjs +0 -154
  710. package/dist/src/mantleChat-wBfAX46o.js +0 -155
  711. package/dist/src/mcp-49jlEcTQ.js +0 -85
  712. package/dist/src/mcp-__PIz81I.js +0 -84
  713. package/dist/src/memoryPoisoning-Chxge74M.js +0 -111
  714. package/dist/src/memoryPoisoning-QH6NCUVE.js +0 -112
  715. package/dist/src/memoryPoisoning-tCxZt8Nz.js +0 -111
  716. package/dist/src/memoryPoisoning-ymrRItRR.cjs +0 -111
  717. package/dist/src/messages-BE_eZ7NA.js +0 -1127
  718. package/dist/src/messages-Bo638ShI.js +0 -1127
  719. package/dist/src/messages-BzR0-NQ1.js +0 -1128
  720. package/dist/src/messages-Cbg5Pfd0.cjs +0 -1161
  721. package/dist/src/mischievousUser-BtED2Z5Z.cjs +0 -51
  722. package/dist/src/mischievousUser-KqSOjrDJ.js +0 -51
  723. package/dist/src/mischievousUser-YMD41YNZ.js +0 -51
  724. package/dist/src/mischievousUser-zBxlNdCu.js +0 -52
  725. package/dist/src/modelslab-B8gZxtfE.js +0 -171
  726. package/dist/src/modelslab-C7bmVpTB.js +0 -170
  727. package/dist/src/modelslab-CCeQCTZg.js +0 -170
  728. package/dist/src/modelslab-CvBJGv7y.cjs +0 -170
  729. package/dist/src/nova-reel-BOEWsEKA.cjs +0 -272
  730. package/dist/src/nova-reel-BtyBXq5M.js +0 -273
  731. package/dist/src/nova-reel-C1eF3-EE.js +0 -272
  732. package/dist/src/nova-reel-YhgrxEKT.js +0 -272
  733. package/dist/src/nova-sonic-BaERP20w.js +0 -374
  734. package/dist/src/nova-sonic-CxgM3O-P.cjs +0 -374
  735. package/dist/src/nova-sonic-DJS22fC3.js +0 -375
  736. package/dist/src/nova-sonic-DwvwHyRX.js +0 -374
  737. package/dist/src/novita-D1l2tG0O.js +0 -116
  738. package/dist/src/novita-D84VM3v0.cjs +0 -115
  739. package/dist/src/novita-DGInvwfR.js +0 -115
  740. package/dist/src/novita-vXHkXhTg.js +0 -114
  741. package/dist/src/nscale-CU0Ldr00.js +0 -209
  742. package/dist/src/nscale-ClfKlQeM.cjs +0 -209
  743. package/dist/src/nscale-DxaVnF0x.js +0 -210
  744. package/dist/src/nscale-_poVxIrO.js +0 -207
  745. package/dist/src/openaiResponses-CJGsneNj.js +0 -317
  746. package/dist/src/openaiResponses-CKSl5Sdg.js +0 -319
  747. package/dist/src/openaiResponses-DC8rzFUc.js +0 -318
  748. package/dist/src/openaiResponses-rMHIA3dV.cjs +0 -318
  749. package/dist/src/openclaw-CCbvsNFW.cjs +0 -1344
  750. package/dist/src/openclaw-CZw1lCDZ.js +0 -1336
  751. package/dist/src/openclaw-ChFLgC-a.js +0 -1338
  752. package/dist/src/openclaw-DrPMoRrH.js +0 -1337
  753. package/dist/src/opencode-sdk-2EfIDhFp.cjs +0 -1018
  754. package/dist/src/opencode-sdk-CHw3F845.js +0 -1013
  755. package/dist/src/opencode-sdk-D0EGGxvy.js +0 -1012
  756. package/dist/src/opencode-sdk-jSS7NI2Q.js +0 -1012
  757. package/dist/src/openinterpreter-CY622xHC.js +0 -431
  758. package/dist/src/openinterpreter-DATyhuhP.js +0 -432
  759. package/dist/src/openinterpreter-DDUMyIf1.js +0 -431
  760. package/dist/src/openinterpreter-s5Tz6Lid.cjs +0 -435
  761. package/dist/src/pricing-C498twd2.js +0 -976
  762. package/dist/src/pricing-DBd_bMIh.cjs +0 -999
  763. package/dist/src/pricing-ISrMCskv.js +0 -976
  764. package/dist/src/promptfoo-6p0WG2ih.js +0 -286
  765. package/dist/src/promptfoo-BQRfgNs_.js +0 -285
  766. package/dist/src/promptfoo-Bqo88z20.cjs +0 -341
  767. package/dist/src/promptfoo-Cq5AVI3I.js +0 -286
  768. package/dist/src/providers-ATbeMX5E.cjs +0 -24180
  769. package/dist/src/providers-B7F1FiNI.js +0 -2
  770. package/dist/src/providers-DazIw8mI.js +0 -24039
  771. package/dist/src/providers-QvGlNAD0.js +0 -24437
  772. package/dist/src/quiverai-BPlNcLkV.cjs +0 -325
  773. package/dist/src/quiverai-By99-YmJ.js +0 -325
  774. package/dist/src/quiverai-CmmByDqo.js +0 -325
  775. package/dist/src/quiverai-HZkoJJqw.js +0 -326
  776. package/dist/src/registry-BLTnTfjT.cjs +0 -131
  777. package/dist/src/registry-BMC-COHT.js +0 -132
  778. package/dist/src/registry-C8UZtmBp.js +0 -131
  779. package/dist/src/registry-CfwEUYXG.js +0 -131
  780. package/dist/src/remoteGeneration-Bgg6kC5V.js +0 -370
  781. package/dist/src/remoteGeneration-CKJFE960.cjs +0 -482
  782. package/dist/src/remoteGeneration-DaxwJDKv.js +0 -370
  783. package/dist/src/remoteGeneration-vHMGVKr1.js +0 -371
  784. package/dist/src/responses-BvnyIHrq.js +0 -1099
  785. package/dist/src/responses-CERAgvf-.js +0 -1098
  786. package/dist/src/responses-CwgjeuOg.cjs +0 -1109
  787. package/dist/src/runtimeTransform-3RF9Avyg.cjs +0 -161
  788. package/dist/src/runtimeTransform-C51Z5j4H.js +0 -156
  789. package/dist/src/runtimeTransform-CKE_Iyv8.js +0 -157
  790. package/dist/src/runtimeTransform-Cs11xJpj.js +0 -156
  791. package/dist/src/sagemaker-BJ4dOCxE.js +0 -713
  792. package/dist/src/sagemaker-Bt3JUAWq.js +0 -714
  793. package/dist/src/sagemaker-QVKyLgLF.cjs +0 -716
  794. package/dist/src/sagemaker-l3IB8iTs.js +0 -713
  795. package/dist/src/scanner-DGjIiTZ1.js +0 -1971
  796. package/dist/src/server-BNaLZH6u.js +0 -63
  797. package/dist/src/server-CBMuQul3.js +0 -189
  798. package/dist/src/server-CMKKIzKv.cjs +0 -74
  799. package/dist/src/server-CN2IS9Cs.js +0 -155
  800. package/dist/src/server-ua4cqbjC.js +0 -2
  801. package/dist/src/session-CQIjq_HZ.cjs +0 -69
  802. package/dist/src/session-FTlg8sEu.js +0 -62
  803. package/dist/src/session-GBQXtPWp.js +0 -63
  804. package/dist/src/session-_0-rTdwY.js +0 -62
  805. package/dist/src/shared-BtuO-OAM.js +0 -1927
  806. package/dist/src/shared-Ci78wTZX.js +0 -1928
  807. package/dist/src/shared-Dd3rimdM.js +0 -1929
  808. package/dist/src/shared-KAjFxRre.cjs +0 -2185
  809. package/dist/src/simulatedUser--OjW6xCx.js +0 -247
  810. package/dist/src/simulatedUser-D0-slRye.cjs +0 -252
  811. package/dist/src/simulatedUser-D1Kh_cwA.js +0 -248
  812. package/dist/src/slack-BX0FUevO.js +0 -144
  813. package/dist/src/slack-CcwXFiJE.cjs +0 -144
  814. package/dist/src/slack-CnfqKfXp.js +0 -145
  815. package/dist/src/strategies-2ntcK4tN.js +0 -2248
  816. package/dist/src/strategies-DZIW7Zcs.js +0 -2385
  817. package/dist/src/strategies-YRDF2j-N.cjs +0 -2420
  818. package/dist/src/telemetry-CL8CVA4p.js +0 -205
  819. package/dist/src/telemetry-Cix90qqz.js +0 -201
  820. package/dist/src/telemetry-CkmlqTjV.js +0 -205
  821. package/dist/src/telemetry-DQH7l5bb.js +0 -2
  822. package/dist/src/telemetry-DUCXc1-r.cjs +0 -216
  823. package/dist/src/togetherai-3yUt5Ck7.js +0 -49
  824. package/dist/src/togetherai-BJUByLwt.cjs +0 -49
  825. package/dist/src/togetherai-Bh6KZkmd.js +0 -50
  826. package/dist/src/togetherai-DDl9yk3b.js +0 -48
  827. package/dist/src/traceContext-BiJVppjT.cjs +0 -1032
  828. package/dist/src/traceContext-CKKluULP.js +0 -1016
  829. package/dist/src/traceContext-D3Sk8fO-.js +0 -1015
  830. package/dist/src/transcription-BoVQKIVz.js +0 -175
  831. package/dist/src/transcription-Bs5u8780.js +0 -175
  832. package/dist/src/transcription-Dl654d1p.cjs +0 -178
  833. package/dist/src/transcription-VEvhM1Fu.js +0 -176
  834. package/dist/src/transform-BAbkGpvl.js +0 -125
  835. package/dist/src/transform-C_j4hUH8.js +0 -126
  836. package/dist/src/transform-Da86hs4M.cjs +0 -154
  837. package/dist/src/transform-_i1raQNo.js +0 -125
  838. package/dist/src/typesafe-CKXBeh82.cjs +0 -253
  839. package/dist/src/typesafe-D3VaGeNm.js +0 -253
  840. package/dist/src/typesafe-DYM-SFNH.js +0 -253
  841. package/dist/src/typesafe-LXmSbw8F.js +0 -254
  842. package/dist/src/util-41rb0XHX.js +0 -743
  843. package/dist/src/util-B0WlHYFM.js +0 -2049
  844. package/dist/src/util-BD1R_PsR.js +0 -1770
  845. package/dist/src/util-BLbM_ItC.js +0 -395
  846. package/dist/src/util-C72P0iIa.js +0 -352
  847. package/dist/src/util-C7MpGlJ6.cjs +0 -2305
  848. package/dist/src/util-CCtqagKc.js +0 -286
  849. package/dist/src/util-CM2Ec_uY.js +0 -2051
  850. package/dist/src/util-CSSAWO8v.js +0 -351
  851. package/dist/src/util-CkQc-fx3.cjs +0 -934
  852. package/dist/src/util-DcOlFTFa.cjs +0 -478
  853. package/dist/src/util-DluGTGVB.js +0 -395
  854. package/dist/src/util-PfQ60chz.js +0 -743
  855. package/dist/src/util-f14-CPij.js +0 -396
  856. package/dist/src/util-l9pXX3Eu.cjs +0 -357
  857. package/dist/src/util-o_BnlYqS.js +0 -2050
  858. package/dist/src/vertex-B_-gQgzc.js +0 -2
  859. package/dist/src/vertex-CU4gqoYa.js +0 -854
  860. package/dist/src/vertex-DZ42UHb3.js +0 -848
  861. package/dist/src/vertex-DsYQJA0T.cjs +0 -871
  862. package/dist/src/vertexLive-BvIaHKGB.js +0 -55
  863. package/dist/src/vertexLive-CTULqNx7.js +0 -56
  864. package/dist/src/vertexLive-DjJ_YQBe.cjs +0 -55
  865. package/dist/src/vertexLive-STUGcteB.js +0 -55
  866. package/dist/src/video-CAQGmtEV.js +0 -703
  867. package/dist/src/video-_FSTWlwX.js +0 -702
  868. package/dist/src/video-aBPJPWdt.js +0 -702
  869. package/dist/src/video-gDjkWv5m.cjs +0 -706
@@ -0,0 +1,2162 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ const require_logger = require("./logger-DXUHJBHJ.cjs");
3
+ const require_fetch = require("./fetch-BKlgUg08.cjs");
4
+ const require_render = require("./render-j-UNQw7s.cjs");
5
+ const require_credentials = require("./credentials-CFfK32uY.cjs");
6
+ const require_providerRegistry = require("./providerRegistry-CAn7vpBJ.cjs");
7
+ const require_genaiTracer = require("./genaiTracer-C32xFIB8.cjs");
8
+ const require_agentic_utils = require("./agentic-utils-CBWD_rcd.cjs");
9
+ const require_agenticRunQueue = require("./agenticRunQueue-Cd8lOVSn.cjs");
10
+ const require_agentWorkspace = require("./agentWorkspace-CEomAcws.cjs");
11
+ const require_billing = require("./billing-ZA1NkqAK.cjs");
12
+ const require_codexSkillMetadata = require("./codexSkillMetadata-B5SLnY2i.cjs");
13
+ let zod = require("zod");
14
+ let path = require("path");
15
+ path = require_rolldown_runtime.__toESM(path, 1);
16
+ let fs = require("fs");
17
+ fs = require_rolldown_runtime.__toESM(fs, 1);
18
+ let dedent = require("dedent");
19
+ dedent = require_rolldown_runtime.__toESM(dedent, 1);
20
+ let child_process = require("child_process");
21
+ let _opentelemetry_api = require("@opentelemetry/api");
22
+ let crypto = require("crypto");
23
+ crypto = require_rolldown_runtime.__toESM(crypto, 1);
24
+ let readline = require("readline");
25
+ readline = require_rolldown_runtime.__toESM(readline, 1);
26
+ //#region src/providers/openai/codex-app-server.ts
27
+ function redactAppServerText(value) {
28
+ return value.replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi, require_logger.REDACTED).replace(/\b(?:sk-(?:proj-)?[A-Za-z0-9_-]{20,}|sk-ant-[A-Za-z0-9_-]{20,}|AKIA[A-Z0-9]{16}|AIza[A-Za-z0-9_-]{35}|Bearer\s+[A-Za-z0-9._~+/-]{20,}|Basic\s+[A-Za-z0-9+/=]{20,})\b/g, require_logger.REDACTED).replace(/(\\["'](?:authorization|auth)\\["']\s*[:=]\s*\\["'])(?:bearer|basic)\s+[^\\\s"'`]+(\\["'])/gi, (_match, prefix, suffix) => `${prefix}${require_logger.REDACTED}${suffix}`).replace(/\b(authorization|auth)(["']?)\s*([=:])(\s*)(["']?)(?:bearer|basic)\s+[^\s"'`]+(\5)/gi, (_match, key, keyQuote, separator, spacing, quote) => `${key}${keyQuote}${separator}${spacing}${quote}${require_logger.REDACTED}${quote}`).replace(/\b(api[_-]?key|token|password|secret|authorization|auth)(["']?)\s*([=:])(\s*)(["']?)[^\s"'`]+(\5)/gi, (_match, key, keyQuote, separator, spacing, quote) => `${key}${keyQuote}${separator}${spacing}${quote}${require_logger.REDACTED}${quote}`);
29
+ }
30
+ const MAX_BUFFERED_JSON_RPC_CHARS = 5e6;
31
+ const MAX_BUFFERED_TURN_EVENT_CHARS = 1e7;
32
+ const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
33
+ const DEFAULT_STARTUP_TIMEOUT_MS = 3e4;
34
+ const CodexCliEnvValueSchema = zod.z.union([
35
+ zod.z.string(),
36
+ zod.z.number(),
37
+ zod.z.boolean()
38
+ ]).transform(String);
39
+ const CodexAppServerReasoningEffortSchema = zod.z.enum([
40
+ "none",
41
+ "minimal",
42
+ "low",
43
+ "medium",
44
+ "high",
45
+ "xhigh",
46
+ "max",
47
+ "ultra"
48
+ ]);
49
+ const CodexAppServerGranularApprovalPolicySchema = zod.z.object({ granular: zod.z.object({
50
+ sandbox_approval: zod.z.boolean(),
51
+ rules: zod.z.boolean(),
52
+ skill_approval: zod.z.boolean(),
53
+ request_permissions: zod.z.boolean(),
54
+ mcp_elicitations: zod.z.boolean()
55
+ }).strict() }).strict();
56
+ const CodexAppServerApprovalPolicySchema = zod.z.union([zod.z.enum([
57
+ "never",
58
+ "on-request",
59
+ "on-failure",
60
+ "untrusted"
61
+ ]), CodexAppServerGranularApprovalPolicySchema]);
62
+ const CommandExecutionApprovalDecisionSchema = zod.z.union([
63
+ zod.z.enum([
64
+ "accept",
65
+ "acceptForSession",
66
+ "decline",
67
+ "cancel"
68
+ ]),
69
+ zod.z.object({ acceptWithExecpolicyAmendment: zod.z.object({ execpolicy_amendment: zod.z.array(zod.z.string()) }).strict() }).strict(),
70
+ zod.z.object({ applyNetworkPolicyAmendment: zod.z.object({ network_policy_amendment: zod.z.object({
71
+ host: zod.z.string().min(1),
72
+ action: zod.z.enum(["allow", "deny"])
73
+ }).strict() }).strict() }).strict()
74
+ ]);
75
+ const McpElicitationPolicySchema = zod.z.union([zod.z.enum([
76
+ "accept",
77
+ "decline",
78
+ "cancel"
79
+ ]), zod.z.object({
80
+ action: zod.z.enum([
81
+ "accept",
82
+ "decline",
83
+ "cancel"
84
+ ]),
85
+ content: zod.z.unknown().optional(),
86
+ _meta: zod.z.unknown().optional()
87
+ }).strict()]);
88
+ const CollaborationModeSchema = zod.z.object({
89
+ mode: zod.z.enum(["plan", "default"]),
90
+ settings: zod.z.object({
91
+ model: zod.z.string().min(1),
92
+ reasoning_effort: CodexAppServerReasoningEffortSchema.nullable(),
93
+ developer_instructions: zod.z.string().nullable()
94
+ }).strict()
95
+ }).strict();
96
+ const ServerRequestPolicySchema = zod.z.object({
97
+ command_execution: CommandExecutionApprovalDecisionSchema.optional(),
98
+ file_change: zod.z.enum([
99
+ "accept",
100
+ "acceptForSession",
101
+ "decline",
102
+ "cancel"
103
+ ]).optional(),
104
+ permissions: zod.z.object({
105
+ permissions: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
106
+ scope: zod.z.enum(["turn", "session"]).optional(),
107
+ strict_auto_review: zod.z.boolean().nullable().optional()
108
+ }).optional(),
109
+ user_input: zod.z.union([zod.z.enum(["empty", "first-option"]), zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]))]).optional(),
110
+ mcp_elicitation: McpElicitationPolicySchema.optional(),
111
+ dynamic_tools: zod.z.record(zod.z.string(), zod.z.object({
112
+ success: zod.z.boolean().optional(),
113
+ text: zod.z.string().optional(),
114
+ contentItems: zod.z.array(zod.z.union([zod.z.object({
115
+ type: zod.z.literal("inputText"),
116
+ text: zod.z.string()
117
+ }), zod.z.object({
118
+ type: zod.z.literal("inputImage"),
119
+ imageUrl: zod.z.string()
120
+ })])).optional()
121
+ })).optional()
122
+ }).strict();
123
+ const CodexAppServerConfigShape = {
124
+ basePath: zod.z.string().optional(),
125
+ prefix: zod.z.string().optional(),
126
+ suffix: zod.z.string().optional(),
127
+ provider: zod.z.unknown().optional(),
128
+ linkedTargetId: zod.z.string().optional(),
129
+ apiKey: zod.z.string().min(1).optional(),
130
+ base_url: zod.z.string().min(1).optional(),
131
+ working_dir: zod.z.string().min(1).optional(),
132
+ additional_directories: zod.z.array(zod.z.string().min(1)).optional(),
133
+ skip_git_repo_check: zod.z.boolean().optional(),
134
+ codex_path_override: zod.z.string().min(1).optional(),
135
+ model: zod.z.string().min(1).optional(),
136
+ model_provider: zod.z.string().min(1).optional(),
137
+ service_tier: zod.z.enum(["fast", "flex"]).optional(),
138
+ sandbox_mode: zod.z.enum([
139
+ "read-only",
140
+ "workspace-write",
141
+ "danger-full-access"
142
+ ]).optional(),
143
+ sandbox_policy: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
144
+ network_access_enabled: zod.z.boolean().optional(),
145
+ approval_policy: CodexAppServerApprovalPolicySchema.optional(),
146
+ approvals_reviewer: zod.z.enum([
147
+ "user",
148
+ "auto_review",
149
+ "guardian_subagent"
150
+ ]).optional(),
151
+ model_reasoning_effort: CodexAppServerReasoningEffortSchema.optional(),
152
+ reasoning_summary: zod.z.enum([
153
+ "auto",
154
+ "concise",
155
+ "detailed",
156
+ "none"
157
+ ]).optional(),
158
+ personality: zod.z.enum([
159
+ "none",
160
+ "friendly",
161
+ "pragmatic"
162
+ ]).optional(),
163
+ base_instructions: zod.z.string().min(1).optional(),
164
+ developer_instructions: zod.z.string().min(1).optional(),
165
+ collaboration_mode: CollaborationModeSchema.optional(),
166
+ output_schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
167
+ thread_id: zod.z.string().min(1).optional(),
168
+ persist_threads: zod.z.boolean().optional(),
169
+ thread_pool_size: zod.z.number().int().positive().optional(),
170
+ thread_cleanup: zod.z.enum([
171
+ "unsubscribe",
172
+ "archive",
173
+ "none"
174
+ ]).optional(),
175
+ ephemeral: zod.z.boolean().optional(),
176
+ persist_extended_history: zod.z.boolean().optional(),
177
+ experimental_raw_events: zod.z.boolean().optional(),
178
+ experimental_api: zod.z.boolean().optional(),
179
+ include_raw_events: zod.z.boolean().optional(),
180
+ cli_config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
181
+ cli_env: zod.z.record(zod.z.string(), CodexCliEnvValueSchema).optional(),
182
+ inherit_process_env: zod.z.boolean().optional(),
183
+ reuse_server: zod.z.boolean().optional(),
184
+ deep_tracing: zod.z.boolean().optional(),
185
+ request_timeout_ms: zod.z.number().int().positive().optional(),
186
+ startup_timeout_ms: zod.z.number().int().positive().optional(),
187
+ turn_timeout_ms: zod.z.number().int().positive().optional(),
188
+ server_request_policy: ServerRequestPolicySchema.optional()
189
+ };
190
+ const CodexAppServerConfigSchema = zod.z.object(CodexAppServerConfigShape).strict();
191
+ const CodexAppServerMergedPromptConfigSchema = zod.z.object(CodexAppServerConfigShape).strip();
192
+ function createDeferred() {
193
+ let resolve;
194
+ let reject;
195
+ return {
196
+ promise: new Promise((promiseResolve, promiseReject) => {
197
+ resolve = promiseResolve;
198
+ reject = promiseReject;
199
+ }),
200
+ resolve,
201
+ reject
202
+ };
203
+ }
204
+ function parseCodexAppServerConfig(config, options = {}) {
205
+ const schema = options.stripUnknownKeys ? CodexAppServerMergedPromptConfigSchema : CodexAppServerConfigSchema;
206
+ try {
207
+ return schema.parse(config ?? {});
208
+ } catch (error) {
209
+ if (error instanceof zod.z.ZodError) {
210
+ const issues = error.issues.map((issue) => {
211
+ return `${issue.path.length > 0 ? issue.path.join(".") : "(root)"}: ${issue.message}`;
212
+ }).join("; ");
213
+ throw new Error(`Invalid OpenAI Codex app-server config: ${issues}`);
214
+ }
215
+ throw error;
216
+ }
217
+ }
218
+ function mergeOptionalRecord(base, override) {
219
+ if (!base && !override) return;
220
+ return {
221
+ ...base ?? {},
222
+ ...override ?? {}
223
+ };
224
+ }
225
+ function mergeServerRequestPolicy(base, override) {
226
+ if (!base && !override) return;
227
+ const merged = {
228
+ ...base ?? {},
229
+ ...override ?? {}
230
+ };
231
+ const permissions = mergeOptionalRecord(base?.permissions, override?.permissions);
232
+ const dynamicTools = mergeOptionalRecord(base?.dynamic_tools, override?.dynamic_tools);
233
+ if (permissions) merged.permissions = permissions;
234
+ else delete merged.permissions;
235
+ if (dynamicTools) merged.dynamic_tools = dynamicTools;
236
+ else delete merged.dynamic_tools;
237
+ return merged;
238
+ }
239
+ function mergeCodexAppServerConfig(base, override) {
240
+ if (!override) return { ...base };
241
+ return {
242
+ ...base,
243
+ ...override,
244
+ cli_config: mergeOptionalRecord(base.cli_config, override.cli_config),
245
+ cli_env: mergeOptionalRecord(base.cli_env, override.cli_env),
246
+ server_request_policy: mergeServerRequestPolicy(base.server_request_policy, override.server_request_policy)
247
+ };
248
+ }
249
+ function isPlainObject(value) {
250
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
251
+ }
252
+ function flattenConfig(value, prefix = "") {
253
+ const entries = [];
254
+ for (const [key, entryValue] of Object.entries(value)) {
255
+ const nextKey = prefix ? `${prefix}.${key}` : key;
256
+ if (isPlainObject(entryValue)) entries.push(...flattenConfig(entryValue, nextKey));
257
+ else if (entryValue !== void 0) entries.push({
258
+ key: nextKey,
259
+ value: entryValue
260
+ });
261
+ }
262
+ return entries;
263
+ }
264
+ function getCodexTraceExporterSettings(config) {
265
+ if (!isPlainObject(config)) return;
266
+ const entries = new Map(flattenConfig(config).map(({ key, value }) => [key, value]));
267
+ for (const exporter of ["otlp-http", "otlp-grpc"]) {
268
+ const prefix = `otel.trace_exporter.${exporter}`;
269
+ const endpoint = entries.get(`${prefix}.endpoint`);
270
+ if (typeof endpoint !== "string" || endpoint.length === 0) continue;
271
+ const protocol = entries.get(`${prefix}.protocol`);
272
+ return {
273
+ endpoint,
274
+ ...typeof protocol === "string" && { protocol },
275
+ endpointConfigKey: `${prefix}.endpoint`,
276
+ protocolConfigKey: `${prefix}.protocol`
277
+ };
278
+ }
279
+ }
280
+ function getCodexTraceExporterValue(config) {
281
+ if (!isPlainObject(config)) return;
282
+ if ("otel.trace_exporter" in config) return config["otel.trace_exporter"];
283
+ const otel = config.otel;
284
+ return isPlainObject(otel) ? otel.trace_exporter : void 0;
285
+ }
286
+ function getCodexConfigOriginType(origins, key) {
287
+ if (!isPlainObject(origins)) return;
288
+ const origin = origins[key];
289
+ if (!isPlainObject(origin)) return;
290
+ const name = origin.name;
291
+ if (typeof name === "string") return name;
292
+ if (isPlainObject(name) && typeof name.type === "string") return name.type;
293
+ return typeof origin.source === "string" ? origin.source : void 0;
294
+ }
295
+ function getSafeTraceExporterOrigin(endpoint) {
296
+ try {
297
+ return new URL(endpoint).origin;
298
+ } catch {
299
+ return "[invalid exporter endpoint]";
300
+ }
301
+ }
302
+ function toTomlLiteral(value) {
303
+ if (typeof value === "string") return JSON.stringify(value);
304
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
305
+ if (Array.isArray(value)) return `[${value.map((item) => toTomlLiteral(item)).join(", ")}]`;
306
+ if (value === null) return "\"\"";
307
+ return JSON.stringify(value);
308
+ }
309
+ function getJsonRpcErrorMessage(message) {
310
+ if (typeof message.error?.message === "string" && message.error.message) return message.error.message;
311
+ return "Unknown app-server error";
312
+ }
313
+ var JsonRpcError = class extends Error {
314
+ code;
315
+ constructor(message, code) {
316
+ super(message);
317
+ this.name = "JsonRpcError";
318
+ this.code = code;
319
+ }
320
+ };
321
+ var StaleExplicitThreadConnectionClosedError = class extends Error {
322
+ constructor() {
323
+ super("stale explicit-thread cleanup closed the current app-server connection");
324
+ this.name = "StaleExplicitThreadConnectionClosedError";
325
+ }
326
+ };
327
+ function isMethodNotFoundError(error) {
328
+ return error instanceof JsonRpcError && error.code === -32601;
329
+ }
330
+ /** Find npm's entrypoint only when Windows cannot launch a native Codex binary. */
331
+ function getCodexNpmEntrypoint(env) {
332
+ const pathKey = Object.keys(env).sort().find((key) => key.toUpperCase() === "PATH");
333
+ const directories = ((pathKey ? env[pathKey] : Object.entries(process.env).find(([key]) => key.toUpperCase() === "PATH")?.[1] ?? "").match(new RegExp(`(?:"[^"]*(?:"|$)|'[^']*(?:'|$)|[^${path.default.delimiter}]+)[^${path.default.delimiter}]*`, "g")) ?? []).map((directory) => directory.replace(/^["']|["']$/g, ""));
334
+ if ((!Object.keys(process.env).some((key) => key.toUpperCase() === "NODEFAULTCURRENTDIRECTORYINEXEPATH") ? [process.cwd(), ...directories] : directories).some((directory) => ["codex.com", "codex.exe"].some((file) => fs.default.existsSync(path.default.resolve(process.cwd(), directory, file))))) return;
335
+ const binDirectory = directories.find((directory) => path.default.isAbsolute(directory) && fs.default.existsSync(path.default.join(directory, "codex.cmd")));
336
+ if (!binDirectory) return;
337
+ const nodeModulesDirectory = path.default.basename(binDirectory).toLowerCase() === ".bin" ? path.default.dirname(binDirectory) : path.default.join(binDirectory, "node_modules");
338
+ const entrypoint = path.default.join(nodeModulesDirectory, "@openai", "codex", "bin", "codex.js");
339
+ return fs.default.existsSync(entrypoint) ? entrypoint : void 0;
340
+ }
341
+ var CodexAppServerConnection = class {
342
+ options;
343
+ instanceId;
344
+ process;
345
+ lineInterface;
346
+ nextRequestId = 1;
347
+ pending = /* @__PURE__ */ new Map();
348
+ closed = false;
349
+ stderrChunks = [];
350
+ stderrTotalLength = 0;
351
+ bufferedJsonRpcLines = [];
352
+ closePromise = null;
353
+ constructor(options) {
354
+ this.options = options;
355
+ this.instanceId = options.connectionInstanceId;
356
+ this.process = (0, child_process.spawn)(options.command, options.args, {
357
+ env: options.env,
358
+ stdio: [
359
+ "pipe",
360
+ "pipe",
361
+ "pipe"
362
+ ]
363
+ });
364
+ this.lineInterface = readline.default.createInterface({ input: this.process.stdout });
365
+ this.lineInterface.on("line", (line) => this.handleLine(line));
366
+ this.process.stderr.on("data", (chunk) => this.recordStderr(chunk));
367
+ this.process.stdin.on("error", (error) => {
368
+ require_logger.logger.debug("[CodexAppServer] stdin error", { error: error.message });
369
+ });
370
+ this.process.on("error", (error) => this.handleProcessFailure(error));
371
+ this.process.on("exit", (code, signal) => {
372
+ if (this.closed) this.rejectPending(/* @__PURE__ */ new Error("codex app-server process closed"));
373
+ else this.handleProcessFailure(/* @__PURE__ */ new Error(`codex app-server exited with code ${code ?? "null"} signal ${signal ?? "null"}`));
374
+ });
375
+ }
376
+ isClosed() {
377
+ return this.closed;
378
+ }
379
+ async initialize(config) {
380
+ await this.request("initialize", {
381
+ clientInfo: {
382
+ name: "promptfoo_codex_app_server",
383
+ title: "Promptfoo Codex App Server Provider",
384
+ version: require_fetch.VERSION
385
+ },
386
+ capabilities: { experimentalApi: config.experimental_api ?? true }
387
+ }, { timeoutMs: this.options.startupTimeoutMs });
388
+ this.notify("initialized", {});
389
+ }
390
+ request(method, params, options = {}) {
391
+ if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("codex app-server connection is closed"));
392
+ if (options.abortSignal?.aborted) return Promise.reject(require_agenticRunQueue.createAbortError(`codex app-server request aborted: ${method}`));
393
+ const id = this.nextRequestId++;
394
+ const message = {
395
+ method,
396
+ id
397
+ };
398
+ if (params !== void 0) message.params = params;
399
+ const timeoutMs = options.timeoutMs ?? this.options.requestTimeoutMs;
400
+ return new Promise((resolve, reject) => {
401
+ const pendingRequest = {
402
+ method,
403
+ resolve,
404
+ reject,
405
+ abortSignal: options.abortSignal,
406
+ onResponse: options.onResponse
407
+ };
408
+ pendingRequest.timeout = setTimeout(() => {
409
+ const error = /* @__PURE__ */ new Error(`codex app-server request timed out: ${method}`);
410
+ this.pending.delete(id);
411
+ if (options.abortSignal && pendingRequest.abortListener) options.abortSignal.removeEventListener("abort", pendingRequest.abortListener);
412
+ reject(error);
413
+ this.closeAfterRequestTimeout(method, error);
414
+ }, timeoutMs);
415
+ if (options.abortSignal) {
416
+ pendingRequest.abortListener = () => {
417
+ const error = require_agenticRunQueue.createAbortError(`codex app-server request aborted: ${method}`);
418
+ this.pending.delete(id);
419
+ clearTimeout(pendingRequest.timeout);
420
+ reject(error);
421
+ require_logger.logger.debug("[CodexAppServer] JSON-RPC request aborted", {
422
+ error: error.message,
423
+ method
424
+ });
425
+ };
426
+ options.abortSignal.addEventListener("abort", pendingRequest.abortListener, { once: true });
427
+ }
428
+ this.pending.set(id, pendingRequest);
429
+ this.send(message);
430
+ });
431
+ }
432
+ notify(method, params) {
433
+ const message = { method };
434
+ if (params !== void 0) message.params = params;
435
+ this.send(message);
436
+ }
437
+ getStderr() {
438
+ return this.stderrChunks.join("").slice(-1e4);
439
+ }
440
+ async close(options = {}) {
441
+ if (this.closePromise !== null) return this.closePromise;
442
+ this.closePromise = new Promise((resolve) => {
443
+ this.closed = true;
444
+ this.rejectPending(/* @__PURE__ */ new Error("codex app-server connection closed"));
445
+ let terminateTimer;
446
+ let killTimer;
447
+ const finish = () => {
448
+ clearTimeout(terminateTimer);
449
+ clearTimeout(killTimer);
450
+ this.lineInterface.close();
451
+ resolve();
452
+ };
453
+ const terminate = () => {
454
+ killTimer = setTimeout(() => {
455
+ try {
456
+ if (this.process.exitCode === null) this.process.kill("SIGKILL");
457
+ } catch {}
458
+ finish();
459
+ }, 1e3);
460
+ try {
461
+ this.process.kill("SIGTERM");
462
+ } catch {
463
+ finish();
464
+ }
465
+ };
466
+ this.process.once("exit", finish);
467
+ if (this.process.killed || this.process.exitCode !== null) {
468
+ finish();
469
+ return;
470
+ }
471
+ try {
472
+ this.process.stdin.end();
473
+ if (options.graceful) terminateTimer = setTimeout(terminate, require_codexSkillMetadata.getCodexTraceShutdownGraceMs(this.options.env));
474
+ else terminate();
475
+ } catch {
476
+ finish();
477
+ }
478
+ });
479
+ return this.closePromise;
480
+ }
481
+ handleLine(line, retryBufferedMessage = true) {
482
+ const trimmed = line.trim();
483
+ if (!trimmed && this.bufferedJsonRpcLines.length === 0) return;
484
+ const candidateLines = this.bufferedJsonRpcLines.length > 0 ? [...this.bufferedJsonRpcLines, line] : [trimmed];
485
+ let candidate = candidateLines.join("\n");
486
+ if (candidate.length > MAX_BUFFERED_JSON_RPC_CHARS) {
487
+ this.bufferedJsonRpcLines = [];
488
+ this.handleProcessFailure(/* @__PURE__ */ new Error(`codex app-server JSON-RPC message exceeded ${MAX_BUFFERED_JSON_RPC_CHARS} characters`));
489
+ this.close();
490
+ return;
491
+ }
492
+ let message;
493
+ try {
494
+ try {
495
+ message = JSON.parse(candidate);
496
+ } catch (error) {
497
+ if (candidateLines.length <= 1 || !(error instanceof Error) || !/Bad control character/i.test(error.message)) throw error;
498
+ candidate = this.escapeStringNewlines(candidate);
499
+ message = JSON.parse(candidate);
500
+ }
501
+ } catch (error) {
502
+ if (this.shouldBufferJsonRpcLine(error, candidate)) {
503
+ this.bufferedJsonRpcLines = candidateLines;
504
+ return;
505
+ }
506
+ require_logger.logger.warn("[CodexAppServer] Failed to parse JSON-RPC line", {
507
+ error,
508
+ line: candidate
509
+ });
510
+ this.bufferedJsonRpcLines = [];
511
+ if (retryBufferedMessage && candidateLines.length > 1) {
512
+ let restartIndex = candidateLines.length - 1;
513
+ for (let index = candidateLines.length - 1; index > 0; index--) if (candidateLines[index].trimStart().startsWith("{")) {
514
+ restartIndex = index;
515
+ break;
516
+ }
517
+ this.bufferedJsonRpcLines = candidateLines.slice(restartIndex, -1);
518
+ this.handleLine(line, false);
519
+ }
520
+ return;
521
+ }
522
+ this.bufferedJsonRpcLines = [];
523
+ this.handleMessage(message);
524
+ }
525
+ escapeStringNewlines(candidate) {
526
+ const parts = [];
527
+ let inString = false;
528
+ let escaped = false;
529
+ let start = 0;
530
+ for (let index = 0; index < candidate.length; index++) {
531
+ const character = candidate[index];
532
+ if (inString && character === "\n" && !escaped) {
533
+ parts.push(candidate.slice(start, index), "\\n");
534
+ start = index + 1;
535
+ }
536
+ if (escaped) escaped = false;
537
+ else if (inString && character === "\\") escaped = true;
538
+ else if (character === "\"") inString = !inString;
539
+ }
540
+ parts.push(candidate.slice(start));
541
+ return parts.join("");
542
+ }
543
+ shouldBufferJsonRpcLine(error, candidate) {
544
+ if (!candidate.trimStart().startsWith("{")) return false;
545
+ const message = error instanceof Error ? error.message : String(error);
546
+ return /Unterminated string|Unexpected end of JSON input/i.test(message) || message.startsWith("Expected ") && message.includes(` in JSON at position ${candidate.length} (line`);
547
+ }
548
+ handleMessage(message) {
549
+ if (message.id !== void 0 && (message.result !== void 0 || message.error !== void 0)) {
550
+ this.handleResponse(message);
551
+ return;
552
+ }
553
+ if (message.id !== void 0 && message.method) {
554
+ this.handleServerRequest(message);
555
+ return;
556
+ }
557
+ if (message.method) {
558
+ this.options.onNotification(message);
559
+ return;
560
+ }
561
+ require_logger.logger.debug("[CodexAppServer] Ignoring unknown JSON-RPC message shape", { message });
562
+ }
563
+ handleResponse(message) {
564
+ const pendingRequest = this.pending.get(message.id);
565
+ if (!pendingRequest) {
566
+ require_logger.logger.debug("[CodexAppServer] Received response for unknown request", { id: message.id });
567
+ return;
568
+ }
569
+ this.pending.delete(message.id);
570
+ clearTimeout(pendingRequest.timeout);
571
+ if (pendingRequest.abortSignal && pendingRequest.abortListener) pendingRequest.abortSignal.removeEventListener("abort", pendingRequest.abortListener);
572
+ if (message.error) {
573
+ pendingRequest.reject(new JsonRpcError(getJsonRpcErrorMessage(message), message.error.code));
574
+ return;
575
+ }
576
+ try {
577
+ pendingRequest.onResponse?.(message.result);
578
+ } catch (error) {
579
+ pendingRequest.reject(error instanceof Error ? error : new Error(String(error)));
580
+ return;
581
+ }
582
+ pendingRequest.resolve(message.result);
583
+ }
584
+ async handleServerRequest(message) {
585
+ try {
586
+ const result = await this.options.onServerRequest(message);
587
+ this.send({
588
+ id: message.id,
589
+ result
590
+ });
591
+ } catch (error) {
592
+ const errorMessage = error instanceof Error ? error.message : String(error);
593
+ try {
594
+ this.send({
595
+ id: message.id,
596
+ error: {
597
+ code: -32e3,
598
+ message: errorMessage
599
+ }
600
+ });
601
+ } catch (sendError) {
602
+ require_logger.logger.debug("[CodexAppServer] Failed to send error response for server request", {
603
+ error: sendError,
604
+ originalError: errorMessage,
605
+ method: message.method
606
+ });
607
+ }
608
+ }
609
+ }
610
+ recordStderr(chunk) {
611
+ const text = chunk.toString("utf8");
612
+ this.stderrChunks.push(text);
613
+ this.stderrTotalLength += text.length;
614
+ if (this.stderrTotalLength > 2e4) {
615
+ const truncated = this.getStderr();
616
+ this.stderrChunks = [truncated];
617
+ this.stderrTotalLength = truncated.length;
618
+ }
619
+ require_logger.logger.debug("[CodexAppServer] stderr", { text: redactAppServerText(require_logger.sanitizeObject(text, { context: "Codex app-server stderr" })) });
620
+ }
621
+ handleProcessFailure(error) {
622
+ if (this.closed) return;
623
+ this.closed = true;
624
+ const stderr = this.getStderr().trim();
625
+ const sanitizedStderr = stderr ? redactAppServerText(require_logger.sanitizeObject(stderr, { context: "Codex app-server stderr" })) : void 0;
626
+ const failure = typeof sanitizedStderr === "string" && sanitizedStderr ? /* @__PURE__ */ new Error(`${error.message}: ${sanitizedStderr}`) : error;
627
+ this.rejectPending(failure);
628
+ require_logger.logger.error("[CodexAppServer] Process failure", {
629
+ error: failure.message,
630
+ stderr: sanitizedStderr
631
+ });
632
+ this.options.onClose(failure);
633
+ }
634
+ closeAfterRequestTimeout(method, error) {
635
+ if (this.closed) return;
636
+ require_logger.logger.warn("[CodexAppServer] Closing app-server after JSON-RPC request timeout", {
637
+ error: error.message,
638
+ method
639
+ });
640
+ this.options.onClose(error);
641
+ this.close().catch((closeError) => {
642
+ require_logger.logger.debug("[CodexAppServer] Error closing app-server after request timeout", { error: closeError });
643
+ });
644
+ }
645
+ rejectPending(error) {
646
+ for (const [id, pendingRequest] of this.pending) {
647
+ clearTimeout(pendingRequest.timeout);
648
+ if (pendingRequest.abortSignal && pendingRequest.abortListener) pendingRequest.abortSignal.removeEventListener("abort", pendingRequest.abortListener);
649
+ pendingRequest.reject(error);
650
+ this.pending.delete(id);
651
+ }
652
+ }
653
+ send(message) {
654
+ if (this.closed) throw new Error("codex app-server connection is closed");
655
+ this.process.stdin.write(`${JSON.stringify(message)}\n`);
656
+ }
657
+ };
658
+ var OpenAICodexAppServerProvider = class {
659
+ registerForCleanup;
660
+ cleanupGeneration = 0;
661
+ config;
662
+ env;
663
+ apiKey;
664
+ providerId = "openai:codex-app-server";
665
+ connections = /* @__PURE__ */ new Map();
666
+ connectionPromises = /* @__PURE__ */ new Map();
667
+ initializingConnections = /* @__PURE__ */ new Set();
668
+ threads = /* @__PURE__ */ new Map();
669
+ threadPromises = /* @__PURE__ */ new Map();
670
+ threadPromiseConnectionInstances = /* @__PURE__ */ new Map();
671
+ explicitThreadAbortCleanups = /* @__PURE__ */ new Map();
672
+ protectedThreadCounts = /* @__PURE__ */ new Map();
673
+ threadRunQueues = new require_agenticRunQueue.AgenticRunQueue("Codex app-server thread turn wait aborted");
674
+ activeTurnsByThread = /* @__PURE__ */ new Map();
675
+ activeTurnsByTurn = /* @__PURE__ */ new Map();
676
+ validatedWorkingDirs = /* @__PURE__ */ new Set();
677
+ ignoredProviderEnvWarningShown = false;
678
+ omittedProcessEnvWarningShown = false;
679
+ deepTracingWarningShown = false;
680
+ traceExporterOverrideWarningShown = false;
681
+ constructor(options = {}) {
682
+ this.registerForCleanup = options.registerForCleanup ?? true;
683
+ this.config = parseCodexAppServerConfig(options.config);
684
+ this.env = options.env;
685
+ this.apiKey = this.getApiKey();
686
+ this.providerId = options.id ?? this.providerId;
687
+ if (this.registerForCleanup) require_providerRegistry.providerRegistry.register(this);
688
+ }
689
+ id() {
690
+ return this.providerId;
691
+ }
692
+ getApiKey(config = this.config) {
693
+ return require_credentials.resolveProviderApiKey(config, this.env, ["OPENAI_API_KEY", "CODEX_API_KEY"]);
694
+ }
695
+ requiresApiKey() {
696
+ return false;
697
+ }
698
+ toString() {
699
+ return "[OpenAI Codex App Server Provider]";
700
+ }
701
+ async cleanup() {
702
+ require_providerRegistry.providerRegistry.unregister(this);
703
+ this.cleanupGeneration++;
704
+ this.resolveActiveTurns(/* @__PURE__ */ new Error("codex app-server provider cleanup interrupted active turn"));
705
+ this.threads.clear();
706
+ this.threadPromises.clear();
707
+ this.explicitThreadAbortCleanups.clear();
708
+ this.threadRunQueues.clear();
709
+ this.activeTurnsByThread.clear();
710
+ this.activeTurnsByTurn.clear();
711
+ this.protectedThreadCounts.clear();
712
+ this.validatedWorkingDirs.clear();
713
+ const connections = Array.from(/* @__PURE__ */ new Set([...this.connections.values(), ...this.initializingConnections]));
714
+ this.connections.clear();
715
+ this.connectionPromises.clear();
716
+ this.initializingConnections.clear();
717
+ await Promise.all(connections.map((connection) => connection.close().catch((error) => {
718
+ require_logger.logger.warn("[CodexAppServer] Error during cleanup", { error });
719
+ })));
720
+ }
721
+ async shutdown() {
722
+ await this.cleanup();
723
+ }
724
+ async callApi(prompt, context, callOptions) {
725
+ const cleanupGeneration = this.cleanupGeneration;
726
+ const mergedConfig = mergeCodexAppServerConfig(this.config, context?.prompt?.config);
727
+ delete mergedConfig.provider;
728
+ const config = require_render.renderVarsInObject(mergedConfig, context?.vars);
729
+ const requestedModel = typeof config.model === "string" && config.model ? config.model : void 0;
730
+ return require_genaiTracer.withGenAISpan(this.buildSpanContext(prompt, context, requestedModel), () => this.callApiInternal(prompt, context, callOptions, config, cleanupGeneration), (response) => this.extractSpanResult(response, requestedModel));
731
+ }
732
+ buildSpanContext(prompt, context, requestedModel) {
733
+ return {
734
+ system: "openai",
735
+ operationName: "invoke_agent",
736
+ model: requestedModel ?? "Codex App Server",
737
+ agentName: "Codex App Server",
738
+ providerId: this.id(),
739
+ evalId: context?.evaluationId || context?.test?.metadata?.evaluationId,
740
+ testIndex: typeof context?.test?.vars?.__testIdx === "number" ? context.test.vars.__testIdx : void 0,
741
+ promptLabel: context?.prompt?.label,
742
+ traceparent: context?.traceparent,
743
+ requestBody: prompt
744
+ };
745
+ }
746
+ extractSpanResult(response, requestedModel) {
747
+ const result = {};
748
+ if (response.tokenUsage) result.tokenUsage = response.tokenUsage;
749
+ if (response.sessionId) result.responseId = response.sessionId;
750
+ if (requestedModel) result.responseModel = requestedModel;
751
+ if (response.cached !== void 0) result.cacheHit = response.cached;
752
+ if (response.output !== void 0) result.responseBody = typeof response.output === "string" ? response.output : JSON.stringify(response.output);
753
+ if (response.metadata?.codexAppServer?.itemCounts) result.additionalAttributes = {
754
+ ...result.additionalAttributes,
755
+ "codex.app_server.items.breakdown": JSON.stringify(response.metadata.codexAppServer.itemCounts)
756
+ };
757
+ return result;
758
+ }
759
+ async callApiInternal(prompt, context, callOptions, rawConfig, cleanupGeneration) {
760
+ let config;
761
+ try {
762
+ config = parseCodexAppServerConfig(rawConfig, { stripUnknownKeys: true });
763
+ } catch (error) {
764
+ const errorMessage = error instanceof Error ? error.message : String(error);
765
+ require_logger.logger.error("Error calling OpenAI Codex app-server", { error: errorMessage });
766
+ return { error: `Error calling OpenAI Codex app-server: ${errorMessage}` };
767
+ }
768
+ if (callOptions?.abortSignal?.aborted) return { error: "OpenAI Codex app-server call aborted before it started" };
769
+ const workingDirectory = this.resolveWorkingDirectory(config);
770
+ const resolvedConfig = {
771
+ approval_policy: "never",
772
+ sandbox_mode: "read-only",
773
+ network_access_enabled: false,
774
+ ephemeral: true,
775
+ thread_cleanup: "unsubscribe",
776
+ reuse_server: true,
777
+ ...config,
778
+ working_dir: workingDirectory,
779
+ additional_directories: this.resolveAdditionalDirectories(config)
780
+ };
781
+ const currentTraceparent = require_genaiTracer.getTraceparent();
782
+ const apiKey = this.getApiKey(resolvedConfig);
783
+ const env = this.prepareEnvironment(resolvedConfig, currentTraceparent, apiKey);
784
+ const promptInput = this.parsePromptInput(prompt);
785
+ const connectionKey = this.generateConnectionKey(env, resolvedConfig);
786
+ const useReusableConnection = resolvedConfig.reuse_server !== false && !resolvedConfig.deep_tracing;
787
+ let localConnection;
788
+ try {
789
+ this.validateWorkingDirectory(resolvedConfig.working_dir, resolvedConfig.skip_git_repo_check);
790
+ this.warnOnceForDeepTracingThreadOptions(resolvedConfig);
791
+ let connection = useReusableConnection ? await this.getOrCreateConnection(connectionKey, env, resolvedConfig) : await this.createConnection(connectionKey, env, resolvedConfig);
792
+ if (!useReusableConnection) localConnection = connection;
793
+ const promptCacheBasis = context?.prompt?.raw ?? prompt;
794
+ const explicitThreadQueueKey = resolvedConfig.thread_id ? `thread_id:${resolvedConfig.thread_id}` : void 0;
795
+ const runThreadTurn = async () => {
796
+ if (useReusableConnection && connection.isClosed()) connection = await this.getOrCreateConnection(connectionKey, env, resolvedConfig);
797
+ let threadHandle;
798
+ try {
799
+ threadHandle = await this.getOrCreateThread(connection, connectionKey, promptCacheBasis, resolvedConfig, useReusableConnection, callOptions);
800
+ } catch (error) {
801
+ if (!(error instanceof StaleExplicitThreadConnectionClosedError)) throw error;
802
+ connection = await this.getOrCreateConnection(connectionKey, env, resolvedConfig);
803
+ threadHandle = await this.getOrCreateThread(connection, connectionKey, promptCacheBasis, resolvedConfig, useReusableConnection, callOptions);
804
+ }
805
+ this.protectThread(threadHandle.threadId);
806
+ let turnStarted = false;
807
+ try {
808
+ const queueKey = explicitThreadQueueKey ? void 0 : this.getThreadRunQueueKey(resolvedConfig, threadHandle);
809
+ return await this.runSerializedThreadTurn(queueKey, callOptions?.abortSignal, async () => {
810
+ turnStarted = true;
811
+ const state = this.createTurnState(connection, connectionKey, connection.instanceId, threadHandle.threadId, promptInput, resolvedConfig, env);
812
+ this.registerTurnState(state);
813
+ try {
814
+ const turnResponse = await connection.request("turn/start", this.buildTurnStartParams(threadHandle.threadId, promptInput, resolvedConfig), {
815
+ abortSignal: callOptions?.abortSignal,
816
+ timeoutMs: this.getRequestTimeoutMs(resolvedConfig),
817
+ onResponse: (response) => {
818
+ const turnId = response?.turn?.id;
819
+ if (typeof turnId === "string") this.updateTurnStateId(state, turnId);
820
+ }
821
+ });
822
+ if (typeof turnResponse?.turn?.id === "string") this.updateTurnStateId(state, turnResponse.turn.id);
823
+ await this.waitForTurnCompletion(connection, state, resolvedConfig, callOptions);
824
+ return this.buildProviderResponse(state, threadHandle, resolvedConfig);
825
+ } finally {
826
+ this.unregisterTurnState(state);
827
+ await this.cleanupThreadAfterTurn(connection, threadHandle, resolvedConfig);
828
+ }
829
+ }, cleanupGeneration);
830
+ } finally {
831
+ this.unprotectThread(threadHandle.threadId);
832
+ if (!turnStarted) await this.cleanupThreadAfterTurn(connection, threadHandle, resolvedConfig, { skipIfActiveTurn: true });
833
+ this.scheduleThreadPoolEnforcement(connection, connectionKey, resolvedConfig);
834
+ }
835
+ };
836
+ return await this.runSerializedThreadTurn(explicitThreadQueueKey, callOptions?.abortSignal, runThreadTurn, cleanupGeneration);
837
+ } catch (error) {
838
+ if (error instanceof Error && error.name === "AbortError" || callOptions?.abortSignal?.aborted) {
839
+ require_logger.logger.warn("OpenAI Codex app-server call aborted");
840
+ return { error: "OpenAI Codex app-server call aborted" };
841
+ }
842
+ const errorMessage = error instanceof Error ? error.message : String(error);
843
+ require_logger.logger.error("Error calling OpenAI Codex app-server", { error: errorMessage });
844
+ return { error: `Error calling OpenAI Codex app-server: ${errorMessage}` };
845
+ } finally {
846
+ if (localConnection) await localConnection.close({ graceful: resolvedConfig.deep_tracing === true }).catch((error) => {
847
+ require_logger.logger.debug("[CodexAppServer] Error closing local connection", { error });
848
+ });
849
+ }
850
+ }
851
+ resolveWorkingDirectory(config) {
852
+ const basePath = config.basePath || require_logger.state.basePath || process.cwd();
853
+ if (!config.working_dir) return process.cwd();
854
+ return require_agentic_utils.resolveAgenticWorkingDir(config.working_dir, basePath) ?? process.cwd();
855
+ }
856
+ resolveAdditionalDirectories(config) {
857
+ if (!config.additional_directories?.length) return;
858
+ const basePath = config.basePath || require_logger.state.basePath || process.cwd();
859
+ return config.additional_directories.map((directory) => path.default.resolve(basePath, directory));
860
+ }
861
+ prepareEnvironment(config, traceparent, apiKey = this.getApiKey(config)) {
862
+ const inheritProcessEnv = config.inherit_process_env === true;
863
+ const cliEnv = Object.fromEntries(Object.entries(config.cli_env ?? {}).map(([key, value]) => [key, String(value)]));
864
+ const env = {
865
+ ...inheritProcessEnv ? require_logger.getProcessEnv() : require_codexSkillMetadata.getMinimalProcessEnv(),
866
+ ...cliEnv
867
+ };
868
+ const ignoredProviderEnvKeys = Object.keys(this.env ?? {}).filter((key) => key !== "OPENAI_API_KEY" && key !== "CODEX_API_KEY" && !(key in (config.cli_env ?? {}))).sort();
869
+ if (ignoredProviderEnvKeys.length > 0 && !this.ignoredProviderEnvWarningShown) {
870
+ require_logger.logger.warn("[CodexAppServer] Ignoring promptfoo-level env overrides for the Codex app-server process. Move these keys into config.cli_env if Codex shell commands need them.", { envKeys: ignoredProviderEnvKeys });
871
+ this.ignoredProviderEnvWarningShown = true;
872
+ }
873
+ if (!inheritProcessEnv && !this.omittedProcessEnvWarningShown) {
874
+ const omittedProcessEnvKeys = this.getOmittedOptionalProcessEnvKeys(config, env);
875
+ if (omittedProcessEnvKeys.length > 0) {
876
+ require_logger.logger.warn("[CodexAppServer] Optional Codex app-server process env vars are not inherited by default. Move these keys into config.cli_env or set inherit_process_env: true if Codex commands need them.", { envKeys: omittedProcessEnvKeys });
877
+ this.omittedProcessEnvWarningShown = true;
878
+ }
879
+ }
880
+ const sortedEnv = {};
881
+ for (const key of Object.keys(env).sort()) if (env[key] !== void 0) sortedEnv[key] = env[key];
882
+ require_codexSkillMetadata.applyApiKeyToCliEnv(sortedEnv, config, apiKey);
883
+ if (config.base_url) {
884
+ sortedEnv.OPENAI_BASE_URL = config.base_url;
885
+ sortedEnv.OPENAI_API_BASE_URL = config.base_url;
886
+ }
887
+ if (config.deep_tracing) {
888
+ if (!sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT) sortedEnv.OTEL_EXPORTER_OTLP_ENDPOINT = require_codexSkillMetadata.getCodexTraceEndpoint();
889
+ if (!sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL) sortedEnv.OTEL_EXPORTER_OTLP_PROTOCOL = require_codexSkillMetadata.getCodexTraceProtocol();
890
+ if (!sortedEnv.OTEL_SERVICE_NAME) sortedEnv.OTEL_SERVICE_NAME = "codex-app-server";
891
+ if (!sortedEnv.OTEL_TRACES_EXPORTER) sortedEnv.OTEL_TRACES_EXPORTER = "otlp";
892
+ if (traceparent) sortedEnv.TRACEPARENT = traceparent;
893
+ } else delete sortedEnv.TRACEPARENT;
894
+ if (config.working_dir && require_agentWorkspace.isAgentWorkspace(config.working_dir)) require_agentWorkspace.clearRepositoryEnv(sortedEnv);
895
+ return sortedEnv;
896
+ }
897
+ getOmittedOptionalProcessEnvKeys(config, env) {
898
+ const shouldWarnForSshEnv = config.network_access_enabled === true;
899
+ return require_codexSkillMetadata.COMMON_OPTIONAL_PROCESS_ENV_KEYS.filter((key) => typeof process.env[key] === "string" && !(key in env) && (shouldWarnForSshEnv || key !== "SSH_AUTH_SOCK" && key !== "GIT_SSH_COMMAND"));
900
+ }
901
+ buildAppServerArgs(config, env) {
902
+ const args = [
903
+ "app-server",
904
+ "--listen",
905
+ "stdio://"
906
+ ];
907
+ const cliConfig = this.getResolvedCliConfig(config, env);
908
+ for (const { key, value } of flattenConfig(cliConfig)) args.push("-c", `${key}=${toTomlLiteral(value)}`);
909
+ return args;
910
+ }
911
+ getResolvedCliConfig(config, env = {}) {
912
+ return require_codexSkillMetadata.withCodexTraceExporter({ ...config.cli_config ?? {} }, env, config.deep_tracing === true);
913
+ }
914
+ getRequestTimeoutMs(config) {
915
+ return config.request_timeout_ms ?? DEFAULT_REQUEST_TIMEOUT_MS;
916
+ }
917
+ async getOrCreateConnection(connectionKey, env, config) {
918
+ const existing = this.connections.get(connectionKey);
919
+ if (existing) return existing;
920
+ const pending = this.connectionPromises.get(connectionKey);
921
+ if (pending) return pending;
922
+ let connectionPromise;
923
+ connectionPromise = this.createConnection(connectionKey, env, config).then((connection) => {
924
+ if (this.connectionPromises.get(connectionKey) !== connectionPromise) {
925
+ connection.close().catch((error) => {
926
+ require_logger.logger.debug("[CodexAppServer] Error closing stale initialized connection", { error });
927
+ });
928
+ throw new Error("codex app-server connection was closed during cleanup");
929
+ }
930
+ this.connections.set(connectionKey, connection);
931
+ return connection;
932
+ }).finally(() => {
933
+ this.connectionPromises.delete(connectionKey);
934
+ });
935
+ this.connectionPromises.set(connectionKey, connectionPromise);
936
+ return connectionPromise;
937
+ }
938
+ async createConnection(connectionKey, env, config) {
939
+ const connectionInstanceId = `${connectionKey}:${crypto.default.randomUUID()}`;
940
+ const entrypoint = process.platform === "win32" && config.codex_path_override === void 0 ? getCodexNpmEntrypoint(env) : void 0;
941
+ const args = this.buildAppServerArgs(config, env);
942
+ const connection = new CodexAppServerConnection({
943
+ connectionInstanceId,
944
+ command: config.codex_path_override ?? (entrypoint ? process.execPath : "codex"),
945
+ args: entrypoint ? [entrypoint, ...args] : args,
946
+ env,
947
+ requestTimeoutMs: this.getRequestTimeoutMs(config),
948
+ startupTimeoutMs: config.startup_timeout_ms ?? DEFAULT_STARTUP_TIMEOUT_MS,
949
+ onNotification: (message) => this.handleNotification(message),
950
+ onServerRequest: (message) => this.handleServerRequest(message, config),
951
+ onClose: (error) => this.handleConnectionClose(connectionKey, connectionInstanceId, error)
952
+ });
953
+ if (this.registerForCleanup) require_providerRegistry.providerRegistry.register(this);
954
+ this.initializingConnections.add(connection);
955
+ try {
956
+ await connection.initialize(config);
957
+ const apiKey = this.getApiKey(config);
958
+ if (require_codexSkillMetadata.shouldInjectApiKey(config, apiKey)) try {
959
+ await connection.request("account/login/start", {
960
+ type: "apiKey",
961
+ apiKey
962
+ }, { timeoutMs: this.getRequestTimeoutMs(config) });
963
+ } catch (error) {
964
+ if (!isMethodNotFoundError(error)) throw error;
965
+ require_logger.logger.debug("[CodexAppServer] account/login/start is unavailable; continuing with API key env auth");
966
+ }
967
+ await this.warnForTraceExporterOverride(connection, config, env);
968
+ return connection;
969
+ } catch (error) {
970
+ await connection.close().catch((closeError) => {
971
+ require_logger.logger.debug("[CodexAppServer] Error closing app-server after failed initialization", { error: closeError });
972
+ });
973
+ throw error;
974
+ } finally {
975
+ this.initializingConnections.delete(connection);
976
+ }
977
+ }
978
+ async warnForTraceExporterOverride(connection, config, env) {
979
+ if (!config.deep_tracing || this.traceExporterOverrideWarningShown) return;
980
+ const requestedExporter = getCodexTraceExporterSettings(this.getResolvedCliConfig(config, env));
981
+ if (!requestedExporter) return;
982
+ let effectiveConfig;
983
+ try {
984
+ effectiveConfig = await connection.request("config/read", { includeLayers: false }, { timeoutMs: this.getRequestTimeoutMs(config) });
985
+ } catch (error) {
986
+ require_logger.logger.debug("[CodexAppServer] Unable to inspect the effective Codex trace exporter", { error: error instanceof Error ? error.message : String(error) });
987
+ return;
988
+ }
989
+ if (!isPlainObject(effectiveConfig)) return;
990
+ const effectiveExporter = getCodexTraceExporterSettings(effectiveConfig.config);
991
+ const effectiveExporterValue = getCodexTraceExporterValue(effectiveConfig.config);
992
+ if (!effectiveExporter && effectiveExporterValue === void 0 || effectiveExporter && effectiveExporter.endpoint === requestedExporter.endpoint && (!effectiveExporter.protocol || !requestedExporter.protocol || effectiveExporter.protocol === requestedExporter.protocol)) return;
993
+ const configOrigin = (effectiveExporter && (getCodexConfigOriginType(effectiveConfig.origins, effectiveExporter.endpointConfigKey) ?? getCodexConfigOriginType(effectiveConfig.origins, effectiveExporter.protocolConfigKey))) ?? getCodexConfigOriginType(effectiveConfig.origins, "otel.trace_exporter");
994
+ const managedOverride = configOrigin !== void 0 && /managed|mdm/i.test(configOrigin);
995
+ const exporterState = typeof effectiveExporterValue === "string" ? effectiveExporterValue : "unsupported";
996
+ this.traceExporterOverrideWarningShown = true;
997
+ require_logger.logger.warn(`[CodexAppServer] ${managedOverride ? "Enterprise-managed" : "Effective"} Codex configuration overrides the requested trace exporter. Native spans will not reach the configured trace receiver.`, {
998
+ requestedOrigin: getSafeTraceExporterOrigin(requestedExporter.endpoint),
999
+ ...effectiveExporter ? { effectiveOrigin: getSafeTraceExporterOrigin(effectiveExporter.endpoint) } : { effectiveExporter: exporterState },
1000
+ requestedProtocol: requestedExporter.protocol,
1001
+ effectiveProtocol: effectiveExporter?.protocol,
1002
+ ...configOrigin && { configOrigin }
1003
+ });
1004
+ }
1005
+ handleConnectionClose(connectionKey, connectionInstanceId, error) {
1006
+ require_logger.logger.warn("[CodexAppServer] Connection closed", {
1007
+ connectionKey,
1008
+ error: error.message
1009
+ });
1010
+ if (this.connections.get(connectionKey)?.instanceId === connectionInstanceId) {
1011
+ this.connections.delete(connectionKey);
1012
+ this.connectionPromises.delete(connectionKey);
1013
+ for (const [threadCacheKey, handle] of this.threads) if (handle.connectionKey === connectionKey) this.threads.delete(threadCacheKey);
1014
+ for (const [threadCacheKey, pending] of this.threadPromises) if (pending.connectionInstanceId === connectionInstanceId) this.threadPromises.delete(threadCacheKey);
1015
+ }
1016
+ this.resolveActiveTurns(error, (state) => state.connectionInstanceId === connectionInstanceId);
1017
+ }
1018
+ resolveActiveTurns(error, predicate = () => true) {
1019
+ for (const state of new Set(this.activeTurnsByThread.values())) {
1020
+ if (!predicate(state)) continue;
1021
+ state.error = error.message;
1022
+ state.completed.resolve();
1023
+ }
1024
+ }
1025
+ generateConnectionKey(env, config) {
1026
+ const stableEnv = { ...env };
1027
+ delete stableEnv.TRACEPARENT;
1028
+ const keyData = {
1029
+ env: stableEnv,
1030
+ codex_path_override: config.codex_path_override,
1031
+ cli_config: this.getResolvedCliConfig(config, env),
1032
+ experimental_api: config.experimental_api
1033
+ };
1034
+ return `openai:codex-app-server:connection:${crypto.default.createHash("sha256").update(JSON.stringify(keyData)).digest("hex")}`;
1035
+ }
1036
+ generateThreadCacheKey(connectionKey, promptCacheBasis, config) {
1037
+ const keyData = {
1038
+ connectionKey,
1039
+ prompt: promptCacheBasis,
1040
+ working_dir: config.working_dir,
1041
+ additional_directories: config.additional_directories,
1042
+ model: config.model,
1043
+ model_provider: config.model_provider,
1044
+ service_tier: config.service_tier,
1045
+ sandbox_mode: config.sandbox_mode,
1046
+ sandbox_policy: config.sandbox_policy,
1047
+ network_access_enabled: config.network_access_enabled,
1048
+ approval_policy: config.approval_policy,
1049
+ approvals_reviewer: config.approvals_reviewer,
1050
+ model_reasoning_effort: config.model_reasoning_effort,
1051
+ reasoning_summary: config.reasoning_summary,
1052
+ personality: config.personality,
1053
+ base_instructions: config.base_instructions,
1054
+ developer_instructions: config.developer_instructions,
1055
+ collaboration_mode: config.collaboration_mode,
1056
+ output_schema: config.output_schema,
1057
+ base_url: config.base_url,
1058
+ ephemeral: config.ephemeral,
1059
+ experimental_raw_events: config.experimental_raw_events,
1060
+ persist_extended_history: config.persist_extended_history
1061
+ };
1062
+ return `openai:codex-app-server:thread:${crypto.default.createHash("sha256").update(JSON.stringify(keyData)).digest("hex")}`;
1063
+ }
1064
+ generateExplicitThreadCachePrefix(threadId) {
1065
+ return `openai:codex-app-server:thread_id:${crypto.default.createHash("sha256").update(threadId).digest("hex")}:`;
1066
+ }
1067
+ generateExplicitThreadCacheKey(connectionKey, threadId, config) {
1068
+ const resumeHash = crypto.default.createHash("sha256").update(JSON.stringify({
1069
+ connectionKey,
1070
+ resume: this.buildThreadResumeParams(threadId, config)
1071
+ })).digest("hex");
1072
+ return `${this.generateExplicitThreadCachePrefix(threadId)}${resumeHash}`;
1073
+ }
1074
+ async discardOtherExplicitThreadVariants(prefix, keepKey, connection, connectionKey, timeoutMs) {
1075
+ const staleKeys = Array.from(this.threads.keys()).filter((key) => key.startsWith(prefix) && key !== keepKey);
1076
+ for (const key of staleKeys) {
1077
+ const stale = this.threads.get(key);
1078
+ this.threads.delete(key);
1079
+ if (!stale) continue;
1080
+ const staleConnection = this.connections.get(stale.connectionKey) ?? (stale.connectionKey === connectionKey ? connection : void 0);
1081
+ if (staleConnection) try {
1082
+ await staleConnection.request("thread/unsubscribe", { threadId: stale.threadId }, { timeoutMs });
1083
+ } catch (error) {
1084
+ require_logger.logger.warn("[CodexAppServer] Failed to unsubscribe stale explicit thread variant", {
1085
+ error,
1086
+ threadId: stale.threadId
1087
+ });
1088
+ if (staleConnection === connection && connection.isClosed()) throw new StaleExplicitThreadConnectionClosedError();
1089
+ }
1090
+ }
1091
+ }
1092
+ async settleOtherExplicitThreadVariants(prefix, keepKey, abortSignal) {
1093
+ const pending = Array.from(this.threadPromises.entries()).filter(([key]) => key.startsWith(prefix) && key !== keepKey).map(([, entry]) => entry.promise);
1094
+ const abortCleanups = Array.from(this.explicitThreadAbortCleanups.entries()).filter(([key]) => key.startsWith(prefix)).map(([, promise]) => promise);
1095
+ pending.push(...abortCleanups);
1096
+ if (pending.length > 0) await this.threadRunQueues.wait(Promise.allSettled(pending).then(() => void 0), abortSignal);
1097
+ }
1098
+ async getOrCreateThread(connection, connectionKey, promptCacheBasis, config, allowThreadPersistence, callOptions) {
1099
+ const canPersistThread = allowThreadPersistence && config.persist_threads === true;
1100
+ if (config.thread_id) {
1101
+ const variantKey = this.generateExplicitThreadCacheKey(connectionKey, config.thread_id, config);
1102
+ const cacheKey = canPersistThread ? variantKey : void 0;
1103
+ await this.settleOtherExplicitThreadVariants(this.generateExplicitThreadCachePrefix(config.thread_id), variantKey, callOptions?.abortSignal);
1104
+ if (cacheKey) await this.discardOtherExplicitThreadVariants(this.generateExplicitThreadCachePrefix(config.thread_id), cacheKey, connection, connectionKey, this.getRequestTimeoutMs(config));
1105
+ const cachedOrPending = (cacheKey ? this.threads.get(cacheKey) : void 0) ?? this.threadPromises.get(variantKey)?.promise;
1106
+ if (cachedOrPending !== void 0) return this.waitForThreadHandle(cachedOrPending, callOptions?.abortSignal);
1107
+ this.throwIfThreadWaitAborted(callOptions?.abortSignal);
1108
+ const threadPromise = this.cacheThreadPromise(variantKey, connection.instanceId, async () => {
1109
+ const response = await connection.request("thread/resume", this.buildThreadResumeParams(config.thread_id, config), { timeoutMs: this.getRequestTimeoutMs(config) });
1110
+ const handle = {
1111
+ connectionKey,
1112
+ threadId: response?.thread?.id ?? config.thread_id,
1113
+ response,
1114
+ cacheKey,
1115
+ persistent: canPersistThread
1116
+ };
1117
+ if (cacheKey) this.threads.set(cacheKey, handle);
1118
+ return handle;
1119
+ });
1120
+ return cacheKey ? this.waitForThreadHandle(threadPromise, callOptions?.abortSignal) : this.waitForThreadHandle(threadPromise, callOptions?.abortSignal, {
1121
+ onAbortResolvedThread: (threadHandle) => this.cleanupThreadAfterTurn(connection, threadHandle, config, { skipIfProtected: true }),
1122
+ onAbortCleanupScheduled: (cleanup) => this.trackExplicitThreadAbortCleanup(variantKey, cleanup)
1123
+ });
1124
+ }
1125
+ const cacheKey = canPersistThread ? this.generateThreadCacheKey(connectionKey, promptCacheBasis, config) : void 0;
1126
+ const cachedOrPending = this.getCachedOrPendingThread(cacheKey);
1127
+ if (cachedOrPending !== void 0) return this.waitForThreadHandle(cachedOrPending, callOptions?.abortSignal);
1128
+ this.throwIfThreadWaitAborted(callOptions?.abortSignal);
1129
+ const threadPromise = this.cacheThreadPromise(cacheKey, connection.instanceId, async () => {
1130
+ const poolSize = config.thread_pool_size ?? 1;
1131
+ if (cacheKey && this.threads.size >= poolSize) await this.evictOldestInactiveCachedThread(connection, connectionKey, this.getRequestTimeoutMs(config));
1132
+ const response = await connection.request("thread/start", this.buildThreadStartParams(config), { timeoutMs: this.getRequestTimeoutMs(config) });
1133
+ const threadId = response?.thread?.id;
1134
+ if (typeof threadId !== "string" || !threadId) throw new Error("codex app-server did not return a thread id");
1135
+ const handle = {
1136
+ connectionKey,
1137
+ threadId,
1138
+ response,
1139
+ cacheKey,
1140
+ persistent: canPersistThread
1141
+ };
1142
+ if (cacheKey) this.threads.set(cacheKey, handle);
1143
+ return handle;
1144
+ });
1145
+ return cacheKey ? this.waitForThreadHandle(threadPromise, callOptions?.abortSignal) : this.waitForThreadHandle(threadPromise, callOptions?.abortSignal, { onAbortResolvedThread: (threadHandle) => this.cleanupThreadAfterTurn(connection, threadHandle, config, { skipIfProtected: true }) });
1146
+ }
1147
+ getCachedOrPendingThread(cacheKey) {
1148
+ if (!cacheKey) return;
1149
+ return this.threads.get(cacheKey) ?? this.threadPromises.get(cacheKey)?.promise;
1150
+ }
1151
+ cacheThreadPromise(cacheKey, connectionInstanceId, createThread) {
1152
+ if (!cacheKey) return createThread();
1153
+ let threadPromise;
1154
+ threadPromise = createThread().finally(() => {
1155
+ if (this.threadPromises.get(cacheKey)?.promise === threadPromise) this.threadPromises.delete(cacheKey);
1156
+ });
1157
+ this.threadPromises.set(cacheKey, {
1158
+ promise: threadPromise,
1159
+ connectionInstanceId
1160
+ });
1161
+ return threadPromise;
1162
+ }
1163
+ throwIfThreadWaitAborted(abortSignal) {
1164
+ if (abortSignal?.aborted) throw require_agenticRunQueue.createAbortError("Codex app-server thread wait aborted");
1165
+ }
1166
+ async waitForThreadHandle(thread, abortSignal, options = {}) {
1167
+ const threadPromise = Promise.resolve(thread);
1168
+ if (!abortSignal) return threadPromise;
1169
+ let abortCleanupScheduled = false;
1170
+ const scheduleAbortCleanup = () => {
1171
+ if (abortCleanupScheduled) return;
1172
+ abortCleanupScheduled = true;
1173
+ const cleanup = threadPromise.then(async (threadHandle) => {
1174
+ if (options.onAbortResolvedThread) await options.onAbortResolvedThread(threadHandle);
1175
+ }).catch((error) => {
1176
+ require_logger.logger.debug("[CodexAppServer] Thread request finished with error after abort", { error });
1177
+ });
1178
+ options.onAbortCleanupScheduled?.(cleanup);
1179
+ };
1180
+ const createThreadAbortError = () => require_agenticRunQueue.createAbortError(options.abortMessage ?? "Codex app-server thread wait aborted");
1181
+ if (abortSignal.aborted) {
1182
+ scheduleAbortCleanup();
1183
+ throw createThreadAbortError();
1184
+ }
1185
+ let abortListener;
1186
+ const abortPromise = new Promise((_, reject) => {
1187
+ abortListener = () => {
1188
+ scheduleAbortCleanup();
1189
+ reject(createThreadAbortError());
1190
+ };
1191
+ abortSignal.addEventListener("abort", abortListener, { once: true });
1192
+ });
1193
+ try {
1194
+ return await Promise.race([threadPromise, abortPromise]);
1195
+ } finally {
1196
+ if (abortListener) abortSignal.removeEventListener("abort", abortListener);
1197
+ }
1198
+ }
1199
+ trackExplicitThreadAbortCleanup(cacheKey, cleanup) {
1200
+ this.explicitThreadAbortCleanups.set(cacheKey, cleanup);
1201
+ cleanup.finally(() => {
1202
+ if (this.explicitThreadAbortCleanups.get(cacheKey) === cleanup) this.explicitThreadAbortCleanups.delete(cacheKey);
1203
+ });
1204
+ }
1205
+ scheduleThreadPoolEnforcement(fallbackConnection, fallbackConnectionKey, config) {
1206
+ if (!config.persist_threads || config.thread_id) return;
1207
+ this.enforceThreadPoolLimit(fallbackConnection, fallbackConnectionKey, config).catch((error) => {
1208
+ require_logger.logger.debug("[CodexAppServer] Error enforcing thread pool limit", { error });
1209
+ });
1210
+ }
1211
+ async enforceThreadPoolLimit(fallbackConnection, fallbackConnectionKey, config) {
1212
+ const poolSize = config.thread_pool_size ?? 1;
1213
+ while (this.threads.size > poolSize) if (!await this.evictOldestInactiveCachedThread(fallbackConnection, fallbackConnectionKey, this.getRequestTimeoutMs(config))) return;
1214
+ }
1215
+ async evictOldestInactiveCachedThread(fallbackConnection, fallbackConnectionKey, timeoutMs) {
1216
+ for (const [cacheKey, handle] of this.threads) {
1217
+ if (this.isThreadProtected(handle.threadId)) continue;
1218
+ await this.evictCachedThread(fallbackConnection, fallbackConnectionKey, cacheKey, timeoutMs);
1219
+ return true;
1220
+ }
1221
+ require_logger.logger.debug("[CodexAppServer] Thread pool is full, but all cached threads are active");
1222
+ return false;
1223
+ }
1224
+ async evictCachedThread(fallbackConnection, fallbackConnectionKey, cacheKey, timeoutMs) {
1225
+ const evicted = this.threads.get(cacheKey);
1226
+ this.threads.delete(cacheKey);
1227
+ if (!evicted) return;
1228
+ const connection = this.connections.get(evicted.connectionKey) ?? (evicted.connectionKey === fallbackConnectionKey ? fallbackConnection : void 0);
1229
+ if (!connection) {
1230
+ require_logger.logger.debug("[CodexAppServer] Evicted cached thread without an active connection", { threadId: evicted.threadId });
1231
+ return;
1232
+ }
1233
+ try {
1234
+ await connection.request("thread/unsubscribe", { threadId: evicted.threadId }, { timeoutMs });
1235
+ } catch (error) {
1236
+ require_logger.logger.warn("[CodexAppServer] Failed to unsubscribe evicted cached thread", {
1237
+ error,
1238
+ threadId: evicted.threadId
1239
+ });
1240
+ }
1241
+ }
1242
+ buildThreadStartParams(config) {
1243
+ return {
1244
+ ...config.model ? { model: config.model } : {},
1245
+ ...config.model_provider ? { modelProvider: config.model_provider } : {},
1246
+ ...config.service_tier ? { serviceTier: config.service_tier } : {},
1247
+ ...config.working_dir ? { cwd: config.working_dir } : {},
1248
+ approvalPolicy: config.approval_policy ?? "never",
1249
+ ...config.approvals_reviewer ? { approvalsReviewer: config.approvals_reviewer } : {},
1250
+ sandbox: config.sandbox_mode ?? "read-only",
1251
+ ...Object.keys(config.cli_config ?? {}).length > 0 ? { config: config.cli_config } : {},
1252
+ serviceName: "promptfoo",
1253
+ ...config.base_instructions ? { baseInstructions: config.base_instructions } : {},
1254
+ ...config.developer_instructions ? { developerInstructions: config.developer_instructions } : {},
1255
+ ...config.personality ? { personality: config.personality } : {},
1256
+ ...config.base_url ? { config: {
1257
+ ...config.cli_config ?? {},
1258
+ openai_base_url: config.base_url
1259
+ } } : {},
1260
+ ephemeral: config.ephemeral ?? true,
1261
+ experimentalRawEvents: config.experimental_raw_events ?? false,
1262
+ persistExtendedHistory: config.persist_extended_history ?? false
1263
+ };
1264
+ }
1265
+ buildThreadResumeParams(threadId, config) {
1266
+ return {
1267
+ threadId,
1268
+ ...config.model ? { model: config.model } : {},
1269
+ ...config.model_provider ? { modelProvider: config.model_provider } : {},
1270
+ ...config.service_tier ? { serviceTier: config.service_tier } : {},
1271
+ ...config.working_dir ? { cwd: config.working_dir } : {},
1272
+ approvalPolicy: config.approval_policy ?? "never",
1273
+ ...config.approvals_reviewer ? { approvalsReviewer: config.approvals_reviewer } : {},
1274
+ sandbox: config.sandbox_mode ?? "read-only",
1275
+ ...Object.keys(config.cli_config ?? {}).length > 0 ? { config: config.cli_config } : {},
1276
+ ...config.base_instructions ? { baseInstructions: config.base_instructions } : {},
1277
+ ...config.developer_instructions ? { developerInstructions: config.developer_instructions } : {},
1278
+ ...config.personality ? { personality: config.personality } : {},
1279
+ ...config.base_url ? { config: {
1280
+ ...config.cli_config ?? {},
1281
+ openai_base_url: config.base_url
1282
+ } } : {},
1283
+ persistExtendedHistory: config.persist_extended_history ?? false
1284
+ };
1285
+ }
1286
+ buildTurnStartParams(threadId, input, config) {
1287
+ return {
1288
+ threadId,
1289
+ input,
1290
+ ...config.working_dir ? { cwd: config.working_dir } : {},
1291
+ approvalPolicy: config.approval_policy ?? "never",
1292
+ ...config.approvals_reviewer ? { approvalsReviewer: config.approvals_reviewer } : {},
1293
+ ...config.sandbox_policy || config.network_access_enabled !== void 0 ? { sandboxPolicy: this.buildSandboxPolicy(config) } : {},
1294
+ ...config.model ? { model: config.model } : {},
1295
+ ...config.service_tier ? { serviceTier: config.service_tier } : {},
1296
+ ...config.model_reasoning_effort ? { effort: config.model_reasoning_effort } : {},
1297
+ ...config.reasoning_summary ? { summary: config.reasoning_summary } : {},
1298
+ ...config.personality ? { personality: config.personality } : {},
1299
+ ...config.collaboration_mode ? { collaborationMode: config.collaboration_mode } : {},
1300
+ ...config.output_schema ? { outputSchema: config.output_schema } : {}
1301
+ };
1302
+ }
1303
+ buildSandboxPolicy(config) {
1304
+ if (config.sandbox_policy) return config.sandbox_policy;
1305
+ const networkAccess = config.network_access_enabled === true;
1306
+ switch (config.sandbox_mode ?? "read-only") {
1307
+ case "danger-full-access": return { type: "dangerFullAccess" };
1308
+ case "workspace-write": return {
1309
+ type: "workspaceWrite",
1310
+ writableRoots: [config.working_dir, ...config.additional_directories ?? []].filter(Boolean),
1311
+ readOnlyAccess: { type: "fullAccess" },
1312
+ networkAccess,
1313
+ excludeTmpdirEnvVar: false,
1314
+ excludeSlashTmp: false
1315
+ };
1316
+ default: return {
1317
+ type: "readOnly",
1318
+ access: { type: "fullAccess" },
1319
+ networkAccess
1320
+ };
1321
+ }
1322
+ }
1323
+ parsePromptInput(prompt) {
1324
+ let parsedPrompt;
1325
+ try {
1326
+ parsedPrompt = JSON.parse(prompt);
1327
+ } catch {
1328
+ return [{
1329
+ type: "text",
1330
+ text: prompt,
1331
+ text_elements: []
1332
+ }];
1333
+ }
1334
+ if (!Array.isArray(parsedPrompt) || parsedPrompt.length === 0) return [{
1335
+ type: "text",
1336
+ text: prompt,
1337
+ text_elements: []
1338
+ }];
1339
+ const input = [];
1340
+ for (const item of parsedPrompt) {
1341
+ if (!this.isPromptInputItem(item)) return [{
1342
+ type: "text",
1343
+ text: prompt,
1344
+ text_elements: []
1345
+ }];
1346
+ input.push(this.normalizePromptInputItem(item));
1347
+ }
1348
+ return input;
1349
+ }
1350
+ isPromptInputItem(item) {
1351
+ if (!item || typeof item !== "object" || Array.isArray(item)) return false;
1352
+ if ("type" in item && item.type === "text") return "text" in item && typeof item.text === "string";
1353
+ if ("type" in item && item.type === "image") return "url" in item && typeof item.url === "string";
1354
+ if ("type" in item && (item.type === "local_image" || item.type === "localImage")) return "path" in item && typeof item.path === "string";
1355
+ if ("type" in item && (item.type === "skill" || item.type === "mention")) return "name" in item && typeof item.name === "string" && "path" in item && typeof item.path === "string";
1356
+ return false;
1357
+ }
1358
+ normalizePromptInputItem(item) {
1359
+ switch (item.type) {
1360
+ case "text": return {
1361
+ type: "text",
1362
+ text: item.text,
1363
+ text_elements: []
1364
+ };
1365
+ case "image": return {
1366
+ type: "image",
1367
+ url: item.url
1368
+ };
1369
+ case "local_image":
1370
+ case "localImage": return {
1371
+ type: "localImage",
1372
+ path: item.path
1373
+ };
1374
+ case "skill": return {
1375
+ type: "skill",
1376
+ name: item.name,
1377
+ path: item.path
1378
+ };
1379
+ case "mention": return {
1380
+ type: "mention",
1381
+ name: item.name,
1382
+ path: item.path
1383
+ };
1384
+ }
1385
+ }
1386
+ formatPromptInputForTrace(input) {
1387
+ return input.map((item) => {
1388
+ switch (item.type) {
1389
+ case "text": return item.text;
1390
+ case "image": return `[image: ${item.url}]`;
1391
+ case "localImage": return `[local_image: ${item.path}]`;
1392
+ case "skill": return `[skill: ${item.name} ${item.path}]`;
1393
+ case "mention": return `[mention: ${item.name} ${item.path}]`;
1394
+ }
1395
+ }).join("\n");
1396
+ }
1397
+ createTurnState(connection, connectionKey, connectionInstanceId, threadId, promptInput, config, appServerEnv) {
1398
+ return {
1399
+ connection,
1400
+ connectionKey,
1401
+ connectionInstanceId,
1402
+ threadId,
1403
+ config,
1404
+ appServerEnv,
1405
+ promptInput,
1406
+ items: [],
1407
+ itemStarts: [],
1408
+ notifications: [],
1409
+ notificationCount: 0,
1410
+ bufferedEventChars: 0,
1411
+ serverRequests: [],
1412
+ agentMessageDeltas: [],
1413
+ agentMessageDeltasByItemId: /* @__PURE__ */ new Map(),
1414
+ commandExecutionOutputDeltasByItemId: /* @__PURE__ */ new Map(),
1415
+ completed: createDeferred(),
1416
+ activeSpans: /* @__PURE__ */ new Map(),
1417
+ itemStartTimes: /* @__PURE__ */ new Map(),
1418
+ lastEventTime: Date.now(),
1419
+ turnCount: 0,
1420
+ activeTurnSpan: void 0,
1421
+ activeTurnIndex: 0
1422
+ };
1423
+ }
1424
+ registerTurnState(state) {
1425
+ this.activeTurnsByThread.set(state.threadId, state);
1426
+ if (state.turnId) this.activeTurnsByTurn.set(state.turnId, state);
1427
+ }
1428
+ updateTurnStateId(state, turnId) {
1429
+ if (state.turnId && state.turnId !== turnId) this.activeTurnsByTurn.delete(state.turnId);
1430
+ state.turnId = turnId;
1431
+ this.activeTurnsByTurn.set(turnId, state);
1432
+ }
1433
+ unregisterTurnState(state) {
1434
+ this.activeTurnsByThread.delete(state.threadId);
1435
+ if (state.turnId) this.activeTurnsByTurn.delete(state.turnId);
1436
+ this.endUnclosedItemSpans(state);
1437
+ }
1438
+ protectThread(threadId) {
1439
+ this.protectedThreadCounts.set(threadId, (this.protectedThreadCounts.get(threadId) ?? 0) + 1);
1440
+ }
1441
+ unprotectThread(threadId) {
1442
+ const count = this.protectedThreadCounts.get(threadId);
1443
+ if (!count || count <= 1) {
1444
+ this.protectedThreadCounts.delete(threadId);
1445
+ return;
1446
+ }
1447
+ this.protectedThreadCounts.set(threadId, count - 1);
1448
+ }
1449
+ isThreadProtected(threadId) {
1450
+ return this.activeTurnsByThread.has(threadId) || (this.protectedThreadCounts.get(threadId) ?? 0) > 0;
1451
+ }
1452
+ getTurnState(threadId, turnId) {
1453
+ if (turnId) return this.activeTurnsByTurn.get(turnId);
1454
+ if (threadId) return this.activeTurnsByThread.get(threadId);
1455
+ }
1456
+ handleNotification(message) {
1457
+ const params = message.params ?? {};
1458
+ const state = this.getTurnState(params.threadId, params.turnId);
1459
+ if (!state) {
1460
+ require_logger.logger.debug("[CodexAppServer] Notification without active turn", { method: message.method });
1461
+ return;
1462
+ }
1463
+ if (!this.reserveTurnEvent(state, message)) return;
1464
+ state.notificationCount += 1;
1465
+ if (state.config.include_raw_events) state.notifications.push(message);
1466
+ const eventTime = Date.now();
1467
+ switch (message.method) {
1468
+ case "turn/started":
1469
+ if (typeof params.turn?.id === "string") this.updateTurnStateId(state, params.turn.id);
1470
+ this.startTurnSpan(state, eventTime, true);
1471
+ break;
1472
+ case "item/started":
1473
+ if (!state.activeTurnSpan) this.startTurnSpan(state, eventTime);
1474
+ this.handleItemStarted(state, params.item, eventTime);
1475
+ break;
1476
+ case "item/completed":
1477
+ if (!state.activeTurnSpan) this.startTurnSpan(state, eventTime);
1478
+ this.handleItemCompleted(state, params.item, eventTime);
1479
+ break;
1480
+ case "item/agentMessage/delta":
1481
+ this.handleAgentMessageDelta(state, params);
1482
+ break;
1483
+ case "item/commandExecution/outputDelta":
1484
+ this.handleCommandExecutionOutputDelta(state, params);
1485
+ break;
1486
+ case "thread/tokenUsage/updated":
1487
+ state.rawTokenUsage = params.tokenUsage;
1488
+ state.tokenUsage = this.buildTokenUsage(params.tokenUsage);
1489
+ break;
1490
+ case "turn/completed":
1491
+ state.turn = params.turn;
1492
+ if (params.turn?.status === "failed") state.error = params.turn?.error?.message ?? "Codex app-server turn failed";
1493
+ if (!state.activeTurnSpan) this.startTurnSpan(state, state.lastEventTime);
1494
+ this.endTurnSpan(state, eventTime, state.error);
1495
+ state.completed.resolve();
1496
+ break;
1497
+ case "error":
1498
+ if (params.willRetry === true) {
1499
+ require_logger.logger.debug("[CodexAppServer] Retryable error received", {
1500
+ error: params.error?.message,
1501
+ threadId: params.threadId,
1502
+ turnId: params.turnId
1503
+ });
1504
+ break;
1505
+ }
1506
+ state.error = params.error?.message ?? "Codex app-server error";
1507
+ if (!state.activeTurnSpan) this.startTurnSpan(state, state.lastEventTime);
1508
+ this.endTurnSpan(state, eventTime, state.error);
1509
+ state.completed.resolve();
1510
+ }
1511
+ state.lastEventTime = eventTime;
1512
+ }
1513
+ handleItemStarted(state, item, eventTime) {
1514
+ if (!item) return;
1515
+ state.itemStarts.push(item);
1516
+ if (!item.id) return;
1517
+ const itemId = String(item.id);
1518
+ const span = this.startItemSpan(item, itemId, void 0, state.activeTurnIndex > 0 ? state.activeTurnIndex : void 0);
1519
+ state.activeSpans.set(itemId, span);
1520
+ state.itemStartTimes.set(itemId, eventTime);
1521
+ }
1522
+ handleItemCompleted(state, item, eventTime) {
1523
+ if (!item) return;
1524
+ const completedItem = this.withCommandExecutionOutput(state, item);
1525
+ if (completedItem?.type === "commandExecution" && typeof completedItem.id === "string" && typeof completedItem.aggregatedOutput === "string") {
1526
+ const existingOutput = state.commandExecutionOutputDeltasByItemId.get(completedItem.id);
1527
+ if (typeof existingOutput !== "string" || completedItem.aggregatedOutput.startsWith(existingOutput)) state.commandExecutionOutputDeltasByItemId.set(completedItem.id, completedItem.aggregatedOutput);
1528
+ }
1529
+ state.items.push(completedItem);
1530
+ const itemId = completedItem.id ? String(completedItem.id) : crypto.default.randomUUID();
1531
+ const span = state.activeSpans.get(itemId) ?? this.startItemSpan(completedItem, itemId, state.lastEventTime, state.activeTurnIndex > 0 ? state.activeTurnIndex : void 0);
1532
+ const startTime = state.itemStartTimes.get(itemId) ?? state.lastEventTime;
1533
+ this.applyItemCompletionAttributes(span, completedItem, eventTime, startTime);
1534
+ span.end();
1535
+ state.activeSpans.delete(itemId);
1536
+ state.itemStartTimes.delete(itemId);
1537
+ }
1538
+ handleAgentMessageDelta(state, params) {
1539
+ if (typeof params.delta !== "string") return;
1540
+ state.agentMessageDeltas.push(params.delta);
1541
+ if (typeof params.itemId === "string") {
1542
+ const existing = state.agentMessageDeltasByItemId.get(params.itemId) ?? "";
1543
+ state.agentMessageDeltasByItemId.set(params.itemId, existing + params.delta);
1544
+ }
1545
+ }
1546
+ handleCommandExecutionOutputDelta(state, params) {
1547
+ if (typeof params.itemId !== "string" || typeof params.delta !== "string") return;
1548
+ const existing = state.commandExecutionOutputDeltasByItemId.get(params.itemId) ?? "";
1549
+ const aggregatedOutput = existing + params.delta;
1550
+ state.commandExecutionOutputDeltasByItemId.set(params.itemId, aggregatedOutput);
1551
+ const completedItem = state.items.find((item) => item?.type === "commandExecution" && String(item.id) === params.itemId);
1552
+ if (completedItem && (typeof completedItem.aggregatedOutput !== "string" || completedItem.aggregatedOutput === existing)) completedItem.aggregatedOutput = aggregatedOutput;
1553
+ }
1554
+ withCommandExecutionOutput(state, item) {
1555
+ if (item?.type !== "commandExecution" || typeof item.id !== "string") return item;
1556
+ const aggregatedOutput = state.commandExecutionOutputDeltasByItemId.get(item.id);
1557
+ if (typeof aggregatedOutput !== "string") return item;
1558
+ if (typeof item.aggregatedOutput === "string" && !aggregatedOutput.startsWith(item.aggregatedOutput)) return item;
1559
+ return {
1560
+ ...item,
1561
+ aggregatedOutput
1562
+ };
1563
+ }
1564
+ async handleServerRequest(message, config) {
1565
+ const params = message.params ?? {};
1566
+ const state = this.getTurnState(params.threadId ?? params.conversationId, params.turnId);
1567
+ if (state && !this.reserveTurnEvent(state, message)) throw new Error(state.error ?? "Codex app-server turn event limit exceeded");
1568
+ const record = {
1569
+ id: message.id,
1570
+ method: message.method ?? "unknown",
1571
+ params: this.sanitizeForMetadata(params)
1572
+ };
1573
+ try {
1574
+ const response = this.buildServerRequestResponse(message, state?.config ?? config);
1575
+ record.response = this.sanitizeForMetadata(response);
1576
+ state?.serverRequests.push(record);
1577
+ return response;
1578
+ } catch (error) {
1579
+ record.error = error instanceof Error ? error.message : String(error);
1580
+ state?.serverRequests.push(record);
1581
+ throw error;
1582
+ }
1583
+ }
1584
+ reserveTurnEvent(state, message) {
1585
+ state.bufferedEventChars += JSON.stringify(message).length;
1586
+ if (state.bufferedEventChars <= MAX_BUFFERED_TURN_EVENT_CHARS) return true;
1587
+ state.error = `codex app-server turn events exceeded ${MAX_BUFFERED_TURN_EVENT_CHARS} characters`;
1588
+ this.handleConnectionClose(state.connectionKey, state.connectionInstanceId, new Error(state.error));
1589
+ state.connection.close();
1590
+ return false;
1591
+ }
1592
+ buildServerRequestResponse(message, config) {
1593
+ const policy = config.server_request_policy ?? {};
1594
+ switch (message.method) {
1595
+ case "item/commandExecution/requestApproval": return { decision: policy.command_execution ?? "decline" };
1596
+ case "execCommandApproval": return this.buildLegacyApprovalResponse(policy.command_execution);
1597
+ case "item/fileChange/requestApproval": return { decision: policy.file_change ?? "decline" };
1598
+ case "applyPatchApproval": return this.buildLegacyApprovalResponse(policy.file_change);
1599
+ case "item/permissions/requestApproval": return {
1600
+ permissions: policy.permissions?.permissions ?? {},
1601
+ scope: policy.permissions?.scope ?? "turn",
1602
+ ...policy.permissions?.strict_auto_review === void 0 ? {} : { strictAutoReview: policy.permissions.strict_auto_review }
1603
+ };
1604
+ case "item/tool/requestUserInput": return this.buildUserInputResponse(message.params, policy.user_input ?? "empty");
1605
+ case "mcpServer/elicitation/request": return this.buildMcpElicitationResponse(policy.mcp_elicitation);
1606
+ case "item/tool/call": return this.buildDynamicToolResponse(message.params, policy.dynamic_tools);
1607
+ case "account/chatgptAuthTokens/refresh": throw new Error("ChatGPT auth token refresh requests are not supported by promptfoo");
1608
+ default: throw new Error(`Unsupported codex app-server request: ${message.method ?? "unknown"}`);
1609
+ }
1610
+ }
1611
+ buildLegacyApprovalResponse(decision = "decline") {
1612
+ if (typeof decision !== "string") return { decision: "denied" };
1613
+ switch (decision) {
1614
+ case "accept": return { decision: "approved" };
1615
+ case "acceptForSession": return { decision: "approved_for_session" };
1616
+ case "cancel": return { decision: "abort" };
1617
+ case "decline": return { decision: "denied" };
1618
+ }
1619
+ }
1620
+ buildMcpElicitationResponse(policy = "decline") {
1621
+ if (typeof policy === "string") return {
1622
+ action: policy,
1623
+ content: null,
1624
+ _meta: null
1625
+ };
1626
+ return {
1627
+ action: policy.action,
1628
+ content: policy.content ?? null,
1629
+ _meta: policy._meta ?? null
1630
+ };
1631
+ }
1632
+ buildUserInputResponse(params, policy) {
1633
+ const answers = Object.create(null);
1634
+ const questions = Array.isArray(params?.questions) ? params.questions : [];
1635
+ for (const question of questions) {
1636
+ if (!question?.id || typeof question.id !== "string") continue;
1637
+ if (policy === "empty") {
1638
+ answers[question.id] = { answers: [] };
1639
+ continue;
1640
+ }
1641
+ if (policy === "first-option") {
1642
+ const firstLabel = Array.isArray(question.options) && typeof question.options[0]?.label === "string" ? question.options[0].label : "";
1643
+ answers[question.id] = { answers: firstLabel ? [firstLabel] : [] };
1644
+ continue;
1645
+ }
1646
+ const configuredAnswer = Object.prototype.hasOwnProperty.call(policy, question.id) ? policy[question.id] : void 0;
1647
+ answers[question.id] = { answers: Array.isArray(configuredAnswer) ? configuredAnswer : configuredAnswer ? [configuredAnswer] : [] };
1648
+ }
1649
+ return { answers };
1650
+ }
1651
+ buildDynamicToolResponse(params, tools) {
1652
+ const configured = typeof params?.tool === "string" && tools && Object.prototype.hasOwnProperty.call(tools, params.tool) ? tools[params.tool] : void 0;
1653
+ if (!configured) return {
1654
+ contentItems: [{
1655
+ type: "inputText",
1656
+ text: "No dynamic tool response configured."
1657
+ }],
1658
+ success: false
1659
+ };
1660
+ return {
1661
+ contentItems: configured.contentItems ?? [{
1662
+ type: "inputText",
1663
+ text: configured.text ?? ""
1664
+ }],
1665
+ success: configured.success ?? true
1666
+ };
1667
+ }
1668
+ async waitForTurnCompletion(connection, state, config, callOptions) {
1669
+ const interruptTurn = () => {
1670
+ if (!state.turnId) return;
1671
+ connection.request("turn/interrupt", {
1672
+ threadId: state.threadId,
1673
+ turnId: state.turnId
1674
+ }, { timeoutMs: 5e3 }).catch((error) => {
1675
+ require_logger.logger.debug("[CodexAppServer] Error interrupting turn", { error });
1676
+ });
1677
+ };
1678
+ let timeout;
1679
+ let abortListener;
1680
+ const timeoutPromise = config.turn_timeout_ms ? new Promise((_, reject) => {
1681
+ timeout = setTimeout(() => {
1682
+ interruptTurn();
1683
+ reject(/* @__PURE__ */ new Error(`codex app-server turn timed out after ${config.turn_timeout_ms}ms`));
1684
+ }, config.turn_timeout_ms);
1685
+ }) : void 0;
1686
+ const abortPromise = callOptions?.abortSignal ? new Promise((_, reject) => {
1687
+ abortListener = () => {
1688
+ interruptTurn();
1689
+ reject(require_agenticRunQueue.createAbortError("OpenAI Codex app-server call aborted"));
1690
+ };
1691
+ callOptions.abortSignal?.addEventListener("abort", abortListener, { once: true });
1692
+ }) : void 0;
1693
+ try {
1694
+ await Promise.race([
1695
+ state.completed.promise,
1696
+ timeoutPromise,
1697
+ abortPromise
1698
+ ].filter((promise) => Boolean(promise)));
1699
+ } finally {
1700
+ clearTimeout(timeout);
1701
+ if (abortListener && callOptions?.abortSignal) callOptions.abortSignal.removeEventListener("abort", abortListener);
1702
+ }
1703
+ if (state.error) throw new Error(state.error);
1704
+ }
1705
+ async cleanupThreadAfterTurn(connection, threadHandle, config, options = {}) {
1706
+ if (threadHandle.persistent || config.thread_cleanup === "none") return;
1707
+ if (options.skipIfProtected && this.isThreadProtected(threadHandle.threadId)) return;
1708
+ if (options.skipIfActiveTurn && this.activeTurnsByThread.has(threadHandle.threadId)) return;
1709
+ if (config.thread_id && (this.protectedThreadCounts.get(threadHandle.threadId) ?? 0) > 1) return;
1710
+ if (config.thread_id && config.thread_cleanup === "archive") return;
1711
+ try {
1712
+ if (config.thread_cleanup === "archive") await connection.request("thread/archive", { threadId: threadHandle.threadId }, { timeoutMs: this.getRequestTimeoutMs(config) });
1713
+ else await connection.request("thread/unsubscribe", { threadId: threadHandle.threadId }, { timeoutMs: this.getRequestTimeoutMs(config) });
1714
+ } catch (error) {
1715
+ require_logger.logger.warn("[CodexAppServer] Error cleaning up thread after turn", {
1716
+ threadId: threadHandle.threadId,
1717
+ error
1718
+ });
1719
+ }
1720
+ }
1721
+ getThreadRunQueueKey(config, threadHandle) {
1722
+ if (config.thread_id) return `thread_id:${threadHandle.threadId}`;
1723
+ if (config.deep_tracing) return;
1724
+ if (threadHandle.persistent && threadHandle.cacheKey) return threadHandle.cacheKey;
1725
+ }
1726
+ async runSerializedThreadTurn(queueKey, abortSignal, executeTurn, cleanupGeneration) {
1727
+ if (cleanupGeneration !== this.cleanupGeneration) throw new Error("codex app-server provider cleanup interrupted queued turn");
1728
+ return this.threadRunQueues.run(queueKey, abortSignal, async () => {
1729
+ if (cleanupGeneration !== this.cleanupGeneration) throw new Error("codex app-server provider cleanup interrupted queued turn");
1730
+ return executeTurn();
1731
+ });
1732
+ }
1733
+ buildProviderResponse(state, threadHandle, config) {
1734
+ const output = this.getFinalOutput(state);
1735
+ const normalizedItems = state.items.map((item) => this.normalizeItemForMetadata(item));
1736
+ const rawItems = state.items.map((item) => this.normalizeItemForRaw(item));
1737
+ const rawTokenUsage = this.sanitizeForMetadata(state.rawTokenUsage);
1738
+ const raw = {
1739
+ finalResponse: output,
1740
+ output,
1741
+ thread: this.sanitizeForMetadata(threadHandle.response?.thread),
1742
+ turn: this.sanitizeForMetadata(state.turn),
1743
+ items: rawItems,
1744
+ usage: this.buildSdkUsage(state.rawTokenUsage),
1745
+ tokenUsage: rawTokenUsage,
1746
+ serverRequests: state.serverRequests,
1747
+ ...config.include_raw_events ? { notifications: this.sanitizeForMetadata(state.notifications) } : {}
1748
+ };
1749
+ const metadata = this.buildResponseMetadata(state, threadHandle, config, normalizedItems);
1750
+ return {
1751
+ output,
1752
+ tokenUsage: state.tokenUsage,
1753
+ cost: this.calculateResponseCost(state.tokenUsage, config.model),
1754
+ metadata,
1755
+ raw: JSON.stringify(raw),
1756
+ sessionId: threadHandle.threadId
1757
+ };
1758
+ }
1759
+ getFinalOutput(state) {
1760
+ const completedAgentMessages = state.items.filter((item) => item?.type === "agentMessage" && typeof item.text === "string").map((item) => item.text);
1761
+ if (completedAgentMessages.length > 0) return completedAgentMessages[completedAgentMessages.length - 1];
1762
+ const deltaMessages = Array.from(state.agentMessageDeltasByItemId.values()).filter(Boolean);
1763
+ if (deltaMessages.length > 0) return deltaMessages[deltaMessages.length - 1];
1764
+ return state.agentMessageDeltas.join("");
1765
+ }
1766
+ buildResponseMetadata(state, threadHandle, config, normalizedItems) {
1767
+ const skillMetadata = this.buildSkillMetadata(state.items, this.getSkillRootPrefixes(config, state.appServerEnv));
1768
+ return {
1769
+ codexAppServer: {
1770
+ threadId: threadHandle.threadId,
1771
+ turnId: state.turnId,
1772
+ model: config.model,
1773
+ modelProvider: config.model_provider,
1774
+ cwd: config.working_dir,
1775
+ sandboxMode: config.sandbox_mode ?? "read-only",
1776
+ approvalPolicy: config.approval_policy ?? "never",
1777
+ itemCounts: this.getItemCounts(state.items),
1778
+ items: normalizedItems,
1779
+ serverRequests: state.serverRequests,
1780
+ notificationCount: state.notificationCount
1781
+ },
1782
+ ...require_codexSkillMetadata.getCodexSkillMetadataFields(skillMetadata)
1783
+ };
1784
+ }
1785
+ normalizeItemForMetadata(item) {
1786
+ const base = {
1787
+ id: item?.id,
1788
+ type: item?.type,
1789
+ status: item?.status
1790
+ };
1791
+ switch (item?.type) {
1792
+ case "commandExecution": return this.sanitizeForMetadata({
1793
+ ...base,
1794
+ command: item.command,
1795
+ cwd: item.cwd,
1796
+ exitCode: item.exitCode,
1797
+ durationMs: item.durationMs,
1798
+ aggregatedOutput: item.aggregatedOutput
1799
+ });
1800
+ case "fileChange": return this.sanitizeForMetadata({
1801
+ ...base,
1802
+ changes: item.changes
1803
+ });
1804
+ case "mcpToolCall": return this.sanitizeForMetadata({
1805
+ ...base,
1806
+ server: item.server,
1807
+ tool: item.tool,
1808
+ arguments: item.arguments,
1809
+ result: item.result,
1810
+ error: item.error,
1811
+ durationMs: item.durationMs
1812
+ });
1813
+ case "dynamicToolCall": return this.sanitizeForMetadata({
1814
+ ...base,
1815
+ tool: item.tool,
1816
+ arguments: item.arguments,
1817
+ success: item.success,
1818
+ contentItems: item.contentItems,
1819
+ durationMs: item.durationMs
1820
+ });
1821
+ case "webSearch": return this.sanitizeForMetadata({
1822
+ ...base,
1823
+ query: item.query,
1824
+ action: item.action
1825
+ });
1826
+ case "agentMessage": return this.sanitizeForMetadata({
1827
+ ...base,
1828
+ text: item.text
1829
+ });
1830
+ case "reasoning": return this.sanitizeForMetadata({
1831
+ ...base,
1832
+ summary: item.summary,
1833
+ content: item.content
1834
+ });
1835
+ default: return this.sanitizeForMetadata(base);
1836
+ }
1837
+ }
1838
+ normalizeItemForRaw(item) {
1839
+ const base = {
1840
+ id: item?.id,
1841
+ type: item?.type,
1842
+ status: item?.status
1843
+ };
1844
+ switch (item?.type) {
1845
+ case "commandExecution": return this.sanitizeForMetadata({
1846
+ ...base,
1847
+ type: "command_execution",
1848
+ command: item.command,
1849
+ cwd: item.cwd,
1850
+ exit_code: item.exitCode,
1851
+ duration_ms: item.durationMs,
1852
+ aggregated_output: item.aggregatedOutput
1853
+ });
1854
+ case "fileChange": return this.sanitizeForMetadata({
1855
+ ...base,
1856
+ type: "file_change",
1857
+ changes: item.changes
1858
+ });
1859
+ case "mcpToolCall": return this.sanitizeForMetadata({
1860
+ ...base,
1861
+ type: "mcp_tool_call",
1862
+ server: item.server,
1863
+ tool: item.tool,
1864
+ arguments: item.arguments,
1865
+ result: item.result,
1866
+ error: item.error,
1867
+ duration_ms: item.durationMs
1868
+ });
1869
+ case "dynamicToolCall": return this.sanitizeForMetadata({
1870
+ ...base,
1871
+ type: "dynamic_tool_call",
1872
+ tool: item.tool,
1873
+ arguments: item.arguments,
1874
+ success: item.success,
1875
+ content_items: item.contentItems,
1876
+ duration_ms: item.durationMs
1877
+ });
1878
+ case "webSearch": return this.sanitizeForMetadata({
1879
+ ...base,
1880
+ type: "web_search",
1881
+ query: item.query,
1882
+ action: item.action
1883
+ });
1884
+ case "agentMessage": return this.sanitizeForMetadata({
1885
+ ...base,
1886
+ type: "agent_message",
1887
+ text: item.text
1888
+ });
1889
+ case "reasoning": return this.sanitizeForMetadata({
1890
+ ...base,
1891
+ type: "reasoning",
1892
+ text: this.extractReasoningText(item),
1893
+ summary: item.summary,
1894
+ content: item.content
1895
+ });
1896
+ case "todoList": return this.sanitizeForMetadata({
1897
+ ...base,
1898
+ type: "todo_list",
1899
+ items: item.items
1900
+ });
1901
+ case "error": return this.sanitizeForMetadata({
1902
+ ...base,
1903
+ type: "error",
1904
+ message: item.message
1905
+ });
1906
+ case "userMessage": return this.sanitizeForMetadata({
1907
+ ...base,
1908
+ type: "user_message",
1909
+ content: item.content
1910
+ });
1911
+ default: return this.sanitizeForMetadata(base);
1912
+ }
1913
+ }
1914
+ extractReasoningText(item) {
1915
+ if (typeof item?.text === "string") return item.text;
1916
+ const blocks = [item?.summary, item?.content].find(Array.isArray);
1917
+ if (!blocks) return;
1918
+ const parts = blocks.flatMap((block) => {
1919
+ if (typeof block === "string") return [block];
1920
+ const text = block?.text;
1921
+ return typeof text === "string" && text.length > 0 ? [text] : [];
1922
+ });
1923
+ return parts.length > 0 ? parts.join("\n") : void 0;
1924
+ }
1925
+ resolveRawUsage(rawTokenUsage) {
1926
+ const usage = rawTokenUsage?.last ?? rawTokenUsage?.total ?? rawTokenUsage;
1927
+ if (!usage) return;
1928
+ const input = usage.inputTokens ?? usage.input_tokens;
1929
+ const output = usage.outputTokens ?? usage.output_tokens;
1930
+ if (typeof input !== "number" || typeof output !== "number") return;
1931
+ return {
1932
+ input,
1933
+ output,
1934
+ cached: usage.cachedInputTokens ?? usage.cached_input_tokens ?? 0,
1935
+ cacheWrite: typeof (usage.cacheWriteInputTokens ?? usage.cache_write_input_tokens) === "number" ? usage.cacheWriteInputTokens ?? usage.cache_write_input_tokens : void 0,
1936
+ reasoning: usage.reasoningOutputTokens ?? usage.reasoning_output_tokens ?? 0
1937
+ };
1938
+ }
1939
+ buildSdkUsage(rawTokenUsage) {
1940
+ const usage = this.resolveRawUsage(rawTokenUsage);
1941
+ if (!usage) return;
1942
+ return {
1943
+ input_tokens: usage.input,
1944
+ cached_input_tokens: usage.cached,
1945
+ cache_write_input_tokens: usage.cacheWrite ?? 0,
1946
+ output_tokens: usage.output,
1947
+ reasoning_output_tokens: usage.reasoning
1948
+ };
1949
+ }
1950
+ buildTokenUsage(rawTokenUsage) {
1951
+ const usage = this.resolveRawUsage(rawTokenUsage);
1952
+ if (!usage) return;
1953
+ return {
1954
+ prompt: usage.input,
1955
+ completion: usage.output,
1956
+ total: usage.input + usage.output,
1957
+ cached: usage.cached,
1958
+ ...typeof usage.cacheWrite === "number" ? { completionDetails: { cacheCreationInputTokens: usage.cacheWrite } } : {}
1959
+ };
1960
+ }
1961
+ calculateResponseCost(tokenUsage, model) {
1962
+ return require_billing.calculateOpenAIUsageCostFromTokenUsage(model, tokenUsage);
1963
+ }
1964
+ getItemCounts(items) {
1965
+ const counts = {};
1966
+ for (const item of items) {
1967
+ const type = typeof item?.type === "string" ? item.type : "unknown";
1968
+ counts[type] = (counts[type] ?? 0) + 1;
1969
+ }
1970
+ return counts;
1971
+ }
1972
+ validateWorkingDirectory(workingDir, skipGitCheck = false) {
1973
+ const cacheKey = `${workingDir}:${skipGitCheck}`;
1974
+ if (this.validatedWorkingDirs.has(cacheKey)) return;
1975
+ let stats;
1976
+ try {
1977
+ stats = fs.default.statSync(workingDir);
1978
+ } catch (err) {
1979
+ throw new Error(`Working directory ${workingDir} does not exist or isn't accessible: ${err.message}`);
1980
+ }
1981
+ if (!stats.isDirectory()) throw new Error(`Working directory ${workingDir} is not a directory`);
1982
+ if (!skipGitCheck && !this.isInsideGitRepository(workingDir)) throw new Error(dedent.default`Working directory ${workingDir} is not inside a Git repository.
1983
+
1984
+ Codex app-server requires a Git repository by default to prevent unrecoverable errors.
1985
+
1986
+ To bypass this check, set skip_git_repo_check: true in your provider config.`);
1987
+ this.validatedWorkingDirs.add(cacheKey);
1988
+ }
1989
+ isInsideGitRepository(workingDir) {
1990
+ return this.findGitRepositoryRoot(workingDir) !== void 0;
1991
+ }
1992
+ findGitRepositoryRoot(workingDir) {
1993
+ return require_codexSkillMetadata.findGitRepositoryRoot(workingDir);
1994
+ }
1995
+ warnOnceForDeepTracingThreadOptions(config) {
1996
+ if (!config.deep_tracing || this.deepTracingWarningShown || !config.persist_threads && (config.thread_pool_size ?? 0) <= 1) return;
1997
+ require_logger.logger.warn("[CodexAppServer] deep_tracing requires a fresh app-server process per call. Persistent thread pooling options (persist_threads, thread_pool_size) are ignored when deep_tracing is enabled. Explicit thread_id values are still resumed and serialized.");
1998
+ this.deepTracingWarningShown = true;
1999
+ }
2000
+ startItemSpan(item, itemId, startTime, turnIndex) {
2001
+ return _opentelemetry_api.trace.getTracer("promptfoo.codex-app-server").startSpan(this.getSpanNameForItem(item), {
2002
+ kind: _opentelemetry_api.SpanKind.INTERNAL,
2003
+ ...startTime === void 0 ? {} : { startTime },
2004
+ attributes: require_genaiTracer.addActiveSpanRoleAttribute({
2005
+ "codex.app_server.item.id": itemId,
2006
+ "codex.app_server.item.type": item?.type ?? "unknown",
2007
+ ...typeof turnIndex === "number" ? { "gen_ai.turn.index": turnIndex } : {},
2008
+ ...this.getAttributesForItem(item)
2009
+ })
2010
+ });
2011
+ }
2012
+ startTurnSpan(state, eventTime, clearPreviousUsage = false) {
2013
+ if (clearPreviousUsage && state.turnCount > 0) {
2014
+ state.rawTokenUsage = void 0;
2015
+ state.tokenUsage = void 0;
2016
+ }
2017
+ require_genaiTracer.openTurnSpan(state, {
2018
+ tracer: _opentelemetry_api.trace.getTracer("promptfoo.codex-app-server"),
2019
+ eventTime,
2020
+ system: "openai",
2021
+ logLabel: "CodexAppServer"
2022
+ });
2023
+ }
2024
+ endTurnSpan(state, eventTime, errorMessage) {
2025
+ const usage = this.resolveRawUsage(state.rawTokenUsage);
2026
+ const attributes = {};
2027
+ if (usage) {
2028
+ attributes["gen_ai.usage.input_tokens"] = usage.input;
2029
+ attributes["gen_ai.usage.output_tokens"] = usage.output;
2030
+ if (usage.cached) attributes[require_genaiTracer.GenAIAttributes.USAGE_CACHE_READ_INPUT_TOKENS] = usage.cached;
2031
+ if (usage.cacheWrite) attributes[require_genaiTracer.GenAIAttributes.USAGE_CACHE_CREATION_INPUT_TOKENS] = usage.cacheWrite;
2032
+ if (usage.reasoning) attributes[require_genaiTracer.GenAIAttributes.USAGE_REASONING_OUTPUT_TOKENS] = usage.reasoning;
2033
+ }
2034
+ require_genaiTracer.closeTurnSpan(state, {
2035
+ eventTime,
2036
+ attributes,
2037
+ errorMessage,
2038
+ logLabel: "CodexAppServer"
2039
+ });
2040
+ }
2041
+ applyItemCompletionAttributes(span, item, eventTime, startTime) {
2042
+ for (const [key, value] of Object.entries(this.getCompletionAttributesForItem(item))) span.setAttribute(key, value);
2043
+ span.setAttribute("codex.app_server.duration_ms", eventTime - startTime);
2044
+ if (this.isItemError(item)) span.setStatus({
2045
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2046
+ message: this.getItemErrorMessage(item)
2047
+ });
2048
+ else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
2049
+ }
2050
+ endUnclosedItemSpans(state) {
2051
+ for (const [itemId, span] of state.activeSpans) {
2052
+ require_logger.logger.warn("[CodexAppServer] Item span not properly closed", { itemId });
2053
+ span.setStatus({
2054
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2055
+ message: "Span not properly closed"
2056
+ });
2057
+ span.end();
2058
+ }
2059
+ state.activeSpans.clear();
2060
+ state.itemStartTimes.clear();
2061
+ if (state.activeTurnSpan) {
2062
+ require_logger.logger.warn("[CodexAppServer] Turn span not properly closed");
2063
+ require_genaiTracer.closeTurnSpan(state, {
2064
+ errorMessage: "Turn span not properly closed",
2065
+ logLabel: "CodexAppServer"
2066
+ });
2067
+ }
2068
+ }
2069
+ getSpanNameForItem(item) {
2070
+ switch (item?.type) {
2071
+ case "commandExecution": return `exec ${typeof item.command === "string" ? item.command.split(" ")[0] || "command" : "command"}`;
2072
+ case "fileChange": return "file change";
2073
+ case "mcpToolCall": return `mcp ${item.server ?? "unknown"}/${item.tool ?? "unknown"}`;
2074
+ case "dynamicToolCall": return `tool ${item.tool ?? "unknown"}`;
2075
+ case "agentMessage": return "agent response";
2076
+ case "reasoning": return "reasoning";
2077
+ case "webSearch": return "web search";
2078
+ default: return `codex.app_server.${item?.type ?? "unknown"}`;
2079
+ }
2080
+ }
2081
+ getAttributesForItem(item) {
2082
+ const attrs = {};
2083
+ if (item?.type === "commandExecution" && typeof item.command === "string") attrs["codex.command"] = this.sanitizeTraceText(item.command, "Codex app-server command trace attribute") ?? "";
2084
+ if (item?.type === "mcpToolCall") {
2085
+ if (typeof item.server === "string") attrs["codex.mcp.server"] = item.server;
2086
+ if (typeof item.tool === "string") {
2087
+ attrs["gen_ai.operation.name"] = "execute_tool";
2088
+ attrs["gen_ai.tool.name"] = item.tool;
2089
+ attrs["codex.mcp.tool"] = item.tool;
2090
+ }
2091
+ }
2092
+ if (item?.type === "dynamicToolCall" && typeof item.tool === "string") {
2093
+ attrs["gen_ai.operation.name"] = "execute_tool";
2094
+ attrs["gen_ai.tool.name"] = item.tool;
2095
+ attrs["codex.tool.name"] = item.tool;
2096
+ }
2097
+ if (item?.type === "webSearch" && typeof item.query === "string") attrs["codex.search.query"] = this.sanitizeTraceText(item.query, "Codex app-server web search trace attribute") ?? "";
2098
+ return attrs;
2099
+ }
2100
+ getCompletionAttributesForItem(item) {
2101
+ const attrs = {};
2102
+ if (typeof item?.status === "string") attrs["codex.status"] = item.status;
2103
+ if (item?.type === "commandExecution") {
2104
+ if (typeof item.exitCode === "number") attrs["codex.exit_code"] = item.exitCode;
2105
+ if (typeof item.aggregatedOutput === "string") attrs["codex.output"] = this.sanitizeTraceText(item.aggregatedOutput, "Codex app-server command output trace attribute") ?? "";
2106
+ }
2107
+ if (item?.type === "agentMessage" && typeof item.text === "string") attrs["codex.message"] = this.sanitizeTraceText(item.text, "Codex app-server message trace attribute") ?? "";
2108
+ return attrs;
2109
+ }
2110
+ isItemError(item) {
2111
+ return item?.status === "failed" || item?.status === "declined" || item?.error !== void 0 || item?.type === "commandExecution" && typeof item.exitCode === "number" && item.exitCode !== 0;
2112
+ }
2113
+ getItemErrorMessage(item) {
2114
+ return (typeof item?.error?.message === "string" ? item.error.message : null) || (item?.type === "commandExecution" && item.exitCode !== 0 ? `Command exited with code ${item.exitCode}` : null) || "Item failed";
2115
+ }
2116
+ getSkillRootPrefixes(config, appServerEnv) {
2117
+ const resolvedWorkingDir = config.working_dir ? path.default.resolve(config.working_dir).replace(/\\/g, "/") : void 0;
2118
+ return require_codexSkillMetadata.getCodexSkillRootPrefixes({
2119
+ codexHome: appServerEnv.CODEX_HOME,
2120
+ gitRepositoryRoot: resolvedWorkingDir ? this.findGitRepositoryRoot(resolvedWorkingDir) : void 0,
2121
+ homeDir: appServerEnv.HOME || appServerEnv.USERPROFILE,
2122
+ workingDir: resolvedWorkingDir
2123
+ });
2124
+ }
2125
+ buildSkillMetadata(items, skillRootPrefixes) {
2126
+ return require_codexSkillMetadata.buildCodexSkillMetadata(items, skillRootPrefixes, {
2127
+ getCommand: (item) => item?.type === "commandExecution" && typeof item.command === "string" && item.command.trim() ? item.command : void 0,
2128
+ isSuccessfulCommand: (item) => this.isSuccessfulCommandExecution(item)
2129
+ });
2130
+ }
2131
+ isSuccessfulCommandExecution(item) {
2132
+ if (item?.type !== "commandExecution") return false;
2133
+ if (typeof item.status === "string" && item.status !== "completed") return false;
2134
+ if (typeof item.exitCode === "number" && item.exitCode !== 0) return false;
2135
+ return true;
2136
+ }
2137
+ sanitizeTraceText(value, context) {
2138
+ const sanitized = this.redactTracePii(require_logger.sanitizeObject(value, { context }));
2139
+ if (typeof sanitized === "string") return sanitized;
2140
+ if (sanitized === void 0 || sanitized === null) return;
2141
+ try {
2142
+ return JSON.stringify(sanitized);
2143
+ } catch (error) {
2144
+ require_logger.logger.debug("[CodexAppServer] Failed to stringify sanitized trace text", { error });
2145
+ return;
2146
+ }
2147
+ }
2148
+ sanitizeForMetadata(value) {
2149
+ return this.redactTracePii(require_logger.sanitizeObject(value, { context: "Codex app-server metadata" }));
2150
+ }
2151
+ redactTracePii(value) {
2152
+ if (typeof value === "string") return redactAppServerText(value);
2153
+ if (Array.isArray(value)) return value.map((item) => this.redactTracePii(item));
2154
+ 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)]));
2155
+ return value;
2156
+ }
2157
+ };
2158
+ //#endregion
2159
+ exports.CodexAppServerConfigSchema = CodexAppServerConfigSchema;
2160
+ exports.OpenAICodexAppServerProvider = OpenAICodexAppServerProvider;
2161
+
2162
+ //# sourceMappingURL=codex-app-server-n7n4uZzC.cjs.map